Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I'm using C# Aforge.net framework, can please help on writing the basic algorithims for, comparing a image with a reference image by motion detection/subtraction of 2 colors.
Thank you. ")

Best regards
Candyl33
Posted

I hope Among of THIS[^] and THIS[^] may help you regarding.
 
Share this answer
 
Comments
JF2015 20-Jan-11 1:35am    
Good links.
Best person to help is Andrew Kirillov, a creator of AForge.NET. He is the best one to help with such a problem.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Jan-11 2:34am    
What, don't want to? :-)
JF2015 20-Jan-11 2:43am    
Your hint to AForge is good - don't know why someone thought it's worth a 1. Have my 5 to counter up :)
Sergey Alexandrovich Kryukov 20-Jan-11 2:48am    
Probably from the one who already talked to Andrew Kirillov :-)
Thank you.
please follow this link , it will help you :

http://www.c-sharpcorner.com/UploadFile/prathore/ImageComparison01022009050404AM/ImageComparison.aspx[^]

<pre lang="cs">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        static string fname1,fname2;
        Bitmap img1, img2;
        int count1=0,count2=0;
        bool flag = true;
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            openFileDialog1.FileName = ""; // Setting the opefiledialog to default
            openFileDialog1.Title = "Images"; // Title of the dialog
            openFileDialog1.Filter = "All Images|*.jpg; *.bmp; *.png"; // In the filter you should write all the types of image
            openFileDialog1.ShowDialog();
            if (openFileDialog1.FileName.ToString() != "")
            {
                fname1 = openFileDialog1.FileName.ToString();
            }

        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            openFileDialog2.FileName = ""; // Setting the opefiledialog to default
            openFileDialog2.Title = "Images"; // Title of the dialog
            openFileDialog2.Filter = "All Images|*.jpg; *.bmp; *.png"; // In the filter you should write all the types of image
            openFileDialog2.ShowDialog();
            if (openFileDialog2.FileName.ToString() != "")
            {
                fname2 = openFileDialog2.FileName.ToString();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            progressBar1.Visible = true;
            string img1_ref,img2_ref;
            img1 = new Bitmap(fname1);
            img2 = new Bitmap(fname2);
            progressBar1.Maximum = img1.Width;
            if (img1.Width == img2.Width && img1.Height == img2.Height)
            {
                for (int i = 0; i < img1.Width; i++)
                {
                    for (int j = 0; j < img1.Height; j++)
                    {
                        img1_ref = img1.GetPixel(i, j).ToString();
                        img2_ref = img2.GetPixel(i, j).ToString();
                        if (img1_ref != img2_ref)
                        {
                            count2++;
                            flag = false;
                            break;
                        }
                        count1++;
                    }
                    progressBar1.Value++;
                 }

                if (flag == false)
                    MessageBox.Show("Sorry, Images are not same , " + count2+ " wrong pixels found");
                else
                    MessageBox.Show(" Images are same , " + count1 + " same pixels found  and " + count2 + " wrong pixels found");
            }
            else
                MessageBox.Show("can not compare this images");
            this.Dispose();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            progressBar1.Visible = false;
            pictureBox1.Visible = false;

        }

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900