shape detection and classification without regionprop command

9 vues (au cours des 30 derniers jours)
jason
jason le 11 Nov 2014
Commenté : Image Analyst le 19 Mar 2017
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 commentaires
jason
jason le 12 Nov 2014
Got it working thanks guys:)
Image Analyst
Image Analyst le 19 Mar 2017
Attach YOUR code. I'm attaching my shape detection demos.

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
Guillaume le 11 Nov 2014
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 commentaires
jason
jason le 12 Nov 2014
Got it working thanks guys:)
jason
jason le 12 Nov 2014
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');

Connectez-vous pour commenter.

Plus de réponses (2)

jason
jason le 11 Nov 2014

jason
jason le 12 Nov 2014
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');

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by