1Pnm(3) User Contributed Perl Documentation Pnm(3)
2
3
4
6 PDL::IO::Pnm -- pnm format I/O for PDL
7
9 use PDL::IO::Pnm;
10 $im = wpnm $pdl, $file, $format[, $raw];
11 rpnm $stack->slice(':,:,:,(0)'),"PDL.ppm";
12
14 pnm I/O for PDL.
15
17 pnminraw
18 Signature: (type(); byte+ [o] im(m,n); int ms => m; int ns => n;
19 int isbin; char* fd)
20
21 Read in a raw pnm file.
22
23 read a raw pnm file. The "type" argument is only there to determine the
24 type of the operation when creating "im" or trigger the appropriate
25 type conversion (maybe we want a byte+ here so that "im" follows
26 strictly the type of "type").
27
28 pnminraw does not process bad values. It will set the bad-value flag
29 of all output ndarrays if the flag is set for any of the input
30 ndarrays.
31
32 pnminascii
33 Signature: (type(); byte+ [o] im(m,n); int ms => m; int ns => n;
34 int format; char* fd)
35
36 Read in an ascii pnm file.
37
38 pnminascii does not process bad values. It will set the bad-value flag
39 of all output ndarrays if the flag is set for any of the input
40 ndarrays.
41
42 pnmout
43 Signature: (a(m); int israw; int isbin; char *fd)
44
45 Write a line of pnm data.
46
47 This function is implemented this way so that threading works
48 naturally.
49
50 pnmout does not process bad values. It will set the bad-value flag of
51 all output ndarrays if the flag is set for any of the input ndarrays.
52
53 rpnm
54 Read a pnm (portable bitmap/pixmap, pbm/ppm) file into an ndarray.
55
56 Usage: $im = rpnm $file;
57
58 Reads a file in pnm format (ascii or raw) into a pdl (magic numbers
59 P1-P6). Based on the input format it returns pdls with arrays of size
60 (width,height) if binary or grey value data (pbm and pgm) or
61 (3,width,height) if rgb data (ppm). This also means for a palette image
62 that the distinction between an image and its lookup table is lost
63 which can be a problem in cases (but can hardly be avoided when using
64 netpbm/pbmplus). Datatype is dependent on the maximum
65 grey/color-component value (for raw and binary formats always PDL_B).
66 rpnm tries to read chopped files by zero padding the missing data (well
67 it currently doesn't, it barfs; I'll probably fix it when it becomes a
68 problem for me ;). You can also read directly into an existing pdl that
69 has to have the right size(!). This can come in handy when you want to
70 read a sequence of images into a datacube.
71
72 For details about the formats see appropriate manpages that come with
73 the netpbm/pbmplus packages.
74
75 $stack = zeroes(byte,3,500,300,4);
76 rpnm $stack->slice(':,:,:,(0)'),"PDL.ppm";
77
78 reads an rgb image (that had better be of size (500,300)) into the
79 first plane of a 3D RGB datacube (=4D pdl datacube). You can also do
80 inplace transpose/inversion that way.
81
82 wpnm
83 Write a pnm (portable bitmap/pixmap, pbm/ppm) file into a file.
84
85 Usage: $im = wpnm $pdl, $file, $format[, $raw];
86
87 Writes data in a pdl into pnm format (ascii or raw) (magic numbers
88 P1-P6). The $format is required (normally produced by wpic) and
89 routine just checks if data is compatible with that format. All
90 conversions should already have been done. If possible, usage of wpic
91 is preferred. Currently RAW format is chosen if compliant with range of
92 input data. Explicit control of ASCII/RAW is possible through the
93 optional $raw argument. If RAW is set to zero it will enforce ASCII
94 mode. Enforcing RAW is somewhat meaningless as the routine will always
95 try to write RAW format if the data range allows (but maybe it should
96 reduce to a RAW supported type when RAW == 'RAW'?). For details about
97 the formats consult appropriate manpages that come with the
98 netpbm/pbmplus packages.
99
101 The stderr of the converters is redirected to a file. The filename is
102 currently generated in a probably non-portable way. A method that
103 avoids a file (and is portable) would be preferred.
104
105 "rpnm" currently relies on the fact that the header is separated from
106 the image data by a newline. This is not required by the p[bgp]m
107 formats (in fact any whitespace is allowed) but most of the pnm writers
108 seem to comply with that. Truncated files are currently treated
109 ungracefully ("rpnm" just barfs).
110
112 Copyright (C) 1996,1997 Christian Soeller <c.soeller@auckland.ac.nz>
113 All rights reserved. There is no warranty. You are allowed to
114 redistribute this software / documentation under certain conditions.
115 For details, see the file COPYING in the PDL distribution. If this file
116 is separated from the PDL distribution, the copyright notice should be
117 included in the file.
118
119
120
121perl v5.34.0 2021-08-16 Pnm(3)