Page 1 of 1

how to save color disparity map from 'ImageTransfer' ?

Posted: Sat Apr 02, 2022 1:36 pm
by jay
hello,

i'm trying to get color disparity map not NVCom but C++ code.

when i use a function 'writePgmFile()', i see '.pgm' images with gray-color.

and a result mat of 'toOpenCVImage()' function is 2-depth.

would you plz give directions to save color disparity map?

thanks.

Re: how to save color disparity map from 'ImageTransfer' ?

Posted: Sat Apr 02, 2022 1:51 pm
by k.schauwecker
If you are trying to replicate the color coding of NVCom, you can download the full source code from our download page. The relevant class is in the files:
nerian-vision-software-9_0_5-src/nvcom/helpers/colcoder.*

This class applies color coding to an OpenCV image, which you can get from the toOpenCVImage() method.

OpenCV itself also provides a similar functionality. Please have a look at this article:
https://docs.opencv.org/4.x/d3/d50/group__imgproc__colormap.html

Re: how to save color disparity map from 'ImageTransfer' ?

Posted: Sat Apr 02, 2022 3:55 pm
by jay
thanks for quick reply. it is very helpful.

Re: how to save color disparity map from 'ImageTransfer' ?

Posted: Tue Apr 05, 2022 1:25 pm
by fdirman
Hello,
is there a way to use the functionality of nvcom/helpers/colorcoder.cpp with Python? More precisely, I would like to know how to apply colormap_rainbow to disparity map with Python just like in the API review page (which uses for example rainbow color map and sets invalid pixels to gray). I tried with cv2.applyColorMap() but it does not set the invalid pixels to gray like in the API.

Re: how to save color disparity map from 'ImageTransfer' ?

Posted: Wed Apr 06, 2022 7:57 am
by k.schauwecker
For the ColorCoder class there is unfortunately no python binding. Given the small size of this class, the best option would be to re-create this class in python. All it does is, it linearly interpolates between the colors in the color table.

There are some optimizations being done, like pre-computing all the colors for 8-bit and 16-bit images, but these optimizations are not necessary if performance is not super critical.