Relatively new to ImageJ so please bear with me.
I am trying to 'fragment' a larger image into lots of smaller ones, which I can then analyse individually. To do this I create a Voronoi pattern, overlay it onto my image of interest and invert the selection. This creates anything from 2 to 2000 smaller ROIs, which I add to the ROI manager. This adds the entire set of ROIs as one large selection, which I can then split up into the individual ROIs and save as an ROIset.zip. I checked the ROIs by labelling them and they are correctly selected, but after this I get stuck. Ideally I would like to save each ROI as an individual .tiff file so I can batch process them, how can I do this? Alternatively, if this is not possible, can I get a colour histogram for each of these particles without extracting them into separate files? The goal is to simulate a fragmentation process and determine the chemical make-up of the 'daughter particles'. I have a single RGB image (no slices) from a scanning electron microscope, where different colours represent different phases. So my goal is to extract the colour data from each individual ROI image and export it into a central Excel file. The colour data represents abundance of particular chemical phases which I can then use for further analysis. Thanks in advance for your help!!! Nick PS This thread got closest to my question but I got lost after exporting the data to ROIset.zip, and I'm not working with stacks http://imagej.1557.x6.nabble.com/I-need-to-copy-and-crop-mutiple-ROI-from-each-image-td5000475.html |
On Feb 21, 2014, at 12:18 PM, Nickwheeler wrote:
> Relatively new to ImageJ so please bear with me. > > I am trying to 'fragment' a larger image into lots of smaller ones, which I > can then analyse individually. To do this I create a Voronoi pattern, > overlay it onto my image of interest and invert the selection. This creates > anything from 2 to 2000 smaller ROIs, which I add to the ROI manager. This > adds the entire set of ROIs as one large selection, which I can then split > up into the individual ROIs and save as an ROIset.zip. I checked the ROIs by > labelling them and they are correctly selected, but after this I get stuck. > > Ideally I would like to save each ROI as an individual .tiff file so I can > batch process them, how can I do this? Alternatively, if this is not > possible, can I get a colour histogram for each of these particles without > extracting them into separate files? -wayne imp = IJ.getImage(); ip = imp.getProcessor(); rm = RoiManager.getInstance(); rois = rm.getRoisAsArray(); rt = new ResultsTable(); for (i=0; i<rois.length; i++) { ip.setRoi(rois[i]); ip.setRGBWeights(1, 0, 0); histogram = ip.getHistogram(); rt.incrementCounter(); rt.addValue("ROI", "R"+i); for (j=0; j<256; j++) rt.addValue("C"+j, histogram[j]); ip.setRGBWeights(0, 1, 0); histogram = ip.getHistogram(); rt.incrementCounter(); rt.addValue("ROI", "G"+i); for (j=0; j<256; j++) rt.addValue("C"+j, histogram[j]); ip.setRGBWeights(0, 0, 1); histogram = ip.getHistogram(); rt.incrementCounter(); rt.addValue("ROI", "B"+i); for (j=0; j<256; j++) rt.addValue("C"+j, histogram[j]); } rt.showRowNumbers(false); rt.show("Results"); [cid:[hidden email]] > > The goal is to simulate a fragmentation process and determine the chemical > make-up of the 'daughter particles'. I have a single RGB image (no slices) > from a scanning electron microscope, where different colours represent > different phases. So my goal is to extract the colour data from each > individual ROI image and export it into a central Excel file. The colour > data represents abundance of particular chemical phases which I can then use > for further analysis. > > Thanks in advance for your help!!! > Nick > > > > PS This thread got closest to my question but I got lost after exporting the > data to ROIset.zip, and I'm not working with stacks > http://imagej.1557.x6.nabble.com/I-need-to-copy-and-crop-mutiple-ROI-from-each-image-td5000475.html > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Extracting-individual-tiffs-from-large-number-of-ROIs-tp5006620.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html Screenshot.png (37K) Download Attachment |
Thanks Wayne! That looks like it'll give me the data I need.
Never done any Java programming before, how do I implement this javascript? I tried to put it into a plugin, but get 56 errors saying 'Cannot find symbol' when I compile and run. This is the code I tried: import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; import ij.plugin.frame.*; public class MultiROIhist_ implements PlugIn { public void run(String arg) { ImagePlus imp = IJ.getImage(); IJ.run(imp, "Invert", ""); IJ.wait(1000); IJ.run(imp, "Invert", ""); } imp = IJ.getImage(); ip = imp.getProcessor(); rm = RoiManager.getInstance(); rois = rm.getRoisAsArray(); rt = new ResultsTable(); for (i=0; i<rois.length; i++) { ip.setRoi(rois[i]); ip.setRGBWeights(1, 0, 0); histogram = ip.getHistogram(); rt.incrementCounter(); rt.addValue("ROI", "R"+i); for (j=0; j<256; j++) rt.addValue("C"+j, histogram[j]); ip.setRGBWeights(0, 1, 0); histogram = ip.getHistogram(); rt.incrementCounter(); rt.addValue("ROI", "G"+i); for (j=0; j<256; j++) rt.addValue("C"+j, histogram[j]); ip.setRGBWeights(0, 0, 1); histogram = ip.getHistogram(); rt.incrementCounter(); rt.addValue("ROI", "B"+i); for (j=0; j<256; j++) rt.addValue("C"+j, histogram[j]); } rt.showRowNumbers(false); rt.show("Results"); } |
On Feb 22, 2014, at 10:29 AM, Nickwheeler wrote:
> Thanks Wayne! That looks like it'll give me the data I need. > > Never done any Java programming before, how do I implement this javascript? JavaScript and Java are not the same thing. JavaScript is an easier to use scripting language. To run this JavaScript, open a new editor window (Plugins>New>JavaScript), paste the script into the window and type ctrl+j (Macros>Evaluate JavaScript). -wayne > I tried to put it into a plugin, but get 56 errors saying 'Cannot find > symbol' when I compile and run. > > This is the code I tried: > > import ij.*; > import ij.process.*; > import ij.gui.*; > import java.awt.*; > import ij.plugin.*; > import ij.plugin.frame.*; > > public class MultiROIhist_ implements PlugIn { > > public void run(String arg) { > ImagePlus imp = IJ.getImage(); > IJ.run(imp, "Invert", ""); > IJ.wait(1000); > IJ.run(imp, "Invert", ""); > } > > imp = IJ.getImage(); > ip = imp.getProcessor(); > rm = RoiManager.getInstance(); > rois = rm.getRoisAsArray(); > rt = new ResultsTable(); > for (i=0; i<rois.length; i++) { > ip.setRoi(rois[i]); > ip.setRGBWeights(1, 0, 0); > histogram = ip.getHistogram(); > rt.incrementCounter(); > rt.addValue("ROI", "R"+i); > for (j=0; j<256; j++) > rt.addValue("C"+j, histogram[j]); > ip.setRGBWeights(0, 1, 0); > histogram = ip.getHistogram(); > rt.incrementCounter(); > rt.addValue("ROI", "G"+i); > for (j=0; j<256; j++) > rt.addValue("C"+j, histogram[j]); > ip.setRGBWeights(0, 0, 1); > histogram = ip.getHistogram(); > rt.incrementCounter(); > rt.addValue("ROI", "B"+i); > for (j=0; j<256; j++) > rt.addValue("C"+j, histogram[j]); > } > rt.showRowNumbers(false); > rt.show("Results"); > > } > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Extracting-individual-tiffs-from-large-number-of-ROIs-tp5006620p5006631.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > 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 |