Change a range of pixel values

1 Ansicht (letzte 30 Tage)
Selina Loh
Selina Loh am 30 Okt. 2017
Beantwortet: Peter Chang am 30 Okt. 2017
Is it possible to change pixel values for pixel values of a certain range? The other pixels will remain the same value.
A(I >= 50 & I <= 110) = 0; I've tried this method but this stores in an array which the image cannot be displayed.

Antworten (2)

Matteo Sangermani
Matteo Sangermani am 30 Okt. 2017
Could you provide an example of the image? Which format are you using? Black-white or RGB? Otherwise is hard to help you
As far as I can see, it looks right. If "I" is your original image, the only recommendation I can give so far is to first initialize A, such as:
A = I;

Peter Chang
Peter Chang am 30 Okt. 2017
Suppose X is a n x m-Matrix which contains the pixel values. xmin and xmax are the minimal and maximal value you defined, respectively. And the xnew is the new pixel value you wish to have. You can try:
X(X>=xmin & X<=xmax) = xnew;

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by