1
0
mirror of https://github.com/2martens/uni.git synced 2026-05-06 11:26:25 +02:00

[CCV] Modified LAB pyramid to work with given image

Signed-off-by: Jim Martens <github@2martens>
This commit is contained in:
2017-05-02 15:11:23 +02:00
parent 2e157035c6
commit 47883edea3
3 changed files with 45 additions and 6 deletions

View File

@ -6,11 +6,17 @@ lab_pyramid::lab_pyramid(cv::String image_filename) {
cv::split(_inputImage_lab ,_imageChannels); cv::split(_inputImage_lab ,_imageChannels);
}; };
void lab_pyramid::create_pyramids(int number_of_layers) lab_pyramid::lab_pyramid(cv::Mat image) {
cv::cvtColor(image, _inputImage_lab, cv::COLOR_RGB2Lab);
_inputImage_lab.convertTo(_inputImage_float, CV_32F);
cv::split(_inputImage_float, _imageChannels);
}
void lab_pyramid::create_pyramids(float sigma, int number_of_layers)
{ {
_pyramids[COLOR_L] = gauss_pyramid(_imageChannels[COLOR_L], number_of_layers); _pyramids[COLOR_L] = gauss_pyramid(_imageChannels[COLOR_L], sigma, number_of_layers);
_pyramids[COLOR_A] = gauss_pyramid(_imageChannels[COLOR_A], number_of_layers); _pyramids[COLOR_A] = gauss_pyramid(_imageChannels[COLOR_A], sigma, number_of_layers);
_pyramids[COLOR_B] = gauss_pyramid(_imageChannels[COLOR_B], number_of_layers); _pyramids[COLOR_B] = gauss_pyramid(_imageChannels[COLOR_B], sigma, number_of_layers);
} }
gauss_pyramid lab_pyramid::get_pyramid(int channel) gauss_pyramid lab_pyramid::get_pyramid(int channel)

View File

@ -7,6 +7,7 @@
class lab_pyramid { class lab_pyramid {
private: private:
cv::Mat _inputImage_lab; cv::Mat _inputImage_lab;
cv::Mat _inputImage_float;
cv::Mat _imageChannels[3]; cv::Mat _imageChannels[3];
gauss_pyramid _pyramids[3]; gauss_pyramid _pyramids[3];
public: public:
@ -21,12 +22,20 @@ public:
*/ */
lab_pyramid(cv::String image_filename); lab_pyramid(cv::String image_filename);
/**
* Initializes a LAB pyramid.
*
* @param image the image that should be used
*/
lab_pyramid(cv::Mat image);
/** /**
* Creates the gaussian pyramids for all channels with the given number of layers each. * Creates the gaussian pyramids for all channels with the given number of layers each.
* *
* @param sigma the sigma for the gaussian pyramids
* @param number_of_layers number of layers for gaussian pyramid * @param number_of_layers number of layers for gaussian pyramid
*/ */
void create_pyramids(int number_of_layers); void create_pyramids(float sigma, int number_of_layers);
/** /**
* Before this method can be called, pyramids have to be created via create_pyramids. * Before this method can be called, pyramids have to be created via create_pyramids.

View File

@ -1,5 +1,29 @@
#include <iostream> #include <iostream>
#include <opencv2/opencv.hpp>
#include "lab_pyramid.h"
int main(int argc, char** argv) {
if ( argc != 2 )
{
printf("usage: <Image_Path>\n");
return -1;
}
cv::Mat image;
image = cv::imread(argv[1], cv::ImreadModes::IMREAD_COLOR);
int layers = 4;
float sigma_center = 3;
float sigma_surround = 5;
// center
lab_pyramid pyr_center = lab_pyramid(image);
pyr_center.create_pyramids(sigma_center, layers);
// surround
lab_pyramid pyr_surround = lab_pyramid(image);
pyr_surround.create_pyramids(sigma_surround, layers);
int main() {
return 0; return 0;
} }