Modified to initialise data if the ROI saved in the image is different from the current ROI. Fixed calculation.