#ifndef __SEAM__CARVING_HPP__ #define __SEAM__CARVING_HPP__ #include #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 &seam) = 0; cv::Mat image; cv::Mat finalImage; int seams; bool grow; int sliderMax; int sliderPos; std::vector> 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 getLeastImportantPath(const cv::Mat &importanceMap); cv::Mat removeLeastImportantPath(const cv::Mat &original, const std::vector &seam); void removePixel(const cv::Mat &original, cv::Mat &outputMap, int row, int minCol); cv::Mat addLeastImportantPath(const cv::Mat &original, const std::vector &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 &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 &seam) override; }; #endif // __SEAM__CARVING_HPP__