Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:22:37+00:00 2026-05-31T05:22:37+00:00

im writing a program to compare two images against each other based on color

  • 0

im writing a program to compare two images against each other based on color and im using the Euclidean distance algorithm however when i run it and pass in two images i get one distance and then when i pass in the same images but the other way round i get a completely different set of results.

is this normal or should the answers be the same?

The statement I’m using to compute the Euclidean distance is:

distance = (int) Math.sqrt(   (rgb1.getR()-rgb2.getR())^2
                            + (rgb1.getG()-rgb2.getG())^2
                            + (rgb1.getB()-rgb2.getB())^2
                          );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:22:38+00:00Added an answer on May 31, 2026 at 5:22 am

    Looking at the code you posted, it looks your RGB values are ints. However, the ^ operator is not the power operator, but XOR (exclusive-OR) – a bitwise operation. So in order to calculate the squares correctly, use regular multiplication – e.g., use a temporary variable int deltaR = rgb1.getR()-rgb2.getR(); and then in the formula write deltaR*deltaR instead of the ^ operator. Your RGB values will probably be in 0 to 255 range, so there shouldn’t be overflow issues. Alternatively, you could use Math.pow(rgb1.getR()-rgb2.getR(),2) etc. in the formula.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program which has two panes (via CSplitter ), however I
I'm currently writing a program that needs to compare each file in an ArrayList
I'm writing an encoding/decoding .COM program using Huffman algorithm for dos 8086 (16-bit tasm
I'm writing a program (for Mac OS X, using Objective-C) and I need to
I'm writing a program that contains a generational garbage collector. There are just two
I am writing program witch runs msi installations silent on background. Using MsiSetExternalUI and
I'm currently writing a simple app to compare two lists and return differences if
Recently, I started writing a program to compare DNA sequence. As the alphabet only
As part of the program that I am writing I need it to: Compare
I am writing a C program to count the lines in files using system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.