-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHorizontalSharping.m
More file actions
31 lines (25 loc) · 886 Bytes
/
HorizontalSharping.m
File metadata and controls
31 lines (25 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function edge_image = HorizontalSharping(image)
if size(image, 3) == 3
image = rgb2gray(image);
end
padded_image = padarray(image, [1, 1], 0, 'both');
% Get the dimensions of the padded image
[rows, cols] = size(padded_image);
kernel = [ 0 0 0;
1 1 -1;
0 0 0 ];
% Initialize the output image with zeros
edge_image = zeros(rows-2, cols-2);
% Loop through each pixel in the image
for i = 1:rows-2
for j = 1:cols-2
% Extract the region around the pixel (3x3 block)
region = double(padded_image(i:i+2, j:j+2));
% Perform element-wise multiplication and sum it
edge_image(i, j) = sum(sum(region .* kernel));
end
end
% Convert the result back to uint8
edge_image = uint8(edge_image);
% figure,imshow(edge_image);
end