Beispiel #1
0
        private unsafe void miGaussianBlur_Click(object sender, System.EventArgs e)
        {
            if (this.ActiveCImage == null)
            {
                return;
            }

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

            ComplexF[] data = cimage.Data;

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

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

            Fourier.FFT3(data, cimage.Width, cimage.Height, 1, FourierDirection.Backward);

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

            cimage.FrequencySpace = true;

            this.ActiveCImage = cimage;
        }
Beispiel #2
0
        private void miOpen_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*";
            if (ofd.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            try {
                this.ActiveCImage = new CImage(ofd.FileName);
            }
            catch (Exception ex) {
                MessageBox.Show(this, "Error opening file '" + ofd.FileName + " because '" + ex.Message + " (" + ex.GetType().Name + ")'.", "Open...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void miBackwardFFT_Click(object sender, System.EventArgs e)
        {
            if (this.ActiveCImage == null)
            {
                return;
            }

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

            ComplexF[] data = cimage.Data;

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

            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++;
                }
            }

            cimage.FrequencySpace = false;

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

            this.ActiveCImage = cimage;
        }
Beispiel #4
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();
        }
Beispiel #5
0
 private void miExit_Click(object sender, System.EventArgs e)
 {
     this.ActiveCImage = null;
     Application.Exit();
 }
Beispiel #6
0
 private void miClose_Click(object sender, System.EventArgs e)
 {
     this.ActiveCImage = null;
 }