04 April 2015 7 2K Report

The following code for rectangle detection somewhat helped me. But now i want to crop the rectangle as a sub image. 

img =imread('xyz6.jpg');

bw = im2bw(img);

% find both black and white regions

stats = [regionprops(bw); regionprops(not(bw))]

% show the image and draw the detected rectangles on it

imshow(bw);

hold on;

for i = 1:numel(stats)

rectangle('Position', stats(i).BoundingBox, ...

'Linewidth', 2, 'EdgeColor', 'r', 'LineStyle', '--');

end

More Dawar Khan's questions See All
Similar questions and discussions