emgu cv near image matching(c#)结果不正确

时间:2015-06-29 14:21:07

标签: c# emgucv

我正在尝试比较两幅图像,其中图像2的差异小于图像1 但我没有得到结果=两个图像是相同的

    private void button1_Click(object sender, EventArgs e)
    {
        Bitmap img = new Bitmap(200, 120);
        Rectangle rect = new Rectangle();
        Image<Gray, Byte> templateImage = new Image<Gray, Byte>(@"D:\IMG1\TestCase1-256.bmp");
        Image<Gray, Byte> sourceImage = new Image<Gray, Byte>(@"D:\IMG1\TestCase1-256.bmp");
        Image<Bgr, Byte> ImageSource = new Image<Bgr, Byte>(100,100);
        int x1, y1, hei, wid;
        Image<Gray, float> imgMatch = sourceImage.MatchTemplate(templateImage, Emgu.CV.CvEnum.TM_TYPE.CV_TM_CCOEFF_NORMED);
        float[, ,] matches = imgMatch.Data;
        for (int y = 0; y < matches.GetLength(0); y++)
        {
            for (int x = 0; x < matches.GetLength(1); x++)
            {
                double matchScore = matches[y, x, 0];
                //0.75
                if (matchScore > 0.99)
                {
                    rect = new Rectangle(new Point(x - templateImage.Width, y - templateImage.Height), new Size(1, 1));
                    ImageSource.Draw(rect, new Bgr(Color.Blue), 1);

                }

            }

        }
        pictureBox1.Image = ImageSource.Bitmap;
    }

Image-1和Image-2的字体变化很小。我是否遵循正确的方法或任何指针都会有所帮助。

0 个答案:

没有答案