Converting an image to grayscale

One of the most popular activities in computer vision is converting to and using a grayscale version of an image. In Julia, this is achieved by using the Gray function. This is shown as follows:

using Imagesimg = load("sample-images/cats-3061372_640.jpg");img_gray = Gray.(img)imshow(img_gray)

Grayscale images are widely used in classic computer vision, for tasks such as feature detection, morphology, and so on. The benefit of using grayscale images is that they are represented in a single dimension, which makes it fast for processing and analysis. We will be using this extensively throughout the book.

Keep in mind that Gray returns a single dimension, compared to three-dimensions for an RGB image. Use the ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.