comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » azimuthal median
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
azimuthal median [message #58026] Mon, 14 January 2008 05:22 Go to next message
Bringfried Stecklum is currently offline  Bringfried Stecklum
Messages: 75
Registered: January 1996
Member
Hi folks,

I am looking for a faster way to compute the azimuthal median in
dependence on radius than the brute-force method, i.e. getting the index
of pixels within a certain annulus, and using median(image[idx]). Is
this another case for the histogram wizards out there?

regards,

Bringfried
Re: azimuthal median [message #58079 is a reply to message #58026] Wed, 16 January 2008 05:46 Go to previous messageGo to next message
Bringfried Stecklum is currently offline  Bringfried Stecklum
Messages: 75
Registered: January 1996
Member
Dear Brian and Wox,

thanks to both of you. What I am doing right now is to set up an array
which holds the radius values, and use the reverse indices returned by
histogram (applied to the radius array) to access the data. This speeds
up things quite a bit.

with kind regards,

Bringfried
Re: azimuthal median [message #58081 is a reply to message #58026] Wed, 16 January 2008 00:38 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Tue, 15 Jan 2008 10:48:12 +0100, Wox <nomail@hotmail.com> wrote:

> On Mon, 14 Jan 2008 14:22:10 +0100, Bringfried Stecklum
> <stecklum@tls-tautenburg.de> wrote:
>
>> Hi folks,
>>
>> I am looking for a faster way to compute the azimuthal median in
>> dependence on radius than the brute-force method, i.e. getting the index
>> of pixels within a certain annulus, and using median(image[idx]). Is
>> this another case for the histogram wizards out there?
>>
>> regards,
>>
>> Bringfried
>
> I'm not familiar azimuthal median but what about image warping:
>
>
> ; Make azimuthal range
> a0=0.
> a1=2*!pi
> ai=0.1
> na=ceil((a1-a0)/ai)+1
> ai=(a1-a0)/(na-1)
> a=a0+ai*indgen(na)
>
> ; Make radial range
> r0=10.
> r1=20.
> ri=0.1
> nr=ceil((r1-r0)/ri)+1
> ri=(r1-r0)/(nr-1)
> r=r0+ri*indgen(nr)
>
> ; Radius and azimuth for warped image
> r=rebin(r,nr,na,/sample)
> a=rebin(transpose(a),nr,na,/sample)
>
> ; X and Y for warped image (xc,yc is center)
> xmap=xc+r*cos(a)
> ymap=yc+r*sin(a)
>
> ; Warped image
> oimage=Interpolate(image,xmap,ymap,/cubic)
>
> ; Median
> m=median(oimage,dim=1)

Should be m=median(oimage,dim=2) otherwise you get the median as a
function of azimuth.
Re: azimuthal median [message #58108 is a reply to message #58026] Tue, 15 January 2008 07:57 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
Bringfried,

I do this all the time and histogram is definitely the correct way. I
find that I have to reread the horrors of histogram often (although
less often lately, maybe I am learning). http://www.dfanning.com/tips/histogram_tutorial.html


The basic idea is that you have to setup histogram to have bins where
you want them then pull the indices out with reverse_indices.

I have a few to many things this second to make an example but in sudo
code it is like this (for me)

;; get the data
;; run histogram on the data
hi = histogram(data, binzise=0.4, min=1, reverse_indices=ri)
for i=0l, n_elements(hi)-1 do begin
;; do the reverse indices magic to get the right indices
;; do whatever computation and store it somewhere
endfor








Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: azimuthal median [message #58115 is a reply to message #58026] Tue, 15 January 2008 01:48 Go to previous messageGo to next message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Mon, 14 Jan 2008 14:22:10 +0100, Bringfried Stecklum
<stecklum@tls-tautenburg.de> wrote:

> Hi folks,
>
> I am looking for a faster way to compute the azimuthal median in
> dependence on radius than the brute-force method, i.e. getting the index
> of pixels within a certain annulus, and using median(image[idx]). Is
> this another case for the histogram wizards out there?
>
> regards,
>
> Bringfried

I'm not familiar azimuthal median but what about image warping:


; Make azimuthal range
a0=0.
a1=2*!pi
ai=0.1
na=ceil((a1-a0)/ai)+1
ai=(a1-a0)/(na-1)
a=a0+ai*indgen(na)

; Make radial range
r0=10.
r1=20.
ri=0.1
nr=ceil((r1-r0)/ri)+1
ri=(r1-r0)/(nr-1)
r=r0+ri*indgen(nr)

; Radius and azimuth for warped image
r=rebin(r,nr,na,/sample)
a=rebin(transpose(a),nr,na,/sample)

; X and Y for warped image (xc,yc is center)
xmap=xc+r*cos(a)
ymap=yc+r*sin(a)

; Warped image
oimage=Interpolate(image,xmap,ymap,/cubic)

; Median
m=median(oimage,dim=1)
Re: azimuthal median - final remark [message #58207 is a reply to message #58079] Thu, 17 January 2008 02:53 Go to previous message
Bringfried Stecklum is currently offline  Bringfried Stecklum
Messages: 75
Registered: January 1996
Member
Another improvement is to compute the radial indices only once, and
account for the different object positions in the image by accessing the
proper index range, i.e. object_idx=idx[r]+nx_pixels*ypos+xpos.


Bringfried Stecklum wrote:
> Dear Brian and Wox,
>
> thanks to both of you. What I am doing right now is to set up an array
> which holds the radius values, and use the reverse indices returned by
> histogram (applied to the radius array) to access the data. This speeds
> up things quite a bit.
>
> with kind regards,
>
> Bringfried
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Map Projection Problem Persists in Perpetuity
Next Topic: Re: Format of contour labels?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:12:16 PDT 2025

Total time taken to generate the page: 0.00581 seconds