next up previous
Next: Conclusions Up: C++ Design For Research Previous: Iterators

Hiding Templates

class TC_ImageBase
{
public:
    virtual ~TC_ImageBase() {};
    const TC_Transform2D& world2im() const;

    virtual int xlo() const =0;
    virtual int xhi() const =0;
    virtual int ylo() const =0;
    virtual int yhi() const =0;
};

template<class T>
class TC_Image : public TC_ImageBase
{
public:
...
    RD_Image<T>& image(); 
}

class TC_ImageToVectorBase {
public:
    ...
    virtual void sample(RD_Vector& v, 
                        const TC_ImageBase& image, 
                        const RD_Array<RD_GmPoint>& pts) =0;
    // Warp image using pts and sample into v
};

For instance:

class TC_RegionModel {
public:
    TC_RegionModel(const TC_ImageToVectorBase&, 
                   const TC_VectorModelBase&,
                   const TC_VTransformBase& normaliser);

    // Find b which best fit model to image given pts:
    void params(RD_Vector& b, RD_Vector& g_trans,
                const TC_ImageBase& image, 
                const RD_Array<RD_GmPoint>& pts);

    // Reconstruct image given b and pts:
    void reconstruct(TC_ImageBase& image,
                     const RD_Vector& b, const RD_Vector& g_trans,
                     const RD_Array<RD_GmPoint>& pts);
    ...
};



Tim Cootes
2/24/1998