简体   繁体   中英

In open cv, how can i convert gray scale image back in to RGB image(color)

In open cv to remove background, using current frame and former frame, i applied absdiff function and created a difference image in gray scale. However, i would like to covert the gray scale image back in to RGB with actual color of the image, but i have no idea how to operate this back in. I'm using C++. Could any one knowledgeable of open cv help me?

You cannot covert the gray scale image back into RGB with actual color of the image again as coverting RGB to gray scale is a data-losing process.

Instead, as @MatsPetersson suggested, you can take the use of the grayscale image to create a mask, eg by further applying a thresholding process . Then you can easily get the ROI color image by:

cv::Mat dst;
src.copyTo(dst, mask); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM