Android Bitmap去噪

 fun Bitmap.toGray(): Bitmap? {
        // 得到图片的长和宽
        // 创建目标灰度图像
        val bmpGray = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565)
        // 创建画布
        val c = Canvas(bmpGray)
        val paint = Paint()
        val cm = ColorMatrix()
        cm.setSaturation(0f)
        val f = ColorMatrixColorFilter(cm)
        paint.colorFilter = f
        c.drawBitmap(this, 0f, 0f, paint)
        return bmpGray
    }

  

posted @ 2022-09-29 11:28  逍遥散人95  阅读(66)  评论(0编辑  收藏  举报