I need to convert an image that we were given to grayscale.
I wrote the code below. When I highlight the whole 'imagesc' line and 'evaluate selction' the image pops up but in color.
logo = imread('..._logo.jpg');
figure;
imagesc(logo);
colormap gray;

 Respuesta aceptada

Image Analyst
Image Analyst el 31 de Ag. de 2021

1 voto

Use imshow() because imagesc() applies some funky colormap by default, and that is usually not what you want.

3 comentarios

Andrew Killian
Andrew Killian el 31 de Ag. de 2021
Editada: Andrew Killian el 31 de Ag. de 2021
So the full code like this? Do I even need that last line?
logo = imread('_logo.jpg');
I = rgb2gray(logo);
figure;
imshow(I);
colormap gray;
Image Analyst
Image Analyst el 31 de Ag. de 2021
No, you don't need that last line. The default for gray scale images is to not use a colormap and show everything in it's original, native gray color.
Image Analyst
Image Analyst el 5 de Sept. de 2021
Andrew, if this solved it, can you click the "Accept this answer" link? Thanks in advance.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 31 de Ag. de 2021

Comentada:

el 5 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by