Bayer to RGB conversion [message #73964] |
Tue, 14 December 2010 17:31  |
David Grier
Messages: 35 Registered: July 2010
|
Member |
|
|
Dear Folks,
Is there a good set of IDL routines for converting Bayer images
to luminance and RGB images? I'm looking for something equivalent
to the Matlab demosaic function, and thought I'd ask before
biting the bullet and coding it myself.
I'm particularly interested in an efficient implementation
of the 5x5 Malvar-He-Cutler interpolation algorithm.
TTFN,
David
|
|
|
Re: Bayer to RGB conversion [message #74044 is a reply to message #73964] |
Wed, 15 December 2010 17:34  |
David Grier
Messages: 35 Registered: July 2010
|
Member |
|
|
On 12/15/10 2:25 PM, Karl wrote:
> On Dec 15, 8:10 am, David Fanning<n...@dfanning.com> wrote:
>> nata writes:
>>> Ok, maybe I didn't understand the question.
>>
>> Well, I didn't understand the question either. :-)
>>
>
> Color quantization has nothing to do with it.
>
> Bayer sensors, or more accurately perhaps, sensors that output Bayer-
> format images are often found in smartphones as part of their built-in
> camera system. The phone probably has a DSP or other specialized
> hardware to convert the Bayer image to RGB and then eventually to the
> JPEG file or whatever ends up storing your photo.
>
> Wikipedia has a decent article about it, including links to GPL
> software that might do the conversion.
>
> I've not looked at the algorithms involved, but if performance is
> important, then I'd doubt that coding it in IDL would work well.
> Matlab has a built-in function for it and there are GPU
> implementations out there. If I could use the GPL code, I'd probably
> put it in a DLM and call it from IDL, if it is not already in IDL or
> ENVI.
>
> Karl
>
I'm using a home-brew dlm to read raw (Bayer-encoded) images from
a Prosilica GigE video camera. This is a reasonably high-end
scientific camera that my group plans to use for holographic
video microscopy. I just finished wrapping an open-source
implementation of the 5x5 Malvar-He-Cutler Bayer conversion
algorithm in a dlm, and am reasonably happy with the result.
I was just hoping for a "pure" IDL implementation.
The most popular conversion algorithms aren't too sophisticated, but
involve some detailed bookkeeping. They'd be a pain to recode.
Mostly, I'm surprised that IDL doesn't support conversions from
this fairly common class of image formats. As Karl mentioned,
Matlab comes with quite sophisticated Bayer conversion algorithms
in the demosaic.m package. Matlab also has read/write support for
all sorts of video formats. Python has all this (and more) through its
opencv bindings.
Sometimes IDL starts to feel a little old and creaky.
TTFN,
David
|
|
|
Re: Bayer to RGB conversion [message #74048 is a reply to message #73964] |
Wed, 15 December 2010 11:25  |
Karl[1]
Messages: 79 Registered: October 2005
|
Member |
|
|
On Dec 15, 8:10 am, David Fanning <n...@dfanning.com> wrote:
> nata writes:
>> Ok, maybe I didn't understand the question.
>
> Well, I didn't understand the question either. :-)
>
Color quantization has nothing to do with it.
Bayer sensors, or more accurately perhaps, sensors that output Bayer-
format images are often found in smartphones as part of their built-in
camera system. The phone probably has a DSP or other specialized
hardware to convert the Bayer image to RGB and then eventually to the
JPEG file or whatever ends up storing your photo.
Wikipedia has a decent article about it, including links to GPL
software that might do the conversion.
I've not looked at the algorithms involved, but if performance is
important, then I'd doubt that coding it in IDL would work well.
Matlab has a built-in function for it and there are GPU
implementations out there. If I could use the GPL code, I'd probably
put it in a DLM and call it from IDL, if it is not already in IDL or
ENVI.
Karl
|
|
|
Re: Bayer to RGB conversion [message #74053 is a reply to message #73964] |
Wed, 15 December 2010 07:10  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nata writes:
> Ok, maybe I didn't understand the question.
Well, I didn't understand the question either. :-)
In fact, I was thinking yesterday about how long I would
be able to play competitive tennis, and I came to the
conclusion that it was not that much longer. Not too many
60 year old men beating the kids. At least around here.
So, last night I play with an, uh, older gentleman,
about my age, and we got our butts kicked by a
couple of young guys. Totally intimidating. I feel
like I should be wearing a cup out there!
Then I come home and read this question. I swear I aged
about five years overnight. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
Re: Bayer to RGB conversion [message #74056 is a reply to message #73964] |
Wed, 15 December 2010 06:49  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nata writes:
> I don't exactly know what are you looking for but when I want to
> retrieve the RGB values of an image, I use the COLOR_QUAN function.
Oh, dear! Really? :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Bayer to RGB conversion [message #74057 is a reply to message #73964] |
Wed, 15 December 2010 06:44  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
I don't exactly know what are you looking for but when I want to
retrieve the RGB values of an image, I use the COLOR_QUAN function.
Cheers,
nata
|
|
|