Ask Your Question

Revision history [back]

I don't know how this method works. But like this results seems right :

int type=CV_16UC1;
Mat x(256,256,type);
for (int i=0;i<x.rows;i++)
    for (int j=0;j<x.cols;j++)
        x.at<short>(i,j)=j*128+i*64+rand()%4096;

cv::Mat inputIm;
cv::Mat outputIm;
x.convertTo(inputIm, CV_8U, 1 / 256.);
vector<float> h = {3};
cv::fastNlMeansDenoising(inputIm, outputIm,h, 7, 21, cv::NORM_L1);
imshow("original",x);
imshow("res uc",outputIm);
outputIm.convertTo(outputIm, CV_16U, 256.0);
//
h[0] = h[0]*256;
cv::fastNlMeansDenoising(x, outputIm, h, 7, 21, cv::NORM_L1);    vector<Mat> m(3);
imshow("res short",outputIm);
waitKey();

I don't know how this method works. But like this results seems right :

int type=CV_16UC1;
Mat x(256,256,type);
for (int i=0;i<x.rows;i++)
    for (int j=0;j<x.cols;j++)
        x.at<short>(i,j)=j*128+i*64+rand()%4096;

cv::Mat inputIm;
cv::Mat outputIm;
x.convertTo(inputIm, CV_8U, 1 / 256.);
vector<float> h = {3};
cv::fastNlMeansDenoising(inputIm, outputIm,h, 7, 21, cv::NORM_L1);
imshow("original",x);
imshow("res uc",outputIm);
outputIm.convertTo(outputIm, CV_16U, 256.0);
//
h[0] = h[0]*256;
cv::fastNlMeansDenoising(x, outputIm, h, 7, 21, cv::NORM_L1);    vector<Mat> m(3);
 imshow("res short",outputIm);
waitKey();