Problem Statement 40
Problem Statement 40
cc = imread('C:\Users\Vijay\Downloads\legImage.png');
cc = uint8(cc);
figure, imshow(cc); title('cc');
cc = rgb2gray(cc);
cc = double(cc);
edg = edgy(cc);
% Pre-allocate the filtered_image matrix with zeros
edg = zeros(size(cc));
Mx = [-1 0 1; -2 0 2; -1 0 1];
My = [-1 -2 -1; 0 0 0; 1 2 1];
for i = 1:size(cc, 1) - 2
for j = 1:size(cc, 2) - 2
% Gradient approximations
Gx = sum(sum(Mx.*cc(i:i+2, j:j+2)));
Gy = sum(sum(My.*cc(i:i+2, j:j+2)));
end
end
edg = uint8(edg);
figure, imshow(edg); title('edg');
thresholdValue = 100; % varies between [0 255]
output_image = max(edg, thresholdValue);
output_image(output_image == round(thresholdValue)) = 0;
output_image = im2bw(output_image);
figure, imshow(output_image); title('Edge Detected Image');