enblend error while stiching large image

147 views
Skip to first unread message

Jared

unread,
Apr 6, 2021, 2:50:42 AM4/6/21
to hugin and other free panoramic software

Hello, all.  New hugin user here.  I'm trying to stich together a scanned poster comprised of 8 different parts using the scanning tutorial here:

I *think* I did everything correctly, but when stitching it fails with this error:

Blending images...
enblend: info: loading next image: ffmap20000.tif 1/1
enblend: info: loading next image: ffmap20001.tif 1/1
enblend: /tmp/portage/media-gfx/enblend-4.2.0_p20161007-r1/work/enblend-4.2.0_p20161007/src/fixmath.h:487: double enblend::PyramidScale<PyramidIntegerBits, PyramidFractionBits>::scale_lightness_for_pyramid(double) const [with int PyramidIntegerBits = 9; int PyramidFractionBits = 7]: Assertion `result >= 0.0' failed.

I tried multiple times but always get the same error.  The images are large, about maybe 300 MB TIFFs (x8) when uncompressed, so I thought maybe I was running out of RAM or disk or something, but I have 32 GB of ram and still had 14.5 GB reported free when running in a 1 second loop the last time it failed.  Disk also looks good.

As mentioned, I'm new to hugin, so I could certainly be doing something wrong myself.  Also may be running into some kind of size limits (though that seems unlikely) or maybe a bug.  Would appreciate if anyone can provide some guidance on how to resolve, or at least further troubleshoot.

Here's the full log:

And the PTO file for reference:

Thanks!

--
Jared

Monkey

unread,
Apr 6, 2021, 11:45:49 AM4/6/21
to hugin and other free panoramic software
I think Enblend doesn't like some of the pixel values in your images. You could try specifying a different blend colorspace (--blend-colorspace=IDENTITY might be a good option, but I'm just guessing). Or you could try Multiblend, which has no such colourspace qualms (though only because it ignores colourspaces completely) and is a LOT quicker.

Bruno Postle

unread,
Apr 6, 2021, 4:32:23 PM4/6/21
to Hugin ptx
On Mon 05-Apr-2021 at 19:40 -0700, Jared wrote:
>
>enblend:
>/tmp/portage/media-gfx/enblend-4.2.0_p20161007-r1/work/enblend-4.2.0_p20161007/src/fixmath.h:487:
>double enblend::PyramidScale<PyramidIntegerBits,
>PyramidFractionBits>::scale_lightness_for_pyramid(double) const [with int
>PyramidIntegerBits = 9; int PyramidFractionBits = 7]: Assertion `result >=
>0.0' failed.

>I tried multiple times but always get the same error. The images are
>large, about maybe 300 MB TIFFs (x8) when uncompressed, so I thought maybe
>I was running out of RAM or disk or something, but I have 32 GB of ram and
>still had 14.5 GB reported free when running in a 1 second loop the last
>time it failed. Disk also looks good.

The error is new to me, but looking at your project, although the
crop area is a reasonable 32600x21922 pixels, the panorama canvas is
53210x1061398 (which is 50+ gigapixels).

I would try reducing the canvas area, as it is possible the big
offset numbers are confusing enblend, click the Fit button in the
Preview window or Calculate Field of View in the Stitcher tab (which
does the same thing). I would also use Calculate Optimal Size in
the Stitcher tab, and centre the output in the panorama using the
Drag tool.

Attached, a more modest 680 megapixel version of your project. This
should be ok, if it isn't then there some problem with the images
themselves.

--
Bruno
ffmap2.pto

Jared

unread,
Apr 6, 2021, 4:46:19 PM4/6/21
to hugin and other free panoramic software
Thank you both!

Monkey - your guess was spot on.  Adding that blend-colorspace option got it working.  I also tried adding mutliblend, and got it to generate a stiched image as well, although at least for now the enblend version is better because it preserved the ICC profile, which multiblend appears to have discarded.  Theoretically I can add it after the fact, but that brings me to the second problem I discovered...

...and I think already answered by Bruno.  I *just* tried to open the stiched image in GIMP to mess with the color settings, and was getting an error about the height being out of range.  I couldn't figure out why, but I suspect it has to do with the canvas size issue you pointed out.  Now that I know what to look for, let me fiddle with the settings a bit and see if I can fix that.

I have one additional question, if you don't mind - the stiching came out well, but the blending is off.  Here's a much smaller version of the stiched image for reference:

Note that the left column is darker than the rest.  The source images aren't like that - they're uniformly blue.  I suspect it's those dark splotches, I guess some kind of oil or water stains, that's throwing off the blending.  Is there any reasonably straightforward way to tune that to get the original brighter blue across the full image?  Both enblend and multiblend produced similar results.

Thank you so much for the help so far.

Bruno Postle

unread,
Apr 6, 2021, 5:00:38 PM4/6/21
to Hugin ptx
On Tue 06-Apr-2021 at 13:46 -0700, Jared wrote:
>
>I have one additional question, if you don't mind - the stiching came out
>well, but the blending is off. Here's a much smaller version of the
>stiched image for reference:
>https://boxdog.legroom.net/public/ffmap-example.jpg
>
>Note that the left column is darker than the rest. The source images
>aren't like that - they're uniformly blue. I suspect it's those dark
>splotches, I guess some kind of oil or water stains, that's throwing off
>the blending. Is there any reasonably straightforward way to tune that to
>get the original brighter blue across the full image? Both enblend and
>multiblend produced similar results.

Hugin will try and optimise the brightness and colour of your images
to match if you ask it to, but your PTO project has default values
for photometric parameters. So it looks like your photos are
different somehow.

In the Photos tab, optimise Photometric -> Low dynamic range,
variable white balance.

--
Bruno

Monkey

unread,
Apr 7, 2021, 6:48:32 AM4/7/21
to hugin and other free panoramic software
If the remapped images don't show the difference in colour, but the blend still does, could you output a reduced size remapped image set and upload it somewhere?

Jared

unread,
Apr 11, 2021, 10:46:41 PM4/11/21
to hugin and other free panoramic software
Hello.  Appreciate your continued guidance on this.  I got the canvas size down to a usable state so I can open it in GIMP now.  Still having trouble with the blending, though.  I tried Bruno's white balance suggestion, and then spent a while fiddling with a bunch of different options to see if I could come up with anything, but no luck.  I've uploaded scaled versions of the remmaped files, plus the full image and PTO file for reference, here:


Looking closely at the source images, it looks like there is a little color difference between the two left-most segments and the rest of the map (even though it was all scanned under the same conditions), but nowhere near what's shown in the final image.  I also noticed that the second column is oddly darker as well - look at the water below point 2 and to the left of point 1 around the bottom center of the map.  All of the water should be a reasonably uniform blue, except for those 4 stains in the upper-left.

Monkey

unread,
Apr 12, 2021, 7:25:13 AM4/12/21
to hugin and other free panoramic software
The problem is the grey border with black lines on the top and left of the images (and the shadow it casts on the page). Mask those out and it should then blend as expected.

Jared

unread,
Apr 12, 2021, 4:34:06 PM4/12/21
to hugin and other free panoramic software
Ha.  So keeping in mind I'm new to hugin and figuring this out as I go, my first attempt at creating a mask didn't exactly go as planned.  Here's a screenshot of the resulting image:

Technically I think I did mask that out, but I'm guessing that's not what you had in mind.  :-)

So that's the result of an exclude mask that I added to the two left-most source images.  Can you provide any more detail on how I *should* create that mask?  I tried referencing the mask tutorial (http://hugin.sourceforge.net/tutorials/Blend-masks/en.shtml), but it seems like that's addressing a fundamentally different issue, so wasn't sure how to apply that to this image.

Monkey

unread,
Apr 12, 2021, 8:13:08 PM4/12/21
to hugin and other free panoramic software
That's not the border I meant. It's the thin gray border with black lines which is at the top and/or left and/or bottom of all the images. It might be part of the scanner lid being visible or something you put behind the folded page.

Jared

unread,
Apr 13, 2021, 12:19:41 AM4/13/21
to hugin and other free panoramic software
Ah.  Well that makes much more sense.  Sorry, that's my bad.  So what you're seeing is a square that I use to align stuff on my scanner - just aligning against any of the edges around the glass results in the sides of the image being cropped off.  I didn't think it'd have an effect on the blending process, so I had planned to crop it out of the stitched image.

Here's my latest attempt:

Sadly, not much of an improvement.  Actually a bit worse, as the middle section is darker now as well.  After applying the mask, I generated one image with no other changes (not shown - pretty much the same as example2, though), and then for this image I clicked Calculate for Optimize, Photometric, Low dynamic range, variable white balance.  Is there some other option I should try to apply proper blending after that border is masked out?

Again, I appreciate the continued support.

Monkey

unread,
Apr 13, 2021, 4:49:15 AM4/13/21
to hugin and other free panoramic software
Was that with Enblend or Multiblend? Have you made sure to mask out the shadowed/darkened strip at the edge, as well as the actual square?

Jared

unread,
Apr 13, 2021, 5:59:41 PM4/13/21
to hugin and other free panoramic software
With enblend.  I just re-tested with multiblend and get roughly the same results.  Yes, reasonably sure I masked that out.  Here's an example, just to verify I didn't misunderstand you again:

I created a mask like that on all 8 source images to mask the square.  Is that what you mean?

Monkey

unread,
Apr 14, 2021, 10:22:23 AM4/14/21
to hugin and other free panoramic software
That looks almost right, but you should mask out that darkened corner as well. And for the other images you just need to make sure you haven't left any of those darkened parts in (even if they are small they can disproportionately affect the blend).

Given the nature of the images you can be pretty aggressive in masking out, at least when using Multiblend - it only needs a tiny overlap to avoid leaving a blank area, and will blend images even if they don't overlap.
Reply all
Reply to author
Forward
0 new messages