Hi folks,
I'm trying to get the parts of an image that fall between 2 values of its grayscale histogram, the revert the image back to its colour form. So far, I am struggling to get anything but a black image! Any ideas on what I'm doing wrong please? Below is my code.
baseGray = rgb2gray(I);isoLower = 135;isoUpper = 155;lessThan = baseGray < isoLower;greaterThan = baseGray > isoUpper;baseGray(lessThan) = 0;baseGray(greaterThan) = 0;grayThresh = imbinarize(baseGray);grayThresh = bwareaopen(grayThresh, 3000);grayThresh = imfill(grayThresh, 'holes');grayThresh = bwperim(grayThresh);grayThresh = imdilate(grayThresh, ones(5));grayThresh = imerode(grayThresh, ones(3));grayThresh = imfill(grayThresh, 'holes');refigure = img.*repmat(uint8(grayThresh),[1 1 3]);imshow(refigure);
Best Answer