Chan Vese Segmentation mask is not working Properly

I cropped my DICOM image so the active contour be faster and segment between the black area and soft tissue.
Instead, I got a contour that overlaps the edge of the image and goes beyond this. How can this happen? See attached image.
Let me know if you need the m files.

 Akzeptierte Antwort

Anton Semechko
Anton Semechko am 26 Jun. 2018

0 Stimmen

Your image appears to be "padded" on the top and bottom with gray values. The transition between the black background (containing the region of interest; ROI) and these gray regions, has large gradient that will attract the contour during segmentation; because evolution of the contour is guided by the strength of the image intensity gradient. My suggestions to you, (1) remove the padding, (2) initialize contour close to the ROI you want to segment.

28 Kommentare

You are right. But how do I do that? I cropped the image without padding still the padding shows up and I am trying to find a way to initialize the contour close to the dark area. If you have any experience on chan vese methods please help
Image Analyst
Image Analyst am 26 Jun. 2018
Bearbeitet: Image Analyst am 26 Jun. 2018
"I cropped the image without padding still the padding shows up" Huh? How could that be? Attach your m-file and dicom image, zipped up if you have to. And you've Accepted this answer, so can we assume that it's solved, or not? Please clarify.
I accepted the answer because he's right to his comment, I guess. No it hasn't been solved. I attach the two m files I use for the contour and the jpg (cropped) image. You'll see that the contour goes outside the image where I want it to go inside of it and match the black area. It must be a tune in the init_mask of the chvese.m but I cannot find it yet.
I don't see any cropping going on there.
The image is already cropped. The original one is much bigger. I only left a thin strip of the dicom image and saved it as jpg
This white padding thing do not exist in the cropped image when opened using imtool
I saved it as png and now no white padding is showing and the contour goes inside the image. But it seems it cannot segment between the soft tissue (gray) and the background. It outlines the whole image
1) Can you post on here the grayscale image you want to process (without the padding) and a separate image showing (approximately) the ROI you want to segment.
2) Is there a reason you chose this particular segmentation algorithm?
@Anton. I just saved it as png (same image). I need an active contour to separate black area (bckgnd) with the soft tissue (foreground). It seems fast enough this algorithm. Do you have any alternative to propose me?
The image background appears relatively uniform and free of noise, so yes, there are simpler and more efficient algorithms that can be used in place of level-set segmentation.
Before we get to that, it seems that you are not getting an important point about the input image you want to process. The image you provided is definitely not an original DICOM image because it contains extraneous padding around the borders:
You should not be using this image as input to a segmentation algorithm, level-set or otherwise, because it contains information that will "confuse" segmentation algorithm and preclude it from finding the ROI you actually want to segment. Do you understand this?
Yes Anton. I understand it. If you see my latest attachment it is the .png format with no padding at all. Still cannot differentiate between black and gray.
Can you please give me using a more efficient segmentation algorithm?
'untitled.png' WAS the image I used to generate the above thumbnail showing the extraneous padding!!!
But I use that image to my pc/Matlab and the contour goes inside the image area. Correctly. Previously with the 'pictoedit.jpg', there was a problem with padding. Are you sure you used the png version? I don't have problem with padding. I have problem that it won't segment correctly
I can't figure out if I am being trolled. Anyone else reading this care to comment?
See my previous attachment. Contour get inside the image. How else to explain it?
Ok, do this:
im=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/122991/untitled.png');
figure('color','w')
imshow(im)
What do you see?
At my first attachment in this post (fig.jpg) contour goes out of image area. That was my problem now I have a different problem. Am I clear or not?
Stelios, does the file 'untitled.png' contain the image you are using as input to the segmentation algorithm?
Yes, I use the 'untitled.png', now
@Anton. Please, give me an efficient segmentation algorithm. The one I use doesn't seem to be able to differentiate between black and gray values
Since you are completely impervious to everything I said up 'till now, I will just give you a demo.
% Get the image
im=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/122991/untitled.png');
% Remove extraneous padding and border drawn on the image
im=im(161:280,11:880,:);
im=max(im,[],3);
% Segment into 4 classes using only intensity information
[C,U,LUT,H]=FastFCMeans(im,4);
L=LUT2label(im,LUT);
% Visualize
figure
subtightplot(3,1,1), imshow(im)
subtightplot(3,1,2), imshow(L,[])
subtightplot(3,1,3), imshow(L>1,[])
Segmentation functions used in this demo can be downloaded from here
'subtightplot' function can be found here
@Anton. Although I got all the functions you suggested me, here are the results. I didn't manage to get your results. I did only copy paste.
Sorry about that. I used slightly modified functions. You can get them here.
Thanks a lot Anton, I do really appreciate your effort and help. One last thing I might need to ask is how can I have the contour visible on the image. I need to control the active contour so will be slightly modified when applied to several images since the images differ between them
'FastFCMeans' performs image segmentation by clustering of image intensities and is thus fundamentally different from the level-set segmentation algorithm you were using before. There is no initialization involved and the resulting segmentation depends only on the input parameters 'c' and 'q'; 'c' controls the number of intensity clusters and 'q' is a fuzzification parameter. See 'FastFCMeans' documentation for additional info.
Hi Anton.
Thanks for your valuable help so far. What I have not understand yet is how to get what I need. FastFCMeans algorithm indeed segmented the gray soft tissue from the background. What I want now is to get the black area above the soft tissue. Only this region above the tissue. I need to somehow segment it and measure its length, pixel area size, dimensions. Do I have to implement a snake contour like chan vese. How else can I obtain the values of this area? (pixel size, pixels in number, dimensions, length from top of the image to the beginning of the tissue).
Stelios Fanourakis
Stelios Fanourakis am 31 Aug. 2018
Bearbeitet: Stelios Fanourakis am 31 Aug. 2018
Moreover, if you notice the soft tissue at the last pic available (untitled.png) you'll notice some black gaps between the soft tissue especially at the lower left side of the image. I need some kind of interpolation method to fill those gaps so the contour will not get messed. So the soft tissue will be a unit of seamless gray or white matter with no black gaps.
I attach an image to see the results so far. See that the contour gets troubled to the points where the soft tissue is not seamless and black gaps occur. Any idea of how to fix it?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by