Measuring and controlling image luminance

Dear Magic Leap community, I have a pupillometry experiment (in Magic Leap) with 2 colored image conditions. I want to measure image luminance of all of my images to: 1) check if there are significant luminance differences between my 2 conditions and 2) be able to account for luminance in my analyses to ensure that any pupil size differences * condition are not due to luminance differences. I have tried measuring luminance with GIMP and in MATLAB (in 2D), but I am not getting convergent results and struggling to find what the gold standard approach would be in vision research / how can I get the best luminance measures of my stimuli on Magic Leap. Thanks a lot!!

PS: I already have extracted the ambient light sensor data from my experiment, but as I understand it this is measuring ambient light rather than light measured through the lenses (where you can see the objects presented).