Apply a colored filter on grayscale image?

조회 수: 4 (최근 30일)
Filippo Gambarota
Filippo Gambarota 2019년 1월 16일
댓글: Filippo Gambarota 2019년 1월 21일
I have two grayscale images and i need to merge as an anaglyph image without shifting. The purpose is to watch this image with red-green glasses thereby having a red filtered image only visible with one lens and a green filtered image only visible with the other.
I've found the function
imfuse()
But i need to apply a red and green filter. It is possible on grayscale images? how can i do?
Thanks

채택된 답변

Naman Chaturvedi
Naman Chaturvedi 2019년 1월 21일
You grayscale image (say iRed) is a m*n*1 matrix. (m, n are x and y dimensions). To make the grayscale image iRed to redscale image, do the following computations:
>> iRedMonochrome=cat(3,iRed,zeros(size(iRed)),zeros(size(iRed))); % for red filter [R 0 0]
>> iGreenMonochrome=cat(3,zeros(size(iGreen)),iGreen,zeros(size(iGreen))); % for green filter [0 G 0]
>> iBlueMonochrome=cat(3,zeros(size(iBlue)),zeros(size(iBlue)),iBlue); % for blue filter [0 0 B]
You can then simply add the images:
>> iRGB=iRedMonochrome+iGreenMonochrome+iBlueMonochrome;
  댓글 수: 3
Image Analyst
Image Analyst 2019년 1월 21일
If the gray is the ref
meanGreen = mean2(greenImage);
meanRed = mean2(redImage);
redImage = double(redImage) * meanGreen / meanRed;
Or use imhistmatch().
Filippo Gambarota
Filippo Gambarota 2019년 1월 21일
Unfortunately the output is a flat red image...
F1_red=cat(3,SHINEd_F1,zeros(size(SHINEd_F1)),zeros(size(SHINEd_F1)));
N1_green=cat(3,zeros(size(SHINEd_N1)),SHINEd_N1,zeros(size(SHINEd_N1)));
final = imhistmatch(N1_green,F1_red)
imshow(final)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by