Smoothing edges change black color - OpenCV Q&A Forum
4.5 (402) In stock
![](https://answers.opencv.org/upfiles/14811356879945593.png)
I am getting foreground image from grabCut algorithm and then i apply below algorithm to smooth its edges. It is working fine and smoothing edges but it is also changing black color in the image. You can see for this image it is working fine for this image but for this image it is changing black color please tell me how to fix this. This is my code for edge smoothing and i got it from Image edge smoothing with opencv #include <iostream> #include <vector> #include <string> #include <fstream> #include <opencv2/opencv.hpp> using namespace cv; using namespace std; int main(int argc, char **argv) { namedWindow("originalImage"); namedWindow("grabCutImage"); namedWindow("smoothImage"); Mat originalImage = imread("../data/original_image_1.jpg"); Mat grabCutImage = imread("../data/grab_cut_image_1.png"); // got from grabcut algorithm originalImage.convertTo(originalImage, CV_32FC3, 1.0 / 255.0); resize(originalImage, originalImage, grabCutImage.size()); grabCutImage.convertTo(grabCutImage, CV_32FC3, 1.0 / 255.0); Mat bg = Mat(grabCutImage.size(), CV_32FC3); bg = Scalar(1.0, 1.0, 1.0); Mat mask; Mat img_gray; cvtColor(grabCutImage, img_gray, COLOR_BGR2GRAY); img_gray.convertTo(mask, CV_32FC1); threshold(1.0 - mask, mask, 0.9, 1.0, THRESH_BINARY_INV); GaussianBlur(mask, mask, Size(21, 21), 11.0); Mat smooth; vector<Mat> ch_img(3); vector<Mat> ch_bg(3); split(originalImage, ch_img); split(bg, ch_bg); ch_img[0] = ch_img[0].mul(mask) + ch_bg[0].mul(1.0 - mask); ch_img[1] = ch_img[1].mul(mask) + ch_bg[1].mul(1.0 - mask); ch_img[2] = ch_img[2].mul(mask) + ch_bg[2].mul(1.0 - mask); merge(ch_img, smooth); merge(ch_bg, bg); imshow("originalImage", originalImage); imshow("grabCutImage", grabCutImage); imshow("smoothImage", smooth); waitKey(0); destroyAllWindows(); } here are images i am using
![](https://media.springernature.com/m685/springer-static/image/art%3A10.1038%2Fs41598-023-32013-9/MediaObjects/41598_2023_32013_Fig4_HTML.jpg)
Edge-preserving smoothing filter using fast M-estimation method with an automatic determination algorithm for basic width
![](https://imagej.net/media/imaging/color-thresholding-manual-threshold2.png)
Particle Analysis
![](https://global.discourse-cdn.com/business4/uploads/imagej/optimized/3X/4/1/4132d466efd61a66c7bed3ba7f3af34fec3dd64c_2_690x343.jpeg)
Automation of measurements inside an specific region using color threshold - Image Analysis - Image.sc Forum
![](https://imagej.net/media/plugins/morpholibj-directional-filtering-principle.png)
MorphoLibJ
![](https://global.discourse-cdn.com/business4/uploads/imagej/original/3X/f/7/f7a1d1e562e41cc3c777b2d32ad51c8b4cd3b193.jpeg)
Automation of measurements inside an specific region using color threshold - Image Analysis - Image.sc Forum
![](https://answers.opencv.org/upfiles/14817063637590582.png)
How to make edges of OpenCV skin detection output “smooth”? - OpenCV Q&A Forum
Opencv Tutorials
![](https://pub.mdpi-res.com/remotesensing/remotesensing-16-00874/article_deploy/html/images/remotesensing-16-00874-ag.png?1709274361)
Remote Sensing, Free Full-Text
![](https://community.robotshop.com/forum/uploads/default/original/2X/6/69fe920d41d05eefe3ccc4e3c716232626eab98d.png)
MyRobotLab - OpenCV - How to find your balls - Tutorials - RobotShop Community
![](https://i.stack.imgur.com/STTBz.jpg)
c++ - smoothing rough edges contour opencv - Stack Overflow
Edge Smoothing — oneIPL Specification documentation
Natural Hair Milk Smooth Edges Creme
How to smooth the edges of a low quality image? - OpenCV Q&A Forum
- BERLEI Barely There Contour Bra Y250 - Black – The Lingerie Bar
- Tiny skirt riding up to reveal those amazing legs : r/katyperry
- PINK
- Gym Shark Fitted Sweatpants Bodybuilding - Black
- POLO RALPH LAUREN Signature Solids V-neck Bralette Bikini Top
- Knosfe Wireless Bra for Women Comfort Cami Lace Bralette Wine Red L