It is currently Thu Apr 25, 2024 7:01 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 16 posts ] 
Author Message
 Post subject: Manually Perspective transform images
PostPosted: Sat Jun 13, 2015 4:42 am  (#1) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
There are times the image registration doesn't do what you want, the perspective transformation doesn't allow you to see through the target image. I decided to write my own script to help. I know I should have bring the tripod, get a wind shield, but I am only an ordinary photographer with a fixed lens, weighted 269g, camera. How this work?
1. create a 4 points path for the target image
Attachment:
target.jpg
target.jpg [ 234.63 KiB | Viewed 8787 times ]

2. create a 4 points path for the active image which match the same reference points in the target image
Attachment:
active.jpg
active.jpg [ 244.68 KiB | Viewed 8787 times ]

3. run the script under filters/distorts/Align to path
Attachment:
script.jpg
script.jpg [ 228.88 KiB | Viewed 8787 times ]

This is an ad hoc version and not much error checks, let me know if you have problems.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Manually align images
PostPosted: Sat Jun 13, 2015 4:47 am  (#2) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
Due to 3 files limit, the script and sample file posted here.
installation: place the .py file into your user/.gimp/plugins directory
test: run animation play


Attachments:
File comment: script and sample file
ob_align.zip [1.52 MiB]
Downloaded 514 times
Top
 Post subject: Re: Manually align images
PostPosted: Sat Jun 13, 2015 10:51 am  (#3) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
okyl168, I'm unsure of your goal; the Align to Path plug-in seems to shift a limited set of pixels rather than matching all available pixels (within a clip or crop area)?

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Manually align images
PostPosted: Sat Jun 13, 2015 12:54 pm  (#4) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
Odinbc wrote:
okyl168, I'm unsure of your goal; the Align to Path plug-in seems to shift a limited set of pixels rather than matching all available pixels (within a clip or crop area)?

No it doesn't, it only uses the first 4 points on each path to create an affine transformation matrix and apply to the whole image. It is similar to tools/image registration except only work on 4 points. There are occasion that you want to fix certain objects in the animation but applying image registration won't guarantee such fixing.


Top
 Post subject: Re: Manually align images
PostPosted: Sat Jun 13, 2015 1:13 pm  (#5) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
You can also do things like setting 2 paths, one for the object and one for the desired shape and apply the script. Example on Issa's monasteries.
Attachment:
trans.jpg
trans.jpg [ 353.49 KiB | Viewed 8672 times ]


Top
 Post subject: Re: Manually align images
PostPosted: Sat Jun 13, 2015 2:44 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 866
okyl168,

Please excuse my butting in on this thread, but could you explain what you have done on Issabellas monastery picture (above).
I tried to achieve the same result by a different method and failed miserably!

david.


Top
 Post subject: Re: Manually align images
PostPosted: Sat Jun 13, 2015 4:38 pm  (#7) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
okyl168 wrote:
No it doesn't, it only uses the first 4 points on each path to create an affine transformation matrix and apply to the whole image. It is similar to tools/image registration except only work on 4 points. There are occasion that you want to fix certain objects in the animation but applying image registration won't guarantee such fixing.
Thank you for the reply and script. I'm familiar with a pixel matrix from GNU Octave and affine transformation. So it makes sense now, I'll give it another go later.

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Manually align images
PostPosted: Sun Jun 14, 2015 2:13 pm  (#8) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
david wrote:
okyl168,

Please excuse my butting in on this thread, but could you explain what you have done on Issabellas monastery picture (above).
I tried to achieve the same result by a different method and failed miserably!

david.

1. create the target path (click on 4 corners of the rectangle), see the red lines in the image and name it ref
2. create the active path (click on 4 corners of the monasteries), see the blue lines in the image
3. run the align to path script, select the active path on top, select the ref path for next, then click ok
4. The changes will apply on the selected layer, you can run fit canvas to layer to show the new image.


Top
 Post subject: Re: Manually align images
PostPosted: Sun Jun 14, 2015 4:25 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
@Okyl168
This is a very clever plug-in, Oberon ..I think it could be very useful. It certainly reduces the amount of guess-work compared with using Gimp's standard Perspective Tool ..at least for situations where you know the shape that you want to transform part of the image to.

Just some minor points of nomenclature:
- in Gimp the term "align" just means moving an item left/right and/or up/down to align with something else ..what your plug-in is doing is perspective transform and I think it should be named and described as such ..perhaps you could call it something like "python_fu_ob_perspective_transform" with blurb "Perspective transform from path to path";
- the terms "active", "target" and "reference" for the paths can be a little confusing ..the term "target" is often used to refer to the image/layer to be worked upon (rather than the result) and "active" could mean either ..it may be better to use simple terms like "From path" and "To path" or "Initial shape path" and "Final shape path".

@David + Odin
Just to clarify what Okyl said above:
- the "active" path describes an area in the input layer;
- the "reference" or "target" path describes the shape you want that area transformed to;
- the necessary transformation is applied to the whole layer.

So to transform Issabella's monastery pic:
- select Path Tool, then click on each corner of the portico in turn (say bottom-left, top-left, top-right, bottom-right);
- in Paths dialog, rename path as "active";
- in Paths dialog, right-click and select New Path ..name it "ref";
- click on each corner of the rectangle (or other shape) that you want to transform the portico to, in the same sequence as used for the "active" path;
- run Filters>Distorts>Align to path, select the "active" and "ref" paths respectively, then hit OK.

Just before running the plugin:
Image

After running the plugin and then Fit-canvas-to-layers:
Image


Top
 Post subject: Re: Manually align images
PostPosted: Mon Jun 15, 2015 2:29 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 866
okyl168 & jontait2,

Many thanks for your help and advice. Paths have been something of a mystery until now! There is so much to learn, but many helpful people to smooth the progress.

david.


Top
 Post subject: Re: Manually align images
PostPosted: Mon Jun 15, 2015 6:56 am  (#11) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
Sorry about the confusion, I do admitted that I didn't spend time on thinking the term in use. Initially, it was designed to align 2 or more images to the reference image. To implement the affine transformation in gimp which required to specify the control points in both images. I borrow path's mechanism to implement it, hence the name align to path evolved.

This plugin not only perform the perspective transformation or the reshape function, it also allow me to specify the position on where it goes in the target/to image. And is this feature that makes image alignment a lot easier. The gimp path mechanism allow me to undo and go back to fine tune the points in the path and re-apply the script.


Top
 Post subject: Re: Manually align images
PostPosted: Mon Jun 15, 2015 7:24 am  (#12) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
david wrote:
okyl168 & jontait2,

Many thanks for your help and advice. Paths have been something of a mystery until now! There is so much to learn, but many helpful people to smooth the progress.

david.
Paths are the current topic of the 8 Feature Tutorials on the Tutorials Index.

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Manually align images
PostPosted: Mon Jun 15, 2015 10:43 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 866
okyl168 & jontait2,

Many thanks. I followed your instructions and it worked like a charm! I have previously used Hugin, which is no doubt mathematically correct but can be long-winded.

Now you have set me some more homework - learning about paths!

Thanks again,
david.


Top
 Post subject: Re: Manually align images
PostPosted: Mon Jun 15, 2015 12:05 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: Aug 16, 2012
Posts: 4271
Location: Göteborg, Sweden
okyl168: looks like a useful plug-in, thanks for sharing.

_________________


Top
 Post subject: Re: Manually align images
PostPosted: Mon Jul 13, 2015 5:54 am  (#15) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
Got an example I can show what it does, here I got 2 images taken at few seconds apart without tripod at a busy cross junction.
Attachment:
P1090459s.jpg
P1090459s.jpg [ 435.46 KiB | Viewed 1713 times ]
Attachment:
P1090460s.jpg
P1090460s.jpg [ 483.3 KiB | Viewed 1713 times ]

after applied align to path where the fixing is the building
The result in difference mode, as you can see only the building is aligned.
Attachment:
diff.jpg
diff.jpg [ 326.12 KiB | Viewed 1713 times ]


Last edited by okyl168 on Mon Jul 13, 2015 6:05 am, edited 3 times in total.

Top
 Post subject: Re: Manually align images
PostPosted: Mon Jul 13, 2015 5:55 am  (#16) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
Then apply layer mask and paint the area you want from another image, you may need to color curve align between 2 images if they were taken at different exposure.
The merged result
Attachment:
merged.jpg
merged.jpg [ 388.09 KiB | Viewed 1713 times ]


Top
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Turn photo to cartoon manually

6

No new posts Attachment(s) Map Transform - using Template

10

No new posts Attachment(s) How can I transform like that with GIMP?

4

No new posts For those interested in the Recursive transform

4

No new posts Attachment(s) Like GIMP's new 3D transform preset.

5



* Login  



Powered by phpBB3 © phpBB Group