How to crop the image?
3 次查看(过去 30 天)
显示 更早的评论
- I have above image and I want to crop it such that the white pixels just reach the corners from all sides using Matlab code automatically not manually
how could I do this...thanks In advance
0 个评论
采纳的回答
Image Analyst
2015-7-18
Have you run my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862? It goes over that.
labeledImage = bwlabel(binaryImage);
blobMeasurements = regionprops(labeledImage, 'BoundingBox');
% Find the bounding box of each blob.
thisBlobsBoundingBox = blobMeasurements.BoundingBox; % Get list of pixels in current blob.
% Extract out this blob into it's own image.
% I'm assuming just one blob. If you have multiple, see my tutorial.
subImage = imcrop(binaryImage, thisBlobsBoundingBox);
6 个评论
Image Analyst
2015-7-20
You should have had this done long long ago - it's not that hard. So I did it for you. See the attached demo.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!