Crop to maximal area issue

61 views
Skip to first unread message

Capri Flyhennessy

unread,
Aug 3, 2018, 2:39:35 PM8/3/18
to hugin and other free panoramic software
Hi,

I am quite new to Hugin but I am writing a bash script to automatically run through all of my panoramas and I have bumped into an irritating issue that I do not really know how to fix.
The whole process works but I would like it to crop the stitched image to the largest possible area where my pictures are and not for it to always crop the top part (sometimes it crops the sides as well).

Is there something I am missing to automatically fix this, it doesn't seem such a far fetched thing.

I have added a screenshot of when I just run the assistant and then view it's result.

Thanks,




Greg 'groggy' Lehey

unread,
Aug 3, 2018, 8:52:15 PM8/3/18
to hugi...@googlegroups.com
On Friday, 3 August 2018 at 11:08:00 -0700, Capri Flyhennessy wrote:
> Hi,
>
> I am quite new to Hugin but I am writing a bash script to automatically run
> through all of my panoramas and I have bumped into an irritating issue that
> I do not really know how to fix.
> The whole process works but I would like it to crop the stitched image to
> the largest possible area where my pictures are and not for it to always
> crop the top part (sometimes it crops the sides as well).
>
> Is there something I am missing to automatically fix this, it doesn't seem
> such a far fetched thing.

Clearly the "autocrop” feature in the GUI works, so it should be
possible. Can you post your bash script? I'm doing something
similar, but I haven't looked at cropping yet.

Greg
--
Sent from my desktop computer.
Finger groo...@gmail.com for PGP public key.
See complete headers for address and phone numbers.
This message is digitally signed. If your Microsoft mail program
reports problems, please read http://lemis.com/broken-MUA
signature.asc

Marius Loots

unread,
Aug 4, 2018, 1:51:47 AM8/4/18
to hugi...@googlegroups.com
Hi,

Friday, August 3, 2018, 8:08:00 PM, you wrote:
> The whole process works but I would like it to crop the stitched
> image to the largest possible area where my pictures are and not for
> it to always crop the top part (sometimes it crops the sides as well).

> Is there something I am missing to automatically fix this, it
> doesn't seem such a far fetched thing.

Cropping as it currently works will select an area so that there are
no empty spaces. There isn't an option - that I am aware of - to crop
to maximal area. I do that by hand in each case.

Groetnis
Marius
mailto:marius...@up.ac.za
BMedSci (Hons) UP, PGCHE (UP) HCM (FPD)

add some chaos to your life and put the world in order
http://www.chaos.co.za/

Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule
onderhewig. Volledige besonderhede is by
www.it.up.ac.za/documentation/governance/disclaimer/
beskikbaar.


--
This message and attachments are subject to a disclaimer.

Please refer to
http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf
<http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf> for
full
details.

Capri Flyhennessy

unread,
Aug 4, 2018, 5:42:31 AM8/4/18
to hugin and other free panoramic software
Hi,

Well in the GUI it also has issues like the top part not being in the canvas and I have to manually remove all of the empty space at the bottom.

This is the part of my bashscript that deals with the creation of the panorama:

        pto_gen -o project.pto *.jpg
        cpfind -o project.pto --multirow --celeste project.pto
        cpclean -o project.pto project.pto
        linefind -o project.pto project.pto
        autooptimiser -a -m -l -s -o project.pto project.pto
        pano_modify -s -c --fov=AUTO --output-type=N --ldr-file=TIF --ldr-compression=LZW --canvas=AUTO --output=project.pto project.pto
        hugin_executor --stitching --prefix="$PANONAME" project.pto

Thanks,

Capri Flyhennessy

unread,
Aug 4, 2018, 5:46:36 AM8/4/18
to hugin and other free panoramic software
Hi,

Could you explain the "no empty spaces" a bit more because isn't the bottom part empty space? Is there some data there? Why is it even so big?

Thanks,

Capri Flyhennessy

unread,
Aug 4, 2018, 10:10:09 AM8/4/18
to hugin and other free panoramic software
Hi,

I also wanted to add that I am not sure why this is happening but when stitching panorama's. Sometimes the stitch outright fails.
I have added an example of this. The only way to fix it, that I have found, is to rerun the stitching part of Hugin. I there a way I can avoid this?

Thanks a lot,

Greg 'groggy' Lehey

unread,
Aug 5, 2018, 4:20:52 AM8/5/18
to hugi...@googlegroups.com
[reformatted]

On Saturday, 4 August 2018 at 2:42:31 -0700, Capri Flyhennessy wrote:
> On Saturday, August 4, 2018 at 2:52:15 AM UTC+2, Groogle wrote:
>> On Friday, 3 August 2018 at 11:08:00 -0700, Capri Flyhennessy wrote:
>>>
>>> I am quite new to Hugin but I am writing a bash script to
>>> automatically run through all of my panoramas and I have bumped
>>> into an irritating issue that I do not really know how to fix.
>>> The whole process works but I would like it to crop the stitched
>>> image to the largest possible area where my pictures are and not
>>> for it to always crop the top part (sometimes it crops the sides
>>> as well).
>>>
>>> Is there something I am missing to automatically fix this, it
>>> doesn't seem such a far fetched thing.
>>
>> Clearly the "autocrop??? feature in the GUI works, so it should be
>> possible. Can you post your bash script? I'm doing something
>> similar, but I haven't looked at cropping yet.
>
> Well in the GUI it also has issues like the top part not being in
> the canvas and I have to manually remove all of the empty space at
> the bottom.

This is beginning to look like an issue with your images.

> This is the part of my bashscript that deals with the creation of the
> panorama:
>
> pto_gen -o project.pto *.jpg
> cpfind -o project.pto --multirow --celeste project.pto
> cpclean -o project.pto project.pto
> linefind -o project.pto project.pto

I've found that linefind pessimizes my images, which contain a number
of trees that are not all vertical. But it doesn't look like this is
your issue.

> autooptimiser -a -m -l -s -o project.pto project.pto
> pano_modify -s -c --fov=AUTO --output-type=N --ldr-file=TIF --ldr-compression=LZW --canvas=AUTO --output=project.pto project.pto
> hugin_executor --stitching --prefix="$PANONAME" project.pto

Apart from that, that's pretty much what I do (I've now looked at
cropping), and "it works for me".

On Saturday, 4 August 2018 at 2:46:36 -0700, Capri Flyhennessy wrote:
> On Saturday, August 4, 2018 at 7:51:47 AM UTC+2, Marius Loots wrote:
>>
>> Hi,
>>
>> Friday, August 3, 2018, 8:08:00 PM, you wrote:
>>> The whole process works but I would like it to crop the stitched
>>> image to the largest possible area where my pictures are and not for
>>> it to always crop the top part (sometimes it crops the sides as well).
>>
>>> Is there something I am missing to automatically fix this, it
>>> doesn't seem such a far fetched thing.
>>
>> Cropping as it currently works will select an area so that there are
>> no empty spaces. There isn't an option - that I am aware of - to crop
>> to maximal area. I do that by hand in each case.
>
> Could you explain the "no empty spaces" a bit more because isn't the bottom
> part empty space? Is there some data there? Why is it even so big?

I'd use the term "hole" rather than "empty space". If there's an
undefined area in the middle of the image, cropping will avoid it.
But this doesn't seem to be your issue.

On Saturday, 4 August 2018 at 7:10:09 -0700, Capri Flyhennessy wrote:
> Hi,
>
> I also wanted to add that I am not sure why this is happening but when
> stitching panorama's. Sometimes the stitch outright fails.

What's the error message?

> I have added an example of this. The only way to fix it, that I have
> found, is to rerun the stitching part of Hugin. I there a way I can
> avoid this?

Are you saying that you run your script, and the hugin_executor fails,
that you re-run just that part, and it works? If so, you really need
to look at those error messages.

> <https://lh3.googleusercontent.com/-r3N-QWisEbE/W2WzZ9P4GGI/AAAAAAAABHg/iD24A-TlrkAmEn73KJs476XpNHFx9HhCACLcBGAs/s1600/pano_incorrect_stitching.jpg>

What I see here is that the cropping didn't work at all. Maybe a
little masking would help. One difference between my script and yours
is that after creating the project files, control points and cropping,
I start the GUI to play around with the results. Then I save the
project file and let hugin_executor finish it off.

Maybe it's worth putting your files (source image and project file) up
for us to take a look at.
signature.asc

Capri Flyhennessy

unread,
Aug 5, 2018, 6:00:37 AM8/5/18
to hugin and other free panoramic software
Hi Greg,

I am sorry, I think I didn't write it correctly but the hugin_executor for the stitch doesn't error out. The panorama it generates is just not correct, the output of when it creates a weird panorama is what I uploaded here.
And it only does it occasionally, meaning that when I rerun the stitching on the the one's which came out bad it usually comes out great (which makes me wonder why it works the second time and not the first time).
I have run more than 20 panorama's with this script and about 4 of them have the stitching issue and about 9 of them have the cropping issue.


And the script:
        pto_gen -o project.pto *.jpg
        cpfind -o project.pto --multirow --celeste project.pto
        cpclean -o project.pto project.pto
        #linefind -o project.pto project.pto

        autooptimiser -a -m -l -s -o project.pto project.pto
        pano_modify -s -c --fov=AUTO --output-type=N --ldr-file=TIF --ldr-compression=LZW --canvas=AUTO --output=project.pto project.pto
        hugin_executor --stitching --prefix=pano project.pto

I checked and when the remapping happens, when I check the intermediary tiffs it creates I can already see the top cropping happening.

Ideally for me it would be cool not to enter the GUI at all, as that would be a way to quickly batch process all of my panorama's (that's why I started creating a bash script for creating the panorama's).

Thanks,

Greg 'groggy' Lehey

unread,
Aug 9, 2018, 12:59:04 AM8/9/18
to hugi...@googlegroups.com
On Sunday, 5 August 2018 at 3:00:37 -0700, Capri Flyhennessy wrote:
> Hi Greg,
>
> Here are the jpg's I am using:
> https://drive.google.com/open?id=1tQ78OvePAh1hb9B_g3XIWhZY48_0L4id
>
> And the script:
> pto_gen -o project.pto *.jpg
> cpfind -o project.pto --multirow --celeste project.pto
> cpclean -o project.pto project.pto
> #linefind -o project.pto project.pto
> autooptimiser -a -m -l -s -o project.pto project.pto
> pano_modify -s -c --fov=AUTO --output-type=N --ldr-file=TIF --ldr-compression=LZW --canvas=AUTO --output=project.pto project.pto
> hugin_executor --stitching --prefix=pano project.pto
>
> I checked and when the remapping happens, when I check the intermediary
> tiffs it creates I can already see the top cropping happening.

OK, I've taken a look at this, and "it works for me". Comparing our
workflows, it seems that you have omitted "--crop-AUTO" from the call
to pano_modify, so there is no crop mask.

> Ideally for me it would be cool not to enter the GUI at all, as that would
> be a way to quickly batch process all of my panorama's (that's why I
> started creating a bash script for creating the panorama's).

That should be possible. I ran your scipt as shown, with the addition
of the --crop=AUTO, and it generated a properly cropped result.
signature.asc
Reply all
Reply to author
Forward
0 new messages