Apologies for my long absence, I have been at the AAS meeting all week.

@Craig, I think I will test using a resampled version via map and t_radial.
I am dealing with datacubes of spatially-resolved spectra, so I'm a little
hesitant to add an extra layer of sampling. However, the spectra would be
more uniformly represented using map/t_radial.

@Matt, Nice! :-)

Many thanks, all.

- Tim


On Thu, Jan 3, 2013 at 3:48 AM, Matthew Kenworthy <
[email protected]> wrote:

> Hi Tim,
>
> In general, this isn't easily threadable, as there are a different number
> of pixels to be medianed in each ring. It's possible, but I think you're
> okay with using a loop because at least the code is readable and you'll
> wonder what on earth you were doing if you try to reread it several months
> later.
>
> My only other comment is that you're only selecting *exactly* the same
> values for the radius of the ring, which is a bit too restrictive.
>
> Here's my go at that:
>
>
>
> my $image = grandom(zeroes(101,101));
>
> my $dr = 3;
>
> for (my $r = 0; $r < 50; $r += $dr) {
>
> $image = medring($image, 20, 30, $r, $r+$dr);
>
> }
>
>
> sub medring {
>
>     # replace the annulus centered at x,y between radii r1 and r2
>     # with the median value of that ring
>     # CAUTION: it modifies $im in place! Make a copy if you don't want
>     # to modify the original im
>     use strict;
>     my ($im, $x, $y, $r1, $r2) = @_;
>
>     my $rv = rvals($im, {CENTER=>[$x,$y]} ) ;
>
>     my $ringmask = ($rv >= $r1) * ($rv < $r2);
>
>     my $ring = $im->where($ringmask);
>
>     my $medring = median ($ring);
>
>     $ring .= $medring;
>
>     return($im);
>
> }
>
>
> On Thu, Jan 3, 2013 at 4:30 AM, Karl Glazebrook <[email protected]>wrote:
>
>> Or rvals()
>>
>>
>> On 25/12/2012, at 1:31 PM, Tim Haines wrote:
>>
>> > Hello, all.
>> >
>> > I am currently working with some simple 2D data, and I would like to
>> replace all of the pixel values lying along the same circular annulus with
>> their median. Currently, I am doing the following:
>> >
>> > my $image = rfits('input.fits');
>> > my $radii = $image->long->inplace->rvals;
>> >
>> > for my $radius ($radii->uniq->list)
>> > {
>> >     $image->whereND($radii==$radius) .=
>> $image->whereND($radii==$radius)->clump(-1)->medover;
>> > }
>> >
>> >
>> > I would like to get rid of the perl loop. I have tried using higher
>> dimensions in the whereND mask, but I couldn't quite get the threading to
>> work out for my purposes.
>> >
>> > Any thoughts?
>> >
>> > Many thanks.
>> >
>> > - Tim
>> > _______________________________________________
>> > Perldl mailing list
>> > [email protected]
>> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>>
>
>
> --
> Matthew Kenworthy / Assistant Professor / Leiden Observatory
> Niels Bohrweg 2 (#463) / P.O. Box 9513 / 2300 RA Leiden / NL
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to