How can I color the pixels of my image depending of it's value in an equation?

1 view (last 30 days)
Hi,
For my final degree project I need to color the pixels of an image depending on the final value when using an specific equation.
For instance, for each pixel I have extracted the PA, P1, P2 and P3 values.
Then I use an exponencial equation to calculate one value (probability) of each pixel just like: Prob=1/(1+exp(2.213.*PA+2.358.*P1-1.625.*P2-1.257.*P3+3.128));
Finnally, if the Prob value is higher than 0.351 I want that pixel to be in green while if it's lower in red (for example, the colors don't matter).
If someone know's how to do it would be a great help, thank you in advanced.

Answers (1)

KSSV
KSSV on 25 Jun 2020
Let I be your image pixle matrix with the values Prob repalced using the shown formula.
% To repalce values less than Prob
idx = I<Prob ;
I(idx) = val1 ; % your value
idx = I<Prob ;
I(idx) = val2 ; % your value

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!