How to Implement an “imshow” function?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Anna Nazarova
el 2 de Dic. de 2018
Comentada: Image Analyst
el 9 de Dic. de 2018
How to Implement an “imshow” function by transforming the range [min, max] on the gray scale into the interval determined by 0 ≤ a, b ≤ 1? I need use variables and it should be suitable for any image not particular. Thank you!
0 comentarios
Respuesta aceptada
Anna Nazarova
el 2 de Dic. de 2018
4 comentarios
Rik
el 2 de Dic. de 2018
Of course the image is not changing: you have defined a and b is such a way that it will not change. The data type that most images will have when loaded is uint8. This has a minimum of 0 and a maximum of 255. If you want to change how the image looks, there are multiple methods:
- the method I showed you, where you will have to define a and b yourself, or use a=min(IM(:));b=max(IM(:));
- the method Walter suggested: use mat2gray(IM) (note that mat2gray(IM,[a b]) is equivalent to my method. mat2gray is in the image processing toolbox, but you appear to have that anyway.)
- the method Image Analist just suggested: don't change the data, but use the empty square brackets to display you image with a scaled color scheme by using imshow(IM,[])
Which of these you think is best for your situation is for you to decide.
Image Analyst
el 2 de Dic. de 2018
I also suggested #2. And there is yet another way that might be useful. It's imadjust(). With imadjust(), you can specify a percentage of the way to come in on the tails of the histogram to determine the range. that way, outliers (like salt and pepper noise) will not prevent a nice picture from appearing.
Más respuestas (3)
Image Analyst
el 2 de Dic. de 2018
To display a gray scale image without changing the values of the array, but only changing the displayed values, do this:
imshow(grayImage, []);
To change the actual matrix, use mat2gray():
% Scale grayImage to between 0 and 1: min goes to 0, max goes to 1
grayImage = mat2gray(grayImage);
5 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
