Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
		private static void applyAdaptiveDeadzone (float[,] array, int numCoeffs)
		{
			int width = array.GetLength (0);
			int height = array.GetLength (1);
			Biorthogonal53Wavelet2D wavelet53 = new Biorthogonal53Wavelet2D (width, height);
			OrderWavelet2D waveletOrder = new OrderWavelet2D (width, height);
            
			wavelet53.EnableCaching = true;
			waveletOrder.EnableCaching = true;
			wavelet53.TransformIsotropic2D (array);
			//Reverse the ordering of the coefficients
			waveletOrder.BacktransformIsotropic2D (array);
			//Use numCoeffs cofficient out of 64 (8x8) -> for e.g. numCoeffs = 5 this
			//means a compression to 7,8% of the original size
			waveletOrder.CropCoefficients (array, 7, 8);
			waveletOrder.TransformIsotropic2D (array);
			wavelet53.BacktransformIsotropic2D (array);
		}
Ejemplo n.º 3
0
        private static void applyAdaptiveDeadzone(float[,] array, int numCoeffs)
        {
            int width  = array.GetLength(0);
            int height = array.GetLength(1);
            Biorthogonal53Wavelet2D wavelet53    = new Biorthogonal53Wavelet2D(width, height);
            OrderWavelet2D          waveletOrder = new OrderWavelet2D(width, height);

            wavelet53.EnableCaching    = true;
            waveletOrder.EnableCaching = true;
            wavelet53.TransformIsotropic2D(array);
            //Reverse the ordering of the coefficients
            waveletOrder.BacktransformIsotropic2D(array);
            //Use numCoeffs cofficient out of 64 (8x8) -> for e.g. numCoeffs = 5 this
            //means a compression to 7,8% of the original size
            waveletOrder.CropCoefficients(array, 7, 8);
            waveletOrder.TransformIsotropic2D(array);
            wavelet53.BacktransformIsotropic2D(array);
        }
Ejemplo n.º 4
0
        private static void applyAdaptiveShapening(float[,] array, float position)
        {
            int width  = array.GetLength(0);
            int height = array.GetLength(1);
            Biorthogonal53Wavelet2D wavelet53    = new Biorthogonal53Wavelet2D(width, height);
            OrderWavelet2D          waveletOrder = new OrderWavelet2D(width, height);

            wavelet53.EnableCaching    = true;
            waveletOrder.EnableCaching = true;
            wavelet53.TransformIsotropic2D(array);
            //Reverse the ordering of the coefficients
            waveletOrder.BacktransformIsotropic2D(array);
            float[] scale = new float[8 * 8];

            for (int x = 0; x < 8 * 8; x++)
            {
                scale [x] = 1.0f + 2.0f / ((position - x) * (position - x) + 1.0f);
            }
            waveletOrder.ScaleCoefficients(array, scale, 8);
            waveletOrder.TransformIsotropic2D(array);
            wavelet53.BacktransformIsotropic2D(array);
        }