Borrar filtros
Borrar filtros

how to display a matrix with negative values as a image

28 visualizaciones (últimos 30 días)
mahesh chathuranga
mahesh chathuranga el 30 de Sept. de 2013
Respondida: Image Analyst el 30 de Sept. de 2013
some arithmatic operations gives negative values.is it a problem for displaying the image.how to display a matrix with negative values as a image

Respuestas (3)

Simon
Simon el 30 de Sept. de 2013
There are many ways of doing this
  1. take the absolute value with "abs"
  2. shift all values so that you don't have negatives anymore
  3. scale the values so that you have 0 in the middle of the RGB values
  4. ...
(may grayscale image is most suitable for this?)

Jan
Jan el 30 de Sept. de 2013
Editada: Jan el 30 de Sept. de 2013
It depends on what you want to display. Some examples:
data = 1 + 2 .* randn(200, 200); % Test data
1. Set all negative value to zero, scale the positive values to be in the range of [0,1]:
img1 = max(data, 0);
img1 = img1 / max(img1(:));
2. Shift all values to the positive range, that scale again as above:
img2 = data - min(data(:));
img2 = img2 / max(img2(:));
3. There is an infinite number of possibilities for pseudo-color images. You could e.g. define colors for different intervals by dividing the total range max(data(:)) - min(data(:)) into 17 different intervals and using the 2nd output of histc to get the interval for each pixel.
4. Perhaps you are talking about RGB images? Then even more possible mappings exist.
Conclusion: Please post any details about the wanted procedure. We cannot guess them.

Image Analyst
Image Analyst el 30 de Sept. de 2013
I gave you some answers in your duplicate question: http://www.mathworks.com/matlabcentral/answers/88637#comment_171537 Why do you have two questions on the same question? Doesn't that make it confusing for you , and us, when you have two places to go to look for answers?

Categorías

Más información sobre Data Type Identification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by