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?
create offset variants of original image
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: create offset variants of original image
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: create offset variants of original image
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
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