# Combined surface area of all ROI in an image

5 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Combined surface area of all ROI in an image

 Easy - yet so difficult: How can I measure the combined total surface area of all ROI in an image? In the attached example : surface area of ROIs 125+126+127+128 = ? I'm wondering if this can be done automatically? My timeseries has 250 images and the number of ROIs is variable from frame to frame => I'd like to get one number/slice.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Combined surface area of all ROI in an image

 In a Java plugin, you could use Roi's point iterator to count the included pixels, as described here: https://imagej.nih.gov/ij/developer/api/ij/gui/Roi.htmlThis should work for composite ROIs too. --Wilhelm -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of mmettlen Sent: Montag, 15. Mai 2017 15:38 To: [hidden email] Subject: Combined surface area of all ROI in an image Easy - yet so difficult: How can I measure the combined total surface area of all ROI in an image? In the attached example : surface area of ROIs 125+126+127+128 = ? I'm wondering if this can be done automatically? My timeseries has 250 images and the number of ROIs is variable from frame to frame => I'd like to get one number/slice. -- View this message in context: http://imagej.1557.x6.nabble.com/Combined-surface-area-of-all-ROI-in-an-image-tp5018716.htmlSent 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
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Combined surface area of all ROI in an image

 If you have all the ROIs in the ROI manager you could use something like below in the macro language. This assumes an 8-bit image. ----------------------------------code snippet------------------------------------------- run("Colors...", "foreground=white background=black selection=red"); run("Set Measurements...", "area display redirect=None decimal=3"); roiManager("Deselect"); roiManager("Fill"); setAutoThreshold("Default dark"); setThreshold(255, 255); getDimensions(width, height, channels, slices, frames); for(i=1;i<=frames;i++){         setSlice(i);         run("Analyze Particles...", "size=25-Infinity pixel summarize"); } ------------------------------------------------------------------------------------ The results should be a summary table with the total area + area fraction for each frame. Hope it works Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aifImageJ workshops 1 and 2 June: http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017-----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Burger Wilhelm Sent: 16 May 2017 08:49 To: [hidden email] Subject: Re: Combined surface area of all ROI in an image In a Java plugin, you could use Roi's point iterator to count the included pixels, as described here: https://imagej.nih.gov/ij/developer/api/ij/gui/Roi.htmlThis should work for composite ROIs too. --Wilhelm -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of mmettlen Sent: Montag, 15. Mai 2017 15:38 To: [hidden email] Subject: Combined surface area of all ROI in an image Easy - yet so difficult: How can I measure the combined total surface area of all ROI in an image? In the attached example : surface area of ROIs 125+126+127+128 = ? I'm wondering if this can be done automatically? My timeseries has 250 images and the number of ROIs is variable from frame to frame => I'd like to get one number/slice. -- View this message in context: http://imagej.1557.x6.nabble.com/Combined-surface-area-of-all-ROI-in-an-image-tp5018716.htmlSent 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-- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Combined surface area of all ROI in an image

 In reply to this post by mmettlen Thanks for your replies! I've worked on it too and wrote a little macro that does what Kees suggested. In a nutshell, the macro takes a stack of images and the corresponding ROI manager that contains all the ROIs. It than makes a new 8-bit black stack with the same dimension as the original stack, copies the ROIs into it, flattens them, and uses them to quantify the total area of all ROIs/slice: if (isOpen("Results")) {selectWindow("Results"); run ("Close");} dir = getDirectory("image"); //the original stack has to be open with its corresponding ROI manager title = getTitle(); getDimensions(width, height, channels, slices, frames); FolderName = split(title,"."); DirName = FolderName[0]; File.makeDirectory(dir+File.separator+DirName); while (nImages>0) {           selectImage(nImages);         close();} run("Set Measurements...", "area limit display redirect=None decimal=2"); newImage("Untitled", "8-bit black", width, height, frames); roiManager("Set Fill Color", "white"); //copies all ROIs into a given slice - pulled from ROI manager roiManager("Show All"); //copies all ROIs into a given slice - pulled from ROI manager for (i=1; i<=nSlices; i++) {run("Set Slice...", "slice="+i); setBatchMode(true); run("Flatten", "slice"); //'burn's white ROIs into black image run("8-bit"); saveAs("tif", dir+DirName+File.separator+"Mask_"+i+".tif"); close();}; //the saved images will be used below to automatically generate a stack while (nImages>0) {           selectImage(nImages);         close();} setBatchMode(false); run("Image Sequence...", "open="+dir+DirName+File.separator+"Mask_1.tif sort"); setThreshold(100, 255); //stack is thresholded and used to measure surface area of all ROIs for (i=1; i<=nSlices; i++) {run("Set Slice...", "slice="+i); run("Measure");} selectWindow("Results"); saveAs("txt", dir+File.separator+"Results_"+DirName+".txt"); run("Close"); while (nImages>0) {           selectImage(nImages);         close();} if (isOpen("Log")) {selectWindow("Log"); run ("Close");}