Hi all,
I have an image(gray scale) whose pixel intensity values ranges from -0.5373 to 0.4744. I would like to change the intensity value which is lesser than 0 to 0. Can any one help me to solve this.
Thanks.

 Respuesta aceptada

Honglei Chen
Honglei Chen el 21 de Feb. de 2012

0 votos

Say your image is x,
x(x<0) = 0;

5 comentarios

Pugazhendhi
Pugazhendhi el 21 de Feb. de 2012
thanks for the quick reply. Its working and one more help how i can do it for RGB images.
thanks in advance.
Honglei Chen
Honglei Chen el 21 de Feb. de 2012
RGB image has 3 pages, so you need to do this for each page. If operation is the same, you can reshape it, do the conversion, and reshape back. For example
x = rand([3 3 3])-0.5;
x = reshape(x,3,[])
x(x<0)=0
reshape(x,3,[],3)
Pugazhendhi
Pugazhendhi el 21 de Feb. de 2012
thanks, Can you explain the role of 0.5 here.
Honglei Chen
Honglei Chen el 21 de Feb. de 2012
I'm just making an example, make sure there are negative numbers in x.
Image Analyst
Image Analyst el 22 de Feb. de 2012
No, you don't need all that reshaping stuff. "x(x<0)=0" is sufficient to work on the whole 3D matrix (e.g., a color image) - no reshaping is needed.

Iniciar sesión para comentar.

Más respuestas (2)

Walter Roberson
Walter Roberson el 21 de Feb. de 2012

0 votos

X = max(0, X); %another way of changing anything less than 0 to 0
vishnu lohith
vishnu lohith el 16 de Feb. de 2018

0 votos

use a suitable transformation to change the intensities from ( 0,255) to (65,180).

1 comentario

Image Analyst
Image Analyst el 17 de Feb. de 2018
Are you sure you posted to the correct six year old question? Not sure what your answer has to do with the original question about clamping the signal to zero.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Feb. de 2012

Comentada:

el 17 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by