Skip to content
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

Merged
merged 26 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e23e838
Module EPF - Edge-Preserving Filter added
Jul 12, 2018
3891dd5
Changed name from template to epf
Jul 12, 2018
538049f
Removed clang-format file
Jul 12, 2018
0d96f6d
Added header Files. Eliminated showWindow function. Used CommandLineP…
Jul 12, 2018
c272800
Moved filter from epf module to ximgproc
Jul 12, 2018
23d45a6
Removed header files from sample
Jul 13, 2018
82dfa23
Minor bug fix in demo. Pointers in demo removed.
Jul 13, 2018
88ce7a7
Pointers removed. InputArray/OutputArray added
Jul 13, 2018
1f115b6
License header added
Jul 31, 2018
19686de
License header from sample file removed
Jul 31, 2018
9cc391b
Unit test for performance added
Jul 31, 2018
c411b39
Replaced manual mean computation with cv::mean
Jul 31, 2018
55766d9
Beautified code via clang-format and https://raw.githubusercontent.co…
Jul 31, 2018
7e89c3d
Merged historic if... else if statement into one if statement
Jul 31, 2018
1b079bd
Trailing whitespace removed and .. changed into .
Aug 1, 2018
16ee637
Tabs replaced with 4 spaces.
Aug 1, 2018
3216c78
Removed subwindow = src(roi);
Aug 1, 2018
5fa0aba
Moved type test to beginning of code
Aug 1, 2018
845d807
Removed indentation from namespace and added //! @}
Aug 1, 2018
c6ea43f
Added name to header
Aug 1, 2018
a91e629
git cleanup introduced some errors fixed here
Aug 1, 2018
7e7d108
Changed path testdata/perf/320x260.png to perf/320x260.png
Aug 1, 2018
acb5b27
Fixed warning declaration of 'subwindow1' hides previous local declar…
Aug 1, 2018
c7e4c3a
Fixed warning 'const' qualifier on reference type 'cv::InputArray' (a…
Aug 1, 2018
fee6573
Accuracy test added/
Aug 1, 2018
5795c0a
Renamed void edgepreservingFilter to void edgePreservingFilter
Aug 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/ximgproc/include/opencv2/ximgproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "ximgproc/ridgefilter.hpp"
#include "ximgproc/brightedges.hpp"
#include "ximgproc/run_length_morphology.hpp"
#include "ximgproc/edgepreserving_filter.hpp"


/** @defgroup ximgproc Extended Image Processing
Expand Down
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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

//! @{

/**
* @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 );
Copy link
Contributor

@berak berak Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you try without the pointers ?

CV_EXPORTS_W void edgepreservingFilter( const InputArray src, OutputArray dst, int d, int threshold );

should be enough. (passing cv::Mat by address is usually a bad idea, since it defeats the internal refcounting)

(the buildbot does not like it, either )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


}} // namespace

#endif
47 changes: 47 additions & 0 deletions modules/ximgproc/samples/edgepreserving_filter_demo.cpp
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>
Copy link
Contributor

@berak berak Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not exist, right ? ( #include <opencv2/ximgproc.hpp> should be enough, here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
}
Loading