We are running FInd Maxima with an ROI selected. Find Maxima "respects"
the ROI, and only marks the maxima that are within the ROI. I should note that the ROI is an "irregular" shape (ie, not rectangular). So the following code in python: IJ.run("Find Maxima...", "noise=" + str(noiseThreshold)+" output=[Maxima Within Tolerance]") works as expected. However, the following API version: max_proc = MaximumFinder().findMaxima(ip, float(noiseThreshold), ImageProcessor.NO_THRESHOLD, int(1), True, False) marks an extra maximum which is outside of the ROI (but inside the bounding rectangle). Here is the link to the API: http://imagej.nih.gov/ij/developer/api/ij/plugin/filter/MaximumFinder.html It appears that the API version is using the bounding box of the ROI. Is this a bug, or did I use it incorrectly? --aryeh -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Jul 16, 2014, at 8:01 AM, Aryeh Weiss wrote:
> We are running FInd Maxima with an ROI selected. Find Maxima "respects" the ROI, > and only marks the maxima that are within the ROI. I should note that the ROI is an "irregular" shape > (ie, not rectangular). So the following code in python: > > IJ.run("Find Maxima...", "noise=" + str(noiseThreshold)+" output=[Maxima Within Tolerance]") > > works as expected. > > However, the following API version: > > max_proc = MaximumFinder().findMaxima(ip, float(noiseThreshold), ImageProcessor.NO_THRESHOLD, int(1), True, False) > > marks an extra maximum which is outside of the ROI (but inside the bounding rectangle). > Here is the link to the API: > http://imagej.nih.gov/ij/developer/api/ij/plugin/filter/MaximumFinder.html > > It appears that the API version is using the bounding box of the ROI. > Is this a bug, or did I use it incorrectly? I am unable to duplicate this problem. The following macro and JavaScript produce exactly the same output. When reporting a potential bug, it is very helpful to include a small, runnable example macro or script that reproduces the problem. // Macro run("Cell Colony (31K)"); run("Invert"); makeOval(133, 85, 110, 243); run("Find Maxima...", "noise=50 output=[Maxima Within Tolerance] exclude"); // JavaScript imp = IJ.openImage("http://imagej.nih.gov/ij/images/Cell_Colony.jpg"); ip = imp.getProcessor(); ip.invert(); roi = new OvalRoi(133, 85, 110, 243); ip.setRoi(roi); ip2 = (new MaximumFinder()).findMaxima(ip, 50, 1, true) new ImagePlus("ip2", ip2).show(); -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Wayne replied to me offlist, but my copy to the list bounced because of
the attachment. For the benefit of the list, I will summarize his reply. On 7/17/14, 12:10 AM, Rasband, Wayne (NIH/NIMH) [E] wrote: > On Jul 16, 2014, at 8:01 AM, Aryeh Weiss wrote: > >> We are running Find Maxima with an ROI selected. Find Maxima "respects" the ROI, >> and only marks the maxima that are within the ROI. I should note that the ROI is an "irregular" shape >> (ie, not rectangular). So the following code in python: >> >> IJ.run("Find Maxima...", "noise=" + str(noiseThreshold)+" output=[Maxima Within Tolerance]") >> >> works as expected. >> >> However, the following API version: >> >> max_proc = MaximumFinder().findMaxima(ip, float(noiseThreshold), ImageProcessor.NO_THRESHOLD, int(1), True, False) >> >> marks an extra maximum which is outside of the ROI (but inside the bounding rectangle). >> Here is the link to the API: >> http://imagej.nih.gov/ij/developer/api/ij/plugin/filter/MaximumFinder.html >> >> It appears that the API version is using the bounding box of the ROI. >> Is this a bug, or did I use it incorrectly? > I am unable to duplicate this problem. The following macro and JavaScript produce exactly the same output. When reporting a potential bug, it is very helpful to include a small, runnable example macro or script that reproduces the problem. > > // Macro > run("Cell Colony (31K)"); > run("Invert"); > makeOval(133, 85, 110, 243); > run("Find Maxima...", "noise=50 output=[Maxima Within Tolerance] exclude"); > > // JavaScript > imp = IJ.openImage("http://imagej.nih.gov/ij/images/Cell_Colony.jpg"); > ip = imp.getProcessor(); > ip.invert(); > roi = new OvalRoi(133, 85, 110, 243); > ip.setRoi(roi); > ip2 = (new MaximumFinder()).findMaxima(ip, 50, 1, true) > new ImagePlus("ip2", ip2).show(); > > -wayne > > ip = imp.getProcessor() max_proc = MaximumFinder().findMaxima(ip, float(noiseThreshold), ImageProcessor.NO_THRESHOLD, int(1), True, False) Where the image had an ROI selected. The mistake is that I did nto transfer the nonrectangular ROI to the image processor. ip = imp.getProcessor()) ip.setRoi(imp.getRoi()) max_proc = MaximumFinder().findMaxima(ip, float(noiseThreshold), ImageProcessor.NO_THRESHOLD, int(1), True, False) solves the problem. --aryeh -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Aryeh,
in a PlugInFilter, you the ROI of the ImageProcessor is always equal to that of the ImagePlus. If you write a PlugIn, you can't be sure about this; you have to care yourself about setting the Roi for the ImageProcessor in case you need it: For area rois, this will typically look like the following: Roi roi = imp.getRoi(); if (roi!=null && roi.isArea()) ip.setRoi(roi); else ip.setRoi((Roi)null); Michael ________________________________________________________________ On Jul 16, 2014, at 14:01, Aryeh Weiss wrote: > We are running FInd Maxima with an ROI selected. Find Maxima "respects" the ROI, > and only marks the maxima that are within the ROI. I should note that the ROI is an "irregular" shape > (ie, not rectangular). So the following code in python: > > IJ.run("Find Maxima...", "noise=" + str(noiseThreshold)+" output=[Maxima Within Tolerance]") > > works as expected. > > However, the following API version: > > max_proc = MaximumFinder().findMaxima(ip, float(noiseThreshold), ImageProcessor.NO_THRESHOLD, int(1), True, False) > > marks an extra maximum which is outside of the ROI (but inside the bounding rectangle). > Here is the link to the API: > http://imagej.nih.gov/ij/developer/api/ij/plugin/filter/MaximumFinder.html > > It appears that the API version is using the bounding box of the ROI. > Is this a bug, or did I use it incorrectly? > > --aryeh > > -- > Aryeh Weiss > Faculty of Engineering > Bar Ilan University > Ramat Gan 52900 Israel > > Ph: 972-3-5317638 > FAX: 972-3-7384051 > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |