我知道我们通过降低饱和度通道中的值来降低图像的饱和度。我想用带有emgu的c#来完成这个例如,这是使用opencv的c ++代码:Mat Image = imread("images/any.jpg");// Specify scaling factorfloat saturationScale = 0.01;Mat hsvImage;// Convert to HSV color spacecv::cvtColor(Image,hsvImage,COLOR_BGR2HSV);// Convert to float32hsvImage.convertTo(hsvImage,CV_32F);vector<Mat>channels(3);// Split the channelssplit(hsvImage,channels);// Multiply S channel by scaling factor channels[1] = channels[1] * saturationScale;// Clipping operation performed to limit pixel values // between 0 and 255min(channels[1],255,channels[1]);max(channels[1],0,channels[1]);// Merge the channels merge(channels,hsvImage);// Convert back from float32hsvImage.convertTo(hsvImage,CV_8UC3);Mat imSat;// Convert to BGR color spacecv::cvtColor(hsvImage,imSat,COLOR_HSV2BGR);// Display the imagesMat combined;cv::hconcat(Image, imSat, combined);namedWindow("Original Image -- Desaturated Image", CV_WINDOW_AUTOSIZE);在c#中,我有:var img = new Image<Gray, byte>("images/any.jpg");var imhHsv = img.Convert<Hsv, byte>();var channels = imhHsv.Split();// Multiply S channel by scaling factor and clip (limit)channels[1] = (channels[1] * saturationScale);我不确定如何合并修改后的饱和通道与,如果我这样做:imHsvCvInvoke.Merge(channels, imhHsv); 有错误:无法将 'Emgu.CV.Image[]' 转换为 'Emgu.CV.IInputArrayOfArrays'
1 回答
HUX布斯
TA贡献1876条经验 获得超6个赞
我把一个放进去,它的工作原理。VectorOfMatCvInvoke.Merge
Mat[] m = new Mat[3];
m[0] = CvInvoke.CvArrToMat(channels[0]);
m[1] = CvInvoke.CvArrToMat(channels[1]);
m[2] = CvInvoke.CvArrToMat(channels[2]);
VectorOfMat vm = new VectorOfMat(m);
CvInvoke.Merge(vm, imhHsv);
- 1 回答
- 0 关注
- 94 浏览
添加回答
举报
0/150
提交
取消