ijpb / MorphoLibJ

Collection of mathematical morphology methods and plugins for ImageJ
http://imagej.net/MorphoLibJ
GNU Lesser General Public License v3.0
98 stars 49 forks source link

Marker-Controlled watershed "Binary markers" inconsistency between ImageJ and Java class. #34

Closed loomcode closed 4 years ago

loomcode commented 4 years ago

I'm using Java to generate a gradient image, and a marker image. I've confirmed that the MorphoLibJ "marker-controlled watershed" plugin works as expected on these images using the following.

Input - gradient image Marker - marker image Mask - None Binary markers - checked Calculate dams - checked Use diagonal connectivity - checked

It fails if "Binary markers" is not checked. However I see no constructor which accepts this as an argument in the class.

Using these same two images and calling:

ImageProcessor res = Watershed.computeWatershed(ip_thumb, ip_markers , 8, true); returns no segmentations and I'm not sure why.

Additionally, the manual indicates that markers must be labelled but nowhere indicates what a "labelled" marker is. For my marker image I'm using an 8-bit grayscale image that is all zeros except for the marker seed pixels which are set to 255.

loomcode commented 4 years ago

looks like I may have figured it out. I was able to infer that what might be considered a labelled marker is a marker with a distinct value (1-n) (but this doesn't seem to work on ColoredProcessor type images). If I set the distinct marker pixels as 1-N this works, however I still don't see a way to run this with "binary markers".

dlegland commented 4 years ago

Hi,

OK, glad you could figure it out!

We call "label images" images with integer values, the value 0 corresponding to the background. In the case of a binary image, there is only one marker, corresponding to the value 255. You can apply a connected component analyis to transform binary to label.

Note that MorphoLibJ does not support colour images as label images, while some label images may be represetnd with colours by using a Look-Up Table (LUT).

Hope this helps?

loomcode commented 4 years ago

Thanks for the prompt response David!