Page 1 of 1
Merge Tiles Vertically, positioning issue
Posted: 2017-01-26T21:54:52-07:00
by matewfeel
Hello guys, i'm trying to merge together a lot of satellite img tiles into one.
At first i tried ''montage -mode concatenate'' but then realised they have been previously exported in a vertical manner,
so after looking around a bit i found a way to create vertical columns and then align them horizontally with another command.
The results seems a bit weird though.
By doing first this :''
''montage -mode concatenate -tile 1x(numb of images in a col) Tile_*.jpg cols.jpg''
i managed to get the exact number of images to fit in a column, then:
'' montage -mode concatenate -tile16x1 cols*.jpg merged.jpg ''
to obtain the final merged picture.
The issue is at STEP ONE when creating the cols there are few images not matching the vertical alignment (!?)
subsequently when i merge everything together those ones don't match up....
I also checked filenames and they are all correct!
find attached 'column' export example and 'merged' example.
https://drive.google.com/open?id=0BydA_ ... XJBU1ZsR0U - column example
https://drive.google.com/open?id=0BydA_ ... Dk5XzJHRms - merged result
I would be very grateful if anyone could help me sorting this out
Thanks
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-26T22:04:47-07:00
by snibgo
matewfeel wrote:The issue is at STEP ONE when creating the cols there are few images not matching the vertical alignment (!?)
This isn't much to go on. I can't see a problem in your images, but I don't know what I'm looking for. How far is the misalignment?
Are all your inputs the same size? What is different about the ones that don't align? Can you isolate the problem to a single pair of images?
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-26T22:42:17-07:00
by fmw42
I do not see any horizontal offsets. But, I do see color changes or possibly tiles out of order. If the latter, are all your tile jpg images numbered and if so do you use leading zeros. If not leading zeros, most OS systems will list them alphabetically, not numerically, so that you have image-10 next to image-1.
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-27T08:00:14-07:00
by matewfeel
The tiles are named respectively 'Tile_0x0' 'Tile_0x1' 'Tile_0x2' 'Tile_0x3' to 'Tile_10x0' 'Tile_10x1' 'Tile_10x2' and so on....
i believe the problem here is as FMW42 mentions. no offsets but tiles are out of order. how would i do to make it list numerically correct ?
shall i add a '0'+its respective number in front of each eg '01Tile_0x1' ?
Thank you
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-27T10:11:11-07:00
by fmw42
You could do that but you need to be sure that you number them in the order you need them. The problem is that XxY numbers are probably not sequential alphabetically. If you have many tiles, it may be tedious doing it manually. You might want to consider writing a script loop over you XxY indices to add the leading sequential number with leading zeros.
You would be better off making the filenames in sequential order in your script/program with leading zeros.
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-27T14:57:52-07:00
by GeeMack
matewfeel wrote: ↑2017-01-27T08:00:14-07:00i believe the problem here is as FMW42 mentions. no offsets but tiles are out of order. how would i do to make it list numerically correct ?
Even if you get the starting images in the correct order for the first command and save them as "cols.jpg", they will be output according to ImageMagick's default numbering scheme. A directory listing of those files may look something like this...
Code: Select all
01/27/2017 03:42 PM 7,052 cols-0.jpg
01/27/2017 03:42 PM 7,052 cols-1.jpg
01/27/2017 03:42 PM 7,052 cols-10.jpg
01/27/2017 03:42 PM 7,052 cols-11.jpg
01/27/2017 03:42 PM 7,052 cols-12.jpg
01/27/2017 03:42 PM 7,052 cols-13.jpg
01/27/2017 03:42 PM 7,052 cols-14.jpg
01/27/2017 03:42 PM 7,052 cols-15.jpg
01/27/2017 03:42 PM 7,052 cols-16.jpg
01/27/2017 03:42 PM 7,052 cols-17.jpg
01/27/2017 03:42 PM 7,052 cols-18.jpg
01/27/2017 03:42 PM 7,052 cols-19.jpg
01/27/2017 03:42 PM 7,052 cols-2.jpg
01/27/2017 03:42 PM 7,052 cols-20.jpg
01/27/2017 03:42 PM 7,052 cols-3.jpg
01/27/2017 03:42 PM 7,052 cols-4.jpg
...
In your first command, the one that creates the "cols*.jpg" files, specify your output with a string format. ImageMagick can do that like this...
Code: Select all
montage ... ... Tile_*.jpg cols%03d.jpg
Using that "cols
%03d.jpg" as the output file name, IM will number them to three places using leading zeros. The result will be files named like this...
Code: Select all
01/27/2017 03:52 PM 7,052 cols000.jpg
01/27/2017 03:52 PM 7,052 cols001.jpg
01/27/2017 03:52 PM 7,052 cols002.jpg
...
Then in your second command, IM will read those into the command in the proper order (assuming they were read correctly into the first command).
Also, unless space is an issue, you might consider saving your intermediate files in a format other than JPG. Using a lossless format like PNG would give you better results, especially for things like those very detailed map quadrants.
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-27T16:12:56-07:00
by GeeMack
matewfeel wrote: ↑2017-01-27T08:00:14-07:00
The tiles are named respectively 'Tile_0x0' 'Tile_0x1' 'Tile_0x2' 'Tile_0x3' to 'Tile_10x0' 'Tile_10x1' 'Tile_10x2' and so on....
You can change the filenames so they are listed in the order you want. For a one-off or if used infrequently, you can do a directory listing of your filenames redirected to a text file, edit the text file so it has those names in the proper order, and use that text file as your list of inputs for "montage". Say for example your text file is named "myfiles.txt", prefix the filename with an "@" to make it happen.
Re: Merge Tiles Vertically, positioning issue
Posted: 2017-01-27T16:15:56-07:00
by fmw42
Note if using @, you may have to modify your policy.xml to allow the use of @.