Thanks to Chris for the inspired information, and
to Ed for suggestions about PDL::Transform that I need to review.
For now I have a first awful but seems to be a functional version

$field is ndarray with doubles [2,$N,$N]
$x are the index for $M < $N that I want to decimate

my @field_int_f=();
my @field_int_c=();

foreach (0..($N-1)){
    my
$spl_fx=PDL::GSL::INTERP->init('cspline',sequence($N),$field->((0),,($_)));
    my
$spl_cx=PDL::GSL::INTERP->init('cspline',sequence($N),$field->((0),($_),));
    my
$spl_fy=PDL::GSL::INTERP->init('cspline',sequence($N),$field->((1),,($_)));
    my
$spl_cy=PDL::GSL::INTERP->init('cspline',sequence($N),$field->((1),($_),));
    push @field_int_f, pdl($spl_fx->eval($x),$spl_fy->eval($x));
    push @field_int_c, pdl($spl_cx->eval($x),$spl_cy->eval($x));
};
my $fint=pdl(pdl(@field_int_f),pdl(@field_int_c))->mv(-1,0)->mv(-1,0);
say $fint->info;
my $ff=index1d($fint(,(0),,), $x->(:,*$x->dims))->mv(-1,0);

Regards

El jue, 13 jun 2024 a las 10:55, chm (<devel.chm...@gmail.com>) escribió:

> If M and N are integers and N%M == 0 then you could use indexing and
> dimension "tricks" to collect the values for the new pixels to the first
> dim
>
> and then apply your preferred interpolation/smoothing operation.
>
>
> You may find inspiration at
> https://github.com/PDLPorters/pdl/wiki/Resampling-up-a-piddle
>
>
> --Chris
>
>
> On 6/13/2024 8:33 AM, Ed . wrote:
>
> Hi Guillermo,
>
> Try https://metacpan.org/pod/PDL::Transform#match ?
>
> Best regards,
> Ed
> ------------------------------
> *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar>
> <gor...@exa.unne.edu.ar>
> *Sent:* 13 June 2024 12:04 AM
> *To:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>
> <pdl-devel@lists.sourceforge.net>; pdl-gene...@lists.sourceforge.net
> <pdl-gene...@lists.sourceforge.net> <pdl-gene...@lists.sourceforge.net>
> *Subject:* [Pdl-devel] decimate function
>
> Hello everybody,
> maybe somebody know how to decimate a 2d ndarray
> through some average and reducing the number
> of pixels from (Nx,Ny) to (Mx,My), (in a 2D image for example?)
> where M< N in order to reduce large amounts
> of data but remaining main information as possible.
>
> I can imagine how to use the PDL::GSL::INTERP module
> for inward interpolation, but it seems that no threading
> (broadcasting) is possible with it
>
> Thank you in advance,
>
> Regards
>
>
> --
>
>
> Dr. Guillermo P. Ortiz
> Electromagnetismo Aplicado
> Dto. Física, Facultad de Ciencias Exactas
> Universidad Nacional del Nordeste
> Avda Libertad 5460, Campus UNNE.
> W3404AAS Corrientes, Argentina.
> (+54) 379-4424678 interno 4613
> gortiz* at *unne edu ar
>
>
> _______________________________________________
> pdl-devel mailing 
> listpdl-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/pdl-devel
>
> _______________________________________________
> pdl-devel mailing list
> pdl-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pdl-devel
>
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to