Is there a wiener function in open cv in c++? - c++

Is there a function in OpenCV (C++ API) to perform Wiener filtering? In this case, which is the header file?
I am looking for a function like matlab's Wiener filter. If there is none, has anyone tried to implement it with OpenCV? My goal is to reduce the noise in disparity maps.

I found C++ source code of Weiner filter is there:
http://gigadom.wordpress.com/2012/05/11/deblurring-with-opencv-weiner-filter-reloaded/
and there
https://github.com/savsun/Filters
You can simply edit it and then call as function.

Bad news: there is none.
Good news: it's not difficult to implement one with the classical equations, using OpenCV's FFT functions. It does even provide an API to multiply spectrums.
Now, you may also try other algorithms such as median filtering or implement TV denoising that have been shown to work with depth maps.

I know that this is an old question but I've encountered the same need few days ago. I wrote my personal C++ implementation of the adaptive Wiener filter (similar to the wiener2 Matlab's function) based on OpenCV library and I've pushed it on github. Hope this helps!

You can try to implement by yourself the Wiener filter, for example the book
PETROU, Maria; PETROU, Costas. Image processing: the fundamentals. John Wiley & Sons, 2010.
has a full derivation of the formula for the Wiener filter and a lot of suggestions and practical explanation for implementing the algorithm (for example it explains how to estimate the power spectrum of the noise and the power spectrum of the original undegraded image/signal starting just from the degraded and noisy image/signal and explaining well some reasonable assumptions).

Related

c++ or matlab code to calculate haar-like features of an image

I intend to calculate haar-like features of input images, and then classify those features using SVM.
My question is: Is there some library (C++ or Matlab) of calculating haar-like features of an image I can use?
By the way, I know the application opencv_traincascade.exe from OpenCV. But I wonder if there is a separated code just for calculating haar-like features in OpenCV?
I've found source codes of opencv_traincascade.exe and opencv_haartraining.exe. They're in directory ".\sources\apps\".
And the code to calculate haar-like features of an image is in class CvHaarEvaluator from haarfeatures.cpp, but I can't find any explanation of its members.
As far as I know, CvHaarEvaluator is used once in CvCascadeClassifier.cpp, and the latter is then used once in traincascade.cpp. But I also can't find explanations of traincascade.cpp.
Since it seems that it will take me a lot of time to understand these source codes, I've decided to implement a simple one by myself.
Anyway, if anybody finds an explanation or example of how to use CvHaarEvaluator, please tell me. Thanks!

VLFeat HOG feature extraction

I found a tutorial about VLFeat HOG
http://www.vlfeat.org/overview/hog.html
I am a little confused by the 16*16*31 matrix. Can anyone tell me how can I extract features that can be used for classification task from the matrix that the function returns?
Thanks!
The entries in that matrix are features! Depending on what you're trying to achieve you might do some dimensionality reduction or augmentation or post processing, but none of that is strictly necessary. Check out the original HoG paper.

FFT based image registration (optionally using OpenCV) in cpp?

I'm trying to align two images taken from a handheld camera.
At first, I was trying to use the OpenCV warpPerspective method based on SIFT/SURF feature points. The problem is the feature-extract & matching process may be extremely slow when the image quality is high (3000x4000). I tried to scale-down the image before find feature-points, the result is not as good as before.(The Mat generated from findHomography shouldn't be affected by scaling down the image, right?) And sometimes, due to lack of good feature point matches, the result is quite strange.
After searching on this topic, it seems that solving the problem in Fourier domain will speed up the registration process. And I've found this question which leads me to the code here.
The only problem is the code is written in python with numpy (not even using OpenCV), which makes it quite hard to re-written to C++ code using OpenCV (In OpenCV, I can only find dft and there's no fftshift nor fft stuff, I'm not quite familiar with NumPy, and I'm not brave enough to simply ignore the missing methods). So I'm wondering why there is not such a Fourier-domain image registration implementation using C++?
Can you guys give me some suggestion on how to implement one, or give me a link to the already implemented C++ version? Or help me to turn the python code into C++ code?
Big thanks!
I'm fairly certain that the FFT method can only recover a similarity transform, that is, only a (2d) rotation, translation and scale. Your results might not be that great using a handheld camera.
This is not quite a direct answer to your question, but, as a suggestion for a speed improvement, have you tried using a faster feature detector and descriptor? In OpenCV SIFT/SURF are some of the slowest methods they have for feature extraction/matching. You could try testing some of their other methods first, they all work quite well and are faster than SIFT/SURF. Especially if you use their FLANN-based matcher.
I've had to do this in the past with similar sized imagery, and using the binary descriptors OpenCV has increases the speed significantly.
If you need only shift you can use OpenCV's phasecorrelate

Best stereo correspondence algorithm in opencv

Well, I have got a stereo setup where it computes the disparity of stereo image pairs using SGBM(Semi-global block matching), BM(Block matching) and Variational matching algorithm using the OpenCV library. But the disparities are not so good as that of the ground truth disparities.
All I wanted to know is, whether opencv provides any function or a program that could compute the ground truth disparity. As per some papers like "A Taxonomy and Evaluation of Dense Two-Frame Stereo Correspondence Algorithms" by Daniel Scharstein and Richard Szeliski says that Belief Propagation algorithm is the best stereo correspondence algorithm.
Is there any existing code that computes disparities using graph-cut algorithm or belief propagation algorithm in opencv.
I don't think that there is in OpenCV, but you do have alternatives. There is C++ code available, and it wouldn't be hard to make it interact with OpenCV:
In the Middlebury stereo website that include graph cut and
belief propagation for stereo
There is also Graphcut code from the
University of Western Ontario which is really good.
I think Semi Global Block Matching algorithm by Hirshmuller is one of the best stereo correspondence algorithm.
This algorithm is provided in OpenCV library.
The OpenCV implementation of belief propagation is only offered for GPU (CUDA and OpenCL), not for CPU implementations. They also have the constant space variant of believe prop.
The Middlebury website keeps an updated state of the art on these algorithms, so keep an eye for new entries.
yeah, TSGO is not open sourced, and its article("Accurate Stereo Matching by Two-Step Energy Minimization") is not free either. Has anyone evaluated it?
There is an opencv implementation for GraphCut one and seems quite good, it deserves a try. http://daily-tech.hatenablog.com/entry/2016/06/25/233203

How to Apply Aritstic effect to images and methods used to achieve it?

I am a newbie and i would like to give artistic effects to the images such as photocopy , blur ,glow edge, mosaic bubble ,pencil sketch ,marker , glass effect,paint brush,glow diffused effect programatically?
I want to implement it and any input is appreciated.
The following link depicts what i want to do exactly...
http://picasaweb.google.com/ashish.j.soni/BloggerPictures?authkey=Gv1sRgCMPHzP2P_fjRlgE#5413931800038472178
I believe that these effects are implemented in the GIMP.
The source code is available online http://www.gimp.org/source/ This may help you see how such algorithms are implemented.
You should check OpenCV, it will make your life easier. It is aimed at real-time computer vision, Not really what you are after, but it has a lot of useful functionality (eg. opening/saving different image formats) and standard image operations.
Matlab/octave is also a good tool to get feeling with image processing algorithms.