我已将图像从 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 仍然显示为 B/W,我听说当真彩色图像转换为灰色时,它不能再次作为真彩色图像返回,那么 CV_GRAY2RGB 是做什么的?