pages tagged image-processingENETDOWNhttp://enetdown.org//tag/image-processing/ENETDOWNikiwiki2016-06-13T07:17:08ZReleasing Data::TestImagehttp://enetdown.org//dot-plan/posts/2014/05/26/data-testimage/zaki2016-06-13T07:17:08Z2014-05-26T09:19:26Z
<p>I've recently been working on putting together modules for image processing in
Perl. One thing that keeps coming up when I write code that I want others to
run is that they don't have the same images on their system as I do. So I put
together a module that wraps up access to some standard test images from the
<a href="http://sipi.usc.edu/database/">USC SIPI image database</a>. So now, instead of
telling people to go download the right set of images, all they have to do is
install <a href="http://p3rl.org/Data::TestImage">Data::TestImage</a> from CPAN and it
will in turn download and extract the image database to a shared location. Then
you can just run</p>
<div class="highlight-perl"><pre class="hl"><span class="hl kwa">use</span> Data<span class="hl opt">::</span>TestImage<span class="hl opt">;</span>
<span class="hl kwc">my</span> <span class="hl kwb">$image</span> <span class="hl opt">=</span> Data<span class="hl opt">::</span>TestImage<span class="hl opt">-></span><span class="hl kwd">get_image</span><span class="hl opt">(</span><span class="hl str">'mandrill'</span><span class="hl opt">);</span>
</pre></div>
<p>and <code>$image</code> will contain the path to a TIFF file with the mandrill test image. Simple!</p>
<p><a href="http://enetdown.org//dot-plan/posts/2014/05/26/gfx/mandrill.png"><img src="http://enetdown.org//dot-plan/posts/2014/05/26/data-testimage/200x-mandrill.png" width="200" height="200" alt="Standard test image of mandrill" class="img" /></a></p>
<p>I put in a couple of nice tweaks in the install process too: it doesn't install
all 130 MB of the USC SIPI database by default, but you can set an environment
variable and it will install only the portions you ask for.</p>
<p>I got some inspiration from the <a href="http://www.mathworks.com/matlabcentral/answers/54439-list-of-builtin-demo-images">MATLAB Image Toolbox's built-in
images</a>
and the <a href="https://github.com/timholy/TestImages.jl">TestImages.jl</a> Julia
package. But mine is more extensible!</p>