Hi Olivier, here is a slightly better version:
#include
#include
#include
namespace boost { namespace gil {
template
struct channel_abs_t : public std::binary_function {
ChannelR operator()(typename channel_traits<Channel1>::const_reference ch1,
typename
channel_traits<Channel2>::const_reference ch2) const {
return std::abs( ChannelR(ch1) - ChannelR(ch2) );
}
};
template // models pixel value concept
struct pixel_abs_t {
PixelR operator() (const PixelRef1& p1,
const PixelRef2& p2) const {
PixelR result;
static_transform(p1,p2,result,
channel_abs_t());
return result;
}
};
typedef double bits64F;
GIL_DEFINE_BASE_TYPEDEFS(64F,gray)
typedef float bits32F;
GIL_DEFINE_BASE_TYPEDEFS(32F,gray)
} // namespace gil
} // namespace boost
using namespace boost;
using namespace gil;
template< typename SRC1, typename SRC2, typename DST >
void generate_diff( const SRC1& src1, const SRC2& src2, const DST& dst )
{
transform_pixels( src1, src2, dst, pixel_abs_t< typename SRC1::value_type
, typename SRC2::value_type
, typename DST::value_type
>()
);
}
int main(int argc, char** argv)
{
{
gray16s_image_t mns( 10, 10 );
gray32F_image_t mnt( 10, 10 ), mne( 10, 10 );
fill_pixels( view( mns ), gray16s_image_t::value_type( 5 ));
fill_pixels( view( mnt ), gray32F_image_t::value_type( 12 ));
fill_pixels( view( mne ), gray32F_image_t::value_type( 0 ));
generate_diff( const_view( mns ), const_view( mnt ), view( mne ) );
gray32F_image_t::value_type p = *view( mne ).xy_at( 0, 0 );
}
return 0;
}
Does that somehow fit your needs?
Regards,
Christian