Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
29th November 2007, 01:36 | #1 | Link |
Registered User
Join Date: Dec 2005
Posts: 250
|
demosaic/debayer
Hi!
We acquired a new camera for our school project, and it outputs something called bayer pattern image. It is me very first time learning about this kind of stuff, I never knew most digital cameras and the like use this. Anyhow, I need a debayering filter, and I'm asking if anyone has written one so far (for either avisynth or dshow). I saw some posts on the forums mentioning debayering, but no plugin. I tried writing one myself, quite primitive. A first try image is attached. Anyone able to help me with this? -- Greets, I. |
29th November 2007, 10:30 | #2 | Link |
Registered User
Join Date: Feb 2002
Posts: 407
|
Yes I have : http://forum.doom9.org/showthread.php?t=127829 (did you use search :whistle: ?)
I didn't publish it because it's still quite rough, not very fast (12 fps @ 1080p on my 1.86ghz c2d laptop) not very tested and i don't know about quality. And i don't know anything about the intellectual property involved, so i should try to contact the authors of the paper... |
29th November 2007, 20:15 | #3 | Link |
Registered User
Join Date: Dec 2005
Posts: 250
|
Hmmm..., I see. Though that thread's subject isn't too descriptive
Anyhow, we need a throughput of around 200 fps preferably on a lower quality mode (for preview), but high quality modes are better of course for later processing. Actually, supporting Y8 is not a problem, because only the input is affected, and in that case Avisynth 2.5 will never give you Y8, so the same code can be used for both 2.5/2.6. I can attach the code if you wish. It's really darn primitive, I haven't read any paper about this yet What I'm concerned about is white balance and color correction. I've read, that these also must be taken into account. I don't know anything about these things yet. I welcome any good ideas/pointers in this matter. -- Greets, I. |
29th November 2007, 20:39 | #4 | Link |
Retired AviSynth Dev ;)
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
|
A good demosaic is quite a hard task. You can have a look at dcraw, which implements Variable Number of Gradients and Pixel Grouping.
http://cybercom.net/~dcoffin/dcraw/ http://web.cecs.pdx.edu/~cklin/demosaic/ You need a gamma correction of 2.2 for linear to sRBG conversion. The color correction is dependent on the individual hardware, so I cannot help you there.
__________________
Regards, sh0dan // VoxPod |
30th November 2007, 10:40 | #5 | Link | |
Registered User
Join Date: Feb 2002
Posts: 407
|
Quote:
If you really want to test it, i can provide a binary of my filter but can't be held responsible if it blows your computer edit : as for color problem, i just have no clue about that aspect of the problem. My filter was merely a test to see if i was able to translate maths from a paper to code. I will gladly follow your investigation on that matter Last edited by bill_baroud; 30th November 2007 at 10:44. |
|
1st December 2007, 04:49 | #6 | Link |
Registered User
Join Date: Dec 2005
Posts: 250
|
@sh0dan
Thanks sh0dan. I already took a look at dcraw. The whole program is a single huge C file. Quite hard to decode I'll see what I can do with it. Full. The image you see above is the resolution of the camera (656*493 to be precise). I'll accept any kind of code as long as it's not a format c: or something similar What are your sources BTW for testing the algorithm? Do you have access to a camera, that provides raw bayer-pattern images? -- Greets, I. |
1st December 2007, 09:21 | #7 | Link |
ангел смерти
Join Date: Nov 2004
Location: Lost
Posts: 9,558
|
GreyCStoration is reasonably good and reasonably fast, though you'd need a monster machine to make it that fast. Scripts I usually use are closer to spf than fps (but I also use it on multi-megapixel snaps), so I can't really help.
|
3rd December 2007, 11:02 | #8 | Link | |||
Registered User
Join Date: Feb 2002
Posts: 407
|
Quote:
Quote:
Anyway you can try : http://moodub.free.fr/video/Avisynth_DebayerFilter.zip No docs, no waranty Quote:
I've also a camera but i'm still messing around with verilog and the fpga to get the raw pictures |
|||
4th December 2007, 09:35 | #9 | Link |
Retired AviSynth Dev ;)
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
|
@Ignus2: Could you post some material we could test on, and perhaps the source code of your current plugin?
Yes dcraw is probably the worst code I've seen to date. To quote David Coffin: "[I] Firmly believe that programming is an art, not a science, and that beautiful code is more reliable and easier to maintain."
__________________
Regards, sh0dan // VoxPod Last edited by sh0dan; 4th December 2007 at 09:39. |
6th December 2007, 04:15 | #10 | Link | |
Registered User
Join Date: Dec 2005
Posts: 250
|
Quote:
@bill: I've tried your plugin, it looks OK, though indeed quite CPU intensive. Can you post source? In the meantime, here's mine. It could hardly be any more primitive, but oh well. Source included. EDIT: Look below for updated plugin. -- Greets, I. Last edited by Ignus2; 4th March 2008 at 00:01. |
|
4th March 2008, 00:04 | #12 | Link |
Registered User
Join Date: Dec 2005
Posts: 250
|
I made some updates to the plugin, added "bilinear" interpolation or whatever, I don't even know if that's what it's called or just something similar.
It is possible now to offset the bayer pattern, though it will result in black borders. The archive also includes a test image and test script. Oh, and I found out that white balance can be done with RGBAdjust() EDIT: If anyone's interested in the algorithm, here's the link I read: http://www.siliconimaging.com/RGB Bayer.htm -- Greets, I. Last edited by Ignus2; 25th June 2008 at 19:44. |
18th April 2013, 21:58 | #14 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Terka,
http://www.mediafire.com/?1m27l83h1uvl1uj Converted to CPP plugin, not much testing done. Contains source + original source. EDIT: Name is DemosaicCPP.dll, same args as original. Code:
// Plugin parameters: // ------------------ // DemosaicCPP(clip, string mosaic, string method, int xoffset, int yoffset) // // clip clip: input clip, can be YUY2, YV12 or Y8 // string mosaic (default: "Bayer"): the color filter array arrangement. Currently only "Bayer" is supported. // string method (default: "bilinear"): interpolation method: "bilinear" or "nearest" // int xoffset (default: 0): color filter array x offset value. // int yoffset (default: 0): color filter array y offset value. // // output: RGB32 color image
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 18th April 2013 at 22:29. |
19th April 2013, 17:59 | #16 | Link |
Registered User
Join Date: Jan 2005
Location: cz
Posts: 704
|
Thanks a lot, ill try.
Want to try denoise before debayer for really high iso settings. Is there some median or weighted median filter that uses only some pixels? abc def ghi for example only replace the e with a,c,g,i or even bigger radius. maybe ill put some samples. If anyone played with something similar, please post your comments. post 12 link did not work for me |
Thread Tools | Search this Thread |
Display Modes | |
|
|