Code covered by the BSD License

### Highlights from shape recognition(many shape)

4.16667
4.2 | 6 ratings Rate this file 51 Downloads (last 30 days) File Size: 42.6 KB File ID: #20666

# shape recognition(many shape)

### Trieu Nguyen Ta (view profile)

11 Jul 2008 (Updated )

with this you can recognize many shape;but only symetrical shape

File Information
Description

with this you can recognize many shape;but only symetrical shape,for example you can improve this for recognize star,polygon if you want

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.1.0 (R14SP3)
17 Sep 2014 rahul

### rahul (view profile)

19 Jul 2014 Juan Carlos

### Juan Carlos (view profile)

hello friend you could they would like to provide me your code, it would be very useful, thanks

Comment only
16 May 2014 dang tins

### dang tins (view profile)

11 Oct 2012 wardah arooj

### wardah arooj (view profile)

its important.

Comment only
11 Oct 2012 wardah arooj

### wardah arooj (view profile)

its important.

11 Oct 2012 wardah arooj

its important.

Comment only
29 Sep 2011 Luz

### Luz (view profile)

its a very good job.
although I have some questions . Please could you explain these khoangcach{k}(1,i) = sqrt ( ( b(i,2) - s(k).Centroid(1) )^2 + ( b(i,1) - s(k).Centroid(2) )^2 )

vuong = c/(4*b^2)
chunhat=c/(4*b*(a^2-b^2)^0.5);

thnks a lot

08 May 2010 abhi

### abhi (view profile)

Hi, can u plz tel wt is this khoangcach{k}(1,i) = sqrt ( ( b(i,2) - s(k).Centroid(1) )^2 + ( b(i,1) - s(k).Centroid(2) )^2 );

Comment only
06 May 2010 abhi m

### abhi m (view profile)

I should recognise circle square rectangle but am struck... the code below is effecient in recognising circle but it is failing to recognise square and recatngle.. plz help me in improvising my code plz....

[rows columns numberOfColorBands] = size(rgbImage);
subplot(3, 2, 1);
imshow(rgbImage, []);
title('Original color Image');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

%STEP 2

%---------------------------------------------------Convert rgb image to grayscale-----------------------------------------

grayImage = rgb2gray(rgbImage);
subplot(3, 2, 2);
imshow(grayImage, []);
title('Converted to gray scale');

%STEP 3

%------------------------------------------------------Detection of edge by canny-------------------------------------------------------

cannyImage = edge(grayImage,'canny');
subplot(3, 2, 3);
imshow(cannyImage, []);
title('Canny Edge Image');

%STEP 4

%-------------------------------------------------------------dilation--------------------------------------------------------

windowSize = 5;
halfWidth = floor(windowSize/2);
dilatedImage = zeros(rows, columns);
for col = (halfWidth+1) : columns - halfWidth
x1 = col - halfWidth;
x2= col + halfWidth;
for row = (halfWidth+1) : rows - halfWidth
y1 = row - halfWidth;
y2 = row + halfWidth;
dilatedImage(row, col) = max(max(cannyImage(y1:y2, x1:x2)));
end
end

%Displaying the dilated image

subplot(3, 2, 4);
imshow(dilatedImage, []);
caption = sprintf('Dilated with a window size of %d',windowSize);
title(caption);

%STEP 5

%------------------------------------------------------------Erosion-------------------------------------------------

windowSize = 5;
halfWidth = floor(windowSize/2);
erodedImage = zeros(rows, columns);
for col = (halfWidth+1) : columns - halfWidth
x1 = col - halfWidth;
x2= col + halfWidth;
for row = (halfWidth+1) : rows - halfWidth
y1 = row - halfWidth;
y2 = row + halfWidth;
erodedImage(row, col) = min(min(dilatedImage(y1:y2, x1:x2)));
end
end

%Displaying eroded image

subplot(3, 2, 5);
imshow(erodedImage, []);
caption = sprintf('Eroded image with a window size of %d',windowSize);
title(caption);
[B,L] = bwboundaries(grayImage, 'noholes');

STATS = regionprops(L, 'all');

figure,
imshow(grayImage),
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

22 Nov 2009 phuc minh

### phuc minh (view profile)

>> im1=im2bw(i1);
>> im2=im2bw(i2);
>> im3=im2bw(i3);
>> p1=reshape(im1,1,176);
>> p2=reshape(im2,1,176);
>> p3=reshape(im3,1,176);
>> p=[p1 p2 p3];
>> t=[1 2 3];
>> %lay du lieu
net=newff(minmax(p),[176,20,7],{'logsig','logsig','purelin'},'traingd');
net.trainParam.epochs=10000;
net.trainParam.goal=0.00000001;
%[net,tr]=train(net,p,t);
[net,tr]=train(net,p,t)
??? Error using ==> minmax at 43
Argument has illegal type.
what is this error ?

Comment only
08 Oct 2009 kidare

### kidare (view profile)

Bác có suorce code nhận dạng ảnh bằng mạng nơtron ko ạ?source này ko sử dụng mạng nơtron thì phải

Comment only
01 Feb 2009 Lee

### Lee (view profile)

Hi, can you please explain all the vietnamese words in the programme? such as dolech, tamgiacdeu ,elip, thoi etc. Thank you very much.

13 Jul 2008 Trieu Nguyen Ta

i'm so sorry becauce i upload file in vietnamese,but now if u don't understant anything u can contact with me,so i can explain it for u,

Comment only