Why 'measure' gives different result from Python code?

I have the following image and ROI file.

test_gap_area.roi.zip (274 Bytes)

If I use manual steps:

Open Image
ROI Manager > Select "Test Gap Area"
Edit > Clear Outside
Image > Crop
Analyze > Measure

I get the following result for mean:

But when I use this code:

from ij.plugin.frame import RoiManager
from ij import IJ

main_path = "/Users/pdubois/Desktop/"

# Set up input ROI file
gap_roi_file        = main_path + "test_gap_area.roi.zip"
image_file_name = main_path + "test.png"

# Begin processing each image
gap_rm = RoiManager()
gap_rm.runCommand("Open", gap_roi_file)

imp = IJ.openImage(image_file_name)
IJ.run(imp, "Clear Outside", "")
IJ.run(imp, "Auto Crop", "")
IJ.run(imp, "Measure", "")

I get this result:

Screen Shot 2020-11-09 at 15.55.16

What’s wrong with my code. What should I do to get consistent result with the steps, i.e.
for it to yield 104.996 as mean value?

Hey @Peverall_Dubois,

can you visualize the ROI before measuring it? I’m asking because I think the “Auto Crop” command you are calling does not correspond to “Crop”. I would wonder what it does…