Page 1 of 1

cat border resize resize/align

Posted: 2014-10-09T08:33:40-07:00
by el_selvaje
Hi,
I have several maps (tif format ) with a slight rotation or scaling differences coming from a scanning operation (see below).
I would like to crop the white borders, resize/align to specific image size.
I checked several forum using the -trim option but seams does not work for my case.
The option of pick control points is too tedious to do for all the 500 maps.

I'm using ImageMagick 6.6.9-7 under Ubuntu 12.04

Any suggestions ?
Best

Image
Image

Re: cat border resize resize/align

Posted: 2014-10-09T09:42:46-07:00
by fmw42
Please fix your images. They do not show up here. Also please always identify your version of IM and platform.

To post images, you need to upload them to some free hosting service such as dropbox.com and put the URLs here.

Re: cat border resize resize/align

Posted: 2014-10-09T21:35:16-07:00
by snibgo
I don't understand exactly what you want.

I have (Windows BAT) scripts for aligning images with each other, by scale/rotate/translate. They may or may not be helpful.

Re: cat border resize resize/align

Posted: 2014-10-09T22:18:15-07:00
by fmw42
If you can remove the text at the top and/or bottom of your images, you can try to use the IM -deskew function. Alternately, after removing the text, you can try my script, unrotate at the link below.

Another possibility is to use -hough-lines, to do straight line detection. Then from the end points reported, you could compute the angle of the lines. Then rotate so as to make line orientations horizontal and vertical.

Re: cat border resize resize/align

Posted: 2014-10-10T13:08:16-07:00
by el_selvaje
Thanks
for the kind replays.
After have been manually cat the text i was able to rotate and cat in automatic the two images with this commands.

Code: Select all

for file in scan*.png  ; do 
    convert  -deskew   40%    $file   rot_$file 
    /tmp/unrotate -a 0   -f 40 -c 1,1  rot_$file crop_$file 
    convert -liquid-rescale  820x820\!  crop_$file  res_$file 
done
Now the images have the same size (820x820), but the are slightly distorted (due to the scanning process), so they do not overlap perfectly.
The results are belows.

So my next step is to find a way to align them in such a way that the can be overlapped.
The best solution would be to take one as a reference image and registered the second one.
I know that this operation can be done with control points but i would avoid this due to high number of images.

Any suggestions?
Best

Image
Image

Re: cat border resize resize/align

Posted: 2014-10-15T09:21:15-07:00
by jaffamuffin
you might need to look at using openCV for this kind of thing. There's loads of tutorials out there for detecting grids/shapes/lines and then to transform them is one line of code