Wip setream carving
This commit is contained in:
@ -1,61 +1,24 @@
|
||||
#ifndef __SEAM__CARVING_HPP__
|
||||
#define __SEAM__CARVING_HPP__
|
||||
#pragma once
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#define DEBUG 0
|
||||
#include <vector>
|
||||
|
||||
class SeamCarving {
|
||||
public:
|
||||
void showImage();
|
||||
const cv::Mat& getFinalImage();
|
||||
virtual void computeNewFinalImage(int pos);
|
||||
void setBlockUpdate(bool bUpdate);
|
||||
bool getBlockUpdateStatus();
|
||||
virtual void showSeamsImg();
|
||||
|
||||
protected:
|
||||
SeamCarving(const cv::Mat &img, int seams, bool grow);
|
||||
void init();
|
||||
virtual cv::Mat drawSeam(const cv::Mat &frame, const std::vector<int> &seam) = 0;
|
||||
cv::Mat image;
|
||||
cv::Mat finalImage;
|
||||
int seams;
|
||||
bool grow;
|
||||
int sliderMax;
|
||||
int sliderPos;
|
||||
std::vector<std::vector<int>> vecSeams;
|
||||
|
||||
private:
|
||||
cv::Mat GetEnergyImg(const cv::Mat &img);
|
||||
cv::Mat computeGradientMagnitude(const cv::Mat &frame);
|
||||
float intensity(float currIndex, int start, int end);
|
||||
cv::Mat computePathIntensityMat(const cv::Mat &rawEnergyMap);
|
||||
std::vector<int> getLeastImportantPath(const cv::Mat &importanceMap);
|
||||
cv::Mat removeLeastImportantPath(const cv::Mat &original, const std::vector<int> &seam);
|
||||
void removePixel(const cv::Mat &original, cv::Mat &outputMap, int row, int minCol);
|
||||
cv::Mat addLeastImportantPath(const cv::Mat &original, const std::vector<int> &seam);
|
||||
void addPixel(const cv::Mat &original, cv::Mat &outputMat, int row, int minCol);
|
||||
bool blockUpdate = false;
|
||||
|
||||
};
|
||||
|
||||
class SeamCarvingHorizontal : public SeamCarving
|
||||
class SeamCarving
|
||||
{
|
||||
public:
|
||||
SeamCarvingHorizontal(char* fileName, int seams=100, bool grow=false);
|
||||
protected:
|
||||
virtual cv::Mat drawSeam(const cv::Mat &frame, const std::vector<int> &seam) override;
|
||||
};
|
||||
private:
|
||||
static cv::Mat GetEnergyImg(const cv::Mat &img);
|
||||
static cv::Mat computeGradientMagnitude(const cv::Mat &frame);
|
||||
static float intensity(float currIndex, int start, int end);
|
||||
static cv::Mat computePathIntensityMat(const cv::Mat &rawEnergyMap);
|
||||
static std::vector<int> getLeastImportantPath(const cv::Mat &importanceMap);
|
||||
static cv::Mat removeLeastImportantPath(const cv::Mat &original, const std::vector<int> &seam);
|
||||
static void removePixel(const cv::Mat &original, cv::Mat &outputMap, int row, int minCol);
|
||||
static cv::Mat addLeastImportantPath(const cv::Mat &original, const std::vector<int> &seam);
|
||||
static void addPixel(const cv::Mat &original, cv::Mat &outputMat, int row, int minCol);
|
||||
static cv::Mat drawSeam(const cv::Mat &frame, const std::vector<int> &seam);
|
||||
|
||||
class SeamCarvingVertical : public SeamCarving {
|
||||
public:
|
||||
SeamCarvingVertical(char* fileName, int seams=100, bool grow=false);
|
||||
virtual void computeNewFinalImage(int pos) override;
|
||||
#if DEBUG
|
||||
virtual void showSeamsImg() override;
|
||||
#endif
|
||||
protected:
|
||||
virtual cv::Mat drawSeam(const cv::Mat &frame, const std::vector<int> &seam) override;
|
||||
public:
|
||||
static bool strechImage(cv::Mat& image, int seams, bool grow, std::vector<std::vector<int>>* seamsVect = nullptr);
|
||||
static bool strechImageVert(cv::Mat& image, int seams, bool grow, std::vector<std::vector<int>>* seamsVect = nullptr);
|
||||
static bool strechImageWithSeamsImage(cv::Mat& image, cv::Mat& seamsImage, int seams, bool grow);
|
||||
};
|
||||
|
||||
#endif // __SEAM__CARVING_HPP__
|
||||
|
Reference in New Issue
Block a user