I have an rgb image matrix (height*width*3) represented in doubles.
After some manipulations on the matrix, some values went biger then 1 or smaller then 0.
I need to normalize those valuse back to 1 and 0.
Thanks.
I have an rgb image matrix (height*width*3) represented in doubles. After some manipulations on
Share
Well, just use the indexing by condition. Let’s say your matrix is called M.
If you just want to set values bigger than 1 to 1 and smaller than 0 to zero, use:
However, if you want to proportionally normalize all the values to the interval [0; 1], then you have to do something similar to:
You have to take account of the case when your matrix M is already in the interval [0; 1] and the normalization is not needed.