Hello Ed, yes you are right. Changing to real /home directory I can run the script with inlinePdlpp. Curiously no problem with running other perl codes I did not have there. Also, I can check the David solution against your firstnonzeroover solution, both works fine for me given the same results. But, your version is almost double quicker !
Thanks you all developers, David, Ingo and for your work and helps Regards El dom, 27 oct 2024 a las 22:42, Ed . (<ej...@hotmail.com>) escribió: > Hi Guillermo, > > This may be very similar to the problem in > https://stackoverflow.com/questions/13502156/what-are-possible-causes-of-failed-to-map-segment-from-shared-object-operation, > and also actually faced by Ingo not so long ago. I suspect it's because the > directory you're using doesn't allow code execution from files there. If > that's right, you'd need to instead run the script (with the compiling and > especially the dynaloading) in a place where you *can* execute code from. > > The alternative here is to install the very latest "git master" version of > PDL, doing effectively the "git clone ..." from Q4.9 of > https://metacpan.org/pod/PDL::FAQ, then "cd pdl; perl Makefile.PL; make > install". Alternatively you can use cpanm: "cpanm > https://github.com/PDLPorters/pdl/tarball/master". > <https://metacpan.org/pod/PDL::FAQ> > PDL::FAQ <https://metacpan.org/pod/PDL::FAQ> > Frequently asked questions about PDL > metacpan.org > Best regards, > Ed > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 28 October 2024 1:24 AM > *To:* Ed . <ej...@hotmail.com> > *Cc:* perldl <pdl-gene...@lists.sourceforge.net> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Hello Ed, > > > My PDL version is > 2.084 > > > Here the output after to add to end of the line: > > use inline ...build_noisy=>1, force_build=>1 > > ===================================== > validate Stage > get_maps Stage > Starting "perl Makefile.PL" Stage > Generating a Unix-style Makefile > Writing Makefile for pru_fnzo_pl_5262 > Writing > MYMETA.yml and MYMETA.json > Finished "perl > Makefile.PL" Stage > > Starting "make" Stage > Running > Mkbootstrap for pru_fnzo_pl_5262 () > chmod 644 " > pru_fnzo_pl_5262.bs" > "/opt/perl5/perls/perl-5.36.0/bin/perl" -MExtUtils::Command::MM -e > 'cp_nonempty' -- pru_fnzo_pl_5262.bs blib/arch/auto/pru_fnzo_pl_5262/ > pru_fnzo_pl_5262.bs 644 > > "/opt/perl5/perls/perl-5.36.0/bin/perl" > "-I/opt/perl5/perls/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux" > "-MPDL::PP=pru_fnzo_pl_5262 > ,pru_fnzo_pl_5262,pru_fnzo_pl_5262,," pru_fnzo_pl_5262.pd > touch pru_fnzo_pl_5262.pm > "/opt/perl5/perls/perl-5.36.0/bin/perl" > "/opt/perl5/perls/perl-5.36.0/lib/5.36.0/ExtUtils/xsubpp" -typemap > '/opt/perl5/perls/perl-5.3 > 6.0/lib/5.36.0/ExtUtils/typemap' -typemap > '/opt/perl5/perls/perl-5.36.0/lib/5.36.0/ExtUtils/typemap' -typemap > '/opt/perl5/perls/perl-5 > .36.0/lib/site_perl/5.36.0/x86_64-linux/PDL/Core/typemap' > pru_fnzo_pl_5262.xs > pru_fnzo_pl_5262.xsc > mv pru_fnzo_pl_5262.xsc pru_fnzo_pl_5262.c > cc -c > "-I/opt/perl5/perls/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux/PDL/Core" > -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong > -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 > -D_FORTIFY_SOURCE=2 -O2 -DVERSION=\"0.00\" -DXS_VERSION=\"0 > .00\" -fPIC "-I/opt/perl5/perls/perl-5.36.0/lib/5.36.0/x86_64-linux/CORE" > pru_fnzo_pl_5262.c rm -f > blib/arch/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so > cc -shared -O2 > -L/usr/local/lib -fstack-protector-strong pru_fnzo_pl_5262.o -o > blib/arch/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so > \ > \ > > > chmod 755 blib/arch/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so > Finished "make" Stage > > Starting "make install" Stage > > "/opt/perl5/perls/perl-5.36.0/bin/perl" -MExtUtils::Command::MM -e > 'cp_nonempty' -- pru_fnzo_pl_5262.bs blib/arch/auto/pru_fnzo_pl_5262/ > pru_fnzo_pl_5262.bs 644 > Files found in blib/arch: installing files in blib/lib into architecture > dependent library tree > Finished "make install" Stage > > > Starting Cleaning Up Stage > Finished Cleaning Up Stage > > Had problems > bootstrapping Inline module 'pru_fnzo_pl_5262' > > Can't load > '/mnt/diskHD/home/gortiz/Proyectos/Clasifica/_Inline/lib/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so' > for module pru_fnzo_pl_5262: > /mnt/diskHD/home/gortiz/Proyectos/Clasifica/_Inline/lib/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so: > failed to map segment from shared object at > /opt/perl5/perls/perl-5.36.0/lib/5.36.0/x86_64-linux/DynaLoader.pm line 206. > at /opt/perl5/perls/perl-5.36.0/lib/site_perl/5.36.0/Inline.pm line 541. > > > at codes/pru_fnzo.pl line 0. > INIT failed--call queue aborted. > > ============================ > > Seems that the lib generated was installed in blib/lib, but after that I > can load the code > Maybe I need to rebuild my tree structure, I did not remember how to do > that if it is the case. > > Regards, > > G. > > > > > > > > El dom., 27 de octubre de 2024 21:44, Ed . <ej...@hotmail.com> escribió: > > Hi Guillermo, > > Please keep at least the pdl-general mailing list on Cc, since this > discussion might help someone in the future googling with similar problems. > > Could you try changing the "use Inline" line to read: > > use Inline Pdlpp => 'DATA', build_noisy => 1, force_build => 1; > > Then re-run it and send the output? You don't need to read the PP doc, > that is for writing/updating the code, not running it. If you want more > directly-useful info, you might do "perldoc Inline" and/or "perldoc > Inline::Pdlpp". I'm using 5.32 here, it shouldn't make any difference what > Perl version you have so long as it's >= 5.10.1. > > It *will* be helpful if you can include what version of PDL you have: > perl -MPDL -E 'say $PDL::VERSION' > > Best regards, > Ed > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 28 October 2024 12:32 AM > *To:* Ed . <ej...@hotmail.com> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Hello Ed, > > before to check the reference for PP and from my impatients > I try to run a code that I named pru_fnzo.pl with the lines from > your message from : use strict ... to the end > and with a bangshe #!/usr/bin/env perl > and the result was > > ========= > perl codes/pru_fnzo.pl > Had problems bootstrapping Inline module 'pru_fnzo_pl_5262' > > Can't load > '/mnt/diskHD/home/gortiz/Proyectos/Clasifica/_Inline/lib/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so' > for module pru_fnzo_pl_5262: > /mnt/diskHD/home/gortiz/Proyectos/Clasifica/_Inline/lib/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.so: > failed to map segment from shared object at > /opt/perl5/perls/perl-5.36.0/lib/5.36.0/x86_64-linux/DynaLoader.pm line 206. > at /opt/perl5/perls/perl-5.36.0/lib/site_perl/5.36.0/Inline.pm line 541. > > > at codes/pru_fnzo.pl line 0. > INIT failed--call queue aborted. > ========================== > > Seems like I need to read first PP, is not it? > I am using perlbrew maybe with an older perl version (5.36.0) than you are > expecting? > > Regards > > > > > > > El dom., 27 de octubre de 2024 15:47, Ed . <ej...@hotmail.com> escribió: > > Hi Guillermo, > > I've just added to PDL::Ufunc "firstnonzeroover", and the script below > produces this output to demo it works: > > in= > [ > [0 0 3 4] > [0 5 0 1] > ] > out=[3 5] > > If you don't want to install the very latest PDL from git "master", see > below for a slightly cut-down Inline::Pdlpp so you can try it. Based on > previous discussion, you probably want this code: > > $final_image = $imn->mv(-1,0)->slice('-1:0')->firstnonzeroover; > > You're exactly right that "pp_def" sets up all the broadcasting stuff, see > https://metacpan.org/pod/PDL::PP for a guide. The "leftzero" stuff is a > term from R.S Bird's paper at > https://academic.oup.com/comjnl/article-pdf/32/2/122/1445670/320122.pdf, > it just means no further computation will make a difference as of that > point, so the loop can conclude there. > > The script you could modify to have that, or a more correct version: > > use strict; > use warnings; > use PDL; > use Inline Pdlpp => 'DATA';#, clean_after_build => 0; > > my $in = pdl '0 0 3 4; 0 5 0 1'; > print "in=$in\nout=", $in->firstnonzeroover, "\n"; > > __DATA__ > __Pdlpp__ > use PDL::Types qw(ppdefs_all); > > %over = ( > firstnonzeroover => { def=>'$GENERIC() tmp', txt => 'first non-zero > value', init => '0', > otype => '', op => 'tmp = $a();', leftzero => 'tmp' }, > ); > my $func = 'firstnonzeroover'; > my $def = $over{$func}{def}; > my $txt = $over{$func}{txt}; > my $init = $over{$func}{init}; > my $otype = $over{$func}{otype}; > my $op = $over{$func}{op}; > my $leftzero = $over{$func}{leftzero}; > pp_def( > $func, > HandleBad => 1, > Pars => 'a(n); ' . $otype . ' [o]b();', > GenericTypes => [ppdefs_all], > Code => <<EOF, > $def = $init; > int flag = 0; > loop(n) %{ > PDL_IF_BAD(if ( \$ISBAD(a()) ) continue; flag = 1;,) > $op > if ( $leftzero ) break; > %} > PDL_IF_BAD(if (!flag) { \$SETBAD(b()); \$PDLSTATESETBAD(b); } else,) > \$b() = tmp; > EOF > ); > > Best regards, > Ed > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 25 October 2024 11:49 PM > *To:* Ed . <ej...@hotmail.com> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Hello Ed, > I'm not sure what help could be useful for you > from my curiosity rather than developers capabilities that I have. > > It is interesting that PP_def is the master part for broadcasting > from loop(n) I suppose but not sure. > > the hash of hash %over have the key zcover for the hash > > { def=>'char tmp', txt => '== 0', init => 1, alltypes => 1, > otype => 'int+', op => 'tmp &= ($a() == 0);', leftzero => '!tmp' }, > > and it seems that op is the key for the $op variable that is > used inside loop(n) for performing zcover I guess. > > I did not understand the trick for $leftzero, they reach a 'break' for > what? > > Lines belows appear pp_def for diffover, or diff2 seems to be more > friendly for a type of CODE like the suggested by David could be placed > for a firstnonzeroover implementation task > > But do not worry about explaining to me. As you can see I have not > expertise > with pp_def nomenclature > > Regards > > > > > > > > > > El vie, 25 oct 2024 a las 17:06, Ed . (<ej...@hotmail.com>) escribió: > > Hi Guillermo, > > Glad that helps a bit. > > Look in Basic/Ufunc/ufunc.pd, and I'd start from "zc" (which is generated > from a hash). Note especially the "leftzero" mechanism, which is the > shortcut. > > Best regards, > Ed > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 25 October 2024 9:03 PM > *To:* Ed . <ej...@hotmail.com> > *Cc:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>; > pdl-gene...@lists.sourceforge.net <pdl-gene...@lists.sourceforge.net> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Thanks Ed, > using $inds runs quicker (a little), maybe. > I believe that you are right a 'firstnonzeroover' could be a such operation > that I need. > From where I can learn how to do xfor for Ufunc ? > > Regards > > > > > > > > > > El vie, 25 oct 2024 a las 14:38, Ed . (<ej...@hotmail.com>) escribió: > > Hi Guillermo, > > Glad you have progress! A quick change that will compute a bit less is to > change: > > $image->where($sub_image > 0) .= $sub_image->where($sub_image > 0); > > to: > > my $inds = $sub_image > 0; > $image->where($inds) .= $sub_image->where($inds); > > The algorithm you're using looks like it takes, for each pixel channel, > the last (highest-n) non-zero pixel channel value. There isn't a "first > non-zero" (which you could use with a slice("-1:0")) operation that I know > of, but if there were, it would operate over the whole image-stack in one > go, which would probably be optimally quick, especially since it would > shortcut. Also with the miracle of auto-pthreading and broadcasting, it > could use POSIX threads. > > Any volunteers to write a "firstnonzeroover" xform for Ufunc? > > Best regards, > Ed > > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 25 October 2024 5:29 PM > *To:* Ed . <ej...@hotmail.com> > *Cc:* David Mertens <dcmertens.p...@gmail.com>; > pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>; > pdl-gene...@lists.sourceforge.net <pdl-gene...@lists.sourceforge.net> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Thanks to Ingo, David, Ed, > > After some minor modification to the David help, and using: > > use PDL::NiceSlice; > my $image = $imn(,,,(0)); > for my $layer (1 .. $imn->dim(3)-1) { > my $sub_image = $imn(,,,($layer)); > $image->where($sub_image > 0) .= $sub_image->where($sub_image > 0); > } > > works fine to solve my problem, but yes it is some slow thinking in > hundreds of these > operations. Nevertheless, it does not impact the overall computation cost. > > The change I made is $image->dim(3) => $imn->dim(3)-1, because $image is > (3,x,y) and the number of layer is > in $imn->dim(3) > > Regards > > > > El vie, 25 oct 2024 a las 9:42, Ed . (<ej...@hotmail.com>) escribió: > > A thing I didn't think of before: to add to David's thought, you might > consider adding a fourth value to make your images RGBA, where the A is > "alpha", i.e. opacity. Then you would only add each pixel (or channel > value) to the final image where its numerical value * the alpha value was > >0 (or, if you're doing addition or "or"-ing, just add/or the value * the > alpha, which if 0 does nothing). > > Best regards, > Ed > ------------------------------ > *From:* David Mertens <dcmertens.p...@gmail.com> > *Sent:* 25 October 2024 11:10 AM > *To:* Ed . <ej...@hotmail.com> > *Cc:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar>; > pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>; > pdl-gene...@lists.sourceforge.net <pdl-gene...@lists.sourceforge.net> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Hello Guillermo, > > You said something interesting. You discussed a sub-image with "a red > circle" and another with "a blue rectangle". But what you have are full > images: an image with a red circle is an image with a red circle and a > black background. It sounds like you want to treat that background color as > transparent, then "layer" the images by overwriting the non-transparent > pixels. > > If I had to do this myself, I can only think of a way to do this using a > Perl loop. If you find that this loop is too slow, then think of ways to > rewrite using a PDL expression, but only if you actually deem it to be too > slow. It would go something like this: > > use PDL::NiceSlice; > my $image = $imn(,,,(0)); > for my $layer (1 .. $image->dim(3)) { > my $sub_image = $imn(,,,($layer)); > $image->where($sub_image > 0) .= $sub_image->where($sub_image > 0); > } > > This isn't perfect: if you have a pixel in your sub-image that is pure > red, it'll copy the red channel to the final image, but not the green or > blue. That's as much as I can put into it for now, thouogh, and hopefully > it's enough to get you started. > > David > > On Thu, Oct 24, 2024 at 3:30 PM Ed . <ej...@hotmail.com> wrote: > > Hi Guillermo, > > That will depend on how you want to combine each pixel. If you can deal > independently with each R/G/B value, then to just add the values together, > you'd do: > > $im = $imn->mv(-1,0)->sumover; > > Otherwise you'll have to spell out a bit more what you mean by sorting. > Another operation that might be useful is "borover" (bitwise or, on each > R/G/B value along the sequence of images). > > Best regards, > Ed > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 24 October 2024 4:52 PM > *To:* Ed . <ej...@hotmail.com> > *Cc:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>; > pdl-gene...@lists.sourceforge.net <pdl-gene...@lists.sourceforge.net> > *Subject:* Re: [Pdl-devel] project ordered sequence image > > Hello again, thanks to Ed for show me a typo error > in my example. Where I wrote > > $im=$imn->reduce('op',2); > > it must say > > $im=$imn->reduce('op',3); > > But, the question remain in how to do an 'op' that > result in a sorted overlapping between all the sub images > > In other words. Suppose you have n=0 sub image with > a red circle and in n=1 a sub image with a blue rectangle. > Some pixeles of both images are in common. > Then, what I want is to get a composed image that shows > the red circle overlapping the blue rectangle. The same > idea for many subimages with sorted overlapping. > > Regards, > > > > > > > > > > > > El jue, 24 oct 2024 a las 9:57, Guillermo P. Ortiz (< > gor...@exa.unne.edu.ar>) escribió: > > Hello Ed, > thanks for your reply. > That I trying to mean with 'reduce' is some of > projection operation (op) like in PDL::Reduce module > that performs "(op)over" to reduce to N-1 > dimension after some operation over the set of > (3,x,y, n) to (3,x,y) rgb images. I mean > a composed rgb image from a set of (layer) n rgb images. > For example: > > $imn-> info : pdl D [3,nx,ny,n] > $im=$imn->reduce('op',2); > $im-> info : pdl D [3,nx,ny] > > Then, maybe I need to introduce some "sort" > operation in order that when I reduce to one > composed $im image each layer in $imn overlap > the following layer. But, I did not realize how to do that > using some pdl trick. > > Thanks a lot for your help > > Regards > > > > El jue, 24 oct 2024 a las 9:12, Ed . (<ej...@hotmail.com>) escribió: > > Hi Guillermo, > > I believe the situation you're describing is you have effectively a series > of (3,x,y) images. You mention "reducing", but you haven't said what you > mean by that - would it turn that series of images into one image? > > wpic is intended to write out a single image, so an ndarray with multiple > images won't work with that. To write out a series of images as a movie you > could use wmpeg, or just to store the data you could use > https://metacpan.org/pod/PDL::IO::FastRaw and specifically writefraw. > Otherwise to write each image in its own file you could use something like: > > $_->wpic(sprintf "img%03d.png", $count++) for $pdl->dog; > > Does that help? > > Best regards, > Ed > ------------------------------ > *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>; > pdl-gene...@lists.sourceforge.net <pdl-gene...@lists.sourceforge.net> > *Subject:* [Pdl-devel] project ordered sequence image > > Hello everyone, > > I have created a pdl with structure (3,size_x,size_y,np) > in order to manage different layer features to compose an rgb > image. > > The idea that I can not connect yet is how to "reduce" over dim 3 > to project to 3 X s_x X s_y rgb image in ordered fashion sequence. For > example, > suppose that for np=0, 1 and 2, in the resulting image is only view of 2 > that > is allowed by 1 and 0 layers, in that order. > > I am trying to use wpic command from PDL::IO::Pic module > to convert via for example pnmtopng using options for it. > There are hashes like {FLAGS => options} used for options > {CONVERTER => 'pnmtopng'} indicating which conversor to use. > But is seems to be intended of rgb 3(4) X s_x X s_y > > Thanks for your attention in advance > > Regards > > > -- > > > Dr. Guillermo P. Ortiz > Electromagnetismo Aplicado > Dto. Física, Facultad de Ciencias Exactas > Universidad Nacional del Nordeste > Avda Libertad 5460 > <https://www.google.com/maps/search/Avda+Libertad+5460?entry=gmail&source=g>, > Campus UNNE. > W3404AAS Corrientes, Argentina. > (+54) 379-4424678 interno 4613 > gortiz* at *unne edu ar > > _______________________________________________ > pdl-devel mailing list > pdl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-devel > > > > -- > "Debugging is twice as hard as writing the code in the first place. > Therefore, if you write the code as cleverly as possible, you are, > by definition, not smart enough to debug it." -- Brian Kernighan > >
_______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel