How do I assign 1 dimensional slices in a 3d array in MATLAB?
I have a logical 2d array named 'CD' which corresponds to the pixels of a 3-D image matrix (RGB format) that I would like to set.
CD = any(d, 3);
CDM(CD) = 255;
So in this case, 'CDM' is a 3d matrix containing R,G,B values for every pixel (e.g. it's a 771x457x3 matrix).
The above code works. It generates an image of red pixels I want them.
But suppose now that I want to generate, say, green or cyan pixels? How do I access the second and third "layers" (the green and blue values) of 'CDM'? I tried assigning
CDM(CD) = [0 255 255];
but this returns the error
In an assignment A(:) = B, the number of elements in A and B must be the same.