0

I have captured a 12bit image from a camera (and converted it to 16bit for openCV) I use the pylon library, because I have a basler camera:

camera.PixelFormat.SetValue(PixelFormat_Mono12); 
formatConverter.OutputPixelFormat = PixelType_Mono16;

With this 12bit image I want to do some calculating stuff. For displaying this image I just converted this image to 8bit by using:

image16bit.convertTo(image8bit, CV_8U);

But now this image is very noisy (image1) image1-noisy-12bit

When I capute a native 8bit image, then this image is not noisy (image2) image 2 -notnoisy-8bit.

Can someone explain, why this happens and how to convert the 12bit image to 8bit without this noise?

HanzDieter
  • 99
  • 1
  • 11
  • OpenCV doesn't support 12-bit images, you will need to convert it to 16-bit preferably so you don't lose information: https://stackoverflow.com/questions/10403841/convert-12-bit-bayer-image-to-8-bit-rgb-using-opencv – EdChum Jun 19 '18 at 07:44
  • How are you reading the 12 bit input image? – sgarizvi Jun 19 '18 at 07:45
  • 1
    yes, right. I captured a 12bit image and have to convert is to 16bit for openCV. I´m using the pylon library for this, because I have a basler camera: camera.PixelFormat.SetValue(PixelFormat_Mono12); formatConverter.OutputPixelFormat = PixelType_Mono16; – HanzDieter Jun 19 '18 at 07:46
  • how many channels are there for this 12bit? – Joseph D. Jun 19 '18 at 07:50
  • there is only one channel for 12bit and there should also be 1 for the 8bit image – HanzDieter Jun 19 '18 at 07:51
  • *edited with more information* Are the two images the same exposure level? The noisier one looks as if it was taken with a higher ISO, and it also looks as if it has more detail, which is sometimes the case in noisier images. The "not noisy" image looks as if some serious noise reduction was performed on it: for instance, it's smudgy, lacks detail and of course it's darker. I have the impression that these aren't comparable as 8-bit images. – John Perry Jun 19 '18 at 08:07
  • 1
    `convertTo(image8bit, CV_8U, 0.0625);` – rustyx Jun 19 '18 at 08:12
  • this one from rustyx works very well, but I have to increase the opening of the camera aperture (iris) – HanzDieter Jun 19 '18 at 08:28
  • convertTo doesn't scale the values automatically. If your values are in range 0 (black) to 4095 (white) (max 12 bit unsigned value) the choose a scaling factor of 255.0/4095.0 in the convertTo parameter. I think currently your noise is just enhanced because of that scaling. Edit: Ah sorry, rustyxy already mentioned it :D – Micka Jun 19 '18 at 10:17

0 Answers0