There are two ways you can include computed values in your template, PHx and config files. Without more details, such as what the input variables for selecting the images are, it's difficult to say what would suit your purpose better.
PHx is in common use, and is well documented in the
Wiki and in
RTFM. Ditto includes its own copy of PHx, so no there's need to install the plugin. See also
http://www.pogwatch.com/ditto/ditto-phx.html
A config file allows you to use computed parameters through a PHP file. Include a Ditto parameter such as
&config=`myTpl`, and Ditto will assign parameter values according to the code in the file
/assets/snippets/ditto/configs/myTpl.config.php. See
http://www.pogwatch.com/ditto/ditto-config.html for more on using config files.
:) KP