shape detection and classification without regionprop command
1 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
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
更多回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!