![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179961/image.png)
How to crop the gray scale image automatically???
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have a gray scale image of Handwritten word, I want to crop only portion of that image which exactly carries that word or information , overthrow another region , how can I do that, figures are attached...
0 个评论
回答(1 个)
Akira Agata
2018-3-12
How about the following script?
I = imread('1.jpg');
BW = imbinarize(I);
BW1 = bwconvhull(~BW);
s = regionprops(BW1,'BoundingBox');
I2 = imcrop(I,s.BoundingBox);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179961/image.png)
2 个评论
Akira Agata
2018-3-12
During your copy&paste, a space seems to be mistakenly inserted.
Correct input:
s = regionprops(BW1,'BoundingBox');
Wrong input:
s = regionprops(BW1,'BoundingBox ');
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!