Inconsistancy with code performance between GUI and Command Line possible issue with multiple reuslts?

Hi, can someone help me find a bug in my code. I have a macro that is working in GUI but when I try to run it via command line, I get an issue with getting my second results where the same value is present for all images. Basically, I open an image do Process 1 and get some results (Mean) then further process and get results (%Area). I can get the results for process one per Image and they match what I expect from GUI results but in process 2, I get the same value for all of my test Images which is not expected. I have added a print line so I can see that the loop is working and not stuck on one Image. I suspect the line of code with and issue (Larger example below) is… var2=getResult("%Area",nResults-1); but as it is giving me a result just not changing with image nor matching the GUI I do not know what the problem is. One thing I considered trying but that I do not know how to do would be to clear the results from process one after I extracted my measurements but as the results in command line are held in some hidden place I’m not sure how to do that.


for (f=0; f<list.length; f++) 
	path = dir[0]+list[f]; 
 	if (!endsWith(path,"/")) open(path);
	//Process 1 commands
	// Process2 commands
	print("Fibroris Value" +t+var2);

Using help found here Results table - copying entire rows in a macro I can see that the issue is the second run(“Meausure”); line Is there a way to get measurements instead of using the run measure command in headless?

Maybe getStatistics would help?

getStatistics(area, mean, min, max, std, histogram)
Returns the area, average pixel value, minimum pixel value, maximum pixel value, standard deviation of the pixel values and histogram of the active image or selection. The histogram is returned as a 256 element array. For 8-bit and RGB images, the histogram bin width is one. For 16-bit and 32-bit images, the bin width is (max-min)/256. For examples, refer to the ShowStatistics macro set. Note that trailing arguments can be omitted. For example, you can use getStatistics(area), getStatistics(area, mean) or getStatistics(area, mean, min, max). See also: getRawStatistics and List.setMeasurements


Thanks, I was able to use this to isolate that my issue is actually with one of my processing steps.
imageCalculator(“Divide create”, “Blue”,“Red”); Which is not working in command line. Any idea why this might fail and how to get around it?

Unfortunately, I don’t know what the issue might be.

As a guess, is it maybe that the measurement is done on some other image, rather than on the result of the “divide” operation?

If you can make a MCVE, then it might help someone more savvy than I to solve the problem.