detect shape in image

11 ビュー (過去 30 日間)
Sahar Mahmoudi
Sahar Mahmoudi 2016 年 7 月 29 日
コメント済み: Sahar Mahmoudi 2016 年 7 月 29 日
How can I detect shape(circle,square,triangle) in RGB image(forexample: apple=circle, bread=square)?

回答 (1 件)

Selva Karna
Selva Karna 2016 年 7 月 29 日
RGB = imread('your image'); imshow(RGB); I = rgb2gray(RGB); threshold = graythresh(I); bw = im2bw(I,threshold); imshow(bw) % remove all object containing fewer than 30 pixels bw = bwareaopen(bw,30);
% fill a gap in the pen's cap se = strel('disk',2); bw = imclose(bw,se);
% fill any holes, so that regionprops can be used to estimate % the area enclosed by each of the boundaries bw = imfill(bw,'holes');
imshow(bw) [B,L] = bwboundaries(bw,'noholes');
% Display the label matrix and draw each boundary imshow(label2rgb(L, @jet, [.5 .5 .5])) hold on for k = 1:length(B) boundary = B{k}; plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2) end
  1 件のコメント
Sahar Mahmoudi
Sahar Mahmoudi 2016 年 7 月 29 日
I run your code but the answer in not related to the automatic shape detection.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by