ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/doc/man/man1/rcomb.1
Revision: 1.6
Committed: Sat Feb 10 19:32:32 2024 UTC (14 months, 3 weeks ago) by greg
Branch: MAIN
Changes since 1.5: +4 -3 lines
Log Message:
docs: typo fix plus clarification

File Contents

# Content
1 .\" RCSid "$Id: rcomb.1,v 1.5 2024/01/17 21:50:15 greg Exp $"
2 .TH RCOMB 12/5/2023 RADIANCE
3 .SH NAME
4 rcomb - combine and convert matrices a row at a time
5 .SH SYNOPSIS
6 .B rcomb
7 [
8 .B \-h
9 ][
10 .B \-w
11 ][
12 .B \-f[afdc]
13 ][
14 .B "\-f file"
15 ][
16 .B "\-e expr"
17 ][
18 .B "\-C {symbols|file}"
19 ][
20 .B "\-c ce .."
21 ][
22 .B "\-s sf .."
23 ]
24 .B "m1 .."
25 [
26 .B "\-m mcat"
27 ]
28 .SH DESCRIPTION
29 .I Rcomb
30 combines inputs given on the command line,
31 one matrix row or picture scanline at a time.
32 By default, the result is a linear combination of
33 the matrix elements or pixels transformed by
34 .I \-c
35 specifications and scaled by
36 .I \-s
37 coefficients, but an arbitrary mapping can be assigned with the
38 .I \-e
39 and
40 .I \-f
41 options, similar to the
42 .I pcomb(1)
43 and
44 .I rcalc(1)
45 commands.
46 (The definitions in each
47 .I \-f source
48 file are read and compiled from the RADIANCE library where it is found.)\0
49 .PP
50 If any
51 .I \-c
52 or
53 .I \-s
54 options follow the last input matrix, output results will be transformed
55 and/or scaled accordingly.
56 These operations are discussed in greater detail further on.
57 A single concatenation matrix may be applied after element operations
58 using the
59 .I \-m
60 option.
61 Matrix concatenation will happen before or after any trailing
62 operations, depending on relative command line placement.
63 .PP
64 Each input file must have a header containing the following metadata:
65 .sp
66 .nf
67 NROWS={number of rows}
68 NCOLS={number of columns}
69 NCOMP={number of components}
70 FORMAT={ascii|float|double|32-bit_rle_rgbe|32-bit_rle_xyze|Radiance_spectra}
71 .fi
72 .sp
73 The number of components indicates that each matrix element is actually
74 composed of multiple elements, most commonly an RGB triple.
75 This is essentially dividing the matrix into planes, where each component
76 participates in a separate calculation.
77 If an appropriate header is not present, it may be added with a call to
78 .I rcollate(1).
79 A matrix may be read from the standard input using a hyphen by itself ('-')
80 in the appropriate place on the command line.
81 Similarly, any of the inputs may be read from a command
82 instead of a file by
83 using quotes and a beginning exclamation point ('!').
84 .PP
85 In the case of Radiance picture files,
86 the number of columns is the X-dimension of the picture, and
87 the number of rows is the Y-dimension.
88 The picture must be in standard pixel ordering, and the zeroeth row
89 is at the top with the zeroeth column on the left.
90 Any exposure changes that were applied to the pictures before
91 .I rcomb
92 will be undone, similar to the
93 .I "pcomb \-o"
94 option.
95 Radiance spectral pictures with more than 3 components are also supported.
96 These are typically produced by
97 .I rtpict(1)
98 or
99 .I rfluxmtx(1).
100 .PP
101 Before each input, the
102 .I \-c
103 and/or
104 .I \-s
105 options may be used to modify the matrix elements.
106 The
107 .I \-c
108 option can "transform" the element values, possibly changing
109 the number of components in the matrix.
110 For example, a 3-component matrix can be transformed into a single-component
111 matrix by using
112 .I \-c
113 with three coefficients.
114 A four-component matrix can be turned into a two-component matrix using 8
115 coefficients, where the first four coefficients will be used to compute
116 the first new component, and the second four coefficients
117 yield the second new component.
118 Note that the number of coefficients must be an even multiple of the number
119 of original components.
120 .PP
121 Alternatively, a set of symbolic output components may be given to the
122 .I \-c
123 option, with the following definitions:
124 .sp
125 .nf
126 R - red channel
127 G - green channel
128 B - blue channel
129 X - CIE X channel
130 Y - CIE Y channel (aka., luminance or illuminance)
131 Z - CIE Z channel
132 S - scotopic luminance or illuminance
133 M - melanopic luminance or illuminance
134 A - average component value
135 .fi
136 .sp
137 These letters may be given in any order as a single string, and if
138 .I "-c RGB"
139 or
140 .I "-c XYZ"
141 is specified for an input picture or the
142 .I "-fc"
143 option is given, the output will be written as a RGBE or XYZE picture.
144 Note that conversion from a float or RGBE color space applies a conversion
145 of 179 lumens/watt (for CIE or melanopic output) or 412 (for scotopic output),
146 and the reverse happens for conversion from XYZE input to RGB or RGBE output.
147 Lower case versions of all these components are also supported, the only
148 difference is that the aforementioned efficacy factors
149 will be left out of the conversion.
150 .PP
151 If a matrix or picture file path is given to the
152 .I \-c
153 option, then the color space of that file will be used, instead.
154 .PP
155 The
156 .I \-C
157 option takes either a symbolic color space or an input file, and will be
158 applied to all subsequent matrices that do not have their own associated
159 .I \-c
160 option.
161 .PP
162 Additionally, the
163 .I \-s
164 option applies the given scalar factor(s) to the elements of the matrix.
165 If only one factor is provided,
166 it will be used for all components.
167 If multiple factors are given, their number must match the number of matrix
168 components
169 .I after
170 application of any
171 .I \-c
172 option for this input matrix or picture, even if the
173 .I \-s
174 option appears first.
175 .PP
176 The number of components in all input
177 matrices after applying any
178 .I -c
179 transform must agree.
180 Similarly, the number of rows and columns of all results must match
181 exactly.
182 (The
183 .I rcrop(1)
184 utility may be used to trim inputs if necessary.)\0
185 .PP
186 If the
187 .I \-e
188 or
189 .I \-f
190 options are used to define a "co" variable or "co(p)" function,
191 this will be evaluated at each output
192 component for the current element.
193 The "co" variable defines identical operations for all components,
194 whereas "co(p)" may specify different operations for each component.
195 The element position is defined
196 by the "r" and "c" variables, where
197 .I r
198 goes from 0 to "nrows" minus one, and
199 .I c
200 goes from 0 to "ncols" minus one.
201 (Note that "nrows" may be zero if unspecified in inputs, and this
202 is a unique capability of
203 .I rcomb
204 to handle these.)\0
205 Component p from input i is accessed with the "ci(i,p)" function,
206 and the number of components is defined by the "ncomp" constant.
207 If given as "ci(i)", the function returns the current component
208 being evaluated by
209 .I rcomb.
210 A different component may be referenced using the second argument.
211 For example, "ci(1,2)" accesses
212 the second component from the first input.
213 If the input is a picture, the the constants "R", "G", and "B"
214 are conveniently defined as the channel numbers 1, 2, and 3,
215 respectively.
216 For color or spectral inputs, the function "wl(p)" gives the
217 central wavelength for channel
218 .I p
219 in nanometers.
220 For convenience and compatibility with
221 .I pcomb,
222 the functions "ri(i)", "gi(i)", and "bi(i)" are predefined as
223 "ci(i,R)", "ci(i,G)", and "ci(i,B)", respectively.
224 Accordingly, the "ro", "go", and "bo"
225 variables may be used in place of "co(R)", "co(G)", and "co(B)",
226 but all three must be defined for this substitution to take place.
227 Finally, the total number of input files is set in the constant "nfiles".
228 .PP
229 Results are sent to the standard output.
230 By default, the values will be written in the lowest precision format
231 among the inputs, but the
232 .I \-f[adfc]
233 option may be used to explicitly output components
234 as ASCII (-fa), binary doubles (-fd), floats (-ff), or common-exponent
235 colors/spectra (-fc).
236 In the latter case, the actual matrix dimensions are written in the resolution string rather than the header.
237 Also, matrix results will be written as standard
238 Radiance pictures if they have either one
239 or three components.
240 In the one-component case, the output is written as grayscale.
241 If more than 3 components are in the final matrix and
242 .I -fc
243 is specified, the output will be a Radiance spectral picture.
244 .PP
245 The
246 .I \-h
247 option may be used to reduce the information header size, which
248 can grow disproportionately, otherwise.
249 The
250 .I \-w
251 option turns off warnings about divide-by-zero and other non-fatal
252 calculation errors.
253 .SH EXAMPLES
254 To convert two hyperspectral inputs to RGB color space,
255 average them together, and write them out as a RADIANCE picture:
256 .IP "" .2i
257 rcomb -C RGB -s .5 img1.spc -s .5 img2.spc > avg.hdr
258 .PP
259 Divide one set of matrix elements by the Euclidean sum of two others:
260 .IP "" .2i
261 rcomb -e "co=ci(1)/sqrt(ci(2)^2+ci(3)^2)" inp1.mtx
262 inp2.mtx inp3.mtx > out.mtx
263 .PP
264 Compute the absolute and relative differences between melanopic and photopic values
265 in a spectral image:
266 .IP "" .2i
267 rcomb -fa -C MY -e "abs(x):if(x,x,-x)"
268 -e "co(p)=select(p,abs(ci(1,1)-ci(1,2)),(ci(1,1)-ci(1,2))/ci(1,2))"
269 input_spec.hsr > compare.mtx
270 .PP
271 Concatenate a spectral flux coefficient matrix with a spectral sky
272 matrix to compute a set of melanopic lux values:
273 .IP "" .2i
274 rcomb view_spec.mtx -m sky_spec.mtx -c M > melux.mtx
275 .SH NOTES
276 The
277 .I rcomb
278 tool was created to overcome some limitations of
279 .I rmtxop
280 and
281 .I pcomb,
282 whose capabilities somewhat overlap.
283 The former loads each matrix into memory before operations,
284 and element components take 8 bytes apiece, adding up quickly.
285 Very large matrices therefore present a problem with that tool.
286 Furthermore,
287 .I rmtxop
288 does not allow arbitrary expressions, limiting
289 what can be accomplished easily on the command-line.
290 In contrast,
291 .I pcomb
292 is fully programmable and operates on its input using a
293 scanline window, so it can handle much larger input dimensions.
294 It also handles single- and three-component float matrices on
295 input and output, but unlike
296 .I rmtxop,
297 .I pcomb
298 has not been extended to handle RADIANCE hyperspectral images
299 or more general matrix data.
300 .PP
301 The
302 .I rcomb
303 tool is a compromise that exceeds the capabilities of either of
304 its predecessors in certain circumstances.
305 In particular, very large matrices may be combined using
306 arbitrary, user-defined operations, and the convenient
307 color conversions of
308 .I rmtxop
309 are supported for both input and output.
310 Finally, a single matrix may be concatenated after operations,
311 permitting a flux transfer matrix with millions of rows to
312 pass through.
313 Generally speaking,
314 .I rcomb
315 should be preferred over
316 .I rmtxop
317 for any operations in can handle, which is everything except
318 multiple matrix concatenations and transpose
319 operations, which are handled more efficiently by
320 .I rcollate(1)
321 in any case.
322 That said, there is no significant difference for
323 simple operations on smallish matrices, and note that only
324 .I rmtxop
325 and
326 .I dctimestep(1)
327 currently accept XML files as inputs.
328 Also, the resizing function of
329 .I pcomb
330 is not supported in
331 .I rcomb,
332 and should instead be handled by
333 .I pfilt(1).
334 .SH BUGS
335 The
336 .I rcomb
337 command currently ignores the "PRIMARIES" setting in input
338 headers, and does not produce any on output, even in
339 circumstances where it would make sense to.
340 .SH AUTHOR
341 Greg Ward
342 .SH "SEE ALSO"
343 dctimestep(1), icalc(1), getinfo(1), pcomb(1), pfilt(1),
344 ra_xyze(1), rcalc(1),
345 rcollate(1), rcontrib(1), rcrop(1), rfluxmtx(1),
346 rmtxop(1), rtpict(1), rtrace(1), vwrays(1)