To convert only black color to white in Matlab

前端 未结 4 407
醉话见心
醉话见心 2020-12-09 13:23

I know this thread about converting black color to white and white to black simultaneously. I would like to convert only black to white. I know this thread about doing thi

4条回答
  •  清歌不尽
    2020-12-09 13:43

    Here is a variation on @rayryeng's solution to extract the blue signal:

    %// retrieve picture
    imgRGB = imread('http://i.stack.imgur.com/cFOSp.png');
    
    %// detect axis lines and labels
    imgHSV = rgb2hsv(imgRGB);
    BW = (imgHSV(:,:,3) < 1);
    BW = imclose(imclose(BW, strel('line',40,0)), strel('line',10,90));
    
    %// clear those masked pixels by setting them to background white color
    imgRGB2 = imgRGB;
    imgRGB2(repmat(BW,[1 1 3])) = 255;
    
    %// show extracted signal
    imshow(imgRGB2)
    

    extracted_signal

    To get a better view, here is the detected mask overlayed on top of the original image (I'm using imoverlay function from the File Exchange):

    figure
    imshow(imoverlay(imgRGB, BW, uint8([255,0,0])))
    

    overlayed_mask

提交回复
热议问题