【发布时间】:2012-05-29 20:37:44
【问题描述】:
我已将图像从 RGB 转换为 B/W,然后我想将其转换回 RGB,但我有一个问题:
我的代码:
int width=zoomedImage->width;
int height=zoomedImage->height;
TempImage=cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,1);
cvCvtColor(zoomedImage, TempImage,CV_RGB2GRAY);
cvThreshold( TempImage, TempImage,128,256,CV_THRESH_BINARY);
cvCvtColor( TempImage,zoomedImage,CV_GRAY2RGB);
this->pictureBox1->Image=(gcnew
System::Drawing::Bitmap(zoomedImage->width,zoomedImage->height,zoomedImage->widthStep,
System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr)zoomedImage->imageData));
在这里,我将 zoomedImage 显示为黑白图像,在另一个动作中,我想将 zoomedImage 显示为 RGB 图像,这里的主要问题是我无法更改将作为我的其他部分绘制的图像代码取决于这个顺序,我在另一个动作中写了:
cvCvtColor( TempImage,zoomedImage,CV_GRAY2RGB);
this->pictureBox1->Image=(gcnew
System::Drawing::Bitmap(zoomedImage->width,zoomedImage->height,zoomedImage->widthStep,
System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr)zoomedImage->imageData));
但是zoomedImage仍然显示为黑白,我听说当真彩色图像转换为灰色时,它不能再次作为真彩色图像返回,那么CV_GRAY2RGB是做什么的?
【问题讨论】:
标签: c++ image-processing opencv