Page 1 of 2

create panorama from cropped stripes by appending img series

Posted: 2013-12-12T05:14:32-07:00
by Frank1000
Hi,
how would a command line in Win look to achieve appending a series of cropped images into a final image ?
My images have sequencial numbering (image.0001.png, image.0002.png, ...) which i got from rendering an animation where the camera rotates around the y-axis. By assembling vertical strips of only a few pixels width to a whole image, i receive a panorama image.

I've seen http://www.imagemagick.org/Usage/layers/ but wasn't able to pull together the necessary syntax for my case yet (newbie), so that i can say i have 180 images that need to be cropped and appended.

Regards,
Frank

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T11:07:53-07:00
by fmw42
Do your images overlap? Do they offset in the vertical dimension?

If you just need to append them side by side with no offsets, then see +append

http://www.imagemagick.org/Usage/layers/#append

If they overlap or offset, then see -mosaic, but you need to know exactly how to offset them as X,Y offsets for -page arguments

http://www.imagemagick.org/Usage/layers/#mosaic

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T11:43:55-07:00
by Frank1000
Hi,
thank you for reply. I wanted to put the formula with the following functionality, is it possible as 1 command that loops through 180 pictures and creates the final file ? Pls help with the necessary syntax.

convert ^
-frame 1-180 <<looping image.0001.png - image.0180.png>> ^
-crop image..png ( -crop 958,x961+3+1080 'Foreground_%[filename:names].png' \) <<cropping out a stripe of x 3 pix and y 1080 pix>> ^
-append <<appending them from left to right without overlap>> ^
result_image.png <<being 180 * 3 pix = x 540 pix, and y = 1080 pix>>


can i insert commenting in my code, so i understand it later on when adjusting to other tasks ?

Frank

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T12:01:42-07:00
by fmw42
Frank1000 wrote:Hi,
thank you for reply. I wanted to put the formula with the following functionality, is it possible as 1 command that loops through 180 pictures and creates the final file ? Pls help with the necessary syntax.

convert ^
-frame 1-180 <<looping image.0001.png - image.0180.png>> ^
-crop image..png ( -crop 958,x961+3+1080 'Foreground_%[filename:names].png' \) <<cropping out a stripe of x 3 pix and y 1080 pix>> ^
-append <<appending them from left to right without overlap>> ^
result_image.png <<being 180 * 3 pix = x 540 pix, and y = 1080 pix>>


can i insert commenting in my code, so i understand it later on when adjusting to other tasks ?

Frank
You will have to write a script to do the looping.

I am not a windows user, and since scripting syntax is different, you will have to wait for a Windows user to try to help make this into a bat file for you or at least a set of commands that loops that you can cut and paste.


You cannot add a comment within a single IM convert command, but can put comments in the script between convert commands.
see
viewtopic.php?f=1&t=24624

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T12:12:32-07:00
by Frank1000
ok thx, ya someone who can help me with the Windows syntax.

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T12:38:27-07:00
by snibgo
Doing this in a single convert will read all the images into memory. If each is 2000x1000 pixels, at 6 bytes/pixel, 180 images, you need 2 GB memory. So I would do this in stages.

1. Within a FOR loop, convert each image, cropping to 3 pixels wide.

2. Convert these 180 files, each 3 pixels wide, with "+append".

Note that "-crop" takes 4 parameters: {width}x{height}+{x_offset}+{y_offset}. So it might be "-crop 3x1080+958+0".

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T12:42:54-07:00
by Frank1000
ok thx.
how is the syntax to make a FOR loop in a .bat ?

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T12:54:32-07:00
by Frank1000
my images go from image.0001.png to image.0180.png.
is this going in the right direction to write it in a .bat file ?:


SET startframe=%0001
SET endframe=%0180
SET times=%180

convert ^
FOR image.%startframe%.png
-crop 3x1080+958+0

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:00:04-07:00
by snibgo
FOR is a Windows command, not ImageMagick. Type "help for" at the command line.

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:13:28-07:00
by Frank1000
that is too complicated for me, does someone know how the correct syntax would be ?

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:15:04-07:00
by snibgo
Something like this:

Code: Select all

set startframe=1
set endframe=180

del sub_*.png

for /L %%i in (%startframe%,1,%endframe%) do (
  set NUM=000%%i
  set NUM=!NUM:~-4!

  convert image.!NUM!.png -crop 3x1080+958+0 +repage sub_!NUM!.png
)

convert sub_*.png +append out.png

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:24:04-07:00
by Frank1000
ok thx :-)
Tried it out, but giving me :

Invalid Parameter - -crop


My image name has two dots before the number and I've inserted it this way : maybe that is the reason ?


set startframe=1
set endframe=180

del sub_*.png

for /L %%i in (%startframe%,1,%endframe%) do (
set NUM=000%%i
set NUM=!NUM:~-4!

convert my_image..!NUM!.png -crop 3x1080+958+0 +repage sub_!NUM!.png
)

convert sub_*.png +append out.png

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:29:50-07:00
by snibgo
Invalid Parameter - -crop
That error message is from the Windows "convert" command.

Okay. First step: have you installed ImageMagic? Is it on your path?

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:38:11-07:00
by Frank1000
ok sure, I forgot to point to the command right. Now I get the command running but it wouldn't yet read the images "Ritter_01_02..0001.pnd ...)

Image

I have copied the .bat into the directory where the image files sit. and calling it from there.

Re: create panorama from cropped stripes by appending img se

Posted: 2013-12-12T13:52:10-07:00
by snibgo
Insert the following line at the start of your command file:

Code: Select all

setlocal enabledelayedexpansion