Extracting a range of pixel values from a specific RGB band?

3 Ansichten (letzte 30 Tage)
I am trying to extract all pixels that are in the range 128 - 256 of the green band on an RGB TIFF. I can create a mask, but when I try to get an image with just these pixels I end up with a binary image, but I want to see all the pixels within my range.
This is what I've done:
>> I = imread(fullfile('D:\MatLab_Practice', 'RGB.tif'));
>> green = I(:,:,2);
>> imhist(green)
>> mask = green > 127; %(I have also tried the roicolor(green,128,256) to create a mask with same results)
>> G1 = double(green);
>> G2 = G1 .* mask;
if I use imhist(G2) I don't see the values I want, but using histogram(G2) I see everything I don't want as zero and and the range of values I need. But when trying to view my image I still only get a binary black and white image.
Any advice on how to proceed?

Akzeptierte Antwort

Emma Tompkins
Emma Tompkins am 24 Okt. 2017
NEVERMIND figured it out!
need to convert mask to integer and then multiply by the original green band
>> I = imread(fullfile('D:\MatLab_Practice', 'RGB.tif'));
>> green = I(:,:,2);
>> imhist(green)
>> mask = green > 127; %(I have also tried the roicolor(green,128,256) to create a mask with same results)
>> mask = uint8(mask); %to match the same data type as image
>> G2 = green .* mask;

Weitere Antworten (0)

Kategorien

Mehr zu Author Block Masks finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by