title: Making black parts of an image transparent opencv in Android
body: <p>I am currently trying to use edge detection to find edges and then converting the remaining picture from black to transparent. I have created 4 different channels and have used <code>Imgproc.threshold</code> to make an alpha channel with complete transparency. After this, I have attempted to merge all 4 channels into one but the resulting image still shows up with a black background. (I know this black background isn't transparent since I have layered the resulting image on top of my camerax preview).</p>
  <pre><code>    private fun detectEdges(image: Bitmap) {
  
      val src = Mat(image.getHeight(), image.getWidth(), CvType.CV_8UC4)
      Utils.bitmapToMat(image, src)
      val edges = Mat(src.size(), CvType.CV_8UC1)
      
      Imgproc.cvtColor(src, edges, Imgproc.COLOR_BGRA2GRAY)
      Imgproc.Canny(edges, edges, 80.0, 100.0)
      
      val src1 = edges.clone()
      val src2 = edges.clone()
      val alpha = Mat(image.height, image.width, CvType.CV_8UC1)
      
      Imgproc.threshold(edges, alpha, 70.0, 0.0, Imgproc.THRESH_BINARY_INV)
  
      val dst = Mat()
      val listMat = listOf(edges, src1, src2, alpha)
      Core.merge(listMat, dst)
  
      val output =
          Bitmap.createBitmap(image.getWidth(), image.getHeight(), Bitmap.Config.ARGB_8888)
      Utils.matToBitmap(dst, output)
  
      BitmapHelper.showBitmap(safeContext, output, binding.edgeDetectionView)
  }
  </code></pre>
  <p>Any ideas on how to make the image transparent?</p>