Connecting nearby pixels of binary image doesn't work with imopen() and imclose()

조회 수: 2 (최근 30일)
Andraz Skoda
Andraz Skoda 2016년 5월 30일
댓글: Image Analyst 2016년 6월 3일
Hy everyone!
I'm writing program that must recongnise nearby pixels in binary images as lines. For example in picture below, right pixels should represend cross and in the left side, white pixels should represend the line. From picture you can see, that there are many dots that should be connectet together in line. The problem is also, that anomalys can be in random angles, shapes and dimensions. I want to make sure, that pixels that are close enought together represent line or other shape (cross), but morphological operations like imopen() and imclose() doesn't work well. I also did a lot of changing structure element to solve this, bit since anomalys are totaly random I cannot define proper structure element. I must also maintain the anomalys dimensions, for example, lenght of lines.
Any suggestions for solving my problem?

답변 (2개)

Image Analyst
Image Analyst 2016년 5월 30일
Of course imopen() won't work. That erodes the blobs, making them smaller, before dilating the smaller blobs.
You can use imline() to burn lines into the image. See attached demo.
Or use edge linking. Demo attached.
Or what is probably the best option, just use a better segmentation routine in the first place so that the lines are better to begin with.
  댓글 수: 1
Image Analyst
Image Analyst 2016년 5월 30일
Regarding your "Answer", you can pass in x and y to imline() to have it draw between some points without user interaction, but then you get the advantage of having it return the binary image of it. So it can be "automatic" if you pass it some lines. That said, like I said, the best way is not to try to fix a crummy segmentation but to get a better segmentation to begin with.

댓글을 달려면 로그인하십시오.


Andraz Skoda
Andraz Skoda 2016년 5월 30일
편집: Andraz Skoda 2016년 6월 2일
Thank You very much for answer!
Ok, so let me try to use better segmentation technique. So..I have to segment errors on the surface like in the picture bellow:
The problem that I have with segmentation is that this errors appear as randomly shaped structures, like dots, scratches,... AND also contrast of surface is changing (some ''healty'' reagions are recognized as errors beacouse of nad contrast). For now I used simple tresholding to get binary image like I posted in the previous question. If I settup higher threshold value for getting binary picture for evalueting errors, of course then I get the right shape of errors(cross and line above are seen better), but also some of the ''healthy'' part of the surface, that should not be error is recognised as error.
My questions are:
How can I equalize contrast in my picture of surface? What will be better way for segmentation of errors: a) To equalize contrast of surface b) Use some kind of addaptive thresholding tehnique? What is your suggestions for solving my problem of segmentation?
I also find some interesting post here about adaptive tresholding. I think I am looking for some code (that I don't have yet,beacouse the code in this post doesn't work for me...) that do something like at picture bellow:
Tnx everyone!
  댓글 수: 3
Andraz Skoda
Andraz Skoda 2016년 6월 2일
편집: Image Analyst 2016년 6월 3일
OK. How can I do indicate that the post is NOT solved yet? Uncheck "Accept this answer"?
Image Analyst
Image Analyst 2016년 6월 3일
Yes. So, upload your original gray scale picture, and your script. You might try things like imtophat or imbothat, or adapthisteq.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by