Page 1 of 1

create offset variants of original image

Posted: 2013-03-08T17:36:07-07:00
by galv
I want to create several variations of a given image that have an offset in x or y. The resulting image's size should be 42x54 (this is the original's size also).
The variations should happen within the range in deviation given if possible. The background should be black.
How can this be done?

Re: create offset variants of original image

Posted: 2013-03-08T17:53:43-07:00
by fmw42
Please explain further and if possible show an example.

Your image can be shifted in x and/or y using -roll, but it will wrap around. So you would need to roll it, chop off the wrapped part and then add a black region to fill in the wrapped part using either -splice or -extent

convert image -roll ... -chop ... -splice ... result

Is that what you are after?

see
http://www.imagemagick.org/script/comma ... s.php#roll
http://www.imagemagick.org/Usage/crop/#shave
http://www.imagemagick.org/Usage/crop/#splice
http://www.imagemagick.org/Usage/crop/#extent


An alternate is to use -crop and then composite it onto a black background at the offsets you need using -geometery.


Another alternate is to use -distort SRT with a viewport crop. See
http://www.imagemagick.org/Usage/distor ... t_viewport
http://www.imagemagick.org/Usage/distorts/#srt

Re: create offset variants of original image

Posted: 2013-03-08T18:38:01-07:00
by galv
Example: http://ge.tt/58Q1SWa/v/0?c

first one is the original, rest are deviations.

Re: create offset variants of original image

Posted: 2013-03-08T19:30:54-07:00
by fmw42
Any of the methods I mentioned above will work to do that. If you have enough black border around the image, then all you need do is -roll.

So another method would be to pad sufficiently (at least as much as the amount you want to shift), then roll, then crop

convert image -bordercolor black -border ... -roll ... -gravity center -crop WxH+0+0 +repage result

where W and H are the input image sizes and the border is the larger amount you roll from X and Y