1 |
.\" RCSid "$Id: rmtxop.1,v 1.17 2019/09/10 17:58:20 greg Exp $" |
2 |
.TH RMTXOP 1 7/8/97 RADIANCE |
3 |
.SH NAME |
4 |
rmtxop - concatenate, add, multiply, divide, transpose, scale, and convert matrices |
5 |
.SH SYNOPSIS |
6 |
.B rmtxop |
7 |
[ |
8 |
.B \-v |
9 |
][ |
10 |
.B \-f[afdc] |
11 |
][ |
12 |
.B \-t |
13 |
][ |
14 |
.B "\-s sf .." |
15 |
][ |
16 |
.B "\-c ce .." |
17 |
] |
18 |
.B m1 |
19 |
[ |
20 |
.B ".+*/" |
21 |
] |
22 |
.B ".." |
23 |
.SH DESCRIPTION |
24 |
.I Rmtxop |
25 |
loads and concatenates or adds/multiplies/divides |
26 |
together component matrix files given on the command line. |
27 |
Each file must have a header containing the following variables: |
28 |
.sp |
29 |
.nf |
30 |
NROWS={number of rows} |
31 |
NCOLS={number of columns} |
32 |
NCOMP={number of components} |
33 |
FORMAT={ascii|float|double|32-bit_rle_rgbe|32-bit_rle_xyze} |
34 |
.sp |
35 |
.fi |
36 |
The number of components indicates that each matrix element is actually |
37 |
composed of multiple elements, most commonly an RGB triple. |
38 |
This is essentially dividing the matrix into planes, where each component |
39 |
participates in a separate calculation. |
40 |
If an appropriate header is not present, it may be added with a call to |
41 |
.I rcollate(1). |
42 |
A matrix may be read from the standard input using a hyphen by itself ('-') |
43 |
in the appropriate place on the command line. |
44 |
.PP |
45 |
Any of the matrix inputs may be read from a command |
46 |
instead of a file by |
47 |
using quotes and a beginning exclamation point ('!'). |
48 |
.PP |
49 |
Two special cases are handled for component matrices that are either |
50 |
XML files containing BTDF data, or Radiance picture files. |
51 |
In the first case, a BSDF library is used to load and interpret the |
52 |
transmission matrix. |
53 |
(XML files cannot be read from the standard input or from a command.)\0 |
54 |
In the second case, the RGBE or XYZE values are loaded in a 3-component |
55 |
matrix where the number of columns match the X-dimension of the picture, and |
56 |
the number of rows match the Y-dimension. |
57 |
The picture must be in standard pixel ordering, and the first row |
58 |
is at the top with the first column on the left. |
59 |
Any exposure changes applied to the pictures beforehand |
60 |
.I rmtxop |
61 |
will be undone, similar to the |
62 |
.I pcomb\(1) |
63 |
.I \-o |
64 |
option. |
65 |
.PP |
66 |
Before each file, the |
67 |
.I \-t |
68 |
and |
69 |
.I \-s |
70 |
or |
71 |
.I \-c |
72 |
options may be used to modify the matrix. |
73 |
The |
74 |
.I \-t |
75 |
option transposes the matrix, swapping rows and columns. |
76 |
The |
77 |
.I \-s |
78 |
option applies the given scalar factor(s) to the elements of the matrix. |
79 |
If only one factor is provided, |
80 |
it will be used for all components. |
81 |
If multiple factors are given, their number must match the number of matrix |
82 |
components. |
83 |
Alternatively, the |
84 |
.I \-c |
85 |
option may be used to "transform" the element values, possibly changing |
86 |
the number of components in the matrix. |
87 |
For example, a 3-component matrix can be transformed into a single-component |
88 |
matrix by using |
89 |
.I \-c |
90 |
with three coefficients. |
91 |
A four-component matrix can be turned into a two-component matrix using 8 |
92 |
coefficients, where the first four coefficients will be used to compute |
93 |
the first new component, and the second four coefficients |
94 |
yield the second new component. |
95 |
Note that the number of coefficients must be an even multiple of the number |
96 |
of original components. |
97 |
The |
98 |
.I \-s |
99 |
and |
100 |
.I \-c |
101 |
options are mutually exclusive, insofar as they cannot be applied together |
102 |
to the same input matrix. |
103 |
.PP |
104 |
If present, the second and subsequent matrices on the command |
105 |
line are concatenated together, unless separated by a plus ('+'), |
106 |
asterisk ('*'), or forward slash ('/') symbol, |
107 |
in which case the individual matrix elements are added, |
108 |
multiplied, or divided, respectively. |
109 |
The concatenation operator ('.') is the default and need not be specified. |
110 |
Note also that the asterisk must be quoted or escaped in most shells. |
111 |
In the case of addition, the two matrices involved must have the same number |
112 |
of components. |
113 |
If subtraction is desired, use addition ('+') with a scaling parameter of -1 |
114 |
for the second matrix (the |
115 |
.I \-s |
116 |
option). |
117 |
For element-wise multiplication and division, the second matrix is |
118 |
permitted to have a single component per element, which will be |
119 |
applied equally to all components of the first matrix. |
120 |
If element-wise division is specified, any zero elements in the second |
121 |
matrix will result in a warning and the corresponding component(s) in the |
122 |
first matrix will be set to zero. |
123 |
.PP |
124 |
Evaluation proceeds from left to right, and all operations have |
125 |
the same precedence. |
126 |
If a different evaluation order is desired, pipe the result of one |
127 |
.I rmtxop |
128 |
command into another, as shown in one of the examples below. |
129 |
.PP |
130 |
The number of components in the next matrix after applying any |
131 |
.I -c |
132 |
transform must agree with the prior result. |
133 |
For concatenation (matrix multiplication), the number of columns |
134 |
in the prior result must equal the number of rows in the next matrix, and |
135 |
the result will have the number of rows of the previous and the number |
136 |
of columns of the next matrix. |
137 |
In the case of addition, multiplication, and division, |
138 |
the number of rows and columns of the prior result and the |
139 |
next matrix must match, and will not be changed by the operation. |
140 |
.PP |
141 |
A final transpose or scaling/transform operation may be applied to |
142 |
the results by appending the |
143 |
.I \-t |
144 |
and |
145 |
.I \-s |
146 |
or |
147 |
.I \-c |
148 |
options after the last matrix on the command line. |
149 |
.PP |
150 |
Results are sent to the standard output. |
151 |
By default, the values will be written in the lowest resolution format |
152 |
among the inputs, but the |
153 |
.I \-f |
154 |
option may be used to explicitly output components |
155 |
as ASCII (-fa), binary doubles (-fd), floats (-ff), or RGBE colors (-fc). |
156 |
In the latter case, the actual matrix dimensions are written in the resolution |
157 |
string rather than the header. |
158 |
Also, matrix results written as Radiance pictures must have either one |
159 |
or three components. |
160 |
In the one-component case, the output is written as grayscale. |
161 |
.PP |
162 |
The |
163 |
.I \-v |
164 |
option turns on verbose reporting, which announces each operation. |
165 |
.SH EXAMPLES |
166 |
To concatenate two matrix files with a BTDF between them and write |
167 |
the result as binary double: |
168 |
.IP "" .2i |
169 |
rmtxop -fd view.vmx blinds.xml exterior.dmx > dcoef.dmx |
170 |
.PP |
171 |
To convert a BTDF matrix into a Radiance picture: |
172 |
.IP "" .2i |
173 |
rmtxop -fc blinds.xml > blinds.hdr |
174 |
.PP |
175 |
To extract the luminance values from a picture as an ASCII matrix: |
176 |
.IP "" .2i |
177 |
rmtxop -fa -c .265 .670 .065 image.hdr > image_lum.mtx |
178 |
.PP |
179 |
To scale a matrix by 4 and add it to the transpose of another matrix: |
180 |
.IP "" .2i |
181 |
rmtxop -s 4 first.mtx + -t second.mtx > result.mtx |
182 |
.PP |
183 |
To multiply elements of two matrices, then concatenate with a third, |
184 |
applying a final transpose to the result: |
185 |
.IP "" .2i |
186 |
rmtxop first.mtx \\* second.mtx . third.mtx -t > result.mtx |
187 |
.PP |
188 |
To left-multiply the element-wise division of two matrices: |
189 |
.IP "" .2i |
190 |
rmtxop -fd numerator.mtx / denominator.mtx | rmtxop left.mtx - > result.mtx |
191 |
.PP |
192 |
To send the elements of a binary matrix to |
193 |
.I rcalc(1) |
194 |
for further processing: |
195 |
.IP "" .2i |
196 |
rmtxop -fa orig.mtx | rcollate -ho -oc 1 | rcalc [operations] |
197 |
.SH NOTES |
198 |
Matrix concatenation is associative but not commutative, so order |
199 |
matters to the result. |
200 |
.I Rmtxop |
201 |
takes advantage of this associative property to concatenate |
202 |
from right to left when it reduces the number of basic operations. |
203 |
If the rightmost matrix is a column vector for example, it is |
204 |
much faster to concatenate from the right, and the result will |
205 |
be the same. |
206 |
Note that this only applies to concatenation; |
207 |
element-wise addition, multiplication, and division are always |
208 |
evaluated from left to right. |
209 |
.SH AUTHOR |
210 |
Greg Ward |
211 |
.SH "SEE ALSO" |
212 |
cnt(1), getinfo(1), histo(1), neaten(1), pcomb(1), rcalc(1), |
213 |
rcollate(1), rcontrib(1), rfluxmtx(1), rlam(1), |
214 |
rsplit(1), tabfunc(1), total(1), wrapBSDF(1) |