Making 1 image fit another?

95 views
Skip to first unread message

paul womack

unread,
Oct 21, 2014, 6:44:13 AM10/21/14
to Hugin ptx
In an almost vestigial instance of optimisation, I would like
to "mate" a pair or photographs. Both are near square, but
are not as high quality as I would wish.

In order to preserve the most quality possible, I would like
to keep one of the images (that happens to carry more important
subject matter) untransformed, and get hugin to calculate and apply
transforms only to the second image.

It's easy to persuade hugin to transform them BOTH
so the transformed PAIR are a mutual match, but how
to I persuade hugin to come up with a transform
for one image (presumably the anchor) which is a pixel
perfect no-op (such that I'll actually use the original :-) and
the second (transformed) image can be matched to it?

BugBear

jepz11

unread,
Oct 22, 2014, 4:56:26 AM10/22/14
to hugi...@googlegroups.com


On Tuesday, October 21, 2014 12:44:13 PM UTC+2, bugbear wrote:

to keep one of  the images (that happens to carry more important
subject matter) untransformed, and get hugin to calculate and apply
transforms only to the second image.

Use a mask 'include region' for the whole first image?

bugbear

unread,
Oct 22, 2014, 5:08:35 AM10/22/14
to hugi...@googlegroups.com
I need the second image to be transformed such that it is a dead fit
for the unaltered first image; I have every intention of using
the source image unaltered for the first image, so it doesn't really
matter what hugin does to it. Only getting the right transform
for the second image (somehow) matters.

BugBear

Roger Broadie

unread,
Oct 22, 2014, 6:36:46 AM10/22/14
to hugi...@googlegroups.com
BugBear wrote on Wed, 22 Oct 2014 at 10:08:30 +0100:
----------------
---------------

You tell us you don't want to transform the first image at all.
Therefore, use it as the anchor, with all its parameters zero and
non-optimisable.

Keep the lens parameters as imported, with, in the example I tried, just
an fov and use a single lens.

Optimise the second image for yaw, pitch and roll. That superimposes
the second image on the first as they sit in Hugin.

Now switch to the Stitcher tab and click Calculate optimum size (it may
be possible to do so earlier, but I haven't tried). Having done that I
reoptimise and normally get a bit of a shock at the greater errors
announced by the optimiser now the output size is greater.

I applied the above to a couple of group photos taken from the same spot
and then got Hugin to output its version of the anchor image. I found it
superimposed pixel-for-pixel on the original, though with a fringe where
the size did not quite match because I cropped within Hugin. In the
group photos I then applied masking to select the heads I preferred
(giving the same effect as using the fuse function in Microsoft Photo
Gallery, if I dare mention that). But combining the images in an
editor, as I think you intend, is probably the better approach.
Nonetheless it may be worth outputting both images from Hugin and
working with those because they will already be in register.

Trivial improvements in optimisation could be achieved by allowing other
parameters to vary for the non-anchor image, but in the example I tried
they had no noticeable effect on the end result.

Roger Broadie

bugbear

unread,
Oct 22, 2014, 7:01:45 AM10/22/14
to hugi...@googlegroups.com
Roger Broadie wrote:

>
> You tell us you don't want to transform the first image at all. Therefore, use it as the anchor, with all its parameters zero and non-optimisable.
>
> Keep the lens parameters as imported, with, in the example I tried, just an fov and use a single lens.

Yep; guessed all that (good to have it confirmed).

>
> Optimise the second image for yaw, pitch and roll. That superimposes the second image on the first as they sit in Hugin.

Agreed.

> Now switch to the Stitcher tab and click Calculate optimum size (it may be possible to do so earlier, but I haven't tried). Having done that I reoptimise and normally get a bit of a shock at the greater errors announced by the optimiser now the output size is greater.

Ah - I thought Optimize size did something like a 75% scale down!

But I didn't test my assumption. My bad.

> I applied the above to a couple of group photos taken from the same spot and then got Hugin to output its version of the anchor image. I found it superimposed pixel-for-pixel on the original, though with a fringe where the size did not quite match because I cropped within Hugin.

That's it!


> In the group photos I then applied masking to select the heads I preferred (giving the same effect as using the fuse function in Microsoft Photo Gallery, if I dare mention that). But combining the images in an editor,
> as I think you intend, is probably the better approach.

Yes, that was my intention - it clearly introduces no sampling degradation whatsoever to image 1.

> Nonetheless it may be worth outputting both images from Hugin and working with those because they will already be in register.

Even my lowly skills can register two "perfect" images in Gimp!!

> Trivial improvements in optimisation could be achieved by allowing other parameters to vary for the non-anchor image, but in the example I tried they had no noticeable effect on the end result.

Thank you!

BugBear

bugbear

unread,
Oct 23, 2014, 8:21:07 AM10/23/14
to hugi...@googlegroups.com
bugbear wrote:

>> I applied the above to a couple of group photos taken from the same spot and then got Hugin to output its version of the anchor image. I found it superimposed pixel-for-pixel on the original, though with a fringe where the size did not quite match because I cropped within Hugin.

Damn. There's obviously some complication in "Optimize size" that you didn't hit, and I have.

My "anchor" is being scaled :-(

This may be because the "other" image is larger, but I'm not sure yet.

BugBear

bugbear

unread,
Oct 23, 2014, 8:22:45 AM10/23/14
to hugi...@googlegroups.com
Roger Broadie wrote:

> You tell us you don't want to transform the first image at all. Therefore, use it as the anchor, with all its parameters zero and non-optimisable.
>
> Keep the lens parameters as imported, with, in the example I tried, just an fov and use a single lens.
>
> Optimise the second image for yaw, pitch and roll. That superimposes the second image on the first as they sit in Hugin.

Oh, and I did the optimisation "mosaic style".

I left the base image locked, used the same lens for both, and optimised the other image
for roll, X Y Z, having set only TWO control points (on the corners of the upper edge of the lower
map, and the lower edge of the upper map).

This (obviously?) gave a 0 error solution.

BugBear

Roger Broadie

unread,
Oct 23, 2014, 3:42:29 PM10/23/14
to hugi...@googlegroups.com
BugBear wrote on Thu, 23 Oct 2014 at 13:22:40 +0100

Oh, and I did the optimisation "mosaic style".

I left the base image locked, used the same lens for both, and optimised
the other image
for roll, X Y Z, having set only TWO control points (on the corners of
the upper edge of the lower map, and the lower edge of the upper map).

This (obviously?) gave a 0 error solution.

---------------------

Sorry, I hadn't understood what you were doing, because I gave an
example applicable to a central viewpoint, whereas I now understand you
are trying to superimpose two photos of (I assume) the same original,
which is a map. Therefore the mosaic mode that depends on X, Y and Z
does seem the one to use.

On the scaling point that was the subject of your previous message, I
can only say (1) in my case at least this does not seem to be a question
of the scaling value set in preferences for the Assistant, because I
have never changed it from its default of 70% and yet there was no
scaling in the example I tried, and (2) in one instance I included a
zoomed-in image of a troublesome area and clicking the Calculate optimal
size button gave me a colossal total - as far as I could tell it was
based on the very high resolution of the zoomed-in area, but treated as
applying to the whole mosaic. On the face of it the stitcher calculates
the value that retains the highest resolution present. But perhaps
someone can give a more informed account of how Calculate optimal size
works.

I have superimposed maps, but I think always they were different maps of
the same area that I wanted to compare - a tithe map with a modern
Ordnance Survey map, for instance. I've normally just scaled, rotated
and shifted one relative to the other within the GIMP, though I think I
have used a panorama program to do the calculations for me. At that
stage I used the small-angle approximation that assumes rays from the
different points within the images are effectively parallel. Now I
would certainly try the translation mode.

As to scaling, personally I would not feel that the advantages of
retaining the original version justified the effort in getting the
second image to match it exactly - in none of my map images does the
detail seem that well-defined in the first place. If Calculate optimal
size gave an unhelpful total I would estimate what I think it should be
and insert that in the stitcher tab. You need only insert one value, in
the canvas width or height, and the other values are calculated in
proportion. But I think you have to base your calculation on the
cropped values. Then I would use the two images produced by the
stitcher, which I would know are already aligned.

Roger Broadie

Reply all
Reply to author
Forward
0 new messages