See an image in the gray scale


see an image in the gray scale.

I have a doubt. I’m working with an image but I want to know why I can not see it fast “in automatic”
without writing

ImageView.imshow (ImageFromTestImages)
[(This is to see a color image but I want to see the image in gray)]

this is the line of code

ImageFromTestImagesGray = Images.Gray. (ImageFromTestImages)

Could someone help me to see the image in gray?



I do not think the color of the image has any relevance here.

Two possibilities:

  • Use Atom, it automatically displays images (Jupyter Notebook may work as well)
  • Define a helper macro
using ImageView
macro imshow(img)
    return :(ImageView.imshow($img))
@imshow img
1 Like


I’m not sure I understand the question, since I think you answered it yourself: imshow(Gray.(img)).



I’m working on this.
import Images
import TestImages
import ImageMetadata
import ImageAxes
import ImageDraw
import ImageView
import ImageTransformations
import ImageFiltering

ImageFromTestImages = TestImages.testimage("lighthouse")
ImageFromTestImagesGray = Images.Gray.(ImageFromTestImages)

But I see that many people say that when putting:

import Images
ImageFromTestImages = TestImages.testimage (“lighthouse”)

the default image appears without putting
imshow (img)



I’m not sure what you want to achieve. Please clearly describe the output you want, and the environment you’re working in (Juno? Jupyter? Terminal?). Additionally, if you’re working interactively, you can load functions more easily with using Images, TestImages, ImageView, since Images.jl already exports a bunch of functionality from all the other packages you’ve imported.

1 Like