This post was updated on .
Hello,
this is my first post here and I hope you can help me. I'm trying to analyze pictures of an agricultural field experiment. I want to find out which is the leaf cover index of my plants. Therefore I open the picture to be analyzed in ImageJ and do the following steps: Image> Adjust...> Color Threshold, then I turn the picture in B&W and adjust the HUE and Brightness scale so that all green pixels of the plants are black and pixels of other colors are white. After that I go on with: Analyze> Analyze Partciles...> mark Clear results> Ok Than I get my results. Important for me is the result of the %area. I got more than 800 pictures so I don't wanna do this all manual. I got a script, which gets this work down in a batch, but it doesn't work right. In the following example I got round about 82,6% for green pixel when I analyzed it manual and only 47% when I let the script do the work. I used the same values in the HUE, Saturation and Brightness scale. I think the script runs not right. I don't know the guy who wrote the script, so I can not ask him where the bug is. Can anybody of you look over it and tell me what is wrong with it? The script inverts the pictures, so that green pixels are white and others are black. Could that be the mistake? And what do I have to change in the script that it does not invert the pictures? Output ImageJ Original Here's the script //run("Threshold..."); // Color Thresholder 1.44p // Autogenerated macro, single images only! min=newArray(3); max=newArray(3); filter=newArray(3); a=getTitle(); run("HSB Stack"); run("Convert Stack to Images");run("RGB Color"); border=25; w=getWidth+border*2; h=getHeight+border*2; run("Canvas Size...", "width=w height=h position=Center zero"); selectWindow("Hue"); rename("0"); selectWindow("Saturation"); rename("1"); selectWindow("Brightness"); rename("2"); min[0]=56; max[0]=255; filter[0]="pass"; min[1]=0; max[1]=255; filter[1]="pass"; min[2]=41; 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("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Nothing summarize"); macro "Close All Windows" { while (nImages>0) { selectImage(nImages); close(); I run it with following steps: Process> Batch> Macro... I hope you understand what I mean and anybody can help me! Thank you in advance! |
G'day,
I had to go to the " View this message in context:" link to see the text of your macro. If I run the macro as you have it, the area is about 46%. But change your line (with two commands) run("Convert Stack to Images"); run("RGB Color"); to inactivate the second command run("Convert Stack to Images"); //run("RGB Color"); Then I run the macro and get area about 82.6%. To see what is happening at the intermediate stages, place "//" before each place that says "close();" and run it each way. Either way, the final image is thresholded, with values 255 or 0. Your 'output' image has other values, so it is not clear how you created it. Read about "inverting LUT" or inverted Look Up Table to understand why the image may show a pixel with value 0 as white and 255 as black. Good luck. C -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of HansMaulwurf Sent: Tuesday, June 24, 2014 5:00 AM To: [hidden email] Subject: Analyze Particles gives different results with script/manual Hello, this is my first post here and I hope you can help me. I'm trying to analyze pictures of an agricultural field experiment. I want to find out which is the leaf cover index of my plants. Therefore I open the picture to be analyzed in ImageJ and do the following steps: Image> Adjust...> Color Threshold, then I turn the picture in B&W and Image> adjust the HUE and Brightness scale so that all green pixels of the plants are black and pixels of other colors are white. After that I go on with: Analyze> Analyze Partciles...> mark Clear results> Ok Than I get my results. Important for me is the result of the %area. I got more than 800 pictures so I don't wanna do this all manual. I got a script, which gets this work down in a batch, but it doesn't work right. In the following example I got round about 82,6% for green pixel when I analyzed it manual and only 47% when I let the script do the work. I used the same values in the HUE, Saturation and Brightness scale. I think the script runs not right. I don't know the guy who wrote the script, so I can not ask him where the bug is. Can anybody of you look over it and tell me what is wrong with it? The script inverts the pictures, so that green pixels are white and others are black. Could that be the mistake? And what do I have to change in the script that it does not invert the pictures? Output ImageJ <http://imagej.1557.x6.nabble.com/file/n5008392/5_5_1.jpg> Original <http://imagej.1557.x6.nabble.com/file/n5008392/5_5.jpg> Here's the script I hope you understand what I mean and anybody can help me! Thank you in advance! -- View this message in context: http://imagej.1557.x6.nabble.com/Analyze-Particles-gives-different-results-with-script-manual-tp5008392.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 |
Thank You, C.
It works well now! |
Free forum by Nabble | Edit this page |