Smoothing edges change black color - OpenCV Q&A Forum
![](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://rfilkov.com/wp-content/uploads/2021/10/k4a-interface-depth-settings.png)
Azure Kinect Examples for Unity
![](https://i.stack.imgur.com/Pb4lL.jpg)
python - Smoothing edges of contours - Stack Overflow
BenQ TK850 4K HDR10/HLG 3000lm Home Entertainment Projector Review/Owners Thread
![](https://www.mdpi.com/vehicles/vehicles-04-00055/article_deploy/html/images/vehicles-04-00055-g008-550.jpg)
Vehicles, Free Full-Text
What are blobs in image processing? - Quora
![](https://pyimagesearch.com/wp-content/uploads/2015/09/max_filter_grand_canyon.png)
Implementing the Max RGB filter in OpenCV - PyImageSearch
Solved: My brushes create 'disconnected' lines - Adobe Community - 12170172
![](https://content.packt.com/B02054/cover_image.jpeg)
Advance your knowledge in tech - Packt+
![](https://answers.opencv.org/upfiles/15765149898753637.png)
Good foreground segmentation methods apart from Canny - OpenCV Q&A Forum
![](https://media.springernature.com/lw685/springer-static/image/chp%3A10.1007%2F978-1-4471-6741-9_3/MediaObjects/978-1-4471-6741-9_3_Fig17_HTML.gif)
Inspection Methods for Metal Surfaces: Image Acquisition and Algorithms for the Characterization of Defects
![](https://viso.ai/wp-content/uploads/2022/02/viso-suite-build-ai-vision-1060x597.png)
What is OpenCV? The Complete Guide (2024)