Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

It's histogram you are looking for, not index. Actually, indexND example pretty clear shows that it does something else. In your case, some selected elements from all-zeroes piddle became incremented from 0 to 1, that's all. Rather (demo output looks correct to me):

use strict; use warnings; use feature 'say'; use PDL; use PDL::IO::Image; use open IO => 'raw'; my $data = `convert -size 5x5 radial-gradient:red-green bmp:-`; my $im = PDL::IO::Image-> new_from_file( \$data ) -> pixels_to_pdl -> long; my $flat = $im-> copy; $flat-> slice( [],[],2 )-> inplace-> shiftleft( 16, 0 ); $flat-> slice( [],[],1 )-> inplace-> shiftleft( 8, 0 ); my $cube = $flat-> mv( 2, 0 ) -> sumover -> flat -> hist( 0, 0x1000000, 1 ) -> reshape( 256, 256, 256 ); ### Demo say $im; say my $uniq_reds = $im-> slice( [],[],0 )-> uniq; say my $uniq_greens = $im-> slice( [],[],1 )-> uniq; say $cube-> dice( $uniq_reds, $uniq_greens, 0 ); __END__ [ [ [ 0 0 0 0 0] [ 0 75 128 75 0] [ 0 128 255 128 0] [ 0 75 128 75 0] [ 0 0 0 0 0] ] [ [128 128 128 128 128] [128 91 64 91 128] [128 64 0 64 128] [128 91 64 91 128] [128 128 128 128 128] ] [ [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] ] ] [0 75 128 255] [0 64 91 128] [ [ [ 0 0 0 1] [ 0 0 4 0] [ 0 4 0 0] [16 0 0 0] ] ]

In reply to Re: How to use a pdl as an index into another pdl by vr
in thread How to use a pdl as an index into another pdl by Barrabas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (None)
    As of 2021-10-16 03:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (69 votes). Check out past polls.

      Notices?