how to crop aportion of an image from in bounding box.?

1 回表示 (過去 30 日間)
oza san
oza san 2017 年 5 月 1 日
コメント済み: Image Analyst 2017 年 5 月 2 日
i use open source code in the link https://www.mathworks.com/help/vision/examples/automatically-detect-and-recognize-text-in-natural-images.html to detect text and finally i get an image like below with more than one bounding box and i need to crop each of the bounding box.i know imcrop with for loop can do this.plaese help me?
textBBoxes = [xmin ymin xmax-xmin+1 ymax-ymin+1];
textBBoxes = [xmin ymin xmax-xmin+1 ymax-ymin+1];
numRegionsInGroup = histcounts(componentIndices);
textBBoxes(numRegionsInGroup == 1, :) = [];
ITextRegion = insertShape(colorImage, 'Rectangle', textBBoxes,'LineWidth',3);
figure imshow(ITextRegion) title('Detected Text')
end

採用された回答

Image Analyst
Image Analyst 2017 年 5 月 1 日
Loop over all boxes, calling imcrop() while passing it the rectangle (xLeft, yTop, width, height] for the box.
  2 件のコメント
oza san
oza san 2017 年 5 月 2 日
編集済み: oza san 2017 年 5 月 2 日
Dear sir thank you for your replay!!!i tried the following but i can not get what i want i end up with errors!!!mind you if you can help me in the code?it works fine when the bounding box is 1.but failed when it is greater than one.about regionprops it accepts binary image and i need it to do on color images. if true
for K = 1 : length(textBBoxes)
figure
text = imcrop(colorImage, textBBoxes);
imshow(text)
end
end
Image Analyst
Image Analyst 2017 年 5 月 2 日
text() is a built-in function - don't use that. Also textBBoxes should be an N by 4 array of doubles, not text. Finally, you need to have the K index with textBBoxes when you send it into imcrop().

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by