On 5/11/2011 6:33 AM, Luca Cappelletti wrote:

This code just take sem.jpg and write sem.png I made it just to understand
if I can have control on writing output images that it's a part of my test.

Now I do not understand how can I transform the $wh_sloppy raw information
into an image composed by sem.jpg plus modification of the color $color at
the matching point at $wh_sloppy to produce a new image mapped into sem.png

The easiest way to understand what is going on is to
use the the PDL shell (either perldl or pdl2) to play
with the different expressions.  Try a command on a
small example/toy image and print the results to see
what happened.  You can use the info command to see
the details of a given piddle or the 'help vars' to
see a list of details for all the piddles in the current
session.  Reading and trying from can get you started:

  pdldoc perldl

For example, here is a cut-and-paste session with your
script:

$ pdl2
Perldl2 Shell v0.005
      PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file
      'COPYING' in the PDL distribution. This is free software and you
      are welcome to redistribute it under certain conditions, see
      the same file for details.

Loaded plugins:

  Commands
  Completion
  CompletionDriver::INC
  CompletionDriver::Keywords
  CompletionDriver::LexEnv
  CompletionDriver::Methods
  DDS
  FindVariable
  History
  Interrupt
  LexEnv
  MultiLine::PPI
  NiceSlice
  PDLCommands
  Packages
  PrintControl
  ReadLineHistory


Type 'help' for online help

Type Ctrl-D or quit to exit

Loaded PDL v2.4.9_001

load_rcfile: got $HOME = /home/chm
load_rcfile: loading /home/chm/.perldlrc

pdl> $color = pdl(128,200,128);

pdl> p $color
[128 200 128]

pdl> p $color->info
PDL: Double D [3]

pdl> $im = floor(random(3,6,4)*10)/10  # instead of reading image

pdl> $im *= 255

pdl> $im = $im->byte

pdl> $dist_sq = (($im-$color)*($im-$color))->sumover;

pdl> p $dist_sq

[
 [45777 48633  8658 22827 28794  8454]
 [17025 11667  7038 16005 36555 16461]
 [ 1785 11310  8709  6618 23427 55977]
 [11781 19104 22329 27834 41289 27081]
]

pdl> $slop = 50

pdl> $mask = ($dist_sq <= $slop*$slop);

pdl> p $mask

[
 [0 0 0 0 0 0]
 [0 0 0 0 0 0]
 [1 0 0 0 0 0]
 [0 0 0 0 0 0]
]

pdl> $wh_sloppy = $mask->whichND;

pdl> p $wh_sloppy

[
 [0 2]
]


pdl> p $wh_sloppy->info
PDL: Long D [2,1]
...

I hope this gives you the idea.

--Chris

I mean I understand more and less that I have tyo build a new matrix
containing someting like a X,Y,RGB dimension but I don't know where to start
and I find the documentation fragmented for my very little knowledge...


Thanks,

Luca

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to