Re: Re: Graphic assertions?
Phlip <[email protected]> Mon, 4 Sep 2006 10:46:16 -0700
| Newsgroups | gmane.comp.programming.test-driven-development,gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <[email protected]> |
Ilja Preuss wrote:
> We once had an assert implemented in Java that could find out whether
> two images were similar to each other. If I remember, the algorithm was
> something along the lines of
>
> - apply a light blur algorithm on both images
> - scale the images down to half the size of the smaller image
> - pixel by pixel, calculate the color-distance between the two pixels
> - build the sum of those distances
> - by manual experimenting find a good threshold for the sum and assert
> against that
Note you can use ImageMagick or GraphicsMagick to do nearly all of
that, from a batch file.
(That's also how I polish ZeekLand, but I'm not sure what the
difference between the two Magicks is!)
> Using that algorithm, we could render a complex vector image in
> different resolutions and write a test that would fail when a line was
> drawn solid instead of dotted, but tolerate slight differences in the
> size of text labels.
However, note that Ilja starts with a "vector image". That implies a
list of high-level commands (such as SVG or PS) that generate the
low-level pixels. Tests should also attack this vector format
directly. In the degenerate case, Ilja's tests could generate vector
commands, render them to graphic images, fuzz them with ImageMagick,
and then compare what's essentially the vector commands again.
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/testdrivendevelopment/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/