-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Edge-Preserving Filter #1690
Changes from 5 commits
e23e838
3891dd5
538049f
0d96f6d
c272800
23d45a6
82dfa23
88ce7a7
1f115b6
19686de
9cc391b
c411b39
55766d9
7e89c3d
1b079bd
16ee637
3216c78
5fa0aba
845d807
c6ea43f
a91e629
7e7d108
acb5b27
c7e4c3a
fee6573
5795c0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#ifndef __OPENCV_EDGEPRESERVINGFILTER_HPP__ | ||
#define __OPENCV_EDGEPRESERVINGFILTER_HPP__ | ||
|
||
#include <opencv2/core.hpp> | ||
|
||
namespace cv { namespace ximgproc { | ||
|
||
//! @addtogroup ximgproc | ||
//! @{ | ||
|
||
/** | ||
* @brief Smoothes an image using the Edge-Preserving filter. | ||
* | ||
* The function smoothes Gaussian noise as well as salt & pepper noise. | ||
* For more details about this implementation, please see | ||
* [ReiWoe18] Reich, S. and Wörgötter, F. and Dellen, B. (2018). A Real-Time Edge-Preserving Denoising Filter. Proceedings of the 13th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISIGRAPP): Visapp, 85-94, 4. DOI: 10.5220/0006509000850094. | ||
* | ||
* @param src Source 8-bit 3-channel image. | ||
* @param dst Destination image of the same size and type as src. | ||
* @param d Diameter of each pixel neighborhood that is used during filtering. Must be greater or equal 3.. | ||
* @param threshold Threshold, which distinguishes between noise, outliers, and data. | ||
*/ | ||
CV_EXPORTS_W void edgepreservingFilter( const InputArray *src, OutputArray *dst, int d, int threshold ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you try without the pointers ?
should be enough. (passing cv::Mat by address is usually a bad idea, since it defeats the internal refcounting) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
}} // namespace | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <opencv2/imgcodecs.hpp> | ||
#include <opencv2/highgui.hpp> | ||
#include <opencv2/ximgproc.hpp> | ||
#include <opencv2/opencv.hpp> | ||
#include <opencv2/epf.hpp> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this does not exist, right ? ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
|
||
using namespace cv; | ||
|
||
|
||
int main(int argc, char **argv) | ||
{ | ||
cv::CommandLineParser parser(argc, argv, | ||
"{help h ? | | help message}" | ||
"{@image | | Image filename to process }" | ||
); | ||
if (parser.has("help") || !parser.has("image")) | ||
{ | ||
parser.printMessage(); | ||
return 0; | ||
} | ||
|
||
// Load image from first parameter | ||
std::string filename = parser.get<string>("@image"); | ||
Mat image = imread(filename, 1), res; | ||
|
||
if (!image.data) | ||
{ | ||
std::cerr << "No image data at " << filename << std::endl; | ||
throw; | ||
} | ||
|
||
// Before filtering | ||
imshow("Original image", image); | ||
waitKey(0); | ||
|
||
// Initialize filter. Kernel size 5x5, threshold 20 | ||
ximgproc::edgepreservingFilter(&image, &res, 5, 20); | ||
|
||
// After filtering | ||
imshow("Filtered image", res); | ||
waitKey(0); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No indentation in namespaces please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.