Exemple #1
0
        private void hLinesWPreprocessingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            float    angleSpacing = 1;
            float    minAngle     = 0;
            float    maxAngle     = 180;
            InputBox Threshold    = new InputBox();

            Threshold.ShowDialog();
            int T = Convert.ToInt32(Threshold.ValueTextBox.Text);

            imgUndo = img.Copy();

            ImageClass.sobelfilter(imgUndo, img, 3);
            ImageClass.otsu(imgUndo, img);

            Image <Gray, float> houghImg = ImageClass.HoughTransform(img.Convert <Gray, byte>(), angleSpacing, minAngle, maxAngle);

            Image <Bgr, byte> lines = ImageClass.ShowHoughLines(img, imgOri, T);

            ShowIMG.ShowIMGStatic(img, lines);
        }
Exemple #2
0
        private void idealFilterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }
            try
            {
                Image <Gray, float> fft_Amp   = null;
                Image <Gray, float> fft_Phase = null;

                InputBox inputFreq = new InputBox("Cut Frequency");

                inputFreq.ShowDialog();

                int freq = Convert.ToInt32(inputFreq.ValueTextBox.Text);

                FFT.GetFFTAmpAndPhase(img, out fft_Amp, out fft_Phase);
                Image <Gray, float> mask = FFT.GenerateFilterMask(fft_Amp.Size, false, freq);
                fft_Amp._Mul(mask);
                Image <Gray, byte> img_filter = FFT.GetFFT_InverseAmpAndPhase(fft_Amp, fft_Phase);

                ShowIMG.ShowIMGStatic(img, img_filter);
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR! Exception: " + ex.Message);
            }
        }
Exemple #3
0
        private void getGPLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            Image <Bgr, byte> imgFinal = ImageClass.GetGPL(img);

            ShowIMG.ShowIMGStatic(img, imgFinal);
        }
Exemple #4
0
        private void byImmersionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Gray, int> imgFinal = ImageClass.GetWatershedByImmersion(img);

            ShowIMG.ShowIMGStatic(img, imgFinal);
        }
Exemple #5
0
        private void componentesLigadosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Gray, int> imgFinal = ImageClass.GetConnectedComponents(img);

            ShowIMG.ShowIMGStatic(img, imgFinal);
        }
Exemple #6
0
        private void houghTransformsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            float angleSpacing           = 1;
            float minAngle               = 0;
            float maxAngle               = 180;
            Image <Gray, float> houghImg = ImageClass.HoughTransform(img.Convert <Gray, byte>(), angleSpacing, minAngle, maxAngle);

            ShowIMG.ShowIMGStatic(img, houghImg);
        }
Exemple #7
0
        private void fFTWebcamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Image <Gray, float> fft_Amp   = null;
            Image <Gray, float> fft_Phase = null;

            Capture capture = new Capture();

            img = capture.QueryFrame().Clone();
            capture.Dispose();

            FFT.GetFFTAmpAndPhase(img, out fft_Amp, out fft_Phase);

            fft_Amp   = FFT.PrepareForVizualization(fft_Amp, true);
            fft_Phase = FFT.PrepareForVizualization(fft_Phase, false);

            ShowIMG.ShowIMGStatic(fft_Amp, fft_Phase);
        }
Exemple #8
0
        private void fromLabelsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();
            OpenFileDialog openMask = new OpenFileDialog();

            if (openMask.ShowDialog() == DialogResult.OK)
            {
                Image <Gray, byte> mask = new Image <Gray, byte>(openMask.FileName);

                Image <Gray, int> imgFinal = ImageClass.GetWatershedFromLabels(img, mask);
                ShowIMG.ShowIMGStatic(img, imgFinal);
            }
        }
Exemple #9
0
        private void houghLinesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            float angleSpacing = 1;
            float minAngle     = 0;
            float maxAngle     = 180;
            int   T            = 2;


            Image <Gray, float> houghImg = ImageClass.HoughTransform(img.Convert <Gray, byte>(), angleSpacing, minAngle, maxAngle);


            //  Image<Bgr, byte> img1 = null;
            Image <Bgr, byte> lines = ImageClass.ShowHoughLines(img, img, T);

            ShowIMG.ShowIMGStatic(houghImg, lines);
        }
Exemple #10
0
        private void fFTSwitchAmpPhaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            Image <Bgr, byte> img_fft1 = new Image <Bgr, byte>(openFileDialog1.FileName);

            openFileDialog1.ShowDialog();
            Image <Bgr, byte> img_fft2 = new Image <Bgr, byte>(openFileDialog1.FileName);

            ShowIMG.ShowIMGStatic(img_fft1, img_fft2);

            Image <Gray, float> fft_Amp1   = null;
            Image <Gray, float> fft_Phase1 = null;
            Image <Gray, float> fft_Amp2   = null;
            Image <Gray, float> fft_Phase2 = null;

            FFT.GetFFTAmpAndPhase(img_fft1, out fft_Amp1, out fft_Phase1);
            FFT.GetFFTAmpAndPhase(img_fft2, out fft_Amp2, out fft_Phase2);

            Image <Gray, byte> res1 = FFT.GetFFT_InverseAmpAndPhase(fft_Amp1, fft_Phase2);
            Image <Gray, byte> res2 = FFT.GetFFT_InverseAmpAndPhase(fft_Amp2, fft_Phase1);


            ShowIMG.ShowIMGStatic(res1, res2);
        }
Exemple #11
0
        private void aula2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Gray, float> matrix = ImageClass.GetQuantificationMatrix(true, 100);
            Image <Ycc, float>  blockYCC;



            //TableForm.ShowTableStatic(matrix,"Matriz de Quantificacao");


            Image <Ycc, float> imgYCC = img.Convert <Ycc, float>(); //Transformar o espaço de cor RGB para YCbCr

            // TODO subsampling

            //Para cada bloco de 8x8 pixéis, fazer: (Copy(new rectangle(...) ) )
            int Yblocks = (int)Math.Ceiling(img.Height / 8.0);
            int Xblocks = (int)Math.Ceiling(img.Width / 8.0);


            for (int x = 0; x < Xblocks; x++)
            {
                for (int y = 0; y < Yblocks; y++)
                {
                    Image <Gray, float> y1 = imgYCC[0].Copy(new Rectangle(x * 8, y * 8, 8, 8));
                    Image <Gray, float> Cr = imgYCC[1].Copy(new Rectangle(x * 8, y * 8, 8, 8));
                    Image <Gray, float> Cb = imgYCC[2].Copy(new Rectangle(x * 8, y * 8, 8, 8));

                    CvInvoke.cvDCT(y1, y1, CV_DCT_TYPE.CV_DXT_FORWARD);//cálculo da transformada de cossenos DCT
                    CvInvoke.cvDCT(Cb, Cb, CV_DCT_TYPE.CV_DXT_FORWARD);
                    CvInvoke.cvDCT(Cr, Cr, CV_DCT_TYPE.CV_DXT_FORWARD);

                    CvInvoke.cvDiv(y1, matrix, y1, 1); // quantificação dos coeficientes
                    CvInvoke.cvDiv(Cb, matrix, Cb, 1);
                    CvInvoke.cvDiv(Cr, matrix, Cr, 1);

                    ImageClass.myRound(y1); //arredondamento dos coeficientes
                    ImageClass.myRound(Cb);
                    ImageClass.myRound(Cr);

                    // DESCOMPRESSÃO

                    CvInvoke.cvMul(y1, matrix, y1, 1); // recuperação dos coeficientes (Mul)
                    CvInvoke.cvMul(Cb, matrix, Cb, 1);
                    CvInvoke.cvMul(Cr, matrix, Cr, 1);

                    CvInvoke.cvDCT(y1, y1, CV_DCT_TYPE.CV_DXT_INVERSE);//cálculo da transformada inversa de cossenos iDCT (
                    CvInvoke.cvDCT(Cb, Cb, CV_DCT_TYPE.CV_DXT_INVERSE);
                    CvInvoke.cvDCT(Cr, Cr, CV_DCT_TYPE.CV_DXT_INVERSE);

                    imgYCC.ROI = new Rectangle(x * 8, y * 8, 8, 8);


                    blockYCC = new Image <Ycc, float>(8, 8);
                    CvInvoke.cvMerge(y1, Cr, Cb, IntPtr.Zero, blockYCC);


                    blockYCC.CopyTo(imgYCC);

                    imgYCC.ROI = Rectangle.Empty;
                }
            }

            Image <Bgr, byte> imgfinal = imgYCC.Convert <Bgr, float>().Convert <Bgr, byte>();

            ShowIMG.ShowIMGStatic(img, imgfinal);
        }