From: abhi m on
Some of the square and rectangle objects can not be recognised .... the code below is effecient in recognising circle but some of the square and rectangle objects cant be identified can anyone help me in improving my code....

rgbImage = imread('test.jpg');
[rows columns numberOfColorBands] = size(rgbImage);
subplot(3, 2, 1);
imshow(rgbImage, []);
title('Original color Image');
set(gcf, 'Position', get(0,'Screensize'));
grayImage = rgb2gray(rgbImage);
subplot(3, 2, 2);
imshow(grayImage, []);
title('Converted to gray scale');
cannyImage = edge(grayImage,'canny');
subplot(3, 2, 3);
imshow(cannyImage, []);
title('Canny Edge Image');
dilate=imdilate(cannyImage,strel('square',2,2);
erode=imerode(dilate,strel('square',2,2);
[B,L] = bwboundaries(erodedImage, 'noholes');
STATS = regionprops(L,'all');

figure,
imshow(rgbImage),
title('Results');
hold on
for i = 1 : length(STATS)
W(i) = uint8(abs(STATS(i).BoundingBox(3)-STATS(i).BoundingBox(4)) < 0.1);
W(i) = W(i) + 2 * uint8((STATS(i).Extent - 1) == 0 );
centroid = STATS(i).Centroid;
switch W(i)
case 1
plot(centroid(1),centroid(2),'wO');
title('circle');
case 2
plot(centroid(1),centroid(2),'wX');
title('rectangle');
case 3
plot(centroid(1),centroid(2),'wS');
title('square');
end
end
return
plz help .....
From: ImageAnalyst on
You can't tell just by comparing width and height of an object. You'd
have better luck looking at the (Perimeter Length)^2/Area ratio, or
something more complicated like the number of angle changes as you go
around the perimeter.
From: abhi m on
How can i do this?? can u plz send me the code...
From: abhi m on
plz help me am in urgent plz