0
我基本上尝试了一些方法来修改这里已经存在的问题的像素数据。然而,没有什么只是工作。如何在openCV中修改cv :: Mat的像素数据?
我正在iOS OpenCV2.framework上工作。
我已经实现了下面的方法,但没有修改outputImage。
UIImage *inputUIImage = [UIImage imageName:@"someImage.png"];
UIImage *outputUIImage = nil;
cv::Mat inputImage = <Getting this from a method that converts UIImage to cv::Mat: Working properly>
cv::Mat outputImage;
inputImage.copyTo(outputImage);
//processing...
for(int i=0; i < outputImage.rows; i++)
{
for (int j=0; j<outputImage.cols; j++)
{
Vec4b bgrColor = outputImage.at<Vec4b>(i,j);
//converting the 1st channel <assuming the sequence to be BGRA>
// to a very small value of blue i.e. 1 (out of 255)
bgrColor.val[0] = (uchar)1.0f;
}
}
outputUIImage = <Converting cv::Mat to UIImage via a local method : Working properly>
self.imageView1.image = inputUIImage;
self.imageView2.image = outputUIImage;
//here both images are same in colour. no changes.
任何人都可以让我知道我错过了什么吗?
但在这里,即使你写了相同的代码,我做了第一个1 ..和它不工作。然而,我会尝试第二个。 – CodenameLambda1
对不起。错字。现在修复 – kamjagin
嗯我看..现在它的一个参考。 – CodenameLambda1