Separate RGB layers of a RAW image

5 views (last 30 days)
Natsu
Natsu on 4 Mar 2012
I am trying to separate the RGB layers of a RAW image. I'm able to get the red layer using rawr=img(:,:,1), but when I'm trying to get the green and blue layer using the command rawg=img(:,:,2) and rawb=img(:,:,3) respectively, I get this error, ??? Index exceeds matrix dimensions. Anyone knows how I can fix this problem? thanks

Answers (3)

Wayne King
Wayne King on 4 Mar 2012
Are you sure that you have an RGB image that is MxNx3
If you enter
>>whos img
what is returned?
  1 Comment
Natsu
Natsu on 5 Mar 2012
name img
size 3516x5344
bytes 37579008
class uint16
attributes --

Sign in to comment.


Image Analyst
Image Analyst on 4 Mar 2012
If it's really a raw image from a digital camera, you'll have twice as many green pixels as red or blue pixels (look up Bayer pattern). The format may be very different than a standard RGB image like you'd get from imread() - you'll have to look up the documentation for the function you used to read the raw image. You could have 4 NxM arrays all strung together in one tall 4N by M 2D array, or who knows what.
  3 Comments
Image Analyst
Image Analyst on 4 Mar 2012
That's true. Just to expand on that....Some have three CCD's, one for each color. Others like the Fuji use a Bayer-like pattern which is hexagonal rather than rectangular. And the Foveon camera uses a single chip RGB co-site sensor where every location has all 3 color pixels at different depths (levels) into the sensor. There is no one single "RAW" format agreed to by everyone. He could have a raw camera image, or he could have a RAW image that someone output from some other program that is simply all the pixels strung together in some fashion, maybe with or without some header info. He needs to find out the actual format of his image, like you also suggested.
Walter Roberson
Walter Roberson on 5 Mar 2012
The Foveon was the one I had in mind; I had read about it when it was released, but had lost the name in the intervening time.

Sign in to comment.


Walter Roberson
Walter Roberson on 4 Mar 2012
"raw" image formats are manufacturer-specific and sometimes model-specific. Some ad-hoc standards for raw images are evolving, but they are not widespread yet. Do a google search for the raw image format for your camera model.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!