RGB layers separation for RAW or TIF image

Hi everyone , I have a raw Image taken from a camera ( unit16 ), i want te separate the RGB layers and i know that i have twice as many green pixels as red or blue pixels so i will get 2 green layers . I thought to convert it to tif Image first . i do not know if it is a good idea .
Can anyone help me to separate each layer please ?
thank you

Risposte (1)

Guillaume
Guillaume il 11 Ott 2016
Modificato: Guillaume il 11 Ott 2016
The demosaic function is what you need to convert you Bayer pattern into an RGB image. You need to know of course which pattern your sensor use (one of 'gbrg', 'grbg', 'bggr' or 'rggb').
You will not get two green layers since otherwise it's not a valid RGB image.
The way an image is stored on file (eg. tif or png) is completely independent from the way it is stored in memory (eg. RGB). As far as I know the tif format does not know anything about bayer patterns. Decoding the pattern would be required before you could even save your image as tif.

4 Commenti

Yassine Zaafouri
Yassine Zaafouri il 12 Ott 2016
Modificato: Yassine Zaafouri il 12 Ott 2016
Hi, Thank you for your answer but the problem is that i do not want to convert the Bayer into an RGB image but i want to extract the matrix (Values of pixels) for each level.And it is 'grbg'. Can you help me with that ? thank you
I do not understand what you mean by the matrix (Values of pixels) for each level. To me that sounds like you want the RGB matrix.
Provide a short example of input and desired output to make it clear.
if true
test1=imread('.\xyz.tif')
J = demosaic(test1,'grbg');
imwrite(uint16(J),'abc.tif')
test01=double(imread('.\abc.tif'))
end
and then i want to extract from test01 each channel and represent it as a matrix .
If you're talking about colour channels, they are already represented as matrices. They're the pages (3rd dimension) of your image matrix:
yourimage(:, :, 1) is the red channel
yourimage(:, :, 2) is the green channel
yourimage(:, :, 3) is the blue channel
You need to learn how images are represented in matlab

Accedi per commentare.

Categorie

Scopri di più su Convert Image Type in Centro assistenza e File Exchange

Richiesto:

il 11 Ott 2016

Commentato:

il 12 Ott 2016

Community Treasure Hunt

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

Start Hunting!

Translated by