필터 지우기
필터 지우기

Greyscale an image via replacing pixels

조회 수: 1 (최근 30일)
Anna
Anna 2013년 8월 6일
I have an image that I want to greyscale. It contains only blue and white pixels and I want to use a method whereby I identify the blue pixels and make them grey. How can I do that?
So far I have got:
fit = imread('RGB.jpg');
size(fit)
imshow(fit);
So I haven't got very far. I have created a function to test if a pixel is blue. Is there any way to use this? An example of using pixels to replace would be much appreciated.
  댓글 수: 1
Ashish Uthama
Ashish Uthama 2013년 8월 6일
Please consider uploading the image here.

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

답변 (1개)

Ashish Uthama
Ashish Uthama 2013년 8월 6일
% air code (untested)
red = fit(:,:,1);
green = fit(:,:,2);
blue = fit(:,:,3);
isblue = blue>250;
% Use logical indexing to set the red and green channels to be the same value as the blue channel. (When R==G==B, then the color is 'gray')
red(isblue) = blue(isblue);
green(isblue) = blue(isblue);
% reassemble
fitout = cat(3, red, green, blue)

카테고리

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