how to save color disparity map from 'ImageTransfer' ?

Post Reply
jay
Posts: 7
Joined: Sat Apr 02, 2022 1:18 pm

how to save color disparity map from 'ImageTransfer' ?

Post 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.
k.schauwecker
Posts: 122
Joined: Mon Mar 25, 2019 1:12 pm

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

Post 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
jay
Posts: 7
Joined: Sat Apr 02, 2022 1:18 pm

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

Post by jay »

thanks for quick reply. it is very helpful.
fdirman
Posts: 1
Joined: Wed Mar 09, 2022 4:23 pm

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

Post 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.
Last edited by fdirman on Tue Apr 05, 2022 1:26 pm, edited 1 time in total.
k.schauwecker
Posts: 122
Joined: Mon Mar 25, 2019 1:12 pm

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

Post 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.
Post Reply