Exemple #1
0
        public static bool MeanRemoval(Bitmap b, int nWeight /* default to 9*/)
        {
            ConvMatrix m = new ConvMatrix();

            m.SetAll(-1);
            m.Pixel  = nWeight;
            m.Factor = nWeight - 8;

            return(BitmapFilter.Conv3x3(b, m));
        }
Exemple #2
0
        public static bool Smooth(Bitmap b, int nWeight /* default to 1 */)
        {
            ConvMatrix m = new ConvMatrix();

            m.SetAll(1);
            m.Pixel  = nWeight;
            m.Factor = nWeight + 8;

            return(BitmapFilter.Conv3x3(b, m));
        }
Exemple #3
0
        public static bool EmbossLaplacian(Bitmap b)
        {
            ConvMatrix m = new ConvMatrix();

            m.SetAll(-1);
            m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = 0;
            m.Pixel  = 4;
            m.Offset = 127;

            return(BitmapFilter.Conv3x3(b, m));
        }
Exemple #4
0
        public static bool Sharpen(Bitmap b, int nWeight /* default to 11*/)
        {
            ConvMatrix m = new ConvMatrix();

            m.SetAll(0);
            m.Pixel  = nWeight;
            m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = -2;
            m.Factor = nWeight - 8;

            return(BitmapFilter.Conv3x3(b, m));
        }
Exemple #5
0
        public static bool GaussianBlur(Bitmap b, int nWeight /* default to 4*/)
        {
            ConvMatrix m = new ConvMatrix();

            m.SetAll(1);
            m.Pixel  = nWeight;
            m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = 2;
            m.Factor = nWeight + 12;

            return(BitmapFilter.Conv3x3(b, m));
        }
Exemple #6
0
        public static bool EdgeDetectQuick(Bitmap b)
        {
            ConvMatrix m = new ConvMatrix();

            m.TopLeft    = m.TopMid = m.TopRight = -1;
            m.MidLeft    = m.Pixel = m.MidRight = 0;
            m.BottomLeft = m.BottomMid = m.BottomRight = 1;

            m.Offset = 127;

            return(BitmapFilter.Conv3x3(b, m));
        }
Exemple #7
0
        public iTemplate(Bitmap myImage)
        {
            //BitmapFilter.GrayScale(myImage);
            BitmapFilter.FixHistogram(ref myImage);
            //   myImage.Save("FixedHistogram.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            BitmapFilter.Binarize(ref myImage, 110);
            //    myImage.Save("Binarized.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            //BitmapFilter.GaussianBlur(myImage, 1);


            /******************************************************/
            CImage cimage = new CImage(myImage);
            float  scale  = 1f / (float)Math.Sqrt(cimage.Width * cimage.Height);

            ComplexF[] data = cimage.Data;

            int offset = 0;

            for (int y = 0; y < cimage.Height; y++)
            {
                for (int x = 0; x < cimage.Width; x++)
                {
                    if (((x + y) & 0x1) != 0)
                    {
                        data[offset] *= -1;
                    }
                    offset++;
                }
            }

            Fourier.FFT2(data, cimage.Width, cimage.Height, FourierDirection.Forward);

            cimage.FrequencySpace = true;

            for (int i = 0; i < data.Length; i++)
            {
                data[i] *= scale;
            }

            myImage = cimage.ToBitmap();

            //       myImage.Save("FFT.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            //pictureBoxFiltred.Size = new System.Drawing.Size(myImage.Width, myImage.Height);
            /******************************************************/


            Bitmap zerImage = new Bitmap(zerSize, zerSize);
            int    ow, oh;

            ow = myImage.Width / 2 - zerSize / 2;
            oh = myImage.Height / 2 - zerSize / 2;

            for (int y = 0; y < zerSize; y++)
            {
                for (int x = 0; x < zerSize; x++)
                {
                    zerImage.SetPixel(x, y, myImage.GetPixel(x + ow, y + oh));
                }
            }

            ZernikeDesc zernikeDesc = new ZernikeDesc(zerImage);

            zerCoefficients = zernikeDesc.Process();
        }