SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Pixel difference between two images?

    I am trying to calculate pixel difference count between two images ? Is there any function that TC provides for doing this?

    I am using TC 6.20

    Thanks
    Manas

  2. #2
    Senior Member
    Join Date
    Mar 2007
    Location
    Waterloo, Ontario, Canada
    Posts
    3,628
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    Not really, that I know of. However, you could use the Regions.compare to do it. Just send youself into a loop starting at a huge threshold (like 10000) and then decrease that number until it begins to fail. You can use some simple heuristics here too and maybe start by cutting it in half, then that in half, and so on until it fails, then do the same the other way until it passes again, then loop back the other way again, and so on until you've arrived at a final failed pixel count.

    Make sense?
    Brent
    --------------------
    9 out of 10 people I prove wrong agree that I'm right. The other person is my wife.
    --------------------

  3. #3
    Senior Member
    Join Date
    Oct 2003
    Posts
    928
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    Hi Manas,

    You can use the following code to count the actual number of differing pixels:

    <font class="small">Code:</font><hr /><pre>
    ' VBScript

    Function GetTolerance(Picture1, Picture2)
    Dim WidthDim, HeightDim, DifPicture, ToleranceValue

    ToleranceValue = 0
    Set DifPicture = Picture1.Difference(Picture2, False, 0, True)
    For WidthDim = 0 To DifPicture.Size.Width - 1
    For HeightDim = 0 To DifPicture.Size.Height - 1
    If DifPicture.Pixels(WidthDim, HeightDim) = vbRed Then
    ToleranceValue = ToleranceValue + 1
    End If
    Next
    Next
    GetTolerance = ToleranceValue
    End Function
    </pre><hr />

    I hope this helps.
    Regards,
    Alex - SmartBear Support

  4. #4
    Moderator
    Join Date
    Sep 2005
    Location
    Dublin, Ireland
    Posts
    1,878
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    To add to Alex's comments, and given your recent posts about DirectX, you may want to consider a slightly fuzzier image matching technique. Myself and Brent had a discussion about this a while back here. If you are comparing a lot of frames, a pixel by pixel comparison in VBscript will also be very slow. In your place, I'd tend to write this as an external routine in C or C++. VBScript and DirectX don't really have similar notions of 'speed' [img]/images/graemlins/wink.gif[/img]

  5. #5
    Member
    Join Date
    Jan 2008
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    Hi Alex, If you can please translate above VB script to Jscript it will be useful for me.

    How fast will be the single comparison of two 1200x1068 sized image? Ca you give any time estimate on this?
    (I will be doing lot of image comparison like this)

    Thanks.

  6. #6
    Senior Member
    Join Date
    Aug 2001
    Posts
    529
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    <font class="small">Code:</font><hr /><pre>
    //JScript
    Function GetTolerance(Picture1, Picture2)
    {
    var WidthDim, HeightDim, DifPicture, ToleranceValue;
    ToleranceValue = 0
    DifPicture = Picture1.Difference(Picture2, False, 0, True);
    for (WidthDim = 0; WidthDim&lt;DifPicture.Size.Width; WidthDim++)
    for (HeightDim = 0;HeightDim &lt; DifPicture.Size.Height; HeightDim++)
    If (DifPicture.Pixels(WidthDim, HeightDim) == vbRed)
    ToleranceValue = ToleranceValue + 1
    return ToleranceValue
    }
    </pre><hr />

    The only thing I not sure of is the vbRed.
    Eric Holton
    Microsoft Corp.

  7. #7
    Member
    Join Date
    Jan 2008
    Location
    Logan, Utah
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    Eric,

    We've analyzed this code sample and think it shows promise. I did have concerns regarding speed. How fast would you expect this to run on a 800x600 image on your average dual core system? &lt; 1 min? A few moments?

    Our latest camera is 11 megapixels, and I am considering instead validating on an array of pixels instead of every pixel, say a 10x10 pixel array spread out across each image. Any thoughts on this? For what we are doing it should be unlikely that all 100 pixels will ever be different between any two frames. Any thoughts?

    For jscript vbRed will not be available however Builtin.clRed should work just fine. We can always use an rgb converter or hex if we needed to do anything different.
    Russell Leikis
    Software QA Engineer - Automation Lead
    Ophir-Spiricon, Inc.

  8. #8
    Member
    Join Date
    Jan 2008
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    We tested above code and found that it is too slow for the practical use as it compares pixel by pixel. It took us around 7 mins to compare two images of size 1024x768.

    If anyone knows better solution for pixel comparison please post it here.

    Thanks
    Manas.

  9. #9
    Senior Member
    Join Date
    Aug 2001
    Posts
    529
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    One thing you could try is a .NET class library and load it using the CLR Bridge and call it. (Or write a TC plug-in)
    Eric Holton
    Microsoft Corp.

  10. #10
    Member
    Join Date
    Jan 2008
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Pixel difference between two images?

    Eric,

    Can you please elaborate on it?

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 8.82%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:31 AM.

Copyright BetaSoft Inc.