예제 #1
0
        // Moution Blur....................................
        public static ByteBitmap WienerFilterFromMoution(ByteBitmap aBitmap, float Length, int Angle, float Nsr)
        {
            //make fft from abitmap
            Point      lStart;
            ByteBitmap lLoc = FFTHelpers.FitByteBitmapForFFT2D(aBitmap, 10, out lStart, 255);

            Complex[,] lFx = FFTHelpers.ByteBitmapToComplex(lLoc);
            FourierTransform.FFT2(lFx, FourierTransform.Direction.Forward);

            //make moution FFT
            Complex[,] lHx = GetMotionComplexImage(new Size(lLoc.Width, lLoc.Height), Angle, Length);
            FourierTransform.FFT2(lHx, FourierTransform.Direction.Forward);

            //make wiener
            Complex[,] lWR = WienerFilter(lFx, lHx, Nsr);

            //backward result
            FourierTransform.FFT2(lWR, FourierTransform.Direction.Backward);

            //convert to bytebitmap
            ByteBitmap lRes = FFTHelpers.ComplexToByteBitmap(lWR);

            lRes = FFTHelpers.GetFittedByteBitmapFromFFT2D(lRes, lStart, new Size(aBitmap.Width, aBitmap.Height));
            return(lRes);
        }
예제 #2
0
        public static ByteBitmap FitByteBitmapForFFT2D(ByteBitmap aBitmap, int Shift, out Point StartPoint, byte DefVal)
        {
            StartPoint = new Point(0, 0);
            ByteBitmap lRes = null;
            //calculate new
            int lNewWidth  = aBitmap.Width;
            int lNewHeight = aBitmap.Height;

            lNewWidth  += AdditionToPowerOfTwo(lNewWidth);
            lNewHeight += AdditionToPowerOfTwo(lNewHeight);
            int lNewShiftX = (lNewWidth - aBitmap.Width);
            int lNewShiftY = (lNewHeight - aBitmap.Height);


            if (0 != DefVal)
            {
                lRes = new ByteBitmap(lNewWidth, lNewHeight, DefVal);
            }
            else
            {
                lRes = new ByteBitmap(lNewWidth, lNewHeight);
            }

            for (int ly = 0; ly < aBitmap.Height; ly++)
            {
                for (int lx = 0; lx < aBitmap.Width; lx++)
                {
                    lRes[lx + lNewShiftX, ly + lNewShiftY] = aBitmap[lx, ly];
                }
            }
            StartPoint.X = 0;
            StartPoint.Y = 0;

            return(lRes);
        }
예제 #3
0
        public static Complex[,] ByteBitmapToComplex(ByteBitmap aBitmap)
        {
            Complex[,] lRes = new Complex[aBitmap.Width, aBitmap.Height];

            for (int ly = 0; ly < aBitmap.Height; ly++)
            {
                for (int lx = 0; lx < aBitmap.Width; lx++)
                {
                    lRes[lx, ly] = new Complex(aBitmap[lx, ly], 0);
                }
            }
            return(lRes);
        }
예제 #4
0
        public static ByteBitmap GetFittedByteBitmapFromFFT2D(ByteBitmap aBitmap, Point StartPoint, Size ImageSize)
        {
            ByteBitmap lRes = new ByteBitmap(ImageSize.Width, ImageSize.Height);

            for (int ly = 0; ly < ImageSize.Height; ly++)
            {
                for (int lx = 0; lx < ImageSize.Width; lx++)
                {
                    lRes[lx, ly] = aBitmap[lx + StartPoint.X, ly + StartPoint.Y];
                }
            }
            return(lRes);
        }
예제 #5
0
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            for (int x = 0; x < 1000; x++)
            {
                sb.Append("This is what I wish to hide into an image file.");
            }


            byte[] hi = ByteCrypt.Crypt(File.ReadAllBytes("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"), Hash.SHA256(new byte[5]), Hash.MD5(new byte[20]), true, "aes");

            ByteBitmap.ToImage8(hi, 500, 500).Save("8.png");
            ByteBitmap.ToImage16(hi, 500, 500).Save("16.png");
            //ByteBitmap.ToImage24(hi, 250, 250).Save("24.png");
            ByteBitmap.ToImage32(hi, 500, 500).Save("32.png");
        }
예제 #6
0
        public static ByteBitmap ComplexToByteBitmap(Complex[,] aBitmap)
        {
            int        w    = aBitmap.GetLength(0);
            int        h    = aBitmap.GetLength(1);
            ByteBitmap lRes = new ByteBitmap(w, h);

            for (int ly = 0; ly < lRes.Height; ly++)
            {
                for (int lx = 0; lx < lRes.Width; lx++)
                {
                    Complex lTmp = aBitmap[lx, ly];
                    float   lVal = (int)Math.Round(Math.Sqrt(lTmp.Re * lTmp.Re + lTmp.Im * lTmp.Im));
                    lRes[lx, ly] = (byte)Math.Min(lVal, 255);
                }
            }

            return(lRes);
        }
예제 #7
0
 /// <summary>Resizes the <see cref="Data"/> bitmap to match the screen size.</summary>
 protected void ResizeBitmap()
 {
     Data = new ByteBitmap(OnMono ? Width - 10 : Width, OnMono ? Height - 10 : Height);
 }