我正在使用OpenCV for Windows Phone 8.1(Windows运行时)在C++与MS开放技术https://github.com/MSOpenTech/opencv发布。MedianBlur问题与OpenCV
该版本基于OpenCV 3,并且medianBlur函数似乎存在问题。 当我使用一个正方形的图像,将medianBlur完美的作品,但是当我使用一个矩形图像时,medianBlur产生奇怪的效果......
下面的结果:http://fff.azurewebsites.net/opencv.png
我使用的代码:
// get the pixels from the WriteableBitmap
byte* pPixels = GetPointerToPixelData(m_bitmap->PixelBuffer);
int height = m_bitmap->PixelHeight;
int width = m_bitmap->PixelWidth;
// create a matrix the size and type of the image
cv::Mat mat(width, height, CV_8UC4);
memcpy(mat.data, pPixels, 4 * height*width);
cv::Mat timg(mat);
cv::medianBlur(mat, timg, 9);
cv::Mat gray0(timg.size(), CV_8U), gray;
// copy processed image back to the WriteableBitmap
memcpy(pPixels, timg.data, 4 * height*width);
// update the WriteableBitmap
m_bitmap->Invalidate();
我没有找到问题所在......它是我的代码中的错误?或OpenCV 3的错误?从MS开放技术的代码?
感谢您的帮助!
哈哈,非常感谢你!它的作用就像一个魅力:D 感谢MS你的样品与这个litle错误;) – Nico 2014-08-29 12:27:35
@biquette的原因可能是,在数学中存在两个约定:矩阵公约索引:行第一。图像约定:首先x轴。这可能与为什么存在两种方式来访问矩阵元素(用矩阵约定中的“.at”之一(行第一)和一个用于图像约定“Point”)是相同的原因。 – Micka 2014-08-29 14:06:50
@Micka,谢谢你的解释。 – biquette 2014-08-29 14:35:09