MATLAB: How to select the pixels outside the region of interest

dermoscopyskin lesion

So, as you can see beside the skin lesion I also have some dark pixels in the corners and also in the immediate area of the lesion that I want to set as white in the mask. I am a bit stuck here, I was thinking about using roicolor but I am open to suggestons

Best Answer

  • Untitl1ed.png
    m = size(I,1); % number of rows
    n = size(I,2); % number of columns
    R = 100; % radius region
    [X,Y] = meshgrid(1:n,1:m);
    ind = (X-n/2).^2+(Y-m/2).^2 > R^2; % circle from the center
    I(ind) = 1; % set white color to pixels outside