what does this do r = img1(:,:,1); % red channel g = img1(:,:,2); % green b = img1(:,:,3);

5 views (last 30 days)
r = img1(:,:,1);
g = img1(:,:,2);
b = img1(:,:,3);

Accepted Answer

Wayne King
Wayne King on 19 Feb 2012
That is taking an RGB image, img1, and extracting the red, green, and blue parts and creating 3 2-D matrices: r,g, and b.
An RGB image, sometimes referred to as a truecolor image, is stored in MATLAB as an M-by-N-by-3 data array that defines red, green, and blue color components for each individual pixel. RGB images do not use a palette. The color of each pixel is determined by the combination of the red, green, and blue intensities stored in each color plane at the pixel's location.
  2 Comments
Prasad MV
Prasad MV on 19 Feb 2012
thank you. . .
can you tell me what does this means. .
repmat(okpxls, [1, 1, 3]);
and
zeros(size(img), class(img));
pls reply asap. .
Wayne King
Wayne King on 19 Feb 2012
repmat(okpxls,[1 1 3]) replicates (copies) an input into 3-D.
x = randn(3,1);
y = repmat(x,[1 1 3]);
zeros(size(img), class(img));
creates a matrix of zeros the same size and class as image
x1 = uint8(randn(8,8));
x2 = zeros(size(x1),class(x1));

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!