morphological

This commit is contained in:
Jared Bruni
2024-03-15 00:31:57 -07:00
parent 8995d906cc
commit c8c5bd45eb
2 changed files with 33 additions and 0 deletions
+3
View File
@@ -381,6 +381,9 @@ void add_layer_filters(Layer &layer1, Layer &layer2, Layer &layer3) {
MirrorBallEffect *mirror_b = new MirrorBallEffect();
new_filter_list.push_back({"New_MirrorBall", mirror_b});
MorphologicalWarpEffect *warp_e = new MorphologicalWarpEffect();
new_filter_list.push_back({"New_MorphologicalWarp", warp_e});
RGB_Real_Increase *r_real = new RGB_Real_Increase();
new_filter_list.push_back({"New_Real_Inc", r_real});
+30
View File
@@ -3119,6 +3119,36 @@ private:
}
};
class MorphologicalWarpEffect : public FilterFunc {
public:
MorphologicalWarpEffect() {}
void init() override {
warp.initValues(5, 1, 5, 50);
}
void proc(cv::Mat &frame) override {
if (!frame.empty()) {
applyMorphologicalWarp(frame);
}
}
void clear() override {}
private:
void applyMorphologicalWarp(cv::Mat &frame) {
cv::Mat warped;
int morph_size = warp.nextValue();
cv::Mat element = cv::getStructuringElement(cv::MORPH_ELLIPSE,
cv::Size(2 * morph_size + 1, 2 * morph_size + 1),
cv::Point(morph_size, morph_size));
cv::erode(frame, warped, element);
cv::dilate(warped, warped, element);
double alpha = 0.5;
cv::addWeighted(frame, alpha, warped, 1 - alpha, 0.0, frame);
}
KnobT<int> warp;
};
void add_layer_filters(Layer&,Layer&,Layer&);