draw bounding box around a character

3 ビュー (過去 30 日間)
Elysi Cochin
Elysi Cochin 2020 年 5 月 24 日
コメント済み: Elysi Cochin 2020 年 5 月 25 日
The code i used is
Ch = bw(boundrow(1):boundrow(end),boundcol(1):boundcol(end));
i'll get the character into the variable Ch
how can i draw a bounding box in the image

採用された回答

Image Analyst
Image Analyst 2020 年 5 月 24 日
Presumably you used regionprops()
props = regionprops(binaryImage, 'BoundingBox');
% Plot all the bounding boxes.
hold on;
for k = 1 : length(props)
rectangle('Position', props(k).BoundingBox, 'EdgeColor', 'y');
end
  3 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 24 日
I would not do it that way, but if you insist, after you get Ch you can put a box around the rectangle in the original image like this:
line([boundcol(1), boundcol(end)], [boundrow(1), boundrow(1), 'Color', 'y', 'LineWidth', 2);
line([boundcol(1), boundcol(end)], [boundrow(end), boundrow(end), 'Color', 'y', 'LineWidth', 2);
line([boundcol(1), boundcol(1)], [boundrow(1), boundrow(end), 'Color', 'y', 'LineWidth', 2);
line([boundcol(end), boundcol(end)], [boundrow(1), boundrow(end), 'Color', 'y', 'LineWidth', 2);
or
% Make rect = [xLeft, yTop, width, height]
r = [boundcol(1), boundrow(1), abs(boundcol(end) - boundcol(1)), abs(boundrow(end) - boundrow(1))];
rectangle('Position', r, 'EdgeColor', 'y', 'LineWidth', 2);
Elysi Cochin
Elysi Cochin 2020 年 5 月 25 日
Thank you Sir. The last comment worked. Its working in both methods

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by