MATLAB: Adding constant if the pixel intensity is greater than 50

image analysispixel

Hello, I am new to Matlab, I would like to check every pixel in 16 bit image, If the pixel intensity is less than 50 its fine but if the intensity is greater than 50 in certain pixels, I should add that particular pixel with a constant and proceed to the next. The aim is to produce a new image by adding 2000 to the pixel Intensity>50, leaving pixel Intensity<50 unchanged. My Image size is 480×640; Thank You very much,

Best Answer

Assuming your image is stored in a variable called img:
highValues = img > 50;
img(highValues) = img(highValues) + 2000;
You don't say what you want to do with values equal to 50. The code above leaves them unchanged.
Related Question