Complex Image Processing with closed contour

7 vues (au cours des 30 derniers jours)
Harak
Harak le 25 Nov 2023
Commenté : Harak le 27 Nov 2023
It is a thread which continues on this one:
Alright. It is not as simple as I thought. Although you people helped me a lot (thanks for that), I think the problem is a little bit more complex. I tried different things, I guess a diffrent approach is needed. I tried to simplify my problem and asked you how I can solve it. But I think my simplification was to simple and other problems occured.
To help you guys to help me at least more simple I drawed an image, which should make it very clear, what my problem is.
The shape is a pentagon, i drawed in yellow.
The red line is the important one, cause i want to know, if that contour is closed or not.
The balck spots within the red contour are noise, which are not important.
Everything outside the yellow contour is not important.
The image is a greyscale image, the yellow contour is bright (120 greyscale), and can therefore filtered easily (?). The red contour is near black (25 greyscale). The spots are between those two.
the brown contour is the same as red, but not relevant, because of the image taken.
So my Idea:
First get rid of everything outside yellow. For this I would work with the greyscale image and do nt change to binary. This should be possible, because I can find my contour and make everything in outside white. However, bwboundaries and so on, don't give me any information about my contour. At least, I don't know how to use the information I can get from it.
I think after that I would delete the yellow stripe to and turn it into a binary image, so I only have my red contour in black color. However. Here I might get problem with my Eulernumber, because of the different shapes inside.
I hope I could explained my problem well know, so you folks can help me. Unfortunately, it is more complex than I thought, I must admit. But that's coding I guess. Having the idea is not enough.
  2 commentaires
Matt J
Matt J le 25 Nov 2023
Please provide a .mat file with an image to work with.
Harak
Harak le 25 Nov 2023
Hey Matt,
unfortunately I cannot upload an image of the "real" image, because its confidential. I am not an expert nor a professional in matlab. But I can code a little. I just need help finding the right path. So if you can give me an idea, about how I can filter out everything outside the yellow circle, I think I can code it. I know that's not optimal, but it is a side project of myself to prove my point.
But I need to filter out everything outside of the yellow contour, and afterwards I think the script we coded in the other thread will work perfectly. I hope you can help me nonetheless.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 25 Nov 2023
Modifié(e) : Matt J le 26 Nov 2023
So, you have an image like this,
load Image
figure; imshow(Image)
and you just want to keep the central part? Then threshold the pentagonal borders and develop a mask like in the following:
mask=Image>1.5;
mask=imfill(mask,'holes')>mask;
figure; imshow(Image.*mask)
  2 commentaires
Image Analyst
Image Analyst le 27 Nov 2023
Or equivalently/alternatively
load Image.mat
subplot(2, 1, 1);
imshow(Image, []);
image2 = Image .* imclearborder(Image < 2);
subplot(2, 1, 2);
imshow(image2, []);
@Harak things like this work for simple synthesized images but rarely for real world images but since you won't give us any, you're on your own to make it work with your images.
Harak
Harak le 27 Nov 2023
Hey @Image Analyst right now I am using the approach vor @Matt J and it works. Programmed a lot in the evening yesterday. As I said, I can code a little, with your help showing me the path it works now fully, as I planned. So Thank you for that. I will have to try it with a bigger Database. I will close the Thread now. Can I donate to your both a coffee cup from my side? :D

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by