필터 지우기
필터 지우기

Image into grayscale without using toolbox

조회 수: 1 (최근 30일)
Krish Desai
Krish Desai 2015년 10월 12일
댓글: Krish Desai 2015년 10월 12일
This is my current code:
function out = luminance(current_img )
R=current_img(:,:,1);
G=current_img(:,:,2);
B=current_img(:,:,3);
I=.299*R + 0.587*G+0.114*B;
out=I;
end
I'm trying to make my image grayscale but that's not what's happening, what am I doing wrong?

채택된 답변

Image Analyst
Image Analyst 2015년 10월 12일
That should work. What's the problem? Perhaps you want to cast it back to uint8 or something.
out = uint8(.299*double(R) + 0.587*double(G)+0.114*double(B));
or else just leave it as floating point and use [] in imshow to display it:
imshow(out, []);
  댓글 수: 2
Krish Desai
Krish Desai 2015년 10월 12일
The image is coming out in blues, yellows and greens. I tried typecasting but it didn't work.
Krish Desai
Krish Desai 2015년 10월 12일
Update: Using the floating point worked

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by