user1725619
user1725619

Reputation:

Splitting image into RGB channels with strange result

I used MATLAB to split one image into RGB channel and export the binary RGB image, the following is the original image:

The original image

I split the image into RGB channel by the following code:

R = secretImg(:,:,1);
G = secretImg(:,:,2);
B = secretImg(:,:,3);

imwrite(R,'RedChannel.tif');
imwrite(G,'GreenChannel.tif');
imwrite(B,'BlueChannel.tif');

However, the following are the results: The result

As you can see, in the red channel binary image, we cannot even see any colour from red component, it just show blue; In blue channel, we cannot see anything in blue component!

What happened?

Upvotes: 1

Views: 425

Answers (1)

Santhan Salai
Santhan Salai

Reputation: 3898

This isn't strange. It works as it should.

Here is a simple illustration which may be easy for you to understand

  • Pure Red    -> R-1 G-0 B-0.
  • Pure Green -> R-0 G-1 B-0.
  • Pure Blue    -> R-0 G-0 B-1.
  • White           -> R-1 G-1 B-1.
  • Black           -> R-0 G-0 B-0.
  • Gray            -> R-x G-x B-x. (x could be anything between 0-1 but same for all components)

So when you view only the red component image, you don't see difference between white and Red color as they both holds value 1.

Similarly you could figure out the reason for missing blue foot print in Blue component image.

Upvotes: 4

Related Questions