Debayer with _VNG is buggy (Bug #2074)


Added by Pierre Chatelier over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-06-21
Priority:Normal Due date:
Assignee:Ilya Lavrenov % Done:

0%

Category:imgproc, video
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

When debayering an image, you can use cvCvtColor(..., CV_BayerGB2BGR) (and other flavors of RG, GB...)
You can also use the (undocumented) cvCvtColor(..., CV_BayerGB2BGR_VNG)

Since OpenCV 2.4.0 (and in 2.4.1 as well), some saturated areas are not handled correctly by the _VNG version
I have attached some files :
image-natural.png (the input)
image-debayered-normal.png (normal output with CV_BayerGB2BGR)
image-debayered-vng.png (wrong output with CV_BayerGB2BGR_VNG)

Do not pay attention to the "blue" or "dotted" aspect of the images. I suppose that the conversion to PNG is not "one channel friendly". On my screen, the output is correct.

If you want the data in another format, just ask me.


image-natural.png - input (177.4 kB) Pierre Chatelier, 2012-06-21 03:17 pm

image-debayered-vng.png - wrong output with _VNG (391.4 kB) Pierre Chatelier, 2012-06-21 03:17 pm

image-debayered-normal.png - normal output with normal Debayer (304.3 kB) Pierre Chatelier, 2012-06-21 03:17 pm

color.cpp (140.7 kB) Kevin Smith, 2012-06-27 05:04 pm


Associated revisions

Revision 71914987
Added by Roman Donchenko about 11 years ago

Merge pull request #2074 from asmorkalov:android_nonfree_cuda

History

Updated by Pierre Chatelier over 12 years ago

When I say "On my screen, the output is correct", I only talk about the general aspect of the images.
The bug to observe is the window, where much green appears in the VNG mode

Updated by Andrey Kamaev over 12 years ago

  • Target version deleted (2.4.2)
  • Category set to imgproc, video

Updated by Kevin Smith over 12 years ago

I have no idea how to submit patches but I ran into this bug while using the software and have a fix. All the code I am talking about is found here - http://code.opencv.org/svn/opencv/trunk/opencv/modules/imgproc/src/color.cpp The specific function is Bayer2RGB_VNG_8u This is happening because the variables x1, x2, and t1 sometimes have a sign bit in the MSB of the 16 bit values we are looking at. This way when we run the _mm_packus_epi16(x1, z), _mm_packus_epi16(x2, z), and _mm_packus_epi16(t1, z) lines of code it will pack down to zero instead of 255 like it is supposed to (thinks it is a negative number). I created a bug fix for my application that is working with the image attached as well as another image that I was testing with. I have attached my code fixes. Basically before packing I AND all the 16 bit values with 0x7fff so that it clears the sign bit and pack to 255 instead of zero.

  • File color.cpp added

Updated by Gilad Kapelushnik over 12 years ago

I would also like to see this fixed. Thanks

Updated by Vadim Pisarevsky over 12 years ago

  • Target version deleted ()

Updated by Ilya Lavrenov over 12 years ago

thank you very much for the patch! the fix has been applied in 2759f0

  • Status changed from Open to Done
  • Assignee set to Ilya Lavrenov

Updated by Andrey Kamaev about 12 years ago

  • Target version set to 2.4.3

Also available in: Atom PDF