Click here to Skip to main content
15,920,596 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am a newbie asp.net .. I am trying to design a page in which we can upload an image and then compare the uploaded image with all the image in the database and display the images which match the uploaded image... I am not able to do the second part i.e comparing and didplaying related result ..so i need a help on that .. Thanks in advance
Posted
Comments
Dave Kreskowiak 30-Apr-13 11:41am    
How do you want to compare the images? Are we talking an exact byte-for-byte comparison or what?
coder_ski 30-Apr-13 12:48pm    
ya kindof
Dave Kreskowiak 2-May-13 21:59pm    
No, no, no. There is no such thing as "kind of" in code. You either define PRECISELY what you mean by comparing an image or you can forget writing code. Why?? Because if you can't precisely define exactly what you mean by comparing images, how on this Earth are going to tell a computer how to do it??

1 solution

I'm going to make some assumptions

1. You are comparing a single image with a number of images.
2. The comparison is a byte-to-byte comparison of two images.
3. Images are in the same format.

Then

C#
foreach image in database
    {
    images_equal = true
    if ( image.Size != uploaded_image.Size )
        {
        images_equal = false
        }
    else
        {
        foreach byte in the images
            {
            if ( image_byte != uploaded_image_byte )
                {
                images_equal = false
                break
                }
            }
        }
    if ( images_equal )
        {
        do something with equal images
        }
    else
        {
        do something with unequal images
        }
    }


The byte to byte comparison may require System.Runtime.InteropServices.
 
Share this answer
 

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