Sign in to follow this  
Followers 0
Sapient

_ColorDiff

1 post in this topic

#1 ·  Posted (edited)

Hi, there is a built-in function PixelSearch that uses an internal calculation "number of shades of variation of the red, green, and blue components of the colour", however I didn't see any separate function available to calculate such color differences independently.

This is a fairly simple thing to calculate, but since I needed it for my Disable Chrome Incognito script I thought I would include it here in case anyone else finds it useful. My apologies if someone already posted something similar, but I did a quick search and didn't see it.

#include <Math.au3>
; Note: Math.au3 needed for _Max()

Func _ColorDiff($color1, $color2, $min_return = 0)
  If $color1 = $color2 Then
    Return $min_return
  EndIf
  Return _ColorDiff(BitShift($color1,8), BitShift($color2,8), _Max($min_return, Abs(BitAnd($color1, 0xFF) - BitAnd($color2, 0xFF))))
EndFunc

Note: my version returns the max shade difference across R G and B (not the sum of the three differences).

Edited by Sapient

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0