patch4 works for align_image_stack but not for HDR panoramas in Hugin. If I read your patch correctly, you introduced a boolean variable, 'intersection', to identify if the point must be inside a whole stack of images; or if it merely must be inside a single image. However the test is for the point to be inside all images, and not inside a stack. align_image_stack is a special case in that there is only one stack. The general case of an HDR panorama has multiple stacks; and to fix bug #679981 the test would need to be limited to each single stack separately; as opposed to all images (= all stacks).

you want to iterate all stacks; and within each stack run the inside/outside test.

The above is an approximation, though it may be good enough. It assumes that the stacks are perfectly aligned and might miss on some marginal pixels with hand held input.

To do it perfectly, you would want to iterate all images within an exposure layer and make sure the point is inside each exposure layer, but this has its limitations as well if the camera was on auto-exposure: the result would depend on the definition of the EV range to be considered a single layer. I personally would try first to iterate the stacks.

Last but not least, next time you produce a patch can you simply use `hg diff > patch.file` to generate it? your patch file did not have the full path information for the patched files, requiring more manual work than necessary to apply them.