Different result when summing intensities using Regions.sample(region, img) vs. Views.interval( img, interval )

I need to sum up intensities inside a region and tested out the two different methods below, which give me slightly different results (~0.5% difference).
The first one uses Views.interval( img, interval ) and the second one uses Regions.sample(region, img).
I do not understand why they should give different results, so I would be grateful, if someone could explain.
Best regards,
Michael

    public static double getTotalIntensity(final Interval interval, final RandomAccessibleInterval<FloatType> img){
        IterableInterval< FloatType > region = Views.interval( img, interval );
        Cursor<FloatType> cursor = region.cursor();
        double totalIntensity = 0;
        while(cursor.hasNext()){
            float value = cursor.get().get();
            totalIntensity += value;
            cursor.fwd();
        }
        return totalIntensity;
    }
    public double getTotalIntensity(LabelRegion<Integer> region, RandomAccessibleInterval<FloatType> img){
        Cursor<FloatType> cursor = new Regions().sample(region, img).cursor();
        double totalIntensity = 0;
        while(cursor.hasNext()){
            totalIntensity += cursor.get().get();
            cursor.fwd();
        }
        return totalIntensity;
    }

What region are you using?

It is a LabelRegion, that is not rectangular but irregularly shaped.
In the given definitions, the above methods will both take the same LabelRegion as input, but give different output.
Does that answer your question?

Without having tested it myself now, I’d guess that Views.interval( img, interval ) is iterating over all the pixels in the interval, i.e. in fact, the bounding box of your region. Could that explain the differences you’re seeing?