كيفية استخدام هذا الكود private fun upscaleImage(bitmap: Bitmap, scale: Double): Bitmap {
        val mat = Mat()
        Utils.bitmapToMat(bitmap, mat)
        Imgproc.resize(mat, mat, Size(), scale, scale, Imgproc.INTER_CUBIC)
        Utils.matToBitmap(mat, bitmap)
        return bitmap
    } في هذا الكود class MainActivity : AppCompatActivity() {
    private lateinit var imageView: ImageView
    private lateinit var enhanceButton: Button

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Initialize the views and buttons
        imageView = findViewById(R.id.imageView)
        enhanceButton = findViewById(R.id.enhanceButton)

        // Set the onClickListener for the enhance button
        enhanceButton.setOnClickListener {
            val originalBitmap = BitmapFactory.decodeResource(resources, R.drawable.image1)
            val enhancedBitmap = enhanceImage(originalBitmap)
            imageView.setImageBitmap(enhancedBitmap)
        }

        enhanceButton.setOnClickListener {
            Glide.with(this)
                .asBitmap()
                .load(R.drawable.image1)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .centerCrop()
                .override(800, 800) // تقليل حجم الصورة
                .into(object : SimpleTarget<Bitmap>() {
                    override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
                        val enhancedBitmap = enhanceImage(resource)
                        imageView.setImageBitmap(enhancedBitmap)
                    }
                })
        }
    }

    private fun enhanceImage(bitmap: Bitmap): Bitmap {
        // Convert the Bitmap to an array of pixels and create a new Bitmap with the same dimensions
        val pixels = IntArray(bitmap.width * bitmap.height)
        bitmap.getPixels(pixels, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height)
        val outputBitmap = Bitmap.createBitmap(bitmap.width, bitmap.height, Bitmap.Config.ARGB_8888)

        // Loop over the pixels and enhance the colors
        for (y in 0 until bitmap.height) {
            for (x in 0 until bitmap.width) {
                val index = y * bitmap.width + x
                val pixel = pixels[index]

                // Extract the red, green, and blue components from the pixel
                val red = (pixel shr 16) and 0xFF
                val green = (pixel shr 8) and 0xFF
                val blue = pixel and 0xFF

                // Enhance the colors by increasing the contrast
                val enhancedRed = enhanceColor(red)
                val enhancedGreen = enhanceColor(green)
                val enhancedBlue = enhanceColor(blue)

                // Combine the enhanced colors and set the pixel in the output Bitmap
                val enhancedPixel = (0xFF shl 24) or (enhancedRed shl 16) or (enhancedGreen shl 8) or enhancedBlue
                outputBitmap.setPixel(x, y, enhancedPixel)
            }
        }

        return outputBitmap
    }

    private fun enhanceColor(color: Int): Int {
        return if (color < 128) 0 else 255
    }
    
    
}