Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Watershed Similar to ImageJ Watershed

82 views
Skip to first unread message

Mustafa

unread,
Jun 25, 2010, 10:30:16 AM6/25/10
to
Hi,

I was wondering if there is an implementation to the watershed algorithem similar to the one in ImageJ or at least some parts of it.

I know that there is a watershed function in matlab (Image Proc. toolbox). but the one in imagej seems to do a much better job at it.

In particular, it is beter in removing extra lines that are produced by the watershed algorithem. I looked quite a bit at their source code and it seems they have some post watershed processing to remove the extra lines (artifacts) somehow!

is there away to do that in matlab? I already looked at the demos/posts/blogs that are around here, and not one of the advices work with the problem.

Thanks in advance

Mustafa

unread,
Jun 25, 2010, 4:56:05 PM6/25/10
to
Just to add: the watershed in imagej only works on binary images.

Steve

unread,
Dec 29, 2010, 1:58:05 PM12/29/10
to
"Mustafa " <Mustafa.Ge...@live.com> wrote in message <i03555$jf$1...@fred.mathworks.com>...

> Just to add: the watershed in imagej only works on binary images.


Have you found a solution to this issue?

Mustafa

unread,
Jan 7, 2011, 10:12:05 AM1/7/11
to
"Steve " <sfk28rem...@drexel.edu> wrote in message <ifg0bs$71$1...@fred.mathworks.com>...

> "Mustafa " <Mustafa.Ge...@live.com> wrote in message <i03555$jf$1...@fred.mathworks.com>...
> > Just to add: the watershed in imagej only works on binary images.
>
>
> Have you found a solution to this issue?

I was able to use the Java source file of imagej watershed algorithem inside matlab. Not the perfect solution since i have to deal with java heap memory (I deal with very large images) but it is better than nothing.

Do you need a more technical solution of how to accomplish this? Basically, Open imagej instance, feed in the image (you have to convert from matlab matrix to java and then to imagej format), watershed, convert back to matlab.

Steve

unread,
Jan 7, 2011, 12:21:05 PM1/7/11
to
Thanks I have still been trying to improve my known watersheding algorithm, with some success using marker controlled segmentation. I would be interested in trying to implement the ImageJ java script into Matlab. However I am not to familiar with using Java sources within Matlab, so if you have any help or suggestions of where to look for going about this, it would be much appreciated.

Thanks for your help,

Steve

"Mustafa " <Mustafa.Ge...@live.com> wrote in message <ig7ag5$nsa$1...@fred.mathworks.com>...

Steve

unread,
Jan 7, 2011, 12:23:04 PM1/7/11
to
Thanks I have still been trying to improve my known watersheding algorithm, with some success using marker controlled segmentation. I would be interested in trying to implement the ImageJ java script into Matlab. However I am not to familiar with using Java sources within Matlab, so if you have any help or suggestions of where to look for going about this, it would be much appreciated.

Thanks for your help,

Steve

"Mustafa " <Mustafa.Ge...@live.com> wrote in message <ig7ag5$nsa$1...@fred.mathworks.com>...

Mustafa

unread,
Jan 15, 2011, 12:39:06 PM1/15/11
to
I'll get back to you tommrow with a detailed describtion of how to use java in matlab and specifically, the watershed in imagej. I don't have time right now to go into the details.

But if you want to code it in matlab you wil have to actually look at the code in java language and not just call it in matlab.

Mustafa

unread,
Jan 16, 2011, 11:56:05 AM1/16/11
to
Alright, here is what you do:

1. first you have to download ImageJ and add it to the java watch list of matlab. to add it use the command javaaddpath "filepathandname". The file path should be the path of ij.jar that is found in ImageJ.

2. use the code "ij.IJ.open()" to open ImageJ from matlab.

3. from that point, you can use the commands that you obtain in the macro window in the macro recorder in ImageJ. For example "ij.IJ.run(imp, 'Watershed', '');"

4. also, you can go deaper and play around with functions inside the java jar directly. Check http://rsbweb.nih.gov/ij/developer/api/index.html.

for exchanging image between matlab and the ImageJ environment, the easiest thing is saving in imageJ somewhere and then loading in matlab and vice versa. There are ways using BufferedImage in java to do it directly. I managed to do that for 8bit and 16bit grayshades images. I haven't tried for colored image.

I hope this helps.

"Steve " <sfk28rem...@drexel.edu> wrote in message <ig7i5o$fs9$1...@fred.mathworks.com>...

0 new messages