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 6129065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:41:56+00:00 2026-05-23T16:41:56+00:00

For a couple days now, I’ve been stuck on a task involving image comparison

  • 0

For a couple days now, I’ve been stuck on a task involving image comparison using PHP. I’m beginning to think that PHP isn’t the language to do this sort of task.

The Objective:

Use a base, compare a new line-art to it, and return the percentage difference between them.
I’ve tried a couple ways of going about this: Compare the differences in pixel count (which doesn’t really solve the goal of line-art difference), make all pixels that overlap, white, and find pixels without transparency/the color white and divide by non-transparent pixels in the base (which doesn’t seem to get the correct number)

Here’s an example:

Baseenter image description here

— — — — — — — — Base — — — — — — — — — — — Line-Art — — — — — — —

The percentage difference should be around 54%. However, none of the ways I’ve tried get close (~5%) to this.

My question is: Can/How can this be done in PHP?
Thanks!

Images © Aywas.com

  • 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-23T16:41:57+00:00Added an answer on May 23, 2026 at 4:41 pm

    You might try using the ImageMagick function compareimagechannels(), using only the black channel?

    Edit: Here’s a basic attempt, and its output. You might be able to manipulate the output numbers to figure out your thresholds. Images 1 and 2 are the line art and image 3 is the Google header logo resized to 200×200.

    $img1 = new Imagick('image1.png');
    $img2 = new Imagick('image2.png');
    $img3 = new Imagick('image3.png');
    
    $diff12 = $img1->compareImageChannels($img2,
                 Imagick::CHANNEL_ALL, Imagick::METRIC_MEANABSOLUTEERROR);
    $diff13 = $img1->compareImageChannels($img3,
                 Imagick::CHANNEL_ALL, Imagick::METRIC_MEANABSOLUTEERROR);
    
    print_r($diff12);
    print_r($diff13);
    

    Output:

    Array
    (
        [0] => Imagick Object
            (
            )
    
        [1] => 1512.25385625
    )
    Array
    (
        [0] => Imagick Object
            (
            )
    
        [1] => 24353.6380375
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been stuck on this for a couple of days now, and I'm really
I've been working on a rails app for a couple of days now that
I've been stuck trying to puzzle this out for a couple days now, and
I've been been using knitr for a couple of days now, it's great! :)
I've been using ScalaTest's FeatureSpec for a couple of days now and I'm trying
Been stuck on this one for a couple days now...I have an existing Liferay
I've been using SASS for a couple of days now and encountered a certain
So I've been struggling with this for a couple days now. I have a
I have been searching for an answer for a couple days now and had
I've been struggling with this one for a couple of days now. My current

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.