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

3 ビュー (過去 30 日間)
Emma Tompkins
Emma Tompkins 2017 年 10 月 24 日
回答済み: Emma Tompkins 2017 年 10 月 24 日
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?

採用された回答

Emma Tompkins
Emma Tompkins 2017 年 10 月 24 日
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;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by