GD::SIRDS - Create a GD image of a Single Image Random Dot Stereogram
use GD; use GD::SIRDS; my ($src, $dst, @colors); $src = GD->new("some.png"); @colors = ( [ 0, 0, 0], # basic black [204,204,204], # a nice grey [ 0, 51,102], # a good dark blue-green [ 0,102,153], # another good blue-green ); $dst = gd_sirds($src, \@colors); binmode STDOUT; print $dst->png;
GD::SIRDS exports a single subroutine,
gd_sirds, that produces a Single Image Random Dot Stereogram (SIRDS).
- gd_sirds MAP,COLORS
- gd_sirds MAP,COLORS,CIRCLES
- gd_sirds MAP,COLORS,CIRCLES,EYESEP
- gd_sirds MAP,COLORS,CIRCLES,EYESEP,FIELDDEPTH
Create a Single Image Random Dot Stereogram based on the given depth MAP, with random dot colors selected from COLORS.
The depth map can be either an instance of GD::Image or a reference to a two-dimensional array of numbers between 0 and 1, inclusive. Lighter colors (for
GD::Images) and higher numbers (for arrays) stick out more from the background.
COLORS is a reference to an array of RGB triples, each triple represented as an array of three integers between 0 and 255, as in GD(3).
Set CIRCLES to true to put two circles at the bottom of the image representing the amount ones eyes need to diverge. (Aligning the circles so that the two become three should produce the proper divergence to see the stereogram.)
EYESEP is the separation, in pixels, of the viewer's eyes. For a computer monitor, the default of 200 seems to work well.
FIELDDEPTH is a bit trickier. Assume that the three-dimensional object displayed has an apparent distance from the viewer equal to twice the distance from the viewer to the screen. That is, the bottom of the object is as far behind the screen as the viewer is in front of the screen. In that case, the top of the three-dimensional object is FIELDDEPTH (default 1/3) of the way up back to the screen.
In some cases, GD seems to posterize (reduce the color depth) of images when it reads them. I don't yet know when this happens. When it does happen, a marked stair-step effect will occur in the generated stereogram.
David "Cogent" Hand, <firstname.lastname@example.org>.
Copyright (c) 2002. All rights reserved. This module is free software; you may restribute and/or modify it under the same terms as Perl itself.
Thimbleby, H.W., Inglis, S., and Witten, I.H. "Displaying 3D images: algorithms for single-image random-dot stereograms" IEEE Computer, 27 (10) 38-48, October 1994.
N.E. Thing Enterprises, Magic Eye Gallery. Andrews McMeel Publishing, 1995.