Three channel image to one channel

I'm trying to convert a 3-channel rgb raw image to a one channel image in Matlab. I've tried concatenating but that was still unsuccessful. Any other suggestions?
The raw image I found online and I personally don't care which format it's in (whether NEX/ARW/etc). Just need to get it to one channel.
Thanks

Answers (1)

Then once the raw image is in MATLAB, you can use rgb2gray() to convert it into grayscale. Or you can simply take one of the color channels, depending on what you want to end up with.
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);

5 Comments

The blog is fantastic and I tried using DNG converter but now when I try to run my demosaicing algorithm against the DNG image it stays all black. as if there's no data, although there is still an array size and pixel values.
Basically I'm trying to start with a single channel image to represent the sensor output and then convert it into a 3-band bayer pattern, and finally run my algorithm. I have the code for everything but can't figure out how to replicate the sensor output with my raw image (make sure that when I open it in matlab it starts as one band).
I don't know because I don't work with raw images. If you do, then you're responsible for demosaicing your image. I don't want to hassle with that, and the images I get from the camera are good enough that I don't need to get raw images with all the dead pixels, etc. and then have to hassle with building an RGB image from it.
agreed, just testing algorithms for a comparison but running into how to get the raw image in a single channel from my camera into matlab.
What did you mean by "The raw image I found online and I personally don't care which format it's in (whether NEX/ARW/etc)." Did you snap a photo from your camera and tell it to save in raw format? If so, then it should have a format and you'll need to read that. I don't understand the concept of finding some random raw image on the internet somewhere and not caring at all what format it is in. What's the point of that?
I did take a picture with a sony camera in ARW format. I also found raw Canon/Nikon images online. So if I found a good method to convert those raw images to one band but it doesn't use ARW formats, I still have images. Since I'm testing the algorithm for demosaicking and not comparing camera formats, it really doesn't matter which type of raw image I have, just that I have a raw image to run through two algorithms and compare the outputs.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

Kat
on 7 May 2014

Commented:

Kat
on 9 May 2014

Community Treasure Hunt

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

Start Hunting!