How can I convert an RGB image to grayscale but keep one color?

前端 未结 3 2053
野性不改
野性不改 2020-11-22 14:05

I am trying to create an effect similar to Sin City or other movies where they remove all colors except one from an image.

I have an RGB image which I want

3条回答
  •  粉色の甜心
    2020-11-22 14:58

    figure
    pic = imread('EcyOd.jpg');
    
    for mm = 1:size(pic,1)
        for nn = 1:size(pic,2)
            if pic(mm,nn,1) < 80 || pic(mm,nn,2) > 80 || pic(mm,nn,3) > 100
                gsc = 0.3*pic(mm,nn,1) + 0.59*pic(mm,nn,2) + 0.11*pic(mm,nn,3);
                pic(mm,nn,:) = [gsc gsc gsc];
            end
        end
    end
    imshow(pic)
    

    alt text

提交回复
热议问题