1 |
greg |
1.15 |
.\" RCSid "$Id: rmtxop.1,v 1.14 2019/08/12 02:26:46 greg Exp $" |
2 |
greg |
1.1 |
.TH RMTXOP 1 7/8/97 RADIANCE |
3 |
|
|
.SH NAME |
4 |
greg |
1.10 |
rmtxop - concatenate, add, multiply, divide, transpose, scale, and convert matrices |
5 |
greg |
1.1 |
.SH SYNOPSIS |
6 |
|
|
.B rmtxop |
7 |
|
|
[ |
8 |
|
|
.B \-v |
9 |
|
|
][ |
10 |
greg |
1.3 |
.B \-f[afdc] |
11 |
greg |
1.1 |
][ |
12 |
|
|
.B \-t |
13 |
|
|
][ |
14 |
|
|
.B "\-s sf .." |
15 |
|
|
][ |
16 |
|
|
.B "\-c ce .." |
17 |
|
|
] |
18 |
|
|
.B m1 |
19 |
|
|
[ |
20 |
greg |
1.13 |
.B ".+*/" |
21 |
greg |
1.1 |
] |
22 |
|
|
.B ".." |
23 |
|
|
.SH DESCRIPTION |
24 |
|
|
.I Rmtxop |
25 |
greg |
1.10 |
loads and concatenates or adds/multiplies/divides |
26 |
|
|
together component matrix files given on the command line. |
27 |
greg |
1.1 |
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 |
greg |
1.9 |
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 |
greg |
1.1 |
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 |
greg |
1.9 |
(XML files cannot be read from the standard input or from a command.)\0 |
54 |
greg |
1.1 |
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 |
greg |
1.7 |
is at the top with the first column on the left. |
59 |
greg |
1.1 |
.PP |
60 |
|
|
Before each file, the |
61 |
|
|
.I \-t |
62 |
|
|
and |
63 |
|
|
.I \-s |
64 |
|
|
or |
65 |
|
|
.I \-c |
66 |
|
|
options may be used to modify the matrix. |
67 |
|
|
The |
68 |
|
|
.I \-t |
69 |
|
|
option transposes the matrix, swapping rows and columns. |
70 |
|
|
The |
71 |
|
|
.I \-s |
72 |
|
|
option applies the given scalar factor(s) to the elements of the matrix. |
73 |
|
|
If only one factor is provided, |
74 |
|
|
it will be used for all components. |
75 |
|
|
If multiple factors are given, their number must match the number of matrix |
76 |
|
|
components. |
77 |
|
|
Alternatively, the |
78 |
|
|
.I \-c |
79 |
|
|
option may be used to "transform" the element values, possibly changing |
80 |
|
|
the number of components in the matrix. |
81 |
|
|
For example, a 3-component matrix can be transformed into a single-component |
82 |
|
|
matrix by using |
83 |
|
|
.I \-c |
84 |
|
|
with three coefficients. |
85 |
|
|
A four-component matrix can be turned into a two-component matrix using 8 |
86 |
|
|
coefficients, where the first four coefficients will be used to compute |
87 |
|
|
the first new component, and the second four coefficients |
88 |
|
|
yield the second new component. |
89 |
|
|
Note that the number of coefficients must be an even multiple of the number |
90 |
|
|
of original components. |
91 |
|
|
The |
92 |
|
|
.I \-s |
93 |
|
|
and |
94 |
|
|
.I \-c |
95 |
|
|
options are mutually exclusive, insofar as they cannot be applied together |
96 |
|
|
to the same input matrix. |
97 |
|
|
.PP |
98 |
|
|
If present, the second and subsequent matrices on the command |
99 |
greg |
1.15 |
line are concatenated to the result, unless separated by a plus ('+'), |
100 |
greg |
1.10 |
asterisk ('*'), or forward slash ('/') symbol, |
101 |
greg |
1.15 |
in which case the individual matrix elements are added, |
102 |
|
|
multiplied, or divided together, respectively. |
103 |
greg |
1.10 |
(Note that the asterisk must be quoted or escaped in most shells.)\0 |
104 |
|
|
In the case of addition, the two matrices involved must have the same number |
105 |
|
|
of components. |
106 |
greg |
1.15 |
If subtraction is desired, use addition ('+') with a scaling parameter of -1 |
107 |
|
|
for the second matrix (the |
108 |
|
|
.I \-s |
109 |
|
|
option). |
110 |
greg |
1.11 |
For element-wise multiplication and division, the second matrix is |
111 |
greg |
1.15 |
permitted to have a single component per element, which will be |
112 |
greg |
1.11 |
applied equally to all components of the first matrix. |
113 |
greg |
1.10 |
If element-wise division is specified, any zero elements in the second |
114 |
|
|
matrix will result in a warning and the corresponding component(s) in the |
115 |
|
|
first matrix will be set to zero. |
116 |
|
|
.PP |
117 |
greg |
1.1 |
The number of components in the new matrix after applying any |
118 |
|
|
.I -c |
119 |
|
|
transform must agree with the prior result. |
120 |
|
|
For concatenation (matrix multiplication), the number of columns |
121 |
|
|
in the prior result must equal the number of rows in the new matrix, and |
122 |
|
|
the result will have the number of rows of the previous and the number |
123 |
|
|
of columns of the new matrix. |
124 |
greg |
1.10 |
In the case of addition, multiplication, and division, |
125 |
|
|
the number of rows and columns of the prior result and the |
126 |
|
|
new matrix must match, and will not be changed by the operation. |
127 |
greg |
1.1 |
.PP |
128 |
greg |
1.14 |
A final transpose or scaling/transform operation may be applied to |
129 |
|
|
the results by appending the |
130 |
|
|
.I \-t |
131 |
|
|
and |
132 |
|
|
.I \-s |
133 |
|
|
or |
134 |
|
|
.I \-c |
135 |
|
|
options after the last matrix on the command line. |
136 |
|
|
.PP |
137 |
greg |
1.1 |
Results are sent to the standard output. |
138 |
greg |
1.4 |
By default, the values will be written in the lowest resolution format |
139 |
greg |
1.6 |
among the inputs, but the |
140 |
greg |
1.1 |
.I \-f |
141 |
greg |
1.4 |
option may be used to explicitly output components |
142 |
|
|
as ASCII (-fa), binary doubles (-fd), floats (-ff), or RGBE colors (-fc). |
143 |
greg |
1.1 |
In the latter case, the actual matrix dimensions are written in the resolution |
144 |
|
|
string rather than the header. |
145 |
|
|
Also, matrix results written as Radiance pictures must have either one |
146 |
|
|
or three components. |
147 |
|
|
In the one-component case, the output is written as grayscale. |
148 |
|
|
.PP |
149 |
|
|
The |
150 |
|
|
.I \-v |
151 |
|
|
option turns on verbose reporting, which announces each operation. |
152 |
|
|
.SH EXAMPLES |
153 |
|
|
To concatenate two matrix files with a BTDF between them and write |
154 |
|
|
the result as binary double: |
155 |
|
|
.IP "" .2i |
156 |
|
|
rmtxop -fd view.vmx blinds.xml exterior.dmx > dcoef.dmx |
157 |
|
|
.PP |
158 |
|
|
To convert a BTDF matrix into a Radiance picture: |
159 |
|
|
.IP "" .2i |
160 |
|
|
rmtxop -fc blinds.xml > blinds.hdr |
161 |
|
|
.PP |
162 |
|
|
To scale a matrix by 4 and add it to the transpose of another matrix: |
163 |
|
|
.IP "" .2i |
164 |
|
|
rmtxop -s 4 left.mtx + -t right.mtx > result.mtx |
165 |
|
|
.PP |
166 |
greg |
1.15 |
To left-multiply the element-wise division of two matrices: |
167 |
|
|
.IP "" .2i |
168 |
|
|
rmtxop -fd numerator.mtx / denominator.mtx | rmtxop left.mtx - > result.mtx |
169 |
|
|
.PP |
170 |
greg |
1.1 |
To send the elements of a binary matrix to |
171 |
|
|
.I rcalc(1) |
172 |
|
|
for further processing: |
173 |
|
|
.IP "" .2i |
174 |
greg |
1.5 |
rmtxop -fa orig.mtx | rcollate -ho -oc 1 | rcalc [operations] |
175 |
greg |
1.13 |
.SH NOTES |
176 |
|
|
Matrix multiplication is associative but not commutative, so order |
177 |
|
|
matters to the result. |
178 |
|
|
.I Rmtxop |
179 |
|
|
takes advantage of the associative property to evaluate the |
180 |
|
|
implicit equation from right to left when this reduces the |
181 |
|
|
number of basic operations. |
182 |
|
|
If the rightmost matrix is a column vector for example, it is |
183 |
|
|
much faster to concatenate from the right, and the result should |
184 |
|
|
be the same. |
185 |
|
|
This only applies to matrix multiplication. |
186 |
|
|
Element-wise addition, multiplication, and division are still |
187 |
|
|
evaluated from left to right. |
188 |
greg |
1.1 |
.SH AUTHOR |
189 |
|
|
Greg Ward |
190 |
|
|
.SH "SEE ALSO" |
191 |
greg |
1.5 |
cnt(1), getinfo(1), histo(1), neaten(1), rcalc(1), rcollate(1), |
192 |
greg |
1.12 |
rcontrib(1), rfluxmtx(1), rlam(1), |
193 |
|
|
rsplit(1), tabfunc(1), total(1), wrapBSDF(1) |