Exemple #1
0
        public static void Main(string[] args)
        {
            Bitmap bmp = new Bitmap("../../sample.png");

            float[,] yArray  = new float[bmp.Width, bmp.Height];
            float[,] cbArray = new float[bmp.Width, bmp.Height];
            float[,] crArray = new float[bmp.Width, bmp.Height];
            float[,] aArray  = new float[bmp.Width, bmp.Height];

            ImageArrayConverter.BitmapToAYCbCrArrays(bmp, aArray, yArray, cbArray, crArray);
            applyAdaptiveShapening(yArray, 5.0f);
            ImageArrayConverter.AYCbCrArraysToBitmap(aArray, yArray, cbArray, crArray, bmp);
            bmp.Save("test.png", ImageFormat.Png);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            Bitmap bmp = new Bitmap("../../sample.png");

            float[,] yArray  = new float[bmp.Width, bmp.Height];
            float[,] cbArray = new float[bmp.Width, bmp.Height];
            float[,] crArray = new float[bmp.Width, bmp.Height];
            float[,] aArray  = new float[bmp.Width, bmp.Height];

            ImageArrayConverter.BitmapToAYCbCrArrays(bmp, aArray, yArray, cbArray, crArray);
            //setting ~95% of luminance coefficients to zero
            applyAdaptiveDeadzone(yArray, 3);
            //compress chroma even more (98,4%)
            applyAdaptiveDeadzone(cbArray, 1);
            applyAdaptiveDeadzone(crArray, 1);
            ImageArrayConverter.AYCbCrArraysToBitmap(aArray, yArray, cbArray, crArray, bmp);
            bmp.Save("test.png", ImageFormat.Png);
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            Bitmap bmp = new Bitmap("../../sample.png");

            Bitmap bmp2 = new Bitmap(2 * bmp.Width, 2 * bmp.Height, PixelFormat.Format32bppArgb);

            float[,] yArray2  = new float[bmp2.Width, bmp2.Height];
            float[,] cbArray2 = new float[bmp2.Width, bmp2.Height];
            float[,] crArray2 = new float[bmp2.Width, bmp2.Height];
            float[,] aArray2  = new float[bmp2.Width, bmp2.Height];

            ImageArrayConverter.BitmapToAYCbCrArrays(bmp, aArray2, yArray2, cbArray2, crArray2);

            Biorthogonal53Wavelet2D wavelet  = new Biorthogonal53Wavelet2D(bmp.Width, bmp.Height);
            Biorthogonal53Wavelet2D wavelet2 = new Biorthogonal53Wavelet2D(bmp2.Width, bmp2.Height);

            wavelet.TransformIsotropic2D(aArray2);
            wavelet.TransformIsotropic2D(yArray2);
            wavelet.TransformIsotropic2D(cbArray2);
            wavelet.TransformIsotropic2D(crArray2);

            wavelet2.BacktransformIsotropic2D(aArray2);
            wavelet2.BacktransformIsotropic2D(yArray2);
            wavelet2.BacktransformIsotropic2D(cbArray2);
            wavelet2.BacktransformIsotropic2D(crArray2);
            for (int y = 0; y < bmp2.Height; y++)
            {
                for (int x = 0; x < bmp2.Width; x++)
                {
                    aArray2[x, y]  *= 4.0f;
                    yArray2[x, y]  *= 4.0f;
                    cbArray2[x, y] *= 4.0f;
                    crArray2[x, y] *= 4.0f;
                }
            }
            ImageArrayConverter.AYCbCrArraysToBitmap(aArray2, yArray2, cbArray2, crArray2, bmp2);
            bmp2.Save("test.png", ImageFormat.Png);
        }