: , in this context means "everything."
red = a(:,:,1)
equivalently
red = a(1:end,1:end,1)
where end automatically replaced by the number of elements in the corresponding Matlab size.
So, if a is an array of 23 by 55 by 3,
a(:,:,1)
there is
a(1:23, 1:55, 1)
This means that it occupies all rows, all columns from the first "plane" a . Since an RGB image consists of a red, green, and blue plane (in that order), a(:,:,1) is the red component of the image.
Jonas
source share