Denoising opencv image in C++, Video is the same. Image in the loop.


My favourite

  • Opencv tutorial people detection
  • Head people cascade download
  • Opencv tutorial optical flow
  • Opencv Video stabilization
  • Opencv car dataset download
  • Opencv tutorial Transparent mask
  • Opencv videowriter
  • Opencv FFMPEG
  • Opencv Canny edge and hough lines

  • Denoising easy opencv tutorial C++

    The Opencv library has build in powerful denoising algorithm based on the non-local means. The metdod is based on the theory published in article by Antoni Buades, Bartomu Coll, Jean-Michel Morel  here. The algorithm is relatively simple, but not so easy to implement. Basically, one single pixel is replace by the average of the colors of area around the most simular pixel. Let say we want to replace pixel and algorithm finding the replacement in some window. It find the most simular replacement and additionally take a smaller window over that most silular replacement and calculate mean value over that. 
    If we have first window of some size and second the smaller just one pixel. We probably replace the original one with the most simular. If the most simular one is the noise. It will be noise. This is great metod for calculating the output image from the sequence of imputs image to achieve better result. Video result is also impresive.. Check the results and enjoy the simple code. 

    fastNlMeansDenoisingColoredMulti opencv denoising method results

    This results are from my video. Upper part of the image is the denoised frame of the video calculated from the 4 surrounded frames. Original imputs is the lower part of the image. If you check the cropped part below the results are clearly visible. No to much blured image, sharp edges and much less noisy. This is exactly what we want to achieve. 

    Denoising opencv noise reduction
    Denoising video sample in opencv 3,1 noise reduction
    Denoising opencv noise reduction

    Iphone sequence of images noise reduction

    I just take the imput 5 image by iphone SE holded in hands. Result will be much better with 5 images using tripod. 

    Denoising opencv noise reductionDenoising opencv noise reduction
    Denoising opencv noise reduction

    Denoising opencv noise reductionDenoising opencv noise reduction
    ZOOM of one of the imput image

    Denoising opencv noise reduction

    Results of  fastNl Means Denoising Colored Multi method

    Denoising opencv noise reduction

    Noise reduction Zoom ot the result

    Denoising opencv noise reduction

    What do you think ? Let me know.. 

    Opencv denoising (noise reduction) c++ code

    There is nothing special. Fill the vector<Mat> buffer(5); buffer with input images calculate from buffer the method based on the templateWindowSize = 12 and searchWindowSize = 48. This is it.

    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/photo.hpp>
    #include <opencv2\videostab.hpp>
    #include "opencv2/imgcodecs.hpp"
    #include "opencv2\highgui.hpp"
    #include "opencv2\imgproc.hpp"
    #include <iostream>
    using namespace cv; using namespace std; int main(int argc, char** argv) { vector buffer(5); Mat image; image = imread("i1.JPG", CV_LOAD_IMAGE_COLOR); buffer[0] = image; imshow("Display window", image); waitKey(2000); image = imread("i2.JPG", CV_LOAD_IMAGE_COLOR); buffer[1] = image; waitKey(2000); imshow("Display window", image); image = imread("i3.JPG", CV_LOAD_IMAGE_COLOR); buffer[2] = image; imshow("Display window", image); waitKey(2000); image = imread("i4.JPG", CV_LOAD_IMAGE_COLOR); buffer[3] = image; imshow("Display window", image); waitKey(2000); image = imread("i5.JPG", CV_LOAD_IMAGE_COLOR); buffer[4] = image; imshow("Display window", image); waitKey(2000); Mat img; int imgs_count = 5; fastNlMeansDenoisingColoredMulti(buffer, img, imgs_count / 2, imgs_count, 12, 48); namedWindow("Display window", WINDOW_AUTOSIZE); imshow("Display window", img); imwrite("result.jpg", img); waitKey(20000); return 0; }

    Denoising Colored Video example

    1 comment:


    Follow by Email

    Powered by Blogger.