Beispiel #1
0
        public static Bitmap MixBothImage()
        {
            int i = 0, j = 0;
            /************Tao mot mang IMG 60 * 80***************/
            //ushort[,] img_arr_pmg = new ushort[60, 80];

            /***********Chuyen Mang du lieu doc duoc thanh mang anh 256 cap xam***************/
            ushort minval = ImageProcessing.MinVal;

            byte[,] raw_to_bmp = new byte[60, 80];
            double scale = 255.0 / ImageProcessing.SubVal;

            for (i = 0; i < 60; i++)
            {
                for (j = 0; j < 80; j++)
                {
                    //int temp = img_arr_pmg[i, j] - minval;
                    //raw_to_bmp[60 - i - 1, j] = (byte)((img_arr_pmg[i, j] - minval) * scale);
                    raw_to_bmp[60 - i - 1, 80 - j - 1] = (byte)((ImageProcessing.imgFLIR16[i * 80 + j] - minval) * scale);
                }
            }

            /*********Tao mang 240 x 320 image scaling *********************/
            byte[,] scaleimg = new byte[240, 320];
            scaleimg         = zoom_in_with_cubic(raw_to_bmp, 80, 60, 320, 240);

            /****************Tao mang 240 x 320 image rotating******************/
            //byte[,] rotateimg = new byte[240, 320];
            //rotateImg(scaleimg, rotateimg, -90);

            /*********Anh RGB******************/
            Pixels[,] img_arr_rgb = ImageProcessing.UndistortedJPGToPixels();//mang anh rgb input
            Pixels[,] img_cutted  = new Pixels[180, 252];
            for (i = 0; i < 180; i++)
            {
                for (j = 0; j < 252; j++)
                {
                    img_cutted[i, j] = img_arr_rgb[i + 17, j + 36];
                }
            }
            Pixels[,] img_zooming_rgb = new Pixels[240, 320];
            img_zooming_rgb           = zoom_in_with_cubic_rgb(img_cutted, 252, 180, 320, 240);
            //average_overlay_rgb(img_zooming_rgb, ImageProcessing.rgb, rotateimg);
            average_overlay_rgb(img_zooming_rgb, ImageProcessing.rgb, scaleimg);

            int n = 0;

            byte[] arrImg = new byte[240 * 320 * 3];
            for (i = 239; i >= 0; i--)
            {
                for (j = 319; j >= 0; j--)
                {
                    arrImg[n]     = (byte)img_zooming_rgb[i, j].blue;
                    arrImg[n + 1] = (byte)img_zooming_rgb[i, j].green;
                    arrImg[n + 2] = (byte)img_zooming_rgb[i, j].red;
                    n            += 3;
                }
            }
            Bitmap bmpTemp = ImageProcessing.CreateBitmapFromBytes(arrImg, 320, 240);

            return(bmpTemp);
        }