does anyone know if it is possible to set the watershed functions (or use a different plugin/function) so that only the very narrow constrictions are separated, but the more broad constrictions are skipped?
Thank you! dani |
On Monday 28 September 2009 14:09:03 danibodor wrote:
> does anyone know if it is possible to set the watershed functions (or use a > different plugin/function) so that only the very narrow constrictions are > separated, but the more broad constrictions are skipped? You cannot set the watershed to do what you want, but you can process the result and retain (using binary reconstruction) the separating cuts that fall in some category that you define, for example, if they are up to certain length. You will need do download the Morphology plugins from: http://www.dentistry.bham.ac.uk/landinig/software/morphology.zip and use the macro below (mind the line breaks added by the mailer). Let me know if it does not work, I have not used it for some time. Cheers, G. //-----------------8<------------------------------- // ConstrainedWatershedSeparation.txt // as suggested by R. Stein at the 2nd IJ Conference (hi Rorvik!) // but using Lines8 to measure the separation lengths. // Expects white particles on a black background // G. Landini at bham ac uk // 7/12/2008 a=getTitle(); setBatchMode(true); run("Duplicate...", "title=ttt"); run("Watershed"); imageCalculator("Subtract create", a,"ttt"); rename("cuts"); run("Duplicate...", "title=skels"); // use the skeletonts to measure the lenght of the watershed lines run("Lines8 ", "white skeletonize show=Lines minimum=0 maximum=9999999 display overwrite redirect=None"); //run("Distribution...", "parameter=SkelLength automatic"); min=100000000; max=-1; n=nResults; sl=newArray(n); xs=newArray(n); ys=newArray(n); // get the lengths and start points for (i=0; i<n; i++) { sl[i] = getResult('SkelLength', i); xs[i] = getResult('XStart', i); ys[i] = getResult('YStart', i); if (sl[i]>max) max=sl[i]; if (sl[i]<min) min=sl[i]; } // let the user choose what to retain Dialog.create("Constrained watershed separation"); Dialog.addMessage("Separate blobs with lines between:"); Dialog.addNumber("Minimum", min); Dialog.addNumber("Maximum", max); Dialog.addMessage("pixels long."); Dialog.show(); min=Dialog.getNumber(); max=Dialog.getNumber(); // set seeds selectImage("skels"); run("Set...", "value=0"); for (i=0; i<n; i++) { if ((sl[i]>=min) && (sl[i]<=max)) setPixel(xs[i],ys[i],255); } // reconstruct the original watershed lines (4-conn) // with start points of their skeletons (8-conn) // This is OK since the 4-conn lines 'contain' the 8-conn // skeletons (and their start poins) run("BinaryReconstruct ", "mask=cuts seed=skels white"); imageCalculator("Subtract", a,"skels"); selectImage("skels"); close(); selectImage("ttt"); close(); selectImage("cuts"); close(); setBatchMode(false); //-----------------8<------------------------------- |
In reply to this post by danibodor
Hi Dani,
what you can try: - create an EDM (best with float accuracy; set this in Binary Options) - threshold, range = 1 ... maximum - Find Maxima with "above lower threshold" and "Segmented" output. The higher the tolerance, the less sensitive it becomes to broad constrictions (use preview to see which particles you get). Michael ________________________________________________________________ On 28 Sep 2009, at 14:43, danibodor wrote: > does anyone know if it is possible to set the watershed functions > (or use a > different plugin/function) so that only the very narrow > constrictions are > separated, but the more broad constrictions are skipped? > > Thank you! > > dani |
I'm sorry Michael, but I don't really understand what I should do.
- How do I create an EDM? If i go to binary options and dont select any operation (erode, etc), i don't think anything changes. Alos, do I create the EDM from a binary image or from the original? - Find maxima in the binary menu doesnt give me the option "above lower background" nor "segmented output". What do you mean here? Could you give me a little bit broader explanation of what i should exactly do, thanks! dani
|
Hi Dani,
danibodor wrote: > - How do I create an EDM? If i go to binary options and dont select any > operation (erode, etc), i don't think anything changes. Alos, do I create > the EDM from a binary image or from the original? I assume what Michael ment is "Process>Binary>Distance Map" to create the Euclidian Distance Map. In the options dialog you just set the accuracy to 32-bit float. You have to work on the binary image. > - Find maxima in the binary menu doesnt give me the option "above lower > background" nor "segmented output". What do you mean here? Choose the output type "Segmented Particles". HTH, jan > Michael Schmid-3 wrote: >> Hi Dani, >> >> what you can try: >> - create an EDM (best with float accuracy; set this in Binary Options) >> - threshold, range = 1 ... maximum >> - Find Maxima with "above lower threshold" and "Segmented" output. >> The higher the tolerance, the less sensitive it becomes to broad >> constrictions (use preview to see which particles you get). >> >> Michael >> ________________________________________________________________ >> >> On 28 Sep 2009, at 14:43, danibodor wrote: >> >>> does anyone know if it is possible to set the watershed functions >>> (or use a >>> different plugin/function) so that only the very narrow >>> constrictions are >>> separated, but the more broad constrictions are skipped? >>> >>> Thank you! >>> >>> dani |
In reply to this post by danibodor
Hi Dani,
sorry, my response was not really clear, I was in a hurry. Here is a macro with the detailed sequence of commands: run("Options...", "edm=32-bit"); // Process>Binary>Options run("Distance Map"); setThreshold(1.0, 99999.0); run("Find Maxima...", "noise=10 output=[Segmented Particles] above light"); //"above" stands for "above lower threshold", "light" for "light background" You can adjust the noise tolerance of "Find Maxima" as you like; higher values give fewer segmentation lines (when doing it interactively, use preview). The accuracy of this approach is slightly lower than that of the built-in "Watershed" command: "Watershed" interpolates between the pixels of the EDM (Euclidian Distance Map) to get more accurate values for the maxima. It won't play a role for large values of the noise tolerance (say, above 5), but you can get improper segmentation at noise tolerance values below 1. Michael ________________________________________________________________ On 28 Sep 2009, at 16:45, danibodor wrote: > I'm sorry Michael, but I don't really understand what I should do. > > - How do I create an EDM? If i go to binary options and dont select > any > operation (erode, etc), i don't think anything changes. Alos, do I > create > the EDM from a binary image or from the original? > - Find maxima in the binary menu doesnt give me the option "above > lower > background" nor "segmented output". What do you mean here? > > > Could you give me a little bit broader explanation of what i should > exactly > do, > thanks! > > > dani > > > > Michael Schmid-3 wrote: >> >> Hi Dani, >> >> what you can try: >> - create an EDM (best with float accuracy; set this in Binary >> Options) >> - threshold, range = 1 ... maximum >> - Find Maxima with "above lower threshold" and "Segmented" output. >> The higher the tolerance, the less sensitive it becomes to broad >> constrictions (use preview to see which particles you get). >> >> Michael >> ________________________________________________________________ >> >> On 28 Sep 2009, at 14:43, danibodor wrote: >> >>> does anyone know if it is possible to set the watershed functions >>> (or use a >>> different plugin/function) so that only the very narrow >>> constrictions are >>> separated, but the more broad constrictions are skipped? >>> >>> Thank you! >>> >>> dani >> >> > > -- > View this message in context: http://n2.nabble.com/watershed- > settings-tp3729209p3729830.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |