Re: Spherical Harmonic Filtering

Jon Watte <[email protected]> Tue, 30 Apr 2013 09:34:45 -0700
Newsgroups gmane.games.devel.algorithms
Message-ID <CAJgyHGO=URAyRuZU-7zkc-Wr-wvyrnA+MOWnaHGJ-kE3YSLiQA@mail.gmail.com>
--===============6069246017144070229==
Content-Type: multipart/alternative; boundary=047d7b4720f845334404db9694c1

--047d7b4720f845334404db9694c1
Content-Type: text/plain; charset=UTF-8

This is a little late, but better late than never :-)

Did you get a reasonable solution? Do you have any images to show?

The way I understand it, those functions are both spatial domain functions.
The first one is the "sinc()" function, and the second one is the "cosine
window" function from sampling theory.
Also, when you use the sinc function, you typically want to either cut off
at a zero crossing (multiple of pi) or further window the sinc() function,
typically with a cosine window.

Finally, to adjust the cosine window, you can raise it to some power for a
trade-off between "preserving detail" and "removing aliasing"; known as a
"raised cosine window function."

Sincerely,

jw





Sincerely,

Jon Watte


--
"I pledge allegiance to the flag of the United States of America, and to
the republic for which it stands, one nation indivisible, with liberty and
justice for all."
~ Adopted by U.S. Congress, June 22, 1942


On Fri, Mar 1, 2013 at 1:56 AM, Alen Ladavac <[email protected]> wrote:

> Hi all,
>
> I was revisiting some of our old shader code (order 2, i.e.
> 9-coefficients) trying to fix ringing in some high contrast environments. I
> am looking at Stupid Spherical Harmonics (SH) Tricks by Peter-Pike Sloan,
> the section about Windowing.
>
> The Lanczos and Han functions mentioned are of form:
>
> sin(pi*x/w)/(x/w)
>
> and
>
> (1+cos(pi*x/w))/2
>
> respectively, for a given filtering window of width "w". The rest of text,
> as far as I can see, seems to imply that w should be equal to the order of
> SH used. (w=6 for 6th order).
>
> Initially, I would expecting filtering to be done by convolution in
> spatial domain, by projecting the filter function to the SH basis and then
> multiplying its y[l,0] coefficients into appropriate bands (y[l,m]) of the
> filtered function. However, all the other notions in there seem to point to
> this actually being done as multiplication in frequency domain. More
> specifically, as if the filtering function as presented here above _already
> is_ the frequency domain presentation. So it would just multiply of y(l,m)
> coefficients of the filtered function by values of the filter evaluated at
> integers.
>
> This looks rather unusual to me, but I guess there is some reasoning
> behind all that.
>
> As a side note, I got some ok-ish results with filtering in spatial domain
> (aka. bluring) using Han function as above (*) with value w=1.5 through
> convolution as described above. (Where the number w=1.5 was "tuned" by
> manual binary search with visual assessment of results to minimize visible
> ringing without introducing "too much" blur.) While on the other hand,
> using the multiplication directly in frequency domain looked way too blurry
> for w=3 and was ringing too much if I tried increasing the number (as with
> multiplication in the frequency domain wider "window" leads to less blur,
> while it opposite happens in the spatial domain.)
>
> I would appreciate if anyone can shed a bit of light onto this.
>
> Thanks a lot in advance,
> Alen
>
> (*) That form of the function does look strange for spatial domain but 1.5
> is an arbitrary "hand-tuned" factor anyway.
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> GDAlgorithms-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
>

--047d7b4720f845334404db9694c1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This is a little late, but better late than never :-)<div>=
<br></div><div style>Did you get a reasonable solution? Do you have any ima=
ges to show?</div><div style><br></div><div style>The way I understand it, =
those functions are both spatial domain functions. The first one is the &qu=
ot;sinc()&quot; function, and the second one is the &quot;cosine window&quo=
t; function from sampling theory.</div>
<div style>Also, when you use the sinc function, you typically want to eith=
er cut off at a zero crossing (multiple of pi) or further window the sinc()=
 function, typically with a cosine window.</div><div style><br></div><div s=
tyle>
Finally, to adjust the cosine window, you can raise it to some power for a =
trade-off between &quot;preserving detail&quot; and &quot;removing aliasing=
&quot;; known as a &quot;raised cosine window function.&quot;</div><div sty=
le>
<br></div><div style>Sincerely,</div><div style><br></div><div style>jw</di=
v><div style><br></div></div><div class=3D"gmail_extra"><br clear=3D"all"><=
div><br><br><br>Sincerely,<br><br>Jon Watte<br><br><br>--<br>&quot;I pledge=
 allegiance to the flag of the United States of America, and to the republi=
c for which it stands, one nation indivisible, with liberty and justice for=
 all.&quot;<br>
~ Adopted by U.S. Congress, June 22, 1942<br></div>
<br><br><div class=3D"gmail_quote">On Fri, Mar 1, 2013 at 1:56 AM, Alen Lad=
avac <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
Hi all,<br>
<br>
I was revisiting some of our old shader code (order 2, i.e. 9-coefficients)=
 trying to fix ringing in some high contrast environments. I am looking at =
Stupid Spherical Harmonics (SH) Tricks by Peter-Pike Sloan, the section abo=
ut Windowing.<br>

<br>
The Lanczos and Han functions mentioned are of form:<br>
<br>
sin(pi*x/w)/(x/w)<br>
<br>
and<br>
<br>
(1+cos(pi*x/w))/2<br>
<br>
respectively, for a given filtering window of width &quot;w&quot;. The rest=
 of text, as far as I can see, seems to imply that w should be equal to the=
 order of SH used. (w=3D6 for 6th order).<br>
<br>
Initially, I would expecting filtering to be done by convolution in spatial=
 domain, by projecting the filter function to the SH basis and then multipl=
ying its y[l,0] coefficients into appropriate bands (y[l,m]) of the filtere=
d function. However, all the other notions in there seem to point to this a=
ctually being done as multiplication in frequency domain. More specifically=
, as if the filtering function as presented here above _already is_ the fre=
quency domain presentation. So it would just multiply of y(l,m) coefficient=
s of the filtered function by values of the filter evaluated at integers.<b=
r>

<br>
This looks rather unusual to me, but I guess there is some reasoning behind=
 all that.<br>
<br>
As a side note, I got some ok-ish results with filtering in spatial domain =
(aka. bluring) using Han function as above (*) with value w=3D1.5 through c=
onvolution as described above. (Where the number w=3D1.5 was &quot;tuned&qu=
ot; by manual binary search with visual assessment of results to minimize v=
isible ringing without introducing &quot;too much&quot; blur.) While on the=
 other hand, using the multiplication directly in frequency domain looked w=
ay too blurry for w=3D3 and was ringing too much if I tried increasing the =
number (as with multiplication in the frequency domain wider &quot;window&q=
uot; leads to less blur, while it opposite happens in the spatial domain.)<=
br>

<br>
I would appreciate if anyone can shed a bit of light onto this.<br>
<br>
Thanks a lot in advance,<br>
Alen<br>
<br>
(*) That form of the function does look strange for spatial domain but 1.5 =
is an arbitrary &quot;hand-tuned&quot; factor anyway.<br>
<br>
<br>
---------------------------------------------------------------------------=
---<br>
Everyone hates slow websites. So do we.<br>
Make your web apps faster with AppDynamics<br>
Download AppDynamics Lite for free today:<br>
<a href=3D"http://p.sf.net/sfu/appdyn_d2d_feb" target=3D"_blank">http://p.s=
f.net/sfu/appdyn_d2d_feb</a><br>
_______________________________________________<br>
GDAlgorithms-list mailing list<br>
<a href=3D"mailto:[email protected]">GDAlgorithms-lis=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/gdalgorithms=
-list</a><br>
Archives:<br>
<a href=3D"http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgo=
rithms-list" target=3D"_blank">http://sourceforge.net/mailarchive/forum.php=
?forum_name=3Dgdalgorithms-list</a><br>
</blockquote></div><br></div>

--047d7b4720f845334404db9694c1--


--===============6069246017144070229==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
--===============6069246017144070229==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
GDAlgorithms-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
--===============6069246017144070229==--