0

I am trying to erode and dilate images but the images that are getting sent are transparent. So that part is getting replaced by black. I require it to be white.

Also, how do I turn that white part to transparent after eroding or dilating it?

Joakim Danielson
  • 43,251
  • 5
  • 22
  • 52
Vidhi V
  • 23
  • 2
  • I guess you are trying on png images. What happens if you read the image in color like this ```cv::Mat input_rgb = cv::imread("some-image-1.png", cv::IMREAD_COLOR);``` – balu Mar 25 '22 at 09:09
  • In my project, I am required to convert a received UIImage to mat `UIImageToMat(receivedImage, matImage);`. So I am not reading it in the way you specified. – Vidhi V Mar 25 '22 at 10:17
  • I have [something close](https://stackoverflow.com/a/61048790/4926757) in Python. In your case, you may use the alpha channel as a mask. Please post a sample image and some code (show what you have tried so far). – Rotem Mar 25 '22 at 21:51
  • @Rotem I am not sure whether doing this could be the solution for what I originally want to achieve. So posting my original question [here](https://stackoverflow.com/questions/71642842/why-is-erosion-and-dilation-of-images-returning-black-images). Please check. – Vidhi V Mar 28 '22 at 05:59
  • Sorry, but it's unclear what you are asking. – Rotem Mar 28 '22 at 08:08

0 Answers0