You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Chan Vese Segmentation mask is not working Properly
4 views (last 30 days)
Show older comments
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.
Accepted Answer
Anton Semechko
on 26 Jun 2018
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 Comments
Stelios Fanourakis
on 26 Jun 2018
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
on 26 Jun 2018
Edited: Image Analyst
on 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.
Stelios Fanourakis
on 26 Jun 2018
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.
Stelios Fanourakis
on 26 Jun 2018
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
Stelios Fanourakis
on 26 Jun 2018
This white padding thing do not exist in the cropped image when opened using imtool
Stelios Fanourakis
on 26 Jun 2018
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
Anton Semechko
on 26 Jun 2018
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?
Stelios Fanourakis
on 26 Jun 2018
@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?
Anton Semechko
on 26 Jun 2018
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?
Stelios Fanourakis
on 26 Jun 2018
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.
Stelios Fanourakis
on 26 Jun 2018
Can you please give me using a more efficient segmentation algorithm?
Anton Semechko
on 26 Jun 2018
'untitled.png' WAS the image I used to generate the above thumbnail showing the extraneous padding!!!
Stelios Fanourakis
on 26 Jun 2018
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
Anton Semechko
on 26 Jun 2018
I can't figure out if I am being trolled. Anyone else reading this care to comment?
Stelios Fanourakis
on 26 Jun 2018
See my previous attachment. Contour get inside the image. How else to explain it?
Anton Semechko
on 26 Jun 2018
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?
Stelios Fanourakis
on 26 Jun 2018
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?
Anton Semechko
on 27 Jun 2018
Stelios, does the file 'untitled.png' contain the image you are using as input to the segmentation algorithm?
Stelios Fanourakis
on 27 Jun 2018
@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
Anton Semechko
on 27 Jun 2018
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,[])
Stelios Fanourakis
on 27 Jun 2018
@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.
Stelios Fanourakis
on 27 Jun 2018
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
Anton Semechko
on 27 Jun 2018
'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.
Stelios Fanourakis
on 31 Aug 2018
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
on 31 Aug 2018
Edited: Stelios Fanourakis
on 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?
More Answers (0)
See Also
Categories
Find more on DICOM Format in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)