From c196e17ed66eab7c07202131f91b19399500b213 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 9 May 2017 15:50:39 +0200 Subject: [PATCH] [CVV] Added laplacian pyramid Signed-off-by: Jim Martens --- ccv/sheet5/CMakeLists.txt | 2 +- ccv/sheet5/laplacian_pyramid.cpp | 11 +++++++++++ ccv/sheet5/laplacian_pyramid.h | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ccv/sheet5/laplacian_pyramid.cpp create mode 100644 ccv/sheet5/laplacian_pyramid.h diff --git a/ccv/sheet5/CMakeLists.txt b/ccv/sheet5/CMakeLists.txt index a9a45e6..27ae729 100644 --- a/ccv/sheet5/CMakeLists.txt +++ b/ccv/sheet5/CMakeLists.txt @@ -5,5 +5,5 @@ set(CMAKE_CXX_STANDARD 11) find_package( OpenCV REQUIRED ) -add_executable(sheet5 main.cpp) +add_executable(sheet5 gauss_pyramid.cpp laplacian_pyramid.cpp main.cpp) target_link_libraries(sheet5 ${OpenCV_LIBS}) diff --git a/ccv/sheet5/laplacian_pyramid.cpp b/ccv/sheet5/laplacian_pyramid.cpp new file mode 100644 index 0000000..11555ff --- /dev/null +++ b/ccv/sheet5/laplacian_pyramid.cpp @@ -0,0 +1,11 @@ +#include "laplacian_pyramid.h" + +laplacian_pyramid::laplacian_pyramid(const gauss_pyramid &pyramid, float sigma) { + _layers = std::vector(); + unsigned long number_of_layers = pyramid.get_number_of_layers(); + for (int i = 0; i < number_of_layers; i++) { + cv::Mat blurred; + cv::GaussianBlur(pyramid.get(i), blurred, cv::Size(), sigma, sigma, cv::BORDER_CONSTANT); + _layers.push_back(blurred); + } +} diff --git a/ccv/sheet5/laplacian_pyramid.h b/ccv/sheet5/laplacian_pyramid.h new file mode 100644 index 0000000..0f68e9d --- /dev/null +++ b/ccv/sheet5/laplacian_pyramid.h @@ -0,0 +1,20 @@ +#ifndef SHEET5_LAPLACIAN_PYRAMID_H +#define SHEET5_LAPLACIAN_PYRAMID_H + +#include +#include "gauss_pyramid.h + +class laplacian_pyramid { +private: + std::vector _layers; +public: + /** + * Initializes the laplacian pyramid. + * @param pyramid the gaussian pyramid + * @param sigma the blur factor + */ + laplacian_pyramid(const gauss_pyramid& pyramid, float sigma); +}; + + +#endif //SHEET5_LAPLACIAN_PYRAMID_H