You can subscribe to this list here.
2015 |
Jan
|
Feb
(44) |
Mar
(75) |
Apr
(42) |
May
(50) |
Jun
(82) |
Jul
(17) |
Aug
(45) |
Sep
(32) |
Oct
(32) |
Nov
(41) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2016 |
Jan
(9) |
Feb
(5) |
Mar
(6) |
Apr
(6) |
May
(34) |
Jun
(47) |
Jul
(10) |
Aug
(2) |
Sep
(6) |
Oct
(35) |
Nov
(6) |
Dec
|
2017 |
Jan
(7) |
Feb
(5) |
Mar
(3) |
Apr
(2) |
May
(12) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
|
Nov
(5) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
(16) |
Apr
(7) |
May
(10) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(1) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
(32) |
May
(11) |
Jun
(5) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
2021 |
Jan
|
Feb
(25) |
Mar
(38) |
Apr
(11) |
May
(3) |
Jun
(6) |
Jul
(2) |
Aug
(22) |
Sep
(12) |
Oct
(18) |
Nov
(6) |
Dec
(1) |
2022 |
Jan
(5) |
Feb
(47) |
Mar
(6) |
Apr
(9) |
May
(7) |
Jun
(2) |
Jul
(5) |
Aug
(15) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2023 |
Jan
|
Feb
(4) |
Mar
(6) |
Apr
(3) |
May
(2) |
Jun
(2) |
Jul
(3) |
Aug
(6) |
Sep
(17) |
Oct
(5) |
Nov
|
Dec
|
2024 |
Jan
(8) |
Feb
(4) |
Mar
(1) |
Apr
(8) |
May
(13) |
Jun
(10) |
Jul
|
Aug
|
Sep
(1) |
Oct
(16) |
Nov
(9) |
Dec
(18) |
2025 |
Jan
(47) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(8) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ed . <ej...@ho...> - 2024-12-03 22:16:35
|
Hi all, This is due to a known problem in MetaCPAN the website (not CPAN as a whole). It's triggered here by me releasing modules as independent distributions that are currently part of the PDL distro (such as PDL::Transform::Proj4); when MetaCPAN sees such a new release, it de-indexes the distro that package was in before, which here is the whole of PDL. See https://github.com/metacpan/metacpan-web/issues/3245 for more context. This should cease to be an issue once I have finished releasing all the contained non-fundamental parts of PDL (which is many, many of them) especially the ones with external dependencies (GSL, Proj4, HDF, GD, OpenGL, the Fortran ones, among others). Shortly after that, I will release the new, slimmed-down PDL. You may see a resemblance between this and the previously (in 2015 and onwards) discussed splitting of PDL into a PDL::Core, other parts, and then a rump PDL. I feel this is a better approach, particularly since those externally-dependent modules could not actually be relied on since you might install PDL without e.g. GSL; to get PDL with GSL, you'd need to reinstall the whole of PDL again and hope for the best. What this means for users of PDL is currently that, as previously, if you make code that needs certain parts of "main" PDL (like the GSL bindings), you need to express this in the metadata of your project. What it will mean when the process is finished, is that PDL will install (much) quicker, and that to get those other modules, you expressly install them, and they will install very quickly (on one device here, Transform::Proj4 builds and tests in about 2 secs, and PDL::GSL in about 10). Any questions or problems, please let me know (possibly on the list)! Best regards, Ed ________________________________ From: David Mertens <dcm...@gm...> Sent: 03 December 2024 2:22 PM To: Jörg Sommrey <jo...@so...>; pdl-devel <pdl...@li...> Subject: Re: [Pdl-devel] PDL disappeared from CPAN? Fyi, this was resolved. I just realized I forgot to CC-all on my reply, so I'm sending this back to the mailing list. David On Tue, Dec 3, 2024, 8:21 AM Jörg Sommrey <jo...@so...<mailto:jo...@so...>> wrote: Probably a transient malfunction on CPAN. Searching CPAN for "PDL" produced some hits, but not including "PDL" or "PDL::Core". Accessing https://metacpan.org/pod/PDL::Core etc. resulted in a 404 error page. Looks like everything is back now. -jo On Tue 03 Dec 2024 01:58:30 PM CET, David Mertens <dcm...@gm...<mailto:dcm...@gm...>> wrote: > I have no trouble locating PDL on metacpan, and from there the > documentation links all work. Googling PDL::Core pulls up meetacpan link as > the first hit. > > Do you mean metacpan or the CPAN client? > > David > > On Tue, Dec 3, 2024, 5:12 AM Jörg Sommrey <jo...@so...<mailto:jo...@so...>> wrote: > >> Hi all, >> >> what happened to PDL on CPAN? Cannot see any of the core modules anymore. >> >> -jo >> >> >> _______________________________________________ >> pdl-devel mailing list >> pdl...@li...<mailto:pdl...@li...> >> https://lists.sourceforge.net/lists/listinfo/pdl-devel >> |
From: David M. <dcm...@gm...> - 2024-12-03 14:22:45
|
Fyi, this was resolved. I just realized I forgot to CC-all on my reply, so I'm sending this back to the mailing list. David On Tue, Dec 3, 2024, 8:21 AM Jörg Sommrey <jo...@so...> wrote: > Probably a transient malfunction on CPAN. Searching CPAN for "PDL" > produced some hits, but not including "PDL" or "PDL::Core". Accessing > https://metacpan.org/pod/PDL::Core etc. resulted in a 404 error page. > > Looks like everything is back now. > > -jo > > > On Tue 03 Dec 2024 01:58:30 PM CET, David Mertens > <dcm...@gm...> wrote: > > > I have no trouble locating PDL on metacpan, and from there the > > documentation links all work. Googling PDL::Core pulls up meetacpan link > as > > the first hit. > > > > Do you mean metacpan or the CPAN client? > > > > David > > > > On Tue, Dec 3, 2024, 5:12 AM Jörg Sommrey <jo...@so...> wrote: > > > >> Hi all, > >> > >> what happened to PDL on CPAN? Cannot see any of the core modules > anymore. > >> > >> -jo > >> > >> > >> _______________________________________________ > >> pdl-devel mailing list > >> pdl...@li... > >> https://lists.sourceforge.net/lists/listinfo/pdl-devel > >> > > > |
From: Jörg S. <jo...@so...> - 2024-12-03 10:12:42
|
Hi all, what happened to PDL on CPAN? Cannot see any of the core modules anymore. -jo |
From: Luis M. <mo...@ic...> - 2024-11-21 15:55:39
|
On Thu, Nov 21, 2024 at 03:09:37PM +0000, Ed . wrote: > Hi Luis, > > Thank you for both the code and the explanation! I was aware of the limitations of diffover for this (including its name - just "diff" caused clashes with Text::Diff in a downstream module). I'm proposing to rename "diffover" to "numdiff" (for numerical differentiation) in the next version of PDL, any objections? However, it just takes the differences between consecutive values. I would call it firstdiff, as there are also second, third, etc. diffs. These are analogous, but not equal, to the corresponding (first, second, etc.) derivatives one find in calculus, and may be used to build approximate derivatives, as in the examples. > I considered using diff2 in my quickly-written prototype, but chose > diffover so as not to shrink the dim by 1. There are other PDL methods that allow the user to specify what to do with the boundaries. Maybe the same should be done here. In my solution the boundary could be kept if the function is periodic, but otherwise, it should be thrown away. Another alternative is to add values beyond the boundary: repeating the boundary value would correspond to a 0 value for the derivative at the boundary. One could also add f_{n+1}=2f_{n}-f_{n-1}, which would correspond to a null curvature at the boundary. Or the easiest, which is to trim down the derivative at the boundary by droping the last element for forward differences, the first for backward differences and both for centered differences. > I am also keen to capture the 3 functions you've made, probably with > "partial" going into Ufunc, and gaining an options param that has > "difference" of either "forward", "backward", or "centred", or > "shrink" using diff2. "div" and "curl" would then "just" be examples > in the docs. Does anyone see any difficulties with this? Boyd, I don't > feel this would clash with an Advent posting in any important way, but > I'm very pleased to hear your thoughts if you disagree :-) Would be useful. Notice that I assumed the function was defined on a regular grid. If not, more elaborate schemes would be needed to estimate the centered derivative. Another alternative for finding derivative, which may be useful in some cases, is to make a Fourier transform of the data, multiply it by i()*(wavevector) and then transform back. Best regards, Luis > > Best regards, > Ed > -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | mo...@fi... /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB |
From: Ed . <ej...@ho...> - 2024-11-21 15:09:52
|
Hi Luis, Thank you for both the code and the explanation! I was aware of the limitations of diffover for this (including its name - just "diff" caused clashes with Text::Diff in a downstream module). I'm proposing to rename "diffover" to "numdiff" (for numerical differentiation) in the next version of PDL, any objections? I considered using diff2 in my quickly-written prototype, but chose diffover so as not to shrink the dim by 1. I am also keen to capture the 3 functions you've made, probably with "partial" going into Ufunc, and gaining an options param that has "difference" of either "forward", "backward", or "centred", or "shrink" using diff2. "div" and "curl" would then "just" be examples in the docs. Does anyone see any difficulties with this? Boyd, I don't feel this would clash with an Advent posting in any important way, but I'm very pleased to hear your thoughts if you disagree :-) Best regards, Ed ________________________________ From: Luis Mochan <mo...@ic...> Sent: 20 November 2024 6:05 PM To: Boyd Duffee <boy...@gm...> Cc: pdl-devel <pdl...@li...>; perldl <pdl...@li...> Subject: Re: [Pdl-devel] curl of vector Hi Boyd, About higher dimensions, if you have a vector field with coordinates V_i in D dimensions, you can build a matrix of derivatives M_ij= partial_i V_j where partial_j denotes the partial derivative with respect to the j-th coordinate. You can then take twice its antisymmetric part A_ij=partial_i V_j-partial_j V_i such that A_ij=-A_ji. In one dimension, A_xx=0 In two dimensions A_xx=A_yy=0 and Axy=-Ayx, so there is only one independent component, i.e., the curl in 2D is a scalar, the only independent component of a 2x2 antysymmetric matrix. In three dimensions all diagonal terms are zero and the three above the diagonal equal minus the three below the diagonal, thus there are three independent components, as in a vector. Acually, the curl would be C=(A_yz, Azx, Axy)=(-A_zy, -A_xz, -A_yx). Thus you may think of the curl as the elements of an antisymmetric matrix or as the elements of a vector. In four dimensions A would have 4x4=16 components, the four along the diagonal are zero and the six above the diagonal are minus the six below, so there are 6 independent components. Thus, one cannot identify the curl with a 4 dimensional vector, nor a 4x4 general matrix, but it may still be identified with the antisymmetric matrix. In general, the antisymmetric part of the matrix of derivatives may be identified with the curl in an arbitrary number D of dimensions, but only in 3D can it be identified with a vector and in 2D with a scalar. (Actually, pseudo vector and pseudo scalar). The case of 4D is frequently used in relativistic calculations. For example, the electromagnetic field is the 4D curl of the electromagnetic potentials. Regards, Luis On Wed, Nov 20, 2024 at 05:22:10PM +0000, Boyd Duffee wrote: > Hi Ingo, > > I'm quite interested in what your use case is. It sounds like a great > Advent Calendar entry (simple question, complete answer) if I could base it > on an actual need. People don't get excited about "an exercise" as much as > they do about someone trying to solve a problem, whether it's circulation > in a fluid or some EM field calculation. As any that I could think of would > be rather artificial, can you tell us yours? > > Knowing the use case would also help with giving it a name in case someone > decides that their Christmas project is writing a module that computes div, > grad, curl and whether to name it PDL::Fields or PDL::VectorCalc. > > (I'm now wondering if a curl over a 2D or 5D vector field makes any sense) > > cheers, > Boyd > > On Wed, 20 Nov 2024 at 10:18, Ed . <ej...@ho...> wrote: > > > This (untested) should work, as it is a fairly direct translation of the > > formula: > > > > $pP = $vec->slice('(0)')->diffover; # no mv as x dim already bottom > > $px = $coords->slice('(0)')->diffover; > > $pQ = $vec->slice('(1)')->mv(1,0)->diffover->mv(0,1); > > $py = $coords->slice('(1)')->mv(1,0)->diffover->mv(0,1); > > $pR = $vec->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > $pz = $coords->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > > > $curl = $vec->zeroes; > > $curl->slice('(0)') .= $pR/$py - $pQ/$pz; > > $curl->slice('(1)') .= $pP/$pz - $pR/$px; > > $curl->slice('(2)') .= $pQ/$px - $pP/$py; > > > > The $curl could be a cat of those 3 expressions, with ->mv(-1,0); there's > > probably a clever way to make one copy of each ndarray and then do inplace > > operations with less mving, and the whole thing could become a PP > > operation, but let's see if this is conceptually correct first! > > > > Best regards, > > Ed > > > > ------------------------------ > > *From:* Ed . <ej...@ho...> > > *Sent:* 20 November 2024 9:54 AM > > *To:* perldl <pdl...@li...>; pdl-devel < > > pdl...@li...>; Ingo Schmid <in...@gm...> > > *Subject:* Re: [Pdl-devel] curl of vector > > > > Hi Ingo, > > > > I'm not aware of any, but I had a quick google to find the formula (I know > > vaguely what divergence and curl are having watched a 3blue1brown video > > about it some time ago). I couldn't find any implementations in Python or > > Fortran. > > > > This ( > > https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula > > 6.17) indicates the formula for curl is: > > > > If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, Qz, Rz, > > Rx, and Ry all exist, then the curl of F is defined by > > > > curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k > > = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k > > > > This suggests to me that for a 3D problem, you need a coordinates ndarray > > dim (3,x,y,z) and a vector field ndarray with the same dims. You can do the > > partial differentiation numerically by some mv-ing and then diffover ( > > https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional i,j,k > > above obviously indicate the final components of curl vector at each point. > > More to follow after I've figured out how to do the partial stuff! > > > > Best regards, > > Ed > > > > ------------------------------ > > *From:* Ingo Schmid via pdl-devel <pdl...@li...> > > *Sent:* 19 November 2024 6:06 PM > > *To:* perldl <pdl...@li...>; pdl-devel < > > pdl...@li...> > > *Subject:* [Pdl-devel] curl of vector > > > > > > Hi, > > > > is there any implementations of calculating the curl of a vector field > > around? > > > > Best wishes > > > > Ingo > > _______________________________________________ > > pdl-devel mailing list > > pdl...@li... > > https://lists.sourceforge.net/lists/listinfo/pdl-devel > > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > https://lists.sourceforge.net/lists/listinfo/pdl-devel -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | mo...@fi... /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB _______________________________________________ pdl-devel mailing list pdl...@li... https://lists.sourceforge.net/lists/listinfo/pdl-devel |
From: Luis M. <mo...@ic...> - 2024-11-20 18:05:55
|
Hi Boyd, About higher dimensions, if you have a vector field with coordinates V_i in D dimensions, you can build a matrix of derivatives M_ij= partial_i V_j where partial_j denotes the partial derivative with respect to the j-th coordinate. You can then take twice its antisymmetric part A_ij=partial_i V_j-partial_j V_i such that A_ij=-A_ji. In one dimension, A_xx=0 In two dimensions A_xx=A_yy=0 and Axy=-Ayx, so there is only one independent component, i.e., the curl in 2D is a scalar, the only independent component of a 2x2 antysymmetric matrix. In three dimensions all diagonal terms are zero and the three above the diagonal equal minus the three below the diagonal, thus there are three independent components, as in a vector. Acually, the curl would be C=(A_yz, Azx, Axy)=(-A_zy, -A_xz, -A_yx). Thus you may think of the curl as the elements of an antisymmetric matrix or as the elements of a vector. In four dimensions A would have 4x4=16 components, the four along the diagonal are zero and the six above the diagonal are minus the six below, so there are 6 independent components. Thus, one cannot identify the curl with a 4 dimensional vector, nor a 4x4 general matrix, but it may still be identified with the antisymmetric matrix. In general, the antisymmetric part of the matrix of derivatives may be identified with the curl in an arbitrary number D of dimensions, but only in 3D can it be identified with a vector and in 2D with a scalar. (Actually, pseudo vector and pseudo scalar). The case of 4D is frequently used in relativistic calculations. For example, the electromagnetic field is the 4D curl of the electromagnetic potentials. Regards, Luis On Wed, Nov 20, 2024 at 05:22:10PM +0000, Boyd Duffee wrote: > Hi Ingo, > > I'm quite interested in what your use case is. It sounds like a great > Advent Calendar entry (simple question, complete answer) if I could base it > on an actual need. People don't get excited about "an exercise" as much as > they do about someone trying to solve a problem, whether it's circulation > in a fluid or some EM field calculation. As any that I could think of would > be rather artificial, can you tell us yours? > > Knowing the use case would also help with giving it a name in case someone > decides that their Christmas project is writing a module that computes div, > grad, curl and whether to name it PDL::Fields or PDL::VectorCalc. > > (I'm now wondering if a curl over a 2D or 5D vector field makes any sense) > > cheers, > Boyd > > On Wed, 20 Nov 2024 at 10:18, Ed . <ej...@ho...> wrote: > > > This (untested) should work, as it is a fairly direct translation of the > > formula: > > > > $pP = $vec->slice('(0)')->diffover; # no mv as x dim already bottom > > $px = $coords->slice('(0)')->diffover; > > $pQ = $vec->slice('(1)')->mv(1,0)->diffover->mv(0,1); > > $py = $coords->slice('(1)')->mv(1,0)->diffover->mv(0,1); > > $pR = $vec->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > $pz = $coords->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > > > $curl = $vec->zeroes; > > $curl->slice('(0)') .= $pR/$py - $pQ/$pz; > > $curl->slice('(1)') .= $pP/$pz - $pR/$px; > > $curl->slice('(2)') .= $pQ/$px - $pP/$py; > > > > The $curl could be a cat of those 3 expressions, with ->mv(-1,0); there's > > probably a clever way to make one copy of each ndarray and then do inplace > > operations with less mving, and the whole thing could become a PP > > operation, but let's see if this is conceptually correct first! > > > > Best regards, > > Ed > > > > ------------------------------ > > *From:* Ed . <ej...@ho...> > > *Sent:* 20 November 2024 9:54 AM > > *To:* perldl <pdl...@li...>; pdl-devel < > > pdl...@li...>; Ingo Schmid <in...@gm...> > > *Subject:* Re: [Pdl-devel] curl of vector > > > > Hi Ingo, > > > > I'm not aware of any, but I had a quick google to find the formula (I know > > vaguely what divergence and curl are having watched a 3blue1brown video > > about it some time ago). I couldn't find any implementations in Python or > > Fortran. > > > > This ( > > https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula > > 6.17) indicates the formula for curl is: > > > > If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, Qz, Rz, > > Rx, and Ry all exist, then the curl of F is defined by > > > > curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k > > = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k > > > > This suggests to me that for a 3D problem, you need a coordinates ndarray > > dim (3,x,y,z) and a vector field ndarray with the same dims. You can do the > > partial differentiation numerically by some mv-ing and then diffover ( > > https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional i,j,k > > above obviously indicate the final components of curl vector at each point. > > More to follow after I've figured out how to do the partial stuff! > > > > Best regards, > > Ed > > > > ------------------------------ > > *From:* Ingo Schmid via pdl-devel <pdl...@li...> > > *Sent:* 19 November 2024 6:06 PM > > *To:* perldl <pdl...@li...>; pdl-devel < > > pdl...@li...> > > *Subject:* [Pdl-devel] curl of vector > > > > > > Hi, > > > > is there any implementations of calculating the curl of a vector field > > around? > > > > Best wishes > > > > Ingo > > _______________________________________________ > > pdl-devel mailing list > > pdl...@li... > > https://lists.sourceforge.net/lists/listinfo/pdl-devel > > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > https://lists.sourceforge.net/lists/listinfo/pdl-devel -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | mo...@fi... /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB |
From: Luis M. <mo...@ic...> - 2024-11-20 18:00:34
|
I see a problem with the use of diffover: at the boundary it takes no difference at all. (I also see a problem with the name, as it is not a reduction as the other 'over' methods). Thus, I would use diff2. Furthermore, both functions use a forward difference. One could conceive a backward difference also, or their average, or, for data on a uniform grid, the centered difference. Assuming periodic boundary conditions, the centered difference could be obtained by rotating. If the boundary conditions are not periodic then the boundary values could be thrown away. My answer would then be: use v5.36; use PDL; use PDL::NiceSlice; sub partial($var, $f){ my $g=$f->mv($var,0); return (($g->rotate(-1)-$g->rotate(1))/2)->mv(0, $var); } sub curl($f){ return pdl( partial(1,$f((2)))-partial(2,$f((1))), partial(2,$f((0)))-partial(0,$f((2))), partial(0,$f((1)))-partial(1,$f((0))), )->mv(-1,0); } sub div($f){ return partial(0,$f((0)))+partial(1,$f((1)))+partial(2,$f((2))); } sub trim3d($f){ return $f->(:,1:-2,1:-2,1:-2); } For example: my $z=zeroes(5,5,5); my $v=pdl(-$z->yvals, $z->xvals, $z->zvals)->mv(-1,0); say trim3d(curl($v)); yields [ [ [ [0 0 2] [0 0 2] [0 0 2] ] [ [0 0 2] [0 0 2] [0 0 2] ] [ [0 0 2] [0 0 2] [0 0 2] ] ] [ [ [0 0 2] [0 0 2] [0 0 2] ] [ [0 0 2] [0 0 2] [0 0 2] ] [ [0 0 2] [0 0 2] [0 0 2] ] ] [ [ [0 0 2] [0 0 2] [0 0 2] ] [ [0 0 2] [0 0 2] [0 0 2] ] [ [0 0 2] [0 0 2] [0 0 2] ] ] ] as curl(-y,x,z)=(0,0,2). Regards, Luis On Wed, Nov 20, 2024 at 10:17:36AM +0000, Ed . wrote: > This (untested) should work, as it is a fairly direct translation of the formula: > > $pP = $vec->slice('(0)')->diffover; # no mv as x dim already bottom > $px = $coords->slice('(0)')->diffover; > $pQ = $vec->slice('(1)')->mv(1,0)->diffover->mv(0,1); > $py = $coords->slice('(1)')->mv(1,0)->diffover->mv(0,1); > $pR = $vec->slice('(2)')->mv(2,0)->diffover->mv(0,2); > $pz = $coords->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > $curl = $vec->zeroes; > $curl->slice('(0)') .= $pR/$py - $pQ/$pz; > $curl->slice('(1)') .= $pP/$pz - $pR/$px; > $curl->slice('(2)') .= $pQ/$px - $pP/$py; > > The $curl could be a cat of those 3 expressions, with ->mv(-1,0); there's probably a clever way to make one copy of each ndarray and then do inplace operations with less mving, and the whole thing could become a PP operation, but let's see if this is conceptually correct first! > > Best regards, > Ed > > ________________________________ > From: Ed . <ej...@ho...> > Sent: 20 November 2024 9:54 AM > To: perldl <pdl...@li...>; pdl-devel <pdl...@li...>; Ingo Schmid <in...@gm...> > Subject: Re: [Pdl-devel] curl of vector > > Hi Ingo, > > I'm not aware of any, but I had a quick google to find the formula (I know vaguely what divergence and curl are having watched a 3blue1brown video about it some time ago). I couldn't find any implementations in Python or Fortran. > > This (https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula 6.17) indicates the formula for curl is: > > If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, Qz, Rz, Rx, and Ry all exist, then the curl of F is defined by > > curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k > = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k > > This suggests to me that for a 3D problem, you need a coordinates ndarray dim (3,x,y,z) and a vector field ndarray with the same dims. You can do the partial differentiation numerically by some mv-ing and then diffover (https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional i,j,k above obviously indicate the final components of curl vector at each point. More to follow after I've figured out how to do the partial stuff! > > Best regards, > Ed > > ________________________________ > From: Ingo Schmid via pdl-devel <pdl...@li...> > Sent: 19 November 2024 6:06 PM > To: perldl <pdl...@li...>; pdl-devel <pdl...@li...> > Subject: [Pdl-devel] curl of vector > > > Hi, > > is there any implementations of calculating the curl of a vector field around? > > Best wishes > > Ingo > _______________________________________________ > pdl-devel mailing list > pdl...@li... > https://lists.sourceforge.net/lists/listinfo/pdl-devel -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | mo...@fi... /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB |
From: Ingo S. <in...@gm...> - 2024-11-20 17:49:40
|
Hi Ed, Luis and Boyd, thanks for the replies, I haven't had the time to look into the proposed solution yet. The problem behind this is to separate the shear component (curl) from the compressional (div) component of sound waves travelling through a liquid/solid medium, i.e. tissue. Ingo On 20.11.24 6:22 PM, Boyd Duffee wrote: > Hi Ingo, > > I'm quite interested in what your use case is. It sounds like a great > Advent Calendar entry (simple question, complete answer) if I could > base it on an actual need. People don't get excited about "an > exercise" as much as they do about someone trying to solve a problem, > whether it's circulation in a fluid or some EM field calculation. As > any that I could think of would be rather artificial, can you tell us > yours? > > Knowing the use case would also help with giving it a name in case > someone decides that their Christmas project is writing a module that > computes div, grad, curl and whether to name it PDL::Fields or > PDL::VectorCalc. > > (I'm now wondering if a curl over a 2D or 5D vector field makes any sense) > > cheers, > Boyd > > On Wed, 20 Nov 2024 at 10:18, Ed . <ej...@ho...> wrote: > > This (untested) should work, as it is a fairly direct translation > of the formula: > > $pP = $vec->slice('(0)')->diffover; # no mv as x dim already bottom > $px = $coords->slice('(0)')->diffover; > $pQ = $vec->slice('(1)')->mv(1,0)->diffover->mv(0,1); > $py = $coords->slice('(1)')->mv(1,0)->diffover->mv(0,1); > $pR = $vec->slice('(2)')->mv(2,0)->diffover->mv(0,2); > $pz = $coords->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > $curl = $vec->zeroes; > $curl->slice('(0)') .= $pR/$py - $pQ/$pz; > $curl->slice('(1)') .= $pP/$pz - $pR/$px; > $curl->slice('(2)') .= $pQ/$px - $pP/$py; > > The $curl could be a |cat| of those 3 expressions, with > |->mv(-1,0)|; there's probably a clever way to make one copy of > each ndarray and then do inplace operations with less |mv|ing, and > the whole thing could become a PP operation, but let's see if this > is conceptually correct first! > > Best regards, > Ed > > ------------------------------------------------------------------------ > *From:* Ed . <ej...@ho...> > *Sent:* 20 November 2024 9:54 AM > *To:* perldl <pdl...@li...>; pdl-devel > <pdl...@li...>; Ingo Schmid <in...@gm...> > *Subject:* Re: [Pdl-devel] curl of vector > Hi Ingo, > > I'm not aware of any, but I had a quick google to find the formula > (I know vaguely what divergence and curl are having watched a > 3blue1brown video about it some time ago). I couldn't find any > implementations in Python or Fortran. > > This > (https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula > 6.17) indicates the formula for curl is: > > If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, > Qz, Rz, Rx, and Ry all exist, then the curl of F is defined by > > curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k > = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k > > This suggests to me that for a 3D problem, you need a coordinates > ndarray dim (3,x,y,z) and a vector field ndarray with the same > dims. You can do the partial differentiation numerically by some > mv-ing and then diffover > (https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional > i,j,k above obviously indicate the final components of curl vector > at each point. More to follow after I've figured out how to do the > partial stuff! > > Best regards, > Ed > > ------------------------------------------------------------------------ > *From:* Ingo Schmid via pdl-devel <pdl...@li...> > *Sent:* 19 November 2024 6:06 PM > *To:* perldl <pdl...@li...>; pdl-devel > <pdl...@li...> > *Subject:* [Pdl-devel] curl of vector > > Hi, > > is there any implementations of calculating the curl of a vector > field around? > > Best wishes > > Ingo > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > https://lists.sourceforge.net/lists/listinfo/pdl-devel > |
From: Boyd D. <boy...@gm...> - 2024-11-20 17:22:35
|
Hi Ingo, I'm quite interested in what your use case is. It sounds like a great Advent Calendar entry (simple question, complete answer) if I could base it on an actual need. People don't get excited about "an exercise" as much as they do about someone trying to solve a problem, whether it's circulation in a fluid or some EM field calculation. As any that I could think of would be rather artificial, can you tell us yours? Knowing the use case would also help with giving it a name in case someone decides that their Christmas project is writing a module that computes div, grad, curl and whether to name it PDL::Fields or PDL::VectorCalc. (I'm now wondering if a curl over a 2D or 5D vector field makes any sense) cheers, Boyd On Wed, 20 Nov 2024 at 10:18, Ed . <ej...@ho...> wrote: > This (untested) should work, as it is a fairly direct translation of the > formula: > > $pP = $vec->slice('(0)')->diffover; # no mv as x dim already bottom > $px = $coords->slice('(0)')->diffover; > $pQ = $vec->slice('(1)')->mv(1,0)->diffover->mv(0,1); > $py = $coords->slice('(1)')->mv(1,0)->diffover->mv(0,1); > $pR = $vec->slice('(2)')->mv(2,0)->diffover->mv(0,2); > $pz = $coords->slice('(2)')->mv(2,0)->diffover->mv(0,2); > > $curl = $vec->zeroes; > $curl->slice('(0)') .= $pR/$py - $pQ/$pz; > $curl->slice('(1)') .= $pP/$pz - $pR/$px; > $curl->slice('(2)') .= $pQ/$px - $pP/$py; > > The $curl could be a cat of those 3 expressions, with ->mv(-1,0); there's > probably a clever way to make one copy of each ndarray and then do inplace > operations with less mving, and the whole thing could become a PP > operation, but let's see if this is conceptually correct first! > > Best regards, > Ed > > ------------------------------ > *From:* Ed . <ej...@ho...> > *Sent:* 20 November 2024 9:54 AM > *To:* perldl <pdl...@li...>; pdl-devel < > pdl...@li...>; Ingo Schmid <in...@gm...> > *Subject:* Re: [Pdl-devel] curl of vector > > Hi Ingo, > > I'm not aware of any, but I had a quick google to find the formula (I know > vaguely what divergence and curl are having watched a 3blue1brown video > about it some time ago). I couldn't find any implementations in Python or > Fortran. > > This ( > https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula > 6.17) indicates the formula for curl is: > > If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, Qz, Rz, > Rx, and Ry all exist, then the curl of F is defined by > > curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k > = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k > > This suggests to me that for a 3D problem, you need a coordinates ndarray > dim (3,x,y,z) and a vector field ndarray with the same dims. You can do the > partial differentiation numerically by some mv-ing and then diffover ( > https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional i,j,k > above obviously indicate the final components of curl vector at each point. > More to follow after I've figured out how to do the partial stuff! > > Best regards, > Ed > > ------------------------------ > *From:* Ingo Schmid via pdl-devel <pdl...@li...> > *Sent:* 19 November 2024 6:06 PM > *To:* perldl <pdl...@li...>; pdl-devel < > pdl...@li...> > *Subject:* [Pdl-devel] curl of vector > > > Hi, > > is there any implementations of calculating the curl of a vector field > around? > > Best wishes > > Ingo > _______________________________________________ > pdl-devel mailing list > pdl...@li... > https://lists.sourceforge.net/lists/listinfo/pdl-devel > |
From: Ed . <ej...@ho...> - 2024-11-20 10:17:50
|
This (untested) should work, as it is a fairly direct translation of the formula: $pP = $vec->slice('(0)')->diffover; # no mv as x dim already bottom $px = $coords->slice('(0)')->diffover; $pQ = $vec->slice('(1)')->mv(1,0)->diffover->mv(0,1); $py = $coords->slice('(1)')->mv(1,0)->diffover->mv(0,1); $pR = $vec->slice('(2)')->mv(2,0)->diffover->mv(0,2); $pz = $coords->slice('(2)')->mv(2,0)->diffover->mv(0,2); $curl = $vec->zeroes; $curl->slice('(0)') .= $pR/$py - $pQ/$pz; $curl->slice('(1)') .= $pP/$pz - $pR/$px; $curl->slice('(2)') .= $pQ/$px - $pP/$py; The $curl could be a cat of those 3 expressions, with ->mv(-1,0); there's probably a clever way to make one copy of each ndarray and then do inplace operations with less mving, and the whole thing could become a PP operation, but let's see if this is conceptually correct first! Best regards, Ed ________________________________ From: Ed . <ej...@ho...> Sent: 20 November 2024 9:54 AM To: perldl <pdl...@li...>; pdl-devel <pdl...@li...>; Ingo Schmid <in...@gm...> Subject: Re: [Pdl-devel] curl of vector Hi Ingo, I'm not aware of any, but I had a quick google to find the formula (I know vaguely what divergence and curl are having watched a 3blue1brown video about it some time ago). I couldn't find any implementations in Python or Fortran. This (https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula 6.17) indicates the formula for curl is: If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, Qz, Rz, Rx, and Ry all exist, then the curl of F is defined by curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k This suggests to me that for a 3D problem, you need a coordinates ndarray dim (3,x,y,z) and a vector field ndarray with the same dims. You can do the partial differentiation numerically by some mv-ing and then diffover (https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional i,j,k above obviously indicate the final components of curl vector at each point. More to follow after I've figured out how to do the partial stuff! Best regards, Ed ________________________________ From: Ingo Schmid via pdl-devel <pdl...@li...> Sent: 19 November 2024 6:06 PM To: perldl <pdl...@li...>; pdl-devel <pdl...@li...> Subject: [Pdl-devel] curl of vector Hi, is there any implementations of calculating the curl of a vector field around? Best wishes Ingo |
From: Ed . <ej...@ho...> - 2024-11-20 09:55:07
|
Hi Ingo, I'm not aware of any, but I had a quick google to find the formula (I know vaguely what divergence and curl are having watched a 3blue1brown video about it some time ago). I couldn't find any implementations in Python or Fortran. This (https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl formula 6.17) indicates the formula for curl is: If F=⟨P,Q,R⟩ is a vector field in R3, and Px, Py, Pz, Qy, Qx, Qz, Rz, Rx, and Ry all exist, then the curl of F is defined by curl F = (Ry−Qz)i + (Pz−Rx)j + (Qx−Py)k = (∂R/∂y − ∂Q/∂z)i + (∂P/∂z − ∂R/∂x)j + (∂Q/∂x − ∂P/∂y)k This suggests to me that for a 3D problem, you need a coordinates ndarray dim (3,x,y,z) and a vector field ndarray with the same dims. You can do the partial differentiation numerically by some mv-ing and then diffover (https://metacpan.org/pod/PDL::Ufunc#diffover), then the notional i,j,k above obviously indicate the final components of curl vector at each point. More to follow after I've figured out how to do the partial stuff! Best regards, Ed ________________________________ From: Ingo Schmid via pdl-devel <pdl...@li...> Sent: 19 November 2024 6:06 PM To: perldl <pdl...@li...>; pdl-devel <pdl...@li...> Subject: [Pdl-devel] curl of vector Hi, is there any implementations of calculating the curl of a vector field around? Best wishes Ingo |
From: Ingo S. <in...@gm...> - 2024-11-19 18:06:32
|
Hi, is there any implementations of calculating the curl of a vector field around? Best wishes Ingo |
From: Ed . <ej...@ho...> - 2024-10-28 18:14:16
|
Hi Guillermo, Very glad to hear you got it working! Scripts are clearly being checked differently, with the code-execution the OS security layer limits being only machine-code stuff. It would be legitimate to have a different check that prevented any script at all, but that's not true here. Best regards, Ed ________________________________ From: Guillermo P. Ortiz <go...@ex...> Sent: 28 October 2024 3:13 PM To: Ed . <ej...@ho...>; pdl...@li... <pdl...@li...> Cc: perldl <pdl...@li...> Subject: Re: [Pdl-devel] project ordered sequence image 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...@ho...<mailto:ej...@ho...>>) 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/static/images/dots.png]<https://metacpan.org/pod/PDL::FAQ> PDL::FAQ<https://metacpan.org/pod/PDL::FAQ> Frequently asked questions about PDL metacpan.org<http://metacpan.org> Best regards, Ed ________________________________ From: Guillermo P. Ortiz <go...@ex...<mailto:go...@ex...>> Sent: 28 October 2024 1:24 AM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: perldl <pdl...@li...<mailto:pdl...@li...>> 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<http://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<http://pru_fnzo_pl_5262.bs> blib/arch/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.bs<http://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<http://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<http://pru_fnzo_pl_5262.bs> blib/arch/auto/pru_fnzo_pl_5262/pru_fnzo_pl_5262.bs<http://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<http://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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 28 October 2024 12:32 AM To: Ed . <ej...@ho...<mailto:ej...@ho...>> 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<http://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<http://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<http://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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 25 October 2024 11:49 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 25 October 2024 9:03 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 25 October 2024 5:29 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: David Mertens <dcm...@gm...<mailto:dcm...@gm...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>>) 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 <dcm...@gm...<mailto:dcm...@gm...>> Sent: 25 October 2024 11:10 AM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: Guillermo P. Ortiz <go...@ex...<mailto:go...@ex...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 24 October 2024 4:52 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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 (<go...@ex...<mailto:go...@ex...>>) 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 23 October 2024 4:42 PM To: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@li...<mailto:pdl...@li...> 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 |
From: Guillermo P. O. <go...@ex...> - 2024-10-28 15:13:45
|
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...@ho...>) 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 <go...@ex...> > *Sent:* 28 October 2024 1:24 AM > *To:* Ed . <ej...@ho...> > *Cc:* perldl <pdl...@li...> > *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...@ho...> 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 <go...@ex...> > *Sent:* 28 October 2024 12:32 AM > *To:* Ed . <ej...@ho...> > *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...@ho...> 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 <go...@ex...> > *Sent:* 25 October 2024 11:49 PM > *To:* Ed . <ej...@ho...> > *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...@ho...>) 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 <go...@ex...> > *Sent:* 25 October 2024 9:03 PM > *To:* Ed . <ej...@ho...> > *Cc:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@ho...>) 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 <go...@ex...> > *Sent:* 25 October 2024 5:29 PM > *To:* Ed . <ej...@ho...> > *Cc:* David Mertens <dcm...@gm...>; > pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@ho...>) 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 <dcm...@gm...> > *Sent:* 25 October 2024 11:10 AM > *To:* Ed . <ej...@ho...> > *Cc:* Guillermo P. Ortiz <go...@ex...>; > pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@ho...> 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 <go...@ex...> > *Sent:* 24 October 2024 4:52 PM > *To:* Ed . <ej...@ho...> > *Cc:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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 (< > go...@ex...>) 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...@ho...>) 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 <go...@ex...> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@li... > 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 > > |
From: Ed . <ej...@ho...> - 2024-10-27 18:49:12
|
Sorry, Missed including the lists! Best regards, Ed ________________________________ From: Ed . <ej...@ho...> Sent: 27 October 2024 6:47 PM To: Guillermo P. Ortiz <go...@ex...> Subject: Re: [Pdl-devel] project ordered sequence image 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 <go...@ex...> Sent: 25 October 2024 11:49 PM To: Ed . <ej...@ho...> 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 25 October 2024 9:03 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 25 October 2024 5:29 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: David Mertens <dcm...@gm...<mailto:dcm...@gm...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>>) 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 <dcm...@gm...<mailto:dcm...@gm...>> Sent: 25 October 2024 11:10 AM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: Guillermo P. Ortiz <go...@ex...<mailto:go...@ex...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 24 October 2024 4:52 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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 (<go...@ex...<mailto:go...@ex...>>) 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 23 October 2024 4:42 PM To: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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, Campus UNNE. W3404AAS Corrientes, Argentina. (+54) 379-4424678 interno 4613 gortiz at unne edu ar _______________________________________________ pdl-devel mailing list pdl...@li...<mailto:pdl...@li...> 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 |
From: Ed . <ej...@ho...> - 2024-10-25 20:06:34
|
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 <go...@ex...> Sent: 25 October 2024 9:03 PM To: Ed . <ej...@ho...> Cc: pdl...@li... <pdl...@li...>; pdl...@li... <pdl...@li...> 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 25 October 2024 5:29 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: David Mertens <dcm...@gm...<mailto:dcm...@gm...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>>) 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 <dcm...@gm...<mailto:dcm...@gm...>> Sent: 25 October 2024 11:10 AM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: Guillermo P. Ortiz <go...@ex...<mailto:go...@ex...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 24 October 2024 4:52 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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 (<go...@ex...<mailto:go...@ex...>>) 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 23 October 2024 4:42 PM To: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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, Campus UNNE. W3404AAS Corrientes, Argentina. (+54) 379-4424678 interno 4613 gortiz at unne edu ar _______________________________________________ pdl-devel mailing list pdl...@li...<mailto:pdl...@li...> 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 |
From: Guillermo P. O. <go...@ex...> - 2024-10-25 20:03:45
|
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...@ho...>) 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 <go...@ex...> > *Sent:* 25 October 2024 5:29 PM > *To:* Ed . <ej...@ho...> > *Cc:* David Mertens <dcm...@gm...>; > pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@ho...>) 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 <dcm...@gm...> > *Sent:* 25 October 2024 11:10 AM > *To:* Ed . <ej...@ho...> > *Cc:* Guillermo P. Ortiz <go...@ex...>; > pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@ho...> 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 <go...@ex...> > *Sent:* 24 October 2024 4:52 PM > *To:* Ed . <ej...@ho...> > *Cc:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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 (< > go...@ex...>) 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...@ho...>) 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 <go...@ex...> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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, Campus UNNE. > W3404AAS Corrientes, Argentina. > (+54) 379-4424678 interno 4613 > gortiz* at *unne edu ar > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > 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 > > |
From: Guillermo P. O. <go...@ex...> - 2024-10-25 17:40:54
|
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...@ho...>) 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 <dcm...@gm...> > *Sent:* 25 October 2024 11:10 AM > *To:* Ed . <ej...@ho...> > *Cc:* Guillermo P. Ortiz <go...@ex...>; > pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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...@ho...> 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 <go...@ex...> > *Sent:* 24 October 2024 4:52 PM > *To:* Ed . <ej...@ho...> > *Cc:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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 (< > go...@ex...>) 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...@ho...>) 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 <go...@ex...> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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, Campus UNNE. > W3404AAS Corrientes, Argentina. > (+54) 379-4424678 interno 4613 > gortiz* at *unne edu ar > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > 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 > |
From: Ed . <ej...@ho...> - 2024-10-25 17:38:47
|
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 <go...@ex...> Sent: 25 October 2024 5:29 PM To: Ed . <ej...@ho...> Cc: David Mertens <dcm...@gm...>; pdl...@li... <pdl...@li...>; pdl...@li... <pdl...@li...> 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...@ho...<mailto:ej...@ho...>>) 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 <dcm...@gm...<mailto:dcm...@gm...>> Sent: 25 October 2024 11:10 AM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: Guillermo P. Ortiz <go...@ex...<mailto:go...@ex...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 24 October 2024 4:52 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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 (<go...@ex...<mailto:go...@ex...>>) 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 23 October 2024 4:42 PM To: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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, Campus UNNE. W3404AAS Corrientes, Argentina. (+54) 379-4424678 interno 4613 gortiz at unne edu ar _______________________________________________ pdl-devel mailing list pdl...@li...<mailto:pdl...@li...> 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 |
From: Ed . <ej...@ho...> - 2024-10-25 12:43:03
|
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 <dcm...@gm...> Sent: 25 October 2024 11:10 AM To: Ed . <ej...@ho...> Cc: Guillermo P. Ortiz <go...@ex...>; pdl...@li... <pdl...@li...>; pdl...@li... <pdl...@li...> 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...@ho...<mailto:ej...@ho...>> 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 <go...@ex...<mailto:go...@ex...>> Sent: 24 October 2024 4:52 PM To: Ed . <ej...@ho...<mailto:ej...@ho...>> Cc: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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 (<go...@ex...<mailto:go...@ex...>>) 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 23 October 2024 4:42 PM To: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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, Campus UNNE. W3404AAS Corrientes, Argentina. (+54) 379-4424678 interno 4613 gortiz at unne edu ar _______________________________________________ pdl-devel mailing list pdl...@li...<mailto:pdl...@li...> 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 |
From: David M. <dcm...@gm...> - 2024-10-25 10:10:23
|
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...@ho...> 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 <go...@ex...> > *Sent:* 24 October 2024 4:52 PM > *To:* Ed . <ej...@ho...> > *Cc:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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 (< > go...@ex...>) 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...@ho...>) 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 <go...@ex...> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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, Campus UNNE. > W3404AAS Corrientes, Argentina. > (+54) 379-4424678 interno 4613 > gortiz* at *unne edu ar > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > 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 |
From: Ingo S. <in...@gm...> - 2024-10-25 08:04:18
|
Dear Guillermo, there are a number of ways you can create your images from the N-image stack. If you want a series of individual images, you could do something like this for (my $ii (0..$imn->dim(3)-1)) { $im(,,,$ii;-)->wpic("image_$ii.png"); } If you want to combine the stack, a mip can be created by $imn->reduce('maximum',3); or $imn->mv(3,0)->maximum; You can do 'average','medover','sumover', etc. instead of 'maximum', depending on what you want. There are many aggregate functions available. I hope this helps. Best, Ingo On 24.10.24 5:52 PM, Guillermo P. Ortiz wrote: > 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 > (<go...@ex...>) 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...@ho...>) 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 <go...@ex...> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl...@li... > <pdl...@li...>; > pdl...@li... > <pdl...@li...> > *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, Campus UNNE. > W3404AAS Corrientes, Argentina. > (+54) 379-4424678 interno 4613 > gortiz*at *unne edu ar > > > > _______________________________________________ > pdl-devel mailing list > pdl...@li... > https://lists.sourceforge.net/lists/listinfo/pdl-devel |
From: Ed . <ej...@ho...> - 2024-10-24 19:30:36
|
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 <go...@ex...> Sent: 24 October 2024 4:52 PM To: Ed . <ej...@ho...> Cc: pdl...@li... <pdl...@li...>; pdl...@li... <pdl...@li...> 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 (<go...@ex...<mailto:go...@ex...>>) 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...@ho...<mailto:ej...@ho...>>) 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 <go...@ex...<mailto:go...@ex...>> Sent: 23 October 2024 4:42 PM To: pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>>; pdl...@li...<mailto:pdl...@li...> <pdl...@li...<mailto:pdl...@li...>> 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, Campus UNNE. W3404AAS Corrientes, Argentina. (+54) 379-4424678 interno 4613 gortiz at unne edu ar |
From: Guillermo P. O. <go...@ex...> - 2024-10-24 16:43:35
|
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 (<go...@ex...>) 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...@ho...>) 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 <go...@ex...> >> *Sent:* 23 October 2024 4:42 PM >> *To:* pdl...@li... <pdl...@li...>; >> pdl...@li... <pdl...@li...> >> *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, Campus UNNE. >> W3404AAS Corrientes, Argentina. >> (+54) 379-4424678 interno 4613 >> gortiz* at *unne edu ar >> > |
From: Guillermo P. O. <go...@ex...> - 2024-10-24 13:03:53
|
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...@ho...>) 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 <go...@ex...> > *Sent:* 23 October 2024 4:42 PM > *To:* pdl...@li... <pdl...@li...>; > pdl...@li... <pdl...@li...> > *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, Campus UNNE. > W3404AAS Corrientes, Argentina. > (+54) 379-4424678 interno 4613 > gortiz* at *unne edu ar > |