I have an image, and I want to get values of a parameter for each pixel of the image. The parameter is a function of the RGB values of the image. In order to evaluate the parameter, I need to perform basic arithmetic operations involving RGB values, but I am not able to to that as RGB values are scaled ones. e.g., if R=243, and I want to add 30 with it, the answer becomes 255 instead of 273, as that is the maximum permissible limit for the pixel intensity values. What I understand is that I cannot treat RGB values as general numeric entities. Any help regarding converting them into numerical values so that arithmetic operations can be performed is highly appreciated.
John Michell answered .
2025-11-20
class(X)
for your data X. Then take a look at this example, which shows that what you are observing has nothing to do with the fact that you data are RGB values:
>> X = uint8(243); >> X+30 % uint8 has max value 255 ans = 255 >> double(X)+30 % convert to double -> much max value ans = 273
Do you see how I fixed your "problem"? By simply converting the value to double, which is a numeric class with a much higher maximum value. Depending on your needs and the algorithm you are implementing it may be suitable to convert to another integer class.