Reshape an object in binary image
2 次查看(过去 30 天)
显示 更早的评论
Hi dear;
I have a binary image that contains an object (some times a lot of objects), I want to reshape the object as showing in the image 1 to the one as showing in the image 2. My goal is to have an object tha has a straight boundaries.
Any help and suggestion will be appreciated.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153640/image.png)
4 个评论
Walter Roberson
2016-1-29
Maybe you would like to skeletonize, remove spurs, and then dilate out again??
采纳的回答
Image Analyst
2016-1-28
编辑:Image Analyst
2016-1-28
Use
[labeledImage, numBlobs] = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'BoundingBox');
then for each blob in a for loop over all blobs, get the bounding box and get the bounding rows and columns,
for k = 1 : numBlobs
xLeft = ceil(measurements(k).BoundingBox(1));
% etc.
binaryImage(yTop:yBottom, xLeft:xRight) = true;
end
Let me know if you can't figure out the rest.
7 个评论
Image Analyst
2016-1-30
Aha, we knew it! You didn't actually want what you asked for (and so all my prior effort went to waste, perhaps). Now, with this image it looks like you actually want some kind of "envelope" of the blob. So it seems like you want activecontour(). This time I'll simply attach my canned demo and you can adapt it yourself.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/182018/image.jpeg)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!