Gaussian-blurring equirectangular panoramas

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
imbennu
Posts: 5
Joined: 2015-11-16T14:35:33-07:00
Authentication code: 1151

Gaussian-blurring equirectangular panoramas

Post by imbennu »

Hi all,
since there is not so much around about this specific task of consistently blur an equirectangular image (ratio 2:1),
here I am to ask what can be automatised via IM and what's my current status.
Image

First off, before applying a gaussain blur, there is the classical method of side-duplicating (append) to the left and to the right the same image and then apply the blur pass, this will create consistent blur around left and right edges (wrap blur).
So far looks quite good: this is what I've done until now.

The problem is: the gaussian blur is non-consistent when the equirectangular is re-mapped to a 3D sphere (i.e. texturized).
This is obvious due to geometrical distortions around the poles: they are "shrinked" thus reducing the applied blur strength.

So how can one apply a consistent gaussian blur, for a spherical mapping?
My ideas so far are related to application of dual polar and depolar transformations, but maybe there are other routes.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gaussian-blurring equirectangular panoramas

Post by fmw42 »

See variable blur mapping at http://www.imagemagick.org/Usage/mapping/#blur and http://www.imagemagick.org/Usage/mapping/#blur_ellipse.

You can create a vertical gradient, then solarize it so that it is brightest at middle and darkest at the top and bottom, so that it blurs more at the equator and less at the poles. You can also apply some non-linear transformation as well to better approximate the spherical effects, such as a cosine. Alternately, create the gradient and use -function sinusoid. Then use that for the mask image.

Input:
Image

The following produces a 1D horizontal blur that varies vertically according to the mask. If you want a 2D blur, then change 5x0 to 5x5, for example.

Unix syntax:

Code: Select all

convert test.png \
\( -size 256x128 gradient: -function sinusoid "1 -90" -write variable_blur_mask.png \) \
-define compose:args="5x0" -compose blur -composite test_variable_blur.png 
Mask:
Image

Result:
Image

Mask Profile:

Code: Select all

profile -c 0 variable_blur_mask.png variable_blur_mask_profile.png
Image


see also
http://www.imagemagick.org/Usage/transf ... ion_arcsin
http://www.imagemagick.org/script/comma ... p#solarize
http://www.imagemagick.org/Usage/color_mods/#solarize

But out of curiosity, why do you want to blur the image?

Please always provide your IM version and platform, so we don't go back and forth about syntax differences. For Windows, see http://www.imagemagick.org/Usage/windows/. Also please always provide individual images so we don't have to crop.
imbennu
Posts: 5
Joined: 2015-11-16T14:35:33-07:00
Authentication code: 1151

Re: Gaussian-blurring equirectangular panoramas

Post by imbennu »

Thank you,
I tested a bit this approach (1) and also with polar -> blur -> depolar (2) double split approach
(polar is applied to original img and flipped img, then both blurred, then combining top halves)

The (2) gives me correct and perfect results on poles, but unfortunately produces some issues on equator (horizonal).
see ref sample here with 20 gaussian:
Image

Using (1) reduces a bit effects but I think mask profile should be a semi-circle to respect the spherical application,
so something like this:
Image

I'll try also this one.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gaussian-blurring equirectangular panoramas

Post by fmw42 »

The sine is what you would have if you project a sphere from its center onto a plane along the axis. I though about the hemisphere also, but did not try than.
willm
Posts: 1
Joined: 2017-10-02T03:38:03-07:00
Authentication code: 1151

Re: Gaussian-blurring equirectangular panoramas

Post by willm »

Has anybody been able to find a workable solution for this? I've started to try and find a method for adding a uniform blur to an equirectangular hdr image. I get a good result by adding -virtual-pixel HorizontalTile, but the poles are evidetally a problem. I've also tried the sine curve approach - however when creating the image the poles are less blurred than the rest.

The reason for wanting the blurred hdr is for creating an 'environment' file for the sIBL standard.

-
Cheers
Will
Post Reply