generate_gaussian_kernel and warning C4244: conversion from double to float
@simmplecoder Would it be possible to get rid of these warnings?
image_processing\numeric.hpp(104): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
image_processing\numeric.hpp(104): warning C4244: 'initializing': conversion from 'double' to 'const float', possible loss of data
Environment
- Compiler version:
_MSC_VER=1922
I was thinking about making the argument a template, after adding boost::gil::gray64f_view_t and tests. Casting after making a template might suppress warnings that would otherwise be useful. Do other Boost libraries handle such issues?
The questions are related to the issue #204 raised by @sdebionne
/cc @stefanseefeld
I think there are two choices at least:
-
Use
doubleas common type for results of arithmetic operations, then explicitly cast to expected result type. Preferably, with sprinkle of assertions checking the intermediate and final values are in expected range. -
Select most precise type at compile time. This approach is used in Boost.Geometry, see geometry::select_most_precise metafunction and how it is used in value_operation executor which is called like this:
detail::value_operation<typename coordinate_type<Point>::type, std::divides>(value);I imagine, we could employ similar approach.
If we consider 2. to be a compelling idea, then we can leave this issue open and the current code (as reminder) until we have PR ready with gil::select_most_precise added and applied to channel and pixel arithmetic.