Boost logo

Boost Users :

Subject: Re: [Boost-users] Template class and any_image_view
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-10-14 12:03:06


Hi Raffaele, I have made some changes and the code now compiles with
VC++ 2005. I believe that your error was to define the template
parameter for BlurGaussSelective class. You wrote this:

BlurGaussSelective<ViewType,ViewType> filter;

but this is correct:

BlurGaussSelective< any_image<ImageType>::const_view_t,
any_image<ImageType>::const_view_t > filter;

Also, you don't need two template parameters. Please review the code
below and let me know if you have questions or remarks.

#include <boost\cstdint.hpp>

#include <boost\gil\gil_all.hpp>
#include <boost\gil\extension\io\jpeg_dynamic_io.hpp>

#include <boost\gil\extension\dynamic_image\dynamic_image_all.hpp>

using namespace std;
using namespace boost;
using namespace gil;

template <typename TView>
class Filter
{
public:
    virtual ~Filter();
    virtual void setParameter(uint8_t id, float value);

    virtual void apply( TView& source, TView& destination) = 0;

protected:
    Filter();
};

template <typename TView >
class BlurGaussSelective : public Filter<TView>
{
public:
    BlurGaussSelective();
    virtual ~BlurGaussSelective();
    void setParameter(uint8_t id, float value);

    void apply( TView& source, TView& destination );
};

int main(int argc, char* argv[])
{
    typedef mpl::vector<rgb8_image_t,gray8_image_t> ImageType;
    typedef mpl::vector<rgb8_view_t,gray8_view_t> ViewType;

    any_image<ImageType> source;
    any_image<ImageType> dest;
    jpeg_read_image("input.jpg", source);
    jpeg_read_image("input.jpg", dest);

    BlurGaussSelective< any_image<ImageType>::const_view_t > filter;
    filter.apply(const_view(source),const_view(dest));
}

Regards,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net