Connecting nearby pixels of binary image doesn't work with imopen() and imclose()
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165427/image.jpeg)
0 commentaires
Réponses (2)
Image Analyst
le 30 Mai 2016
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 commentaire
Image Analyst
le 30 Mai 2016
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
le 30 Mai 2016
Modifié(e) : Andraz Skoda
le 2 Juin 2016
3 commentaires
Image Analyst
le 3 Juin 2016
Yes. So, upload your original gray scale picture, and your script. You might try things like imtophat or imbothat, or adapthisteq.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!