From: Ian S. <ian...@st...> - 2003-12-18 10:16:47
|
There are several good reasons for treating complex<T> as a single scalar rather than a two component pixel of component type T. 1. Mathematically, complex<T> is a scalar. We treat rgb<T> as a vector. (think conversion to HSV. complex converted to (magnitude,argument) is still a complex<T>) 2. Most functions that operate on multiplane images treat the two planes independently. This is not correct behaviour for complex<T>. vil_convolve is a good example. 3. What are the two components of a complex<T>? [re, im] is a rather arbitrary separation, and can be dangerous http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf p 11. 4. AFAIK, there is no requirement in C++ that sizeof(complex<T>) = 2*sizeof(T), or that the data is stored as struct {T real; T imag;}. vil assumes that a two component pixel can be split like this. (Of course every real implmentation I have seen does look like this.) Of course there are reasons for treating image<complex<T>> as a two-component scalar and hence as a two plane image<T>. 1. Its what most (non-mathematical) programmers expect. 2. It reduces the number of types. In partial answer to 2 We made complex<float> and complex<double> special cases, and there is no reason to see this as a "slippery slope" to adding any more fundamental pixel types. Amtiha: Are there cases where you are being forced to deal with image<complex<T> >, you would not otherwise need to? I had thought the design was such that: a. For templated functions, the code will deal with complex<T> just as easily as it deals with rgb<T>. No extra code needed except in the rare case where you need to specialisations (e.g. vil_convert) b. For the non-templated vil_image_resource style functions - if you don;t want to support complex<T> pixels, then don't bother. If you have found this persuasive, by all means add any useful bits to the vil/notes.html. Ian. > -----Original Message----- > From: Amitha Perera [mailto:pe...@cs...] > Sent: Wednesday, December 17, 2003 10:37 PM > To: Ian Scott; Fred Wheeler > Subject: component type of vcl_complex<T>? > > > Ian, > > From the notes page of vil > > http://paine.wiau.man.ac.uk/pub/doc_vxl/core/vil/html/Design.html > > and from vil_pixel_format.h, the component type of vcl_complex<T> is > vcl_complex<T>, and not T. Why? > > Fred and I discussed this a bit, and couldn't really think of what > we'd lose by making the component type T. The advantage is that there > would be fewer possible component types overall. > > Do you remember why that decision was made? > > Thanks, > Amitha. > |