How to draw represent connected components bounding boxes with different color??

10 vues (au cours des 30 derniers jours)
IP student ;(
IP student ;( le 17 Avr 2019
Commenté : Image Analyst le 18 Avr 2019
I'm working on handwritten documents,so I want to show bounding boxes of different line with different color. I've a matrix which contains the connected components values and I want to color bounding boxes using this color.
  4 commentaires
Walter Roberson
Walter Roberson le 17 Avr 2019
regionprops() finds bounding boxes but does not draw them.
IP student ;(
IP student ;( le 17 Avr 2019
Sorry,I used rectangle to draw bounding boxes

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 17 Avr 2019
Use plot(xBox, yBox, 'Color', yourColor), or rectangle('Position', bb, 'EdgeColor', yourColor) or something like that. xBox is obtained from the bounding box like
props = regionprops(binaryImage, 'BoundingBox');
for k = 1 : length(props)
bb = props(k).BoundingBox);
xBox = [bb(1), bb(1)+bb(3), bb(1)+bb(3), bb(1), bb(1)];
yBox = [bb(2), bb(2), bb(2)+bb(4), bb(2)+bb(4), bb(2)];
plot(xBox, yBox, 'Color', rand(1,3));
hold on;
end
If you still can't figure it out, write back.
  5 commentaires
IP student ;(
IP student ;( le 18 Avr 2019
I tried your code I'm getting a graph with different colored boxes of different sizes.
I want the bounding boxes around my texts and I've that already. Now I want to have different color bounding boxes for selected connected components
Image Analyst
Image Analyst le 18 Avr 2019
Yes, my code should do that assuming you have rows and columns for where you want to put the boxes.
Again, I don't see a question in your comment (i.e. a sentence ending with a question mark), but if you want to colorize blobs, use label2rgb(). Then you can make each box have the same color as the blob if you want to.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots 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