Skip to content

Commit 8378bad

Browse files
committed
Update generate_octave template function implementation
Update generate_octave template function implementation
1 parent db453bb commit 8378bad

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

image_operations.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6159,7 +6159,9 @@ namespace TinyDIP
61596159
// generate_octave template function implementation (Multi-Channel Overload)
61606160
template<typename ElementT, typename SigmaT = double>
61616161
requires((std::floating_point<SigmaT> || std::integral<SigmaT>) and
6162-
((std::same_as<ElementT, RGB>) || (std::same_as<ElementT, RGB_DOUBLE>) || (std::same_as<ElementT, HSV>) || (is_MultiChannel<ElementT>::value))
6162+
((std::same_as<ElementT, RGB>) || (std::same_as<ElementT, RGB_DOUBLE>) || (std::same_as<ElementT, HSV>) || (is_MultiChannel<ElementT>::value)) and
6163+
(!is_bool_data_v<ElementT>) and
6164+
(!is_complex_data_v<ElementT>)
61636165
)
61646166
static auto generate_octave(
61656167
const Image<ElementT>& input,
@@ -6180,6 +6182,11 @@ namespace TinyDIP
61806182
// Force floating-point precision on the plane before DoG evaluation
61816183
return TinyDIP::difference_of_gaussian(TinyDIP::im2double(std::forward<decltype(each_plane)>(each_plane)), initial_sigma, initial_sigma);
61826184
}
6185+
else
6186+
{
6187+
// Compile-time firewall preventing cryptic void deduction errors on unsupported raw types
6188+
static_assert(!std::same_as<ScalarT, ScalarT>, "The underlying channel type of the multi-channel image is not supported by difference_of_gaussian or im2double.");
6189+
}
61836190
};
61846191
using MultiChannelDiffT = decltype(apply_each(input, deduce_type_lambda));
61856192

@@ -6206,19 +6213,23 @@ namespace TinyDIP
62066213
if constexpr (std::same_as<ScalarT, double>)
62076214
{
62086215
return TinyDIP::difference_of_gaussian(
6209-
each_plane,
6216+
std::forward<decltype(each_plane)>(each_plane),
62106217
sig1,
62116218
sig2
62126219
);
62136220
}
6214-
else
6221+
else if constexpr (requires { TinyDIP::im2double(std::forward<decltype(each_plane)>(each_plane)); })
62156222
{
62166223
return TinyDIP::difference_of_gaussian(
6217-
TinyDIP::im2double(each_plane),
6224+
TinyDIP::im2double(std::forward<decltype(each_plane)>(each_plane)),
62186225
sig1,
62196226
sig2
62206227
);
62216228
}
6229+
else
6230+
{
6231+
static_assert(!std::same_as<ScalarT, ScalarT>, "The underlying channel type of the multi-channel image is not supported by difference_of_gaussian or im2double.");
6232+
}
62226233
});
62236234
}
62246235

0 commit comments

Comments
 (0)