CrazyEngineers
  • JAVA codes for Image Comparison

    GULNAZ KMT

    Member

    Updated: Oct 26, 2024
    Views: 1.3K
    Hi.. Am looking for appropriate java codes for Comparing images.. I searched thru net but no apt codes related 2 it.. Anybody 2 help me out thre???😔
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Reya

    MemberDec 20, 2010

    You mean to compare two images whether they are equal?
    Are you sure? This action cannot be undone.
    Cancel
  • GULNAZ KMT

    MemberDec 20, 2010

    Yup.. Irrespective of size of the image, I need to write a JAVA code, where it'l compare the image given as an input with another image already contained in my database and return true if comparison matches. For Eg., if I give an image of computer, my code should be able to compare with images of computer in my database and return the o/p.. Database codin part, leave it upto me. I just need help in, how Java compares two images..
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorDec 21, 2010

    Hi Gulnaz,

    I searched for your query on the net and found this result:

    <a href="https://mindmeat.blogspot.com/2008/07/java-image-comparison.html" target="_blank" rel="noopener noreferrer">Mind Meat: Java Image Comparison / Motion Detection</a>

    Does that help?
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorDec 21, 2010

    Here is some information about processing pixels in an image using Java :

    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • Morningdot Hablu

    MemberDec 27, 2010

    Sorry for late reply actually i am busy in exams.
    Well i have an idea how to compare two images check this code.
    Use it to compare two images hope it works.But it's just an idea you can edit it on your own way.
    import javax.swing.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    /*<Applet code="comp" height=400 width=400></applet>*/
    public class comp extends JApplet implements ActionListener
    {
    Button b;
    String str,str1;
    public void init()
    {
    b=new Button("submit");
    add(b);
    setLayout(new FlowLayout());
    b.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
    repaint();
    byte b1[]=new byte[60000];
    byte b2[]=new byte[60000];
    try
    {
    int i=0;
    FileInputStream f1=new FileInputStream("kk.jpg");
    f1.read(b1);
    FileInputStream f2=new FileInputStream("kk1.jpg");
    f2.read(b2);
    while(b1!=3 || b2!=3)
    {
    if(b1==b2)
    i++;
    else
    {
    str="not matched";
    break;
    }
    }
    if(b1[i-1]==b2[i-1])
    {
    str="matched";
    str1=Integer.toString(i);
    }
    }
    catch(Exception ee)
    {
    System.out.println("Exception caught");
    }
    }
    public void paint(Graphics g)
    {
    g.drawString(str,100,100);
    g.drawString(str1,200,200);
    }
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register