Add the three channels in a image to obtain a color image MATLAB

后端 未结 1 1624
野趣味
野趣味 2021-01-24 06:37

I am modifying images in matlab and I have a problem.

I need to separate the 3 channels of color and modify them separately.

I use this to obtain the three chann

相关标签:
1条回答
  • 2021-01-24 07:10

    You are adding the values of the three layers instead of concatenating them in a 3D array.

    Try this:

    A= cat(3, a(:,:,1), a(:,:,2), a(:,:,3));
    

    I should also note that you can edit the layers simply by indexing, say you want to switch the red and green components:

    I1 = imread('http://i.stack.imgur.com/1KyJA.jpg');
    I2=I1;
    I2(:,:,1)=I1(:,:,2);
    I2(:,:,2)=I1(:,:,1);
    imshowpair(I1,I2, 'montage');
    

    Green and red channels swap

    Now if I take your title literally, let's say you do want to add the three layers and display the result with a colormap, you can do:

    A=a(:,:,1)+a(:,:,2)+a(:,:,3)
    imagesc(A); axis image; 
    colorbar;
    

    Results:

    Sum of the 3 rub layers

    0 讨论(0)
提交回复
热议问题