ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/doc/man/man1/rcomb.1
Revision: 1.2
Committed: Mon Dec 18 23:04:05 2023 UTC (17 months ago) by greg
Branch: MAIN
Changes since 1.1: +5 -1 lines
Log Message:
fix(rcomb): Fixed handling of matrix inputs where NROWS is unspecified

File Contents

# User Rev Content
1 greg 1.2 .\" RCSid "$Id: rcomb.1,v 1.1 2023/12/12 16:31:45 greg Exp $"
2 greg 1.1 .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 rtrace(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     .PP
148     If a matrix or picture file path is given to the
149     .I \-c
150     option, then the color space of that file will be used, instead.
151     .PP
152     The
153     .I \-C
154     option takes either a symbolic color space or an input file, and will be
155     applied to all subsequent matrices that do not have their own associated
156     .I \-c
157     option.
158     .PP
159     Additionally, the
160     .I \-s
161     option applies the given scalar factor(s) to the elements of the matrix.
162     If only one factor is provided,
163     it will be used for all components.
164     If multiple factors are given, their number must match the number of matrix
165     components
166     .I after
167     application of any
168     .I \-c
169     option for this input matrix or picture, even if the
170     .I \-s
171     option appears first.
172     .PP
173     The number of components in all input
174     matrices after applying any
175     .I -c
176     transform must agree.
177     Similarly, the number of rows and columns of all results must match
178     exactly.
179     (The
180     .I rcrop(1)
181     utility may be used to trim inputs if necessary.)\0
182     .PP
183     If the
184     .I \-e
185     or
186     .I \-f
187     options are used to define a "co" variable or "co(p)" function,
188     this will be evaluated at each output
189     component for the current element.
190     The "co" variable defines identical operations for all components,
191     whereas "co(p)" may specify different operations for each component.
192     The element position is defined
193     by the "r" and "c" variables, where
194     .I r
195     goes from 0 to "nrows" minus one, and
196     .I c
197     goes from 0 to "ncols" minus one.
198 greg 1.2 (Note that "nrows" may be zero if unspecified in inputs, and this
199     is a unique capability of
200     .I rcomb
201     to handle these.)\0
202 greg 1.1 Component p from input i is accessed with the "ci(i,p)" function,
203     and the number of components is defined by the "ncomp" constant.
204     If given as "ci(i)", the function returns the current component
205     being evaluated by
206     .I rcomb.
207     A different component may be referenced using th second argument.
208     For example, "ci(1,2)" accesses
209     the second component from the first input.
210     If the input is a picture, the the constants "R", "G", and "B"
211     are conveniently defined as the channel numbers 1, 2, and 3,
212     respectively.
213     For color or spectral inputs, the function "wl(p)" gives the
214     central wavelength for channel
215     .I p
216     in nanometers.
217     For convenience and compatibility with
218     .I pcomb,
219     the functions "ri(i)", "gi(i)", and "bi(i)" are predefined as
220     "ci(i,R)", "ci(i,G)", and "ci(i,B)", respectively.
221     Accordingly, the "ro", "go", and "bo"
222     variables may be used in place of "co(R)", "co(G)", and "co(B)".
223     Finally, the total number of input files is set in the constant "nfiles".
224     .PP
225     Results are sent to the standard output.
226     By default, the values will be written in the lowest precision format
227     among the inputs, but the
228     .I \-f[adfc]
229     option may be used to explicitly output components
230     as ASCII (-fa), binary doubles (-fd), floats (-ff), or common-exponent
231     colors/spectra (-fc).
232     In the latter case, the actual matrix dimensions are written in the resolution string rather than the header.
233     Also, matrix results will be written as standard
234     Radiance pictures if they have either one
235     or three components.
236     In the one-component case, the output is written as grayscale.
237     If more than 3 components are in the final matrix and
238     .I -fc
239     is specified, the output will be a Radiance spectral picture.
240     .PP
241     The
242     .I \-h
243     option may be used to reduce the information header size, which
244     can grow disproportionately, otherwise.
245     The
246     .I \-w
247     option turns off warnings about divide-by-zero and other non-fatal
248     calculation errors.
249     .SH EXAMPLES
250     To convert two hyperspectral inputs to RGB color space,
251     average them together, and write them out as a RADIANCE picture:
252     .IP "" .2i
253     rcomb -C RGB -s .5 img1.spc -s .5 img2.spc > avg.hdr
254     .PP
255     Divide one set of matrix elements by the Euclidean sum of two others:
256     .IP "" .2i
257     rcomb -e "co=ci(1)/sqrt(ci(2)^2+ci(3)^2)" inp1.mtx
258     inp2.mtx inp3.mtx > out.mtx
259     .PP
260     Compute the absolute and relative differences between melanopic and photopic values
261     in a spectral image:
262     .IP "" .2i
263     rcomb -fa -C MY -e "abs(x):if(x,x,-x)"
264     -e "co(p)=select(p,abs(ci(1,1)-ci(1,2)),(ci(1,1)-ci(1,2))/ci(1,2))"
265     input_spec.hsr > compare.mtx
266     .PP
267     Concatenate a spectral flux coefficient matrix with a spectral sky
268     matrix to compute a set of melanopic lux values:
269     .IP "" .2i
270     rcomb view_spec.mtx -m sky_spec.mtx -c M > melux.mtx
271     .SH NOTES
272     The
273     .I rcomb
274     tool was created to overcome some limitations of
275     .I rmtxop
276     and
277     .I pcomb,
278     whose capabilities somewhat overlap.
279     The former loads each matrix into memory before operations,
280     and element components take 8 bytes apiece, adding up quickly.
281     Very large matrices therefore present a problem with that tool.
282     Furthermore,
283     .I rmtxop
284     does not allow arbitrary expressions, limiting
285     what can be accomplished easily on the command-line.
286     In contrast,
287     .I pcomb
288     is fully programmable and operates on its input using a
289     scanline window, so it can handle much larger input dimensions.
290     It also handles single- and three-component float matrices on
291     input and output, but unlike
292     .I rmtxop,
293     .I pcomb
294     has not been extended to handle RADIANCE hyperspectral images
295     or more general matrix data.
296     .PP
297     The
298     .I rcomb
299     tool is a compromise that exceeds the capabilities of either of
300     its predecessors in certain circumstances.
301     In particular, very large matrices may be combined using
302     arbitrary, user-defined operations, and the convenient
303     color conversions of
304     .I rmtxop
305     are supported for both input and output.
306     Finally, a single matrix may be concatenated after operations,
307     permitting a flux transfer matrix with millions of rows to
308     pass through.
309     Generally speaking,
310     .I rcomb
311     should be preferred over
312     .I rmtxop
313     for any operations in can handle, which is everything except
314     multiple matrix concatenations and transpose
315     operations, which are handled more efficiently by
316     .I rcollate(1)
317     in any case.
318     That said, there is no significant difference for
319     simple operations on smallish matrices, and note that only
320     .I rmtxop
321     and
322     .I dctimestep(1)
323     currently accept XML files as inputs.
324     Also, the resizing function of
325     .I pcomb
326     is not supported in
327     .I rcomb,
328     and should instead be handled by
329     .I pfilt(1).
330     .SH AUTHOR
331     Greg Ward
332     .SH "SEE ALSO"
333     dctimestep(1), icalc(1), getinfo(1), pcomb(1), pfilt(1),
334     ra_xyze(1), rcalc(1),
335     rcollate(1), rcontrib(1), rcrop(1), rfluxmtx(1),
336     rmtxop(1), rtpict(1), rtrace(1), vwrays(1)