Accessing pixels

When you use a load command in Julia, it reads the image and encodes it in RGB. In the following example, we will see how Julia manages information for a single pixel:

using Imagesimg = load("sample-images/cats-3061372_640.jpg")img[1:1, 1:1, :]

After Julia executes the preceding set of commands, you should expect to see the following output:

julia> img[1:1, 1:1, :]1×1×1 Array{RGB4{N0f8},3}:[:, :, 1] = RGB4{N0f8}(0.349,0.282,0.212)

Pay attention to the last line. Our pixel is composed of an RGB object with 0.349,0.282,0.212 being the values corresponding to the values for each of the three channels. 

You will also notice that the images are represented on a scale from 0 to 1:

  • 0 represents black
  • 1 represents white (saturated ...

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.