JAVA codes for Image Comparison

GULNAZ KMT

GULNAZ KMT

@gulnaz-kmt-fHFb0M Oct 26, 2024
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???😔

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Reya

    Reya

    @reya-SMihdC Dec 20, 2010

    You mean to compare two images whether they are equal?
  • GULNAZ KMT

    GULNAZ KMT

    @gulnaz-kmt-fHFb0M Dec 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..
  • Ankita Katdare

    Ankita Katdare

    @abrakadabra Dec 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?
  • Ankita Katdare

    Ankita Katdare

    @abrakadabra Dec 21, 2010

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

    #-Link-Snipped-#
  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Dec 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);
    }
    }