From 4bdd4268fb7ed32696d8dda1490ed28ed62994f0 Mon Sep 17 00:00:00 2001 From: Scramjet911 Date: Mon, 25 Jan 2021 10:50:43 +0530 Subject: [PATCH 1/3] Fixed most of the warnings in the examples and many of the boost build process --- example/hessian.cpp | 4 ++-- example/mandelbrot.cpp | 2 +- include/boost/gil/channel_algorithm.hpp | 2 +- include/boost/gil/image_processing/harris.hpp | 4 ++-- include/boost/gil/image_processing/hessian.hpp | 4 ++-- include/boost/gil/image_processing/numeric.hpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/example/hessian.cpp b/example/hessian.cpp index e27199f5f4..50f192790a 100644 --- a/example/hessian.cpp +++ b/example/hessian.cpp @@ -80,9 +80,9 @@ void apply_gaussian_blur(gil::gray8_view_t input_view, gil::gray8_view_t output_ for (std::ptrdiff_t y = 0; y < height; ++y) { double intensity = 0.0; - for (std::ptrdiff_t filter_y = 0; filter_y < filter_height; ++filter_y) + for (std::ptrdiff_t filter_y = 0; filter_y < static_cast(filter_height); ++filter_y) { - for (std::ptrdiff_t filter_x = 0; filter_x < filter_width; ++filter_x) + for (std::ptrdiff_t filter_x = 0; filter_x < static_cast(filter_width); ++filter_x) { int image_x = x - filter_width / 2 + filter_x; int image_y = y - filter_height / 2 + filter_y; diff --git a/example/mandelbrot.cpp b/example/mandelbrot.cpp index 0bcfc2ea14..1aa5a90897 100644 --- a/example/mandelbrot.cpp +++ b/example/mandelbrot.cpp @@ -40,7 +40,7 @@ struct mandelbrot_fn t=pow(t,0.2); value_type ret; - for (int k=0; k::value; ++k) + for (std::size_t k=0; k::value; ++k) ret[k]=(typename channel_type

::type)(_in_color[k]*t + _out_color[k]*(1-t)); return ret; } diff --git a/include/boost/gil/channel_algorithm.hpp b/include/boost/gil/channel_algorithm.hpp index 12ecd01b0a..848c9652ad 100644 --- a/include/boost/gil/channel_algorithm.hpp +++ b/include/boost/gil/channel_algorithm.hpp @@ -79,7 +79,7 @@ struct unsigned_integral_max_value> template struct unsigned_integral_num_bits - : std::integral_constant + : std::integral_constant(sizeof(UnsignedIntegralChannel) * 8)> {}; template diff --git a/include/boost/gil/image_processing/harris.hpp b/include/boost/gil/image_processing/harris.hpp index c5deedda99..c868d35da9 100644 --- a/include/boost/gil/image_processing/harris.hpp +++ b/include/boost/gil/image_processing/harris.hpp @@ -57,10 +57,10 @@ void compute_harris_responses( float dxdy = 0; float ddyy = 0; for (gil::gray32f_view_t::coord_t y_kernel = 0; - y_kernel < window_length; + y_kernel < static_cast(window_length); ++y_kernel) { for (gil::gray32f_view_t::coord_t x_kernel = 0; - x_kernel < window_length; + x_kernel < static_cast(window_length); ++x_kernel) { ddxx += m11(x + x_kernel - half_length, y + y_kernel - half_length) .at(std::integral_constant{}) * weights.at(x_kernel, y_kernel); diff --git a/include/boost/gil/image_processing/hessian.hpp b/include/boost/gil/image_processing/hessian.hpp index 2c8c3adeb1..f88c153607 100644 --- a/include/boost/gil/image_processing/hessian.hpp +++ b/include/boost/gil/image_processing/hessian.hpp @@ -50,9 +50,9 @@ inline void compute_hessian_responses( auto ddxx_i = channel_t(); auto ddyy_i = channel_t(); auto dxdy_i = channel_t(); - for (typename OutputView::coord_t w_y = 0; w_y < weights.size(); ++w_y) + for (typename OutputView::coord_t w_y = 0; w_y < static_cast(weights.size()); ++w_y) { - for (typename OutputView::coord_t w_x = 0; w_x < weights.size(); ++w_x) + for (typename OutputView::coord_t w_x = 0; w_x < static_cast(weights.size()); ++w_x) { ddxx_i += ddxx(x + w_x - center, y + w_y - center) .at(std::integral_constant{}) * weights.at(w_x, w_y); diff --git a/include/boost/gil/image_processing/numeric.hpp b/include/boost/gil/image_processing/numeric.hpp index 2109c555f4..b601b17dd0 100644 --- a/include/boost/gil/image_processing/numeric.hpp +++ b/include/boost/gil/image_processing/numeric.hpp @@ -48,7 +48,7 @@ inline double lanczos(double x, std::ptrdiff_t a) if (0 <= x && x <= 0) return 1; - if (-a < x && x < a) + if (static_cast(-a) < x && x < static_cast(a)) return normalized_sinc(x) / normalized_sinc(x / static_cast(a)); return 0; From 800c79707e4ddd37f4a1edebcc703ddcc8e832f9 Mon Sep 17 00:00:00 2001 From: Scramjet911 Date: Wed, 27 Jan 2021 16:57:29 +0530 Subject: [PATCH 2/3] Reduced more warnings --- include/boost/gil/color_base.hpp | 2 +- include/boost/gil/color_convert.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/gil/color_base.hpp b/include/boost/gil/color_base.hpp index a05b409de8..b638aacbba 100644 --- a/include/boost/gil/color_base.hpp +++ b/include/boost/gil/color_base.hpp @@ -84,7 +84,7 @@ struct homogeneous_color_base typename U = Element, typename = typename std::enable_if::value>::type > - homogeneous_color_base() : v0_{} {}; + homogeneous_color_base() : v0_{} {} explicit homogeneous_color_base(Element v) : v0_(v) {} diff --git a/include/boost/gil/color_convert.hpp b/include/boost/gil/color_convert.hpp index 080d758ae9..a4b6427023 100644 --- a/include/boost/gil/color_convert.hpp +++ b/include/boost/gil/color_convert.hpp @@ -170,13 +170,13 @@ struct default_color_converter_impl // Apply color correction, strengthening, reducing non-zero components by // s = 1 / (1 - k) for k < 1, where 1 denotes dst_t max, otherwise s = 1 (literal). uint_t const dst_max = channel_traits::max_value(); - uint_t const s_div = dst_max - k; + uint_t const s_div = static_cast(dst_max - k); if (s_div != 0) { double const s = dst_max / static_cast(s_div); - c = (c - k) * s; - m = (m - k) * s; - y = (y - k) * s; + c = static_cast((c - k) * s); + m = static_cast((m - k) * s); + y = static_cast((y - k) * s); } else { From e9555893b4fac1c2b0f31523faedab80c05294bd Mon Sep 17 00:00:00 2001 From: Scramjet911 Date: Fri, 29 Jan 2021 19:01:04 +0530 Subject: [PATCH 3/3] Variable initializing improvements --- example/hessian.cpp | 8 ++++---- include/boost/gil/image_processing/harris.hpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/hessian.cpp b/example/hessian.cpp index 50f192790a..cf05050bcc 100644 --- a/example/hessian.cpp +++ b/example/hessian.cpp @@ -60,8 +60,8 @@ gil::gray8_image_t to_grayscale(gil::rgb8_view_t original) void apply_gaussian_blur(gil::gray8_view_t input_view, gil::gray8_view_t output_view) { - constexpr static auto filter_height = 5ull; - constexpr static auto filter_width = 5ull; + constexpr static std::ptrdiff_t filter_height = 5ull; + constexpr static std::ptrdiff_t filter_width = 5ull; constexpr static double filter[filter_height][filter_width] = { { 2, 4, 6, 4, 2 }, @@ -80,9 +80,9 @@ void apply_gaussian_blur(gil::gray8_view_t input_view, gil::gray8_view_t output_ for (std::ptrdiff_t y = 0; y < height; ++y) { double intensity = 0.0; - for (std::ptrdiff_t filter_y = 0; filter_y < static_cast(filter_height); ++filter_y) + for (std::ptrdiff_t filter_y = 0; filter_y < filter_height; ++filter_y) { - for (std::ptrdiff_t filter_x = 0; filter_x < static_cast(filter_width); ++filter_x) + for (std::ptrdiff_t filter_x = 0; filter_x < filter_width; ++filter_x) { int image_x = x - filter_width / 2 + filter_x; int image_y = y - filter_height / 2 + filter_y; diff --git a/include/boost/gil/image_processing/harris.hpp b/include/boost/gil/image_processing/harris.hpp index c868d35da9..18185afd81 100644 --- a/include/boost/gil/image_processing/harris.hpp +++ b/include/boost/gil/image_processing/harris.hpp @@ -44,7 +44,7 @@ void compute_harris_responses( " tensor from the same image"); } - auto const window_length = weights.size(); + std::ptrdiff_t const window_length = weights.size(); auto const width = m11.width(); auto const height = m11.height(); auto const half_length = window_length / 2; @@ -57,10 +57,10 @@ void compute_harris_responses( float dxdy = 0; float ddyy = 0; for (gil::gray32f_view_t::coord_t y_kernel = 0; - y_kernel < static_cast(window_length); + y_kernel < window_length; ++y_kernel) { for (gil::gray32f_view_t::coord_t x_kernel = 0; - x_kernel < static_cast(window_length); + x_kernel < window_length; ++x_kernel) { ddxx += m11(x + x_kernel - half_length, y + y_kernel - half_length) .at(std::integral_constant{}) * weights.at(x_kernel, y_kernel);