Debayering / demosaicing


    May 19 2008 | 5:22 pm
    Hello list,
    Do you know if it's possible to implement (and eventually how) a debayering (or demosaicing / demosaicking) algorithm in Jitter ? I got an Allied Tecs. color camera which works in RAW format. I searched the forum but didn't find anything about that.
    Any idea or help would be greatly appreciated... Best
    Thierry
    ---------------------------------------- Thierry Fournier http://www.thierryfournier.net

    • May 21 2008 | 4:27 am
    • May 21 2008 | 2:16 pm
    • Jun 13 2008 | 10:33 am
      im aiming for a simple linear debayer conversion. if anyone like to help that'll be great. its impossible
      tags: demosaic, debayer, fail
    • Jun 13 2008 | 1:00 pm
      tighter, the wikipedia image source was not pixel accurate, now it looks better, but jaggy. need interpolation or fancier algo.
      On Fri, Jun 13, 2008 at 12:33 PM, yair reshef wrote:
      > im aiming for a simple linear debayer conversion. > if anyone like to help that'll be great. its impossible > > souces - > http://en.wikipedia.org/wiki/Demosaicing > > http://scien.stanford.edu/class/psych221/projects/07/demosaicing/introduction.htm > http://web.cecs.pdx.edu/~cklin/demosaic/ > http://tinyurl.com/6nu8nq - googlecode search, see demosaic section > (highlighted) > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #N vpatcher 35 85 632 259; > #P window setfont "Sans Serif" 9.; > #P newex 223 35 27 9109513 + 30; > #P newex 191 36 27 9109513 + 36; > #P outlet 72 130 15 0; > #P newex 51 130 16 9109513 t l; > #P toggle 288 52 15 0; > #P message 289 69 64 9109513 usedstdim $1; > #P number 488 72 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 452 72 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 400 71 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 364 71 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 417 90 95 9109513 pak dstdimend 12 10; > #P newex 326 90 89 9109513 pak dstdimstart 0 0; > #P toggle 50 50 15 0; > #P message 51 67 64 9109513 usesrcdim $1; > #P number 250 70 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 214 70 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 162 69 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 126 69 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 179 88 95 9109513 pak srcdimend 12 10; > #P newex 88 88 89 9109513 pak srcdimstart 0 0; > #P connect 7 0 6 0; > #P fasten 9 0 16 0 422 119 56 119; > #P fasten 8 0 16 0 331 119 56 119; > #P fasten 14 0 16 0 294 108 56 108; > #P connect 6 0 16 0; > #P connect 0 0 16 0; > #P fasten 1 0 16 0 184 118 56 118; > #P connect 16 0 17 0; > #P connect 2 0 0 1; > #P connect 3 0 0 2; > #P connect 2 0 18 0; > #P connect 18 0 4 0; > #P connect 4 0 1 1; > #P connect 3 0 19 0; > #P connect 19 0 5 0; > #P connect 5 0 1 2; > #P connect 15 0 14 0; > #P connect 10 0 8 1; > #P connect 11 0 8 2; > #P connect 12 0 9 1; > #P connect 13 0 9 2; > #P pop; > #P newobj 42 103 44 9109513 p srcdim; > #P newex 17 126 218 9109513 jit.matrix 3 char 12 10 @planemap 1 2 3 @adapt > 0; > #P user jit.pwindow 263 105 122 102 1 0 0 0 1 0; > #P toggle 17 21 15 0; > #P newex 17 41 44 9109513 metro 2; > #P newex 17 78 81 9109513 jit.qt.movie 12 10; > #B color 5; > #P message 67 42 290 9109513 read > http://shup.com/Shup/45595/Shades_framed_bayer_small.png; > #P user jit.fpsgui 102 520 60 9109513 3; > #P user jit.pwindow 16 511 82 62 1 0 0 0 1 0; > #P newex 17 487 568 9109513 jit.pack 3; > #P user jit.pwindow 208 409 82 62 1 0 0 0 1 0; > #P newex 209 381 132 9109513 jit.matrix 1 char 6 5 @adapt 0; > #P newex 209 335 146 9109513 jit.matrix 1 float32 6 5 @adapt 0; > #P newex 209 358 90 9109513 jit.op @op * @val 2; > #P newex 209 314 100 9109513 cv.jit.resize @size 6 5; > #P user jit.pwindow 400 409 82 62 1 0 0 0 1 0; > #P newex 401 339 147 9109513 jit.demultiplex @demultiplexdim 1; > #P newex 401 315 147 9109513 jit.demultiplex @demultiplexdim 0; > #P user jit.pwindow 84 409 82 62 1 0 0 0 1 0; > #P newex 17 339 147 9109513 jit.demultiplex @demultiplexdim 1; > #P newex 17 315 147 9109513 jit.demultiplex @demultiplexdim 0; > #P user jit.pwindow 415 245 82 62 1 0 0 0 1 0; > #P user jit.pwindow 221 245 82 62 1 0 0 0 1 0; > #P user jit.pwindow 37 245 82 62 1 0 0 0 1 0; > #P newex 17 223 586 9109513 jit.unpack 3; > #N vpatcher 15 55 932 466; > #P origin 0 -16; > #P window setfont "Sans Serif" 9.; > #P window linecount 2; > #P newex 419 27 371 9109513 jit.expr @expr > "(cell[0]%4.>0.)*(cell[0]%4.0.6)*0.15-0.075" > "0." "(cell[0]%4.>0.)*(cell[0]%4.0.6)*0.1"; > #P comment 438 60 302 9109513 this jit.expr object is the key to how we > generate a quad for each point in the incoming matrix , and assign texture > coordinates to each point.; > #P window linecount 1; > #P message 785 181 33 9109513 cell[0]; > #P message 720 181 61 9109513 "(cell[0]%2) "; > #P message 705 146 94 9109513 "(cell[0]%2) + cell[0]"; > #P newex 532 225 84 9109513 t b l; > #P button 522 183 15 0; > #P number 643 113 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 619 167 50 9109513 tosymbol; > #P newex 633 213 26 9109513 print; > #P newex 619 146 83 9109513 pak cell[0]% 0 + 2; > #P newex 620 190 62 9109513 prepend expr; > #P newex 521 298 94 9109513 jit.expr @expr cell[0]; > #P newex 521 201 40 9109513 jit.noise; > #P window linecount 2; > #P newex 521 249 80 9109513 jit.matrix 1 float32 12 10 @adapt 0; > #P window linecount 1; > #P newex 172 264 175 9109513 jit.matrix 1 char 6 5 @interp 1 @adapt 0; > #P newex 92 124 356 9109513 jit.matrix 1 char 12 10 @adapt 0 @usedstdim 1 > @dstdimstart 0 0 @dstdimend 10 8; > #P newex 93 213 86 9109513 jit.pack; > #P newex 75 66 78 9109513 jit.unpack; > #P newex 91 94 166 9109513 jit.submatrix @dim 12 10 @offset 1 1; > #B color 5; > #N vpatcher 35 85 632 259; > #P outlet 72 130 15 0; > #P window setfont "Sans Serif" 9.; > #P newex 51 130 16 9109513 t l; > #P toggle 288 52 15 0; > #P message 289 69 64 9109513 usedstdim $1; > #P number 488 72 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 452 72 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 400 71 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 364 71 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 417 90 95 9109513 pak dstdimend 12 10; > #P newex 326 90 89 9109513 pak dstdimstart 0 0; > #P toggle 50 50 15 0; > #P message 51 67 64 9109513 usesrcdim $1; > #P number 250 70 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 214 70 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 162 69 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 126 69 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 179 88 95 9109513 pak srcdimend 12 10; > #P newex 88 88 89 9109513 pak srcdimstart 0 0; > #P connect 7 0 6 0; > #P fasten 9 0 16 0 422 119 56 119; > #P fasten 8 0 16 0 331 119 56 119; > #P fasten 14 0 16 0 294 108 56 108; > #P connect 6 0 16 0; > #P connect 0 0 16 0; > #P fasten 1 0 16 0 184 118 56 118; > #P connect 16 0 17 0; > #P connect 2 0 0 1; > #P connect 3 0 0 2; > #P connect 4 0 1 1; > #P connect 5 0 1 2; > #P connect 15 0 14 0; > #P connect 10 0 8 1; > #P connect 11 0 8 2; > #P connect 12 0 9 1; > #P connect 13 0 9 2; > #P pop; > #P newobj 56 269 90 9109513 p; > #P window linecount 2; > #P newex 50 290 298 9109513 jit.matrix 1 char 12 10 @adapt 0 @usesrcdim 1 > @srcdimstart 1 1 @srcdimend 11 9 @usedstdim 0 @dstdimstart 0 0 @dstdimend 11 > 9; > #P window linecount 1; > #P newex 113 164 185 9109513 jit.matrix 1 char 24 20 @interp 1 @adapt 0; > #P inlet 75 46 15 0; > #P connect 3 0 2 0; > #P connect 0 0 5 0; > #P connect 5 1 4 0; > #P connect 4 0 7 0; > #P connect 7 0 6 0; > #P connect 5 2 1 0; > #P connect 1 0 6 1; > #P connect 5 3 6 2; > #P connect 17 0 10 0; > #P fasten 10 0 9 0 526 223 526 223; > #P connect 18 0 9 0; > #P connect 9 0 11 0; > #P fasten 18 1 11 0 611 289 526 289; > #P fasten 12 0 18 0 625 221 537 221; > #P fasten 13 0 15 0 624 166 624 166; > #P connect 15 0 12 0; > #P fasten 19 0 12 0 710 188 625 188; > #P connect 20 0 12 0; > #P connect 21 0 12 0; > #P fasten 12 0 14 0 625 211 638 211; > #P connect 16 0 13 1; > #P pop; > #P newobj 491 55 30 9109513 p; > #P comment 67 26 174 9109513 http://en.wikipedia.org/wiki/Demosaicing; > #P user jit.pwindow 109 164 62 52 1 0 0 0 1 0; > #P connect 22 0 26 0; > #P fasten 22 0 25 0 22 99 269 99; > #P fasten 21 0 22 0 72 68 22 68; > #P fasten 23 0 22 0 22 71 22 71; > #P connect 26 0 3 0; > #P fasten 26 0 0 0 22 161 115 161; > #P fasten 27 0 26 0 47 124 22 124; > #P connect 18 0 19 0; > #P fasten 18 0 20 0 22 509 107 509; > #P connect 11 0 12 0; > #P fasten 11 0 18 2 406 361 580 361; > #P connect 3 2 10 0; > #P connect 3 2 6 0; > #P connect 10 0 11 0; > #P connect 16 0 17 0; > #P fasten 16 0 18 1 214 404 301 404; > #P connect 3 1 13 0; > #P connect 3 1 5 0; > #P connect 14 0 16 0; > #P connect 15 0 14 0; > #P connect 13 0 15 0; > #P fasten 8 1 18 0 90 369 22 369; > #P fasten 8 1 9 0 90 361 90 361; > #P connect 3 0 7 0; > #P connect 3 0 4 0; > #P fasten 7 1 8 0 90 336 22 336; > #P connect 24 0 23 0; > #P window clipboard copycount 28; > > tags: demosaic, debayer, fail >
    • Jun 14 2008 | 10:55 pm
      i've been reading about this demosaicing thing, and its a bitch. tons of different concepts. demosaicing on gpu- http://rw4.cs.uni-sb.de/~phlucas/pubs/Diss.pdf (see p. 146) RAW decoder comparison - http://users.tkk.fi/%7Estanhua/rawcomp/
      im aiming low and skip cross gradient checking, group ranking etc etc for a simple working one. but I'm failing with implementing some basic ideas with jitter matrices.
      1.how do i write an efficient exprop that for every ON pixel will copy the value of the ON pixel to the one to its right (and latter, to which one of its nine neighbours) like if getcell(x,y)>0 then cell(x+1,y)=getcell(x,y)
      2. how do i preform a sum of pixels with fixed distribution (not sure about the usage of Distro here), like set of {0 0 1 0 0 1 0 0 1 0 0 1} sum every 3rd member. [jit.demultiplex @scan_a 3] > cv.jit.sum
      zl for matrices.
    • Jun 16 2008 | 4:43 pm
      for the interested, a repos version, but this is going nowhere
      On Sun, Jun 15, 2008 at 12:55 AM, yair reshef wrote:
      > i've been reading about this demosaicing thing, and its a bitch. tons of > different concepts. > demosaicing on gpu- http://rw4.cs.uni-sb.de/~phlucas/pubs/Diss.pdf(see p. 146) > RAW decoder comparison - http://users.tkk.fi/%7Estanhua/rawcomp/ > > im aiming low and skip cross gradient checking, group ranking etc etc for a > simple working one. but I'm failing with implementing some basic ideas with > jitter matrices. > > 1.how do i write an efficient exprop that for every ON pixel will copy the > value of the ON pixel to the one to its right (and latter, to which one of > its nine neighbours) > like > if getcell(x,y)>0 then cell(x+1,y)=getcell(x,y) > > 2. how do i preform a sum of pixels with fixed distribution (not sure about > the usage of Distro here), > like > set of {0 0 1 0 0 1 0 0 1 0 0 1} sum every 3rd member. > [jit.demultiplex @scan_a 3] > cv.jit.sum > > > zl for matrices. > > >
    • Jun 16 2008 | 6:05 pm
      Hrm. This sounds fun, Im at work so cant check it out too much, but for your "1.how do i write an efficient exprop that for every ON pixel will copy the value of the ON pixel to the one to its right (and latter, to which one of its nine neighbours)?"
      Perhaps you could do a jit.op @op > 1, and then a convolution filter, which would move all values to the left, a filter something like?
      0 0 0 1 1 0 0 0 0
      ? for a 9 point convolution kernel?
      This sounds like a really fun challenge.
    • Jun 16 2008 | 8:11 pm
      Unfortunately, I don't have too much time to play around with this right now,but in looking at some of the links you provided, I came up with a quick fragment shader that (I think) does what you are trying to accomplish. Check out the attached patch and shader file.
      Best, Andrew B.
    • Jun 16 2008 | 8:13 pm
      Sorry, here is the shader...
    • Jun 17 2008 | 11:46 am
      the internets will (also) thank you for this
      i'll look into the shader, i know your have a lot of work so double tnx
    • Jun 14 2013 | 12:20 pm
      Andrew, can you please upload the shader again?
    • Jun 14 2013 | 12:27 pm
      By the way, now I see that it works without it.
      And it is a bit weird that the patch works even though I don't have the ab.debayer.jxs file on my mac. "jit.gl.shader: can't find file ab.debayer.jxs"