-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSeamCarving.hpp
60 lines (53 loc) · 1.97 KB
/
SeamCarving.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __SEAM__CARVING_HPP__
#define __SEAM__CARVING_HPP__
#include <opencv2/core/core.hpp>
#define DEBUG 0
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
{
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;
};
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;
};
#endif // __SEAM__CARVING_HPP__