MATLAB: Take the average from a region of a plot and subtract the background

Image Processing Toolbox

I have a histogram ranging from 0 to 700 (along X axis). It is an exponential decay curve. I want to take the average from 600 to 700. This average is the background. I want to subtract this background from the plot. How can I perform this in Matlab?

Best Answer

Try this:
binaryImage = grayImage > 600;
meanGL = mean(grayImage(binaryImage ))
newImage = double(grayImage) - meanGL; % Casting to double is needed to get negative values.
imshow(newImage, []); % The [] is needed.