Rejoin tiles that overlap...

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Rejoin tiles that overlap...

Post by afre »

Been using ImageMagick for some time. A steep learning curve but rewarding I suppose. My computer isn't very powerful, so I cut my images before I process them. I am wondering if there is a simple way to rejoin tiles that overlap. E.g., to undo:

Code: Select all

-crop 2x2+0+2@ +repage +adjoin
I end up having to crop the edges before using montage to reconstitute the image, which isn't very straightforward. It would also be nice if I could blend or even interpolate the overlapping pixels, but that would be asking for too much. :lol:

~afre
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rejoin tiles that overlap...

Post by fmw42 »

If you crop without the +repage so the virtual canvas geometry is kept, then you can just flatten or possibly mosaic all the tiles to get back your image.

convert lena.png -crop 2x2+0+2@ lena_%d.png
convert lena_0.png lena_1.png lena_2.png lena_3.png -background black -flatten lena_recovered.png
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Rejoin tiles that overlap...

Post by afre »

I will give it a try. Thanks.
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rejoin tiles that overlap...

Post by fmw42 »

If all your files are in one folder and no others that are named as lena_xxx.png, then you can do

convert lena_*.png -background black -flatten lena_recovered.png

Note, this does not work with jpg, since jpg does not keep any virtual canvas information.
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Rejoin tiles that overlap...

Post by afre »

BTW, I am not using IM to process the tiles, so the virtual canvas isn't preserved. I am not successful in reapplying this info though. :?

Code: Select all

$ identify -set page 4280x2854+2140+1426 L1077429_3d.png
L1077429_3d.png PNG 2140x1428 4280x2854+2140+1426 8-bit DirectClass 2.439MB 0.000u 0:00.000
$ identify -format %g L1077429_3d.png
2140x1428+0+0
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rejoin tiles that overlap...

Post by fmw42 »

I am afraid you are out of luck if the virtual canvas data is missing, unless you know exactly how to put them back together using -page xxx image1 -page ... image2 -flatten.

see
http://www.imagemagick.org/Usage/layers/#flatten

In identify -verbose yourimage, what do you see from Page Geometry. If the value always has +0+0, then you have no virtual canvas data preserved.
afre
Posts: 57
Joined: 2014-01-22T15:02:53-07:00
Authentication code: 6789

Re: Rejoin tiles that overlap...

Post by afre »

-page xxx image1 -page ... image2 -flatten
Thanks for the tip. I got it working by redirecting the geometry.

~afre
ImageMagick 7.0.7-25 Q16 x64 2018-03-04 · Cipher DPC HDRI Modules OpenMP · Windows 7
Post Reply