Ask Your Question
0

Issues by performing non-local means filter operation on 16bit image

asked 2016-04-12 04:01:43 -0500

NewDeveloper gravatar image

updated 2016-04-12 04:12:22 -0500

Dear great OpenCV community,

I have some issues by processing 16bit Images through the cv::fastNlMeansDenoising Image filter. I have read in the documentation that it is possible if you set the normType = NORM_L1 So i have tried it but nothing happens. The Images still look like the origin Images. So i thought maybe it is a issue with the depth of the Images. Therefore i have integrated in my program a down sampling of the Image before the filtering Operation (16bit -> 8bit) and after the filtering Operation is performed i integrated a up sampling of the Images (8bit -> 16bit). And now the supprising result was that it works with 8bit data perfectly and with 16bit data it seems like the filtering Operation isn't performed because the processed Images look exactly like the original Images

This is my code which i use for the filtering Operation. The Settings of the filter become inserted by the user of my program

//this works perfectly

cv::Mat inputIm;
cv::Mat outputIm;
filterInputCvImage.convertTo(inputIm, CV_8U, 1 / 256.);
cv::fastNlMeansDenoising(inputIm, outputIm, h, templateWindowSize, searchWindowSize, cv::NORM_L1);
outputIm.convertTo(filterOutputImage, CV_16U, 256.0);

//this does not work

cv::fastNlMeansDenoising(filterInputImage, filterOutputImage, h, templateWindowSize, searchWindowSize, cv::NORM_L1);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-04-12 05:12:19 -0500

LBerger gravatar image

updated 2016-04-12 05:13:03 -0500

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);   
imshow("res short",outputIm);
waitKey();
edit flag offensive delete link more

Comments

oke thank you really mutch for the fast answer! you gave me the hint i really needed! i have to multiply my h-value by 256. This make sense! now it also works for me in my application.

NewDeveloper gravatar imageNewDeveloper ( 2016-04-12 06:28:45 -0500 )edit

I wish for Non Local Means for 32f images.

Royi gravatar imageRoyi ( 2016-05-29 11:08:26 -0500 )edit

That's not possible using opencv 3.1. You can convert your image in CV16U using convertto

LBerger gravatar imageLBerger ( 2016-05-29 12:12:56 -0500 )edit

Well, that wouldn't do. I wist someone would optimize a 32f Images version.

Royi gravatar imageRoyi ( 2016-06-03 05:05:08 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-04-12 04:01:43 -0500

Seen: 288 times

Last updated: Apr 12 '16