Python Forum
Image comparison, a more pythonic method
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image comparison, a more pythonic method
#3
(Jun-07-2018, 01:55 AM)scidam Wrote: You can use numpy to do such comparison, e.g.

import numpy as np 
img_a_array = np.array(img_a_pixels)
img_b_array = np.array(img_b_pixels)
difference = (img_a_array == img_b_array).sum()
Also, you can use the threshold to specify colors similarity, e.g.

threshold = 2
difference_with_threshold = (np.abs(img_a_array - img_b_array) <= threshold).sum()

Cool, I will do some speed comparisons with the numpy code that you provided. Thank you.
I use the threshold and comparison counter method for determining how much of an image is black or white.
Reply


Messages In This Thread
RE: Image comparison, a more pythonic method - by Grok_It - Jun-07-2018, 02:31 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020