Jump to content

Search the Community

Showing results for tags 'data compare'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hey guys, saw a couple posts in the help section recently asking for a way to compare images, to get how different the two actually are. So I wrote a function that directly compares sets of data and gets how different one character is from the next. In other words this function won't tell you the percentage of data that changed what is does do is tell you is how different the two sets of data are from each other. You may ask what's the difference? Well put quite simply if you have a string 001 and 021, the percentage of change is 33% however the difference between the two is 3.7%, Simmilarly with the sets of data 001 and 051, the percentage of change is still 33%, however the difference is now 15%. We're not checking to see what has changed, but rather, how much it has changed from it's original value. While this was primarily deigned to compare the difference between two colors, you could get the relative difference between any two sets of data. This can also be used to see how random an output is. I'm sure other's will think of interesting uses too! The example below creates two random 1000x1000 pixel images and compares them. You'll notice the output is always around 34%, this means that the random() function is only about 34% random! Example: Global $pixelseed = StringSplit('0123456789abcdef', ""), $image1, $image2 for $i=1 to 2000 ;let's make a 1000x1000 pixels image $image1 &= $pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)] $image2 &= $pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)]&$pixelseed[Random(1, $pixelseed[0], 1)] Next $timer = TimerInit() $compare = _datacompare($image1, $image2) ConsoleWrite($compare&'% Different'&@CRLF&'Took '&(TimerDiff($timer)/1000)&' seconds.'&@CRLF) Functions: #cs Function _datacompare($data1, $data2, [$declimal]) -$data1: A string of data, any length. -$data2: A string of data, must be the same length as $data1 -$decimal: 1=Binary 9=Base-10, 15=Base-16, 31=Base-32 Note: If you just want to compare two sets of binary data you probably want to use base-16. Unless you are sure your binary is in 1's and 0's. Returns: A float containing the percentage of difference. #ce func _datacompare($data1, $data2, $decimal=15) Local $difference $data1 = StringSplit($data1, "") $data2 = StringSplit($data2, "") $difference = 0 for $i=1 to $data1[0] if $data1[$i] <> $data2[$i] Then $difference += Abs(_tonum($data1[$i]) - _tonum($data2[$i])) EndIf Next $difference = (($difference/$data1[0])/$decimal)*100 Return $difference EndFunc #cs Function _tonum() -$info: A single digit or carachter. Returns: A 0-based value. #ce func _tonum($info) if $info+0 > 0 Then Return $info $info = StringLower($info) $return = asc($info)-87 switch $return Case -39 Return 0 Case Else Return $return EndSwitch EndFunc Comments, questions, criticisms, improvements? Post them! This is pretty slow right now, about 60 seconds on a 1000x1000 image. I would really like to get it working faster for more practice uses. And help is much appreciated!
×
×
  • Create New...