shape detection and classification without regionprop command

2 ビュー (過去 30 日間)
jason
jason 2014 年 11 月 11 日
コメント済み: Image Analyst 2017 年 3 月 19 日
1. A binary (black and white) image with all the shapes in white and background in black. In addition, a number, indicating the classification according to the above numbered descriptors, must be inserted in the center of each shape. A value of zero (0) should be placed in the center of the shape that does not fall into one of the above classifications.
A color image with each shape displayed in a pre-assigned color i.e. instead of inserting a number into each shape they can be displayed in different colors e.g. blue for all circles and yellow for all hexagons. The color black must be assigned to all unclassified shapes. The background of this image must be white.
A binary (black and white) image with all the shapes in white and background in black. In addition, a number, indicating the area (in m2 and 3 decimal places), must be inserted in the center of each shape in the image. A text value of "N/A" should be placed in the center of the shape that does not fall into one of the above classifications. Assume each pixel represents a distance of 1 mm.
In my attached files you would find my progress on each part of the question. I have done most of it, i just need your help to see where i am wrong.
  9 件のコメント
jason
jason 2014 年 11 月 12 日
Got it working thanks guys:)
Image Analyst
Image Analyst 2017 年 3 月 19 日
Attach YOUR code. I'm attaching my shape detection demos.

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

採用された回答

Guillaume
Guillaume 2014 年 11 月 11 日
Using text on a figure, only displays that text on the figure. It doesn't write it on the original image that you've used to create the figure.
Therefore, if you want all the numbers to be displayed on the final figure. You need to store their position and value until you're ready to write them at the end.
So at the beginning of your script, once you know how many shapes, predeclare a matrix for your centroids and a cell array for your text:
allcentroids = zeros(2, Ne);
texts = cell(1, Ne);
After you display your individual figures, you then store the centroid and text in the corresponding column of the above matrix/cell
allcentroids(:, n) = Centroid';
texts{n} = num2str(a);
Then after you display the final image, you also display the text at the coordinate you saved
figure(99),imshow(img_wk_bw_L_total);
for shapenumber = 1:Ne
text(allcentroids(1, shapenumber), allcentroids(2, shapenumber), texts{shapenumber});
end
  11 件のコメント
jason
jason 2014 年 11 月 12 日
Got it working thanks guys:)
jason
jason 2014 年 11 月 12 日
Now that each shape is classified into its group, how would i go about to add color to each shape, each shape must be colored according to group i.e squares all blue, circles all red,but shape that don't fall into the classification should be black in color. I used RGB2 below but i cant add the shapes together into an image with a white background. Is there any other method???
RGB2 = label2rgb(L==n, 'copper', 'w', 'noshuffle');

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

その他の回答 (2 件)

jason
jason 2014 年 11 月 11 日

jason
jason 2014 年 11 月 12 日
Now that each shape is classified into its group, how would i go about to add color to each shape, each shape must be colored according to group i.e squares all blue, circles all red,but shape that don't fall into the classification should be black in color. I used RGB2 below but i cant add the shapes together into an image with a white background. Is there any other method???
RGB2 = label2rgb(L==n, 'copper', 'w', 'noshuffle');

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by