File Exchange

## shape recognition(many shape)

version 1.0 (42.6 KB) by

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

Updated

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

Yongjun Wang

Yongjun Wang

### Yongjun Wang (view profile)

V ery good,thank you.

TY

rahul

Juan Carlos

### Juan Carlos (view profile)

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

dang tins

wardah arooj

its important.

wardah arooj

its important.

wardah arooj

its important.

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

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 );

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

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 ?

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

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.

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,

##### MATLAB Release
MATLAB 7.1.0 (R14SP3)