How to segment this image correctly?
2 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Image Analyst
2016-12-25
See Steve's blog for how you can use watershed segmentation to separate the blobs: http://blogs.mathworks.com/steve/2013/11/19/watershed-transform-question-from-tech-support/
4 个评论
John BG
2017-1-7
fine to me, you choose as accepted answer IA's, it's ok.
But it's worth mentioning that with dell2 you get 3 blocks and there is no contour deformation whatsoever.
Yet with IA suggested segmentation when each block too close each other the 'corridors' suffer deformation.
Your original image has a more or less diagonal alley between the first from left segment and the 2nd segment, kind of hand written, yet IA proposed segmentation returns a Z-like straight segments uniformly narrow alley which is clearly different from the original image.
更多回答(2 个)
John BG
2016-12-25
编辑:John BG
2016-12-27
I tried watershed and label2rgb but didn't produce the desired result
1.
A=imread('im1.jpg');imshow(A)
BW=watershed(A)
Lrgb=label2rgb(BW);imshow(Lrgb)
2.
the Laplacian seems to get somewhere yet the contour is still a bit noisy
A1=double(A(:,:,1))
B=del2(A1);
figure(2);imshow(B)
3.
So I cleaned it with the following basic lines and the contour shows up
A1(A1<80)=0
A1(A1>120)=255
C=del2(A1);
figure(3);imshow(C)

and it also works for the fragmented image
A=imread('im2.jpg');figure(4);imshow(A)
A2=double(A(:,:,1))
A2(A2<80)=0
A2(A2>120)=255
C2=del2(A2);
figure(3);figure(5);imshow(C2)

if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help, please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG
5 个评论
Image Analyst
2016-12-28
编辑:Image Analyst
2016-12-28
No of course I don't mind you asking John. Honestly I didn't try either your method or Steve Eddins method.
But with either method, the bad jpeg artifacts should be repaired so that you're starting with a pure binary image.
I saw a lot of clutter in your first two images that just didn't seem right and I think that if he had posted the pure binary images, you wouldn't have all that clutter and you might get different results. But with a binary image you wouldn't want to or need to do the Laplacian. If you just wanted to find the edges you can use bwperim() or bwboundaries(). Have you tried your method after the jpeg junk has been removed/repaired? Maybe you could attach your entire algorithm in one chunk/file so we can easily copy and paste it.
Again, smallmonster, never use JPEG format to save images that you want to do image analysis on. Use PNG instead.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



