when recording a Macro, I do a Color Threshold, and hit the Macro button to send the threshold settings into the macro, it also adds a bunch of routines that I don't want, like HSB Stack & some other stuff that ends up making the resultant image completely white except for the thresholded voids. This makes it hard to see if it picked the void area correctly without seeing the image in the background. If I Color Threshold manually & then manually do a analyze Particles, I can pick Outline Overlay as an option & get what I want. Is there not a way to record in the Macro just the Color Threshold Settings as if I were doing it manually? See the Macro below, issue is in the Color Thresholder 1.48v section Thanks, Steve run("Enhance Contrast...", "saturated=0.3 equalize"); // Color Thresholder 1.48v // Autogenerated macro, single images only! min=newArray(3); max=newArray(3); filter=newArray(3); a=getTitle(); run("HSB Stack"); run("Convert Stack to Images"); selectWindow("Hue"); rename("0"); selectWindow("Saturation"); rename("1"); selectWindow("Brightness"); rename("2"); min[0]=16; max[0]=250; filter[0]="stop"; min[1]=101; max[1]=173; filter[1]="pass"; min[2]=127; max[2]=255; filter[2]="pass"; for (i=0;i<3;i++){ selectWindow(""+i); setThreshold(min[i], max[i]); run("Convert to Mask"); if (filter[i]=="stop") run("Invert"); } imageCalculator("AND create", "0","1"); imageCalculator("AND create", "Result of 0","2"); for (i=0;i<3;i++){ selectWindow(""+i); close(); } selectWindow("Result of 0"); close(); selectWindow("Result of Result of 0"); rename(a); // Colour Thresholding------------- run("Set Scale...", "distance=599.24 known=1 pixel=1 unit=INCH global"); //Example macro calculating stats from a results table column //Import any data into a results table and then use the following to extract summary stats //The examples use "Area" as the column heading //All results checked with OpenOffice Calc, note: variance uses n-1 to correct for sample bias //Some variables N=0; total_area=0; mean_area=0; total_variance=0; variance_area=0; SD_Area=0; SE_Area=0; CI95_Area=0; max_area=0; min_area=0; Voiding_Total_Area=0; Percent_Voiding=0; //Generate a results table run("Clear Results"); run("Set Measurements...", "area redirect=None decimal=4"); run("Analyze Particles...", "size=0.00010-Infinity show=[Overlay Outlines] display clear include summarize in_situ"); //Number of results in "Area" Column N = nResults; //Mean "Area"column for (a=0; a<nResults(); a++) { total_area=total_area+getResult("Area",a); mean_area=total_area/nResults; } //Voiding Total_Area; //for (a=0; a<nResults(); a++) { //total_area=total_area+getResult("Area",a); //Voiding_Total_Area=total_area/2; Voiding_Total_Area=total_area; //%_Voiding; for (a=0; a<nResults(); a++) { total_area=total_area+getResult("Area",a); Percent_Voiding=total_area/12.08*100/2; } //Max value in "Area" column for (a=0; a<nResults(); a++) { if (getResult("Area",a)>max_area) { max_area = getResult("Area",a); } else{}; } //Min value in "Area" column (note: requires max value) min_area=max_area; for (a=0; a<nResults(); a++) { if (getResult("Area",a)<min_area) { min_area = getResult("Area",a); } else{}; } //Variance of "Area" column for (a=0; a<nResults(); a++) { total_variance=total_variance+(getResult("Area",a)-(mean_area))*(getResult("Area",a)-(mean_area)); variance_area=total_variance/(nResults-1); } //SD of "Area" column (note: requires variance) SD_Area=sqrt(variance_area); //SE of "Area" column (note: requires SD) SE_Area = (SD_Area/(sqrt(N))); //95% CI of column "Area" (note: requires SE) CI95_Area = 1.96*SE_Area; //Return values print("N = "+N); print("Mean = "+mean_area); print("Var = "+variance_area); print("SD = "+SD_Area); print("SE = "+SE_Area); print("95% CI = "+CI95_Area); print("Max = "+max_area); print("Min = "+min_area); print("Voiding Total Area = "+Voiding_Total_Area); print("Percent_Voiding = "+Percent_Voiding); //Richard |
On Tuesday 02 Dec 2014 15:21:47 Steve R wrote:
> when recording a Macro, I do a Color Threshold, and hit the Macro button to > send the threshold settings into the macro, it also adds a bunch of routines > that I don't want, like HSB Stack & some other stuff that ends up making > the resultant image completely white except for the thresholded voids. I wrote the routine that generates the macro code, so I might be able to help here. The colour threshold procedure converts a colour image to binary (black and white), so the macro generated is doing what it is supposed to do and needs all that code. If the image were leaving other colours, it would not be a thresholded image. What you want to is masking some colour combinations set with the sliders. > This > makes it hard to see if it picked the void area correctly without seeing > the image in the background. If I Color Threshold manually & then manually > do a analyze Particles, I can pick Outline Overlay as an option & get what > I want. I understand the problem, but there is no automatic way of doing this. > Is there not a way to record in the Macro just the Color Threshold Settings > as if I were doing it manually? Unfortunately not, but you can easily do this: if the "white is the part where you want to see the original colours (and the rest black) then you can do an AND operation between the original and the binary image. If it is the "black" part where you want to see the colours, then invert the binary image and then apply the AND operation with the original. Hope this helps. Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
It's the White area I want to see, if you can help with the AND command line & where I would insert it in the macro I pasted earlier, it would be appreciated.
I tried a couple things that didn't work, & like I said I'm a newbie :) Thanks! |
On Wednesday 03 Dec 2014 07:50:04 you wrote:
> It's the White area I want to see, if you can help with the AND command line > & where I would insert it in the macro I pasted earlier, it would be > appreciated. > I tried a couple things that didn't work, & like I said I'm a newbie :) > Thanks! Use the macro recorder and then Process>Image Calculator Choose the 2 images and the AND operation. Then the macro recorder will show the macro line you need to add at the end of the macro generated by the colour thresholder. To make this work with "any" image you will need to substitute the file name strings with some variable that you obtain with, e.g. getTitle(). Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Ok, when you say choose the 2 images, you mean the original image & the result image after macro has run? Thanks Gabriel, I really appreciate you taking the time to help me out. Steve From: Gabriel Landini [via ImageJ] [mailto:ml-node+[hidden email]]
On Wednesday 03 Dec 2014 07:50:04 you wrote:
If you reply to this email, your message will be added to the discussion below: http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010745.html
To unsubscribe from IJ Color Thresholding in Macro,
click here. |
On Wednesday 03 Dec 2014 09:48:14 you wrote:
> Ok, when you say choose the 2 images, you mean the original image & the > result image after macro has run? Thanks Gabriel, I really appreciate you > taking the time to help me out. Steve Yes that is right. Actually I forgot that the macro version creates an 8 bit image (and the interactive mode does not), so you should choose the original (open it again) as image 1 and the binary result as image 2. Let's suppose you open the clown,jpg image. If you run the macro generated by the colour thresholder, then the binary image (8bit) is still named clown.jpg. Now you open again the colour image (or duplicated before applying the macro) so now the colour image is named clown-1.jpg. The image calculator operation should be: imageCalculator("AND create", "clown-1.jpg","clown.jpg"); That is the colour image (clown-1.jpg) has to be the first one as this set the image type (RGB) of the result. Alternative if the binary result is converted to RGB (still looks as B/W) then the order of the images in the Image Calculator does not matter as they are both RGB. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Ok, I see, got that to work & that’s a big improvement over what I had. Here is the code it generated. So I think I know where to insert his in my macro, but how do I replace these 2 names with instruction to act on the images within the macro? Like you said “all
images” Let me know, Thanks again, Steve imageCalculator("AND create", "NthRun_ 352_CR_01-1.jpg","NthRun_ 352_CR_01.jpg"); selectWindow("Result of NthRun_ 352_CR_01-1.jpg"); close(); From: Gabriel Landini [via ImageJ] [mailto:ml-node+[hidden email]]
On Wednesday 03 Dec 2014 09:48:14 you wrote:
If you reply to this email, your message will be added to the discussion below: http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010749.html
To unsubscribe from IJ Color Thresholding in Macro,
click here. |
On Wednesday 03 Dec 2014 11:56:34 you wrote:
> Ok, I see, got that to work & that's a big improvement over what I had. > Here is the code it generated. So I think I know where to insert his in my > macro, but how do I replace these 2 names with instruction to act on the > images within the macro? Like you said "all images" Let me know, Thanks > again, Steve After you open the first image, execute in a macro. n1=getTitle(); n1 holds the name, so you replace the "clown.jpg" string (with " " ) for the variable n1 with no " ". And do similarly for the 2nd image. But perhaps it is easier if you rename the images within the macro after they are opened, (like "image1" and "image2"and use that in the Image Calculator. Cheers. G -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Sorry, still a little confused with this:
n1 holds the name, so you replace the "clown.jpg" string
(with " " ) for the Guess I’m dense, but not sure what to do from your instructions above. I understand about adding the variable & where to put it, but not the code to combine the 2 images. This is the string where I need to replace the image names with the variables referencing the 2 images, right? imageCalculator("AND create", "clown-1.jpg","clown.jpg"); Can you explain more, appreciate it. Steve From: Gabriel Landini [via ImageJ] [mailto:ml-node+[hidden email]]
On Wednesday 03 Dec 2014 11:56:34 you wrote:
If you reply to this email, your message will be added to the discussion below: http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010756.html
To unsubscribe from IJ Color Thresholding in Macro,
click here. |
On Thursday 04 Dec 2014 07:59:50 Steve R <[hidden email]> wrote:
> Sorry, still a little confused with this: This should explain it. run("Clown (14K)"); n1=getTitle(); run("Duplicate...", " "); n2=getTitle(); selectImage(n1); // include the the thresholding macro code here // it will threshold the selected image n1 imageCalculator("AND create", n2, n1); Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Gabriel, Thanks so much! I have it working now. I had an error at first when I ran the macro saying the image must be color thresholded before doing an Analyze
Particles. So I moved the ImageCalculator string down after the Analyze Particles routine in the macro & it worked. Again appreciate your help, wouldn’t have been able to even come close if it wasn’t for your help. Oh yeah, one more quick question, is there not a way to save all the settings in ImageJ, like a configuration file or something, so that next time you open ImageJ
& run things like Color Threshold, the default starting settings come up with what you had saved? Let me know, Thanks, Steve From: Gabriel Landini [via ImageJ] [mailto:ml-node+[hidden email]]
On Thursday 04 Dec 2014 07:59:50 Steve R <[hidden email]> wrote:
If you reply to this email, your message will be added to the discussion below: http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010766.html
To unsubscribe from IJ Color Thresholding in Macro,
click here. |
In reply to this post by Gabriel Landini
Hi Gabriel, One thing I just noticed is the Overlay Outlines created in Analyze Particles doesn’t transfer to the combined image after the Image Calculator routine. (see
attached pics) Is there any way to combine them & keep the outline overlay? like with ImagePro you can burn the overlay into the image so it’s part of the picture. Reason this is important is the black Areas highlight everything thresholded, but if I don’t want to include very small voids in the data analysis, I set the
filter range in the analyze particles routine to exclude the smaller voids, so after analyze particles routine it only outlines the voids in the Area range I’ve selected. Which is what the operators need to see to confirm the analysis has correctly chosen
voids. Let me know, thanks Steve From: Steve Roach
Gabriel, Thanks so much! I have it working now. I had an error at first when I ran the macro saying the image must be color thresholded before doing an Analyze
Particles. So I moved the ImageCalculator string down after the Analyze Particles routine in the macro & it worked. Again appreciate your help, wouldn’t have been able to even come close if it wasn’t for your help. Oh yeah, one more quick question, is there not a way to save all the settings in ImageJ, like a configuration file or something, so that next time you open ImageJ
& run things like Color Threshold, the default starting settings come up with what you had saved? Let me know, Thanks, Steve From: Gabriel Landini [via ImageJ] [[hidden email]]
On Thursday 04 Dec 2014 07:59:50 Steve R <[hidden email]> wrote:
If you reply to this email, your message will be added to the discussion below: http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010766.html
To unsubscribe from IJ Color Thresholding in Macro,
click here. 2 images I'm Combining.bmp (1M) Download Attachment Result After Combining.bmp (5M) Download Attachment |
Dear Steve,
this is going to become a privatissimum. What about consulting the ImageJ-manual? <rsb.info.nih.gov/ij/docs/guide/user-guide.pdf> BTW, you may flatten selections (Image > Overlay > Flatten), that is make them part of the pixel array. HTH Herbie ::::::::::::::::::::::::::::::::: On 04.12.14 21:59, Steve R wrote: > Hi Gabriel, > One thing I just noticed is the Overlay Outlines created in Analyze Particles doesn't transfer to the combined image after the Image Calculator routine. (see attached pics) > Is there any way to combine them & keep the outline overlay? like with ImagePro you can burn the overlay into the image so it's part of the picture. > > Reason this is important is the black Areas highlight everything thresholded, but if I don't want to include very small voids in the data analysis, I set the filter range in the analyze particles routine to exclude the smaller voids, so after analyze particles routine it only outlines the voids in the Area range I've selected. Which is what the operators need to see to confirm the analysis has correctly chosen voids. > Let me know, thanks Steve > [cid:image003.jpg@01D00FCA.46B45C20] > > From: Steve Roach > Sent: Thursday, December 4, 2014 1:07 PM > To: 'Gabriel Landini [via ImageJ]' > Subject: RE: IJ Color Thresholding in Macro > > > Gabriel, Thanks so much! I have it working now. I had an error at first when I ran the macro saying the image must be color thresholded before doing an Analyze Particles. > So I moved the ImageCalculator string down after the Analyze Particles routine in the macro & it worked. > Again appreciate your help, wouldn't have been able to even come close if it wasn't for your help. > > Oh yeah, one more quick question, is there not a way to save all the settings in ImageJ, like a configuration file or something, so that next time you open ImageJ & run things like Color Threshold, the default starting settings come up with what you had saved? > Let me know, > Thanks, > Steve > > > From: Gabriel Landini [via ImageJ] [mailto:[hidden email]] > Sent: Thursday, December 4, 2014 9:18 AM > To: Steve Roach > Subject: Re: IJ Color Thresholding in Macro > > On Thursday 04 Dec 2014 07:59:50 Steve R <[hidden email]</user/SendEmail.jtp?type=node&node=5010766&i=0>> wrote: >> Sorry, still a little confused with this: > > This should explain it. > > run("Clown (14K)"); > n1=getTitle(); > run("Duplicate...", " "); > n2=getTitle(); > selectImage(n1); > // include the the thresholding macro code here > // it will threshold the selected image n1 > imageCalculator("AND create", n2, n1); > > Cheers > Gabriel > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > ________________________________ > If you reply to this email, your message will be added to the discussion below: > http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010766.html > To unsubscribe from IJ Color Thresholding in Macro, click here< > NAML<http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > > > image003.jpg (9K) <http://imagej.1557.x6.nabble.com/attachment/5010772/0/image003.jpg> > 2 images I'm Combining.bmp (1M) <http://imagej.1557.x6.nabble.com/attachment/5010772/1/2%20images%20I%27m%20Combining.bmp> > Result After Combining.bmp (5M) <http://imagej.1557.x6.nabble.com/attachment/5010772/2/Result%20After%20Combining.bmp> > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/IJ-Color-Thresholding-in-Macro-tp5010727p5010772.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 |
In reply to this post by Steve R
On Thursday 04 Dec 2014 12:59:34 you wrote:
> One thing I just noticed is the Overlay Outlines created in Analyze > Particles doesn't transfer to the combined image after the Image Calculator > routine. (see attached pics) Is there any way to combine them & keep the > outline overlay? like with ImagePro you can burn the overlay into the image > so it's part of the picture. I do not use ImagePro, so I do not know. If it is the ROI that you are missing, perhaps look into the macro functions for "Restore ROI". I am not sure what is that you are intending to do and this is getting complicated to follow because this is not the way that the plugins were intended to be used, but to make the process as automated as possible without user interaction. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |