Watershed Over Segmenting Image

1 Ansicht (letzte 30 Tage)
Nathan
Nathan am 27 Mai 2015
Kommentiert: Image Analyst am 28 Mai 2015
Hello, I am using watershed to segment an image into its various components, but the problem I am running into is the that my image is being over segmented. For example, this is the result of my segmentation algorithm
As you can see it segments off the drop forming on the end, which is what I want it to do, however it also breaks the stream into two separate parts, which I do not want it to do. I have tried changing the connectivity from 8 to 4, but this does not give better results. I have also tried using 'chessboard' as my distance metric, but that yielded no change. Any help anyone could provide would be greatly appreciated. My code is as follows
D = -bwdist(~bw,);
Ld = watershed(D);
bw2 = bw;
bw2(Ld == 0) = 0;
mask = imextendedmin(D,2);
D2 = imimposemin(D,mask);
Ld2 = watershed(D2);
bw3 = bw;
bw3(Ld2 == 0) = 0;
  2 Kommentare
Ashish Uthama
Ashish Uthama am 27 Mai 2015
Could you potentially do some processing with regionprops and rule out certain regions based on properties like say Major/MinorAxisLength?
I saw your other questions, I am curious about the images and what you are trying to do - find out the number of droplets? quantify the droplets? Find the point where the 'stream' breaks to droplets?
Nathan
Nathan am 27 Mai 2015
I could rule out certain regions, but the problem is the region would change on an image to image basis as the stream isn't a constant length. And I am trying to essentially count the number of droplets that are forming, and then find the area of the droplets. Both counting and finding the area is easy using regionprops, I'm just going to have my code drop one region, the stream, and then drop the largest area, which should also be the stream, and all I should be left with after segmentation is the drops and their areas.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 27 Mai 2015
Is that a pipette squirting out liquid? If so, just get an image of it when there is no drop at the tip and use that as a mask to mask it out from the images with droplets. Anyway, you might not want to count a drop that is attached to the stream or pipette because it's not completely formed yet.
  3 Kommentare
Ashish Uthama
Ashish Uthama am 28 Mai 2015
Could you then maybe use some kind of template matching to locate the end of the pipette? I would expect it looks similar in all the pictures even if it had a bit of a drop forming off of its end. If the length of the pipette (or its not that, the 'steam') varies, does the 'shape' look consistent? Maybe you could then use a min length of it that you expect to see in each image as the template to search for?
You might get better answers if you could share more info. Maybe there is a different lighting condition you can use to get better results?
Image Analyst
Image Analyst am 28 Mai 2015
Here's what I would do. The isolated blobs on the right are really straightforward and there's no problem there - they're easy. The only problem is the long blob on the left and whether it has a droplet connected to it or not. So what I would do it to get the sum of all columns, which will give you the thickness of the stream:
thickness = sum(binaryImage, 1);
Now you can look for the end of that stream, say where the thickness is less than 3 pixels or whatever.
lastColumn = find(thickness < 3, 1, 'first');
Now get the mean thickness over, say, the first 90% of that distance.
meanThickness = mean(thickness(1:round(0.9*lastColumn)));
Now you can look for the first column where the thickness dips below, say 80% of the mean thickness:
dividingColumn = find(thickness(1:lastColumn) < 0.8*meanThickness, 1, 'first');
Now, draw a line to zero out that column, if it found such a column:
if ~isempty(dividingColumn)
binaryImage(:, dividingColumn) = false;
end
Now remove the stream from the image. It's connected to the left edge of the image so we can use imclearborder:
binaryImage = imclearborder(binaryImage);
I think that ought to do it. Try it out and let me know how it goes. Obviously you may have to tweak some of the numbers to get it to work best.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by