diff --git a/intrinsiccv/include/ctypes.h b/intrinsiccv/include/ctypes.h index 428bb1315bbb7820ee230087e1a7792a7eb829ba..46caa0fa4ba28f594202d370145bef2ffab3ed0d 100644 --- a/intrinsiccv/include/ctypes.h +++ b/intrinsiccv/include/ctypes.h @@ -1,7 +1,11 @@ -// SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates // // SPDX-License-Identifier: Apache-2.0 +/// @file +/// @brief C-style enums and structs +/// + #ifndef INTRINSICCV_CTYPES_H #define INTRINSICCV_CTYPES_H @@ -15,6 +19,7 @@ #include +/// IntrinsicCV error types typedef enum INTRINSICCV_NODISCARD { /// Success. INTRINSICCV_OK = 0, @@ -45,21 +50,25 @@ typedef struct { double right; } intrinsiccv_border_values_t; +/// IntrinsicCV border types typedef enum { - // The border is a constant value. + /// The border is a constant value. INTRINSICCV_BORDER_TYPE_CONSTANT, - // The border is the value of the first/last element. + /// The border is the value of the first/last element. INTRINSICCV_BORDER_TYPE_REPLICATE, - // The border is the mirrored value of the first/last elements. + /// The border is the mirrored value of the first/last elements. INTRINSICCV_BORDER_TYPE_REFLECT, - // The border simply acts as a "wrap around" to the beginning/end. + /// The border simply acts as a "wrap around" to the beginning/end. INTRINSICCV_BORDER_TYPE_WRAP, - // Like INTRINSICCV_BORDER_TYPE_REFLECT, but the first/last elements are - // ignored. + /// Like INTRINSICCV_BORDER_TYPE_REFLECT, but the first/last elements are + /// ignored. INTRINSICCV_BORDER_TYPE_REVERSE, - // The border is the "continuation" of the + /// The border is the "continuation" of the input rows. It is the caller's + /// responsibility to provide the input data (and an appropriate stride value) + /// in a way that the rows can be under and over read. E.g. can be used when + /// executing an operation on a region of a picture. INTRINSICCV_BORDER_TYPE_TRANSPARENT, - // The border is a hard border, there are no additional values to use. + /// The border is a hard border, there are no additional values to use. INTRINSICCV_BORDER_TYPE_NONE, } intrinsiccv_border_type_t; diff --git a/intrinsiccv/include/intrinsiccv.h b/intrinsiccv/include/intrinsiccv.h index 2711470eceaa223a297ea5bba212d66047435772..da088e4c842dba803334481f8b9c450459cd44cf 100644 --- a/intrinsiccv/include/intrinsiccv.h +++ b/intrinsiccv/include/intrinsiccv.h @@ -559,8 +559,8 @@ intrinsiccv_error_t intrinsiccv_yuv_sp_to_bgra_u8( /// @param dst_stride Distance in bytes from the start of one row to the /// start of the next row for the destination data. Must /// not be less than width * sizeof(type). -/// @param width How many elements are in a row for the output. -/// @param height How many rows are in the output. +/// @param width Number of elements in a row. +/// @param height Number of rows in the data. /// @param threshold The value that the elements of the source data are /// compared to. /// @param value The value that the larger elements are set to. @@ -642,10 +642,62 @@ intrinsiccv_error_t intrinsiccv_resize_to_quarter_u8( const uint8_t *src, size_t src_stride, size_t src_width, size_t src_height, uint8_t *dst, size_t dst_stride, size_t dst_width, size_t dst_height); +/// Calculates vertical derivative approximation with Sobel filter. +/// +/// The used convolution kernel is: +/// ``` +/// [ 1 2 1 ] +/// [ 0 0 0 ] +/// [ -1 -2 -1 ] +/// ``` +/// Note, that the kernel is mirrored both vertically and horizontally during +/// the convolution. +/// +/// The only supported border type is ::INTRINSICCV_BORDER_TYPE_REPLICATE +/// +/// @param src Pointer to the source data. Must be non-null. +/// @param src_stride Distance in bytes from the start of one row to the +/// start of the next row in the source data. Must not be +/// less than width * sizeof(type) * channels. +/// @param dst Pointer to the destination data. Must be non-null. +/// @param dst_stride Distance in bytes from the start of one row to the +/// start of the next row in the destination data. Must not +/// be less than width * sizeof(type) * channels. +/// @param width Number of pixels in the data. (One pixel consists of +/// 'channels' number of elements.) +/// @param height Number of rows in the data. +/// @param channel Number of channels in the data. +/// intrinsiccv_error_t intrinsiccv_sobel_3x3_vertical_s16_u8( const uint8_t *src, size_t src_stride, int16_t *dst, size_t dst_stride, size_t width, size_t height, size_t channel); +/// Calculates horizontal derivative approximation with Sobel filter. +/// +/// The used convolution kernel is: +/// ``` +/// [ 1 0 -1 ] +/// [ 2 0 -2 ] +/// [ 1 0 -1 ] +/// ``` +/// Note, that the kernel is mirrored both vertically and horizontally during +/// the convolution. +/// +/// The only supported border type is ::INTRINSICCV_BORDER_TYPE_REPLICATE +/// +/// @param src Pointer to the source data. Must be non-null. +/// @param src_stride Distance in bytes from the start of one row to the +/// start of the next row in the source data. Must not be +/// less than width * sizeof(type) * channels. +/// @param dst Pointer to the destination data. Must be non-null. +/// @param dst_stride Distance in bytes from the start of one row to the +/// start of the next row in the destination data. Must not +/// be less than width * sizeof(type) * channels. +/// @param width Number of pixels in the data. (One pixel consists of +/// 'channels' number of elements.) +/// @param height Number of rows in the data. +/// @param channel Number of channels in the data. +/// intrinsiccv_error_t intrinsiccv_sobel_3x3_horizontal_s16_u8( const uint8_t *src, size_t src_stride, int16_t *dst, size_t dst_stride, size_t width, size_t height, size_t channel); @@ -690,9 +742,10 @@ intrinsiccv_error_t intrinsiccv_gaussian_blur_5x5_u8( /// stride values in the array must be the same as the /// channel number. All stride values must not be less than /// width * sizeof(type). -/// @param width Number of elements in a row. -/// @param height Number of rows in the data. -/// @param channels Number of channels in the data. +/// @param width Number of pixels in one row of the source data. (One +/// pixel consists of 'channels' number of elements.) +/// @param height Number of rows in the source data. +/// @param channels Number of channels in the source data. /// @param element_size Size of one element in bytes. /// intrinsiccv_error_t intrinsiccv_split(const void *src_data, size_t src_stride, diff --git a/intrinsiccv/src/filters/sobel_neon.cpp b/intrinsiccv/src/filters/sobel_neon.cpp index fbaf520194c31a6e6cad4ec66699634a57f1b779..0dd403f4b03ac35e3bbaa3df96c81bd92fcb4592 100644 --- a/intrinsiccv/src/filters/sobel_neon.cpp +++ b/intrinsiccv/src/filters/sobel_neon.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates // // SPDX-License-Identifier: Apache-2.0 @@ -12,6 +12,8 @@ namespace intrinsiccv::neon { // Template for 3x3 Sobel filters which calculate horizontal derivative // approximations, often denoted as Gx. // +// The applied weights, as the kernel is mirrored both vertically and +// horizontally during the convolution: // [ -1, 0, 1 ] [ 1 ] // F = [ -2, 0, 2 ] = [ 2 ] * [ -1, 0, 1 ] // [ -1, 0, 1 ] [ 1 ] @@ -69,9 +71,11 @@ class HorizontalSobel3x3 { // Template for 3x3 Sobel filters which calculate vertical derivative // approximations, often denoted as Gy. // -// [ -1, -2, 1 ] [ -1 ] -// F = [ 0, 0, 0 ] = [ 0 ] * [ 1, 2, 1 ] -// [ 1, 2, 1 ] [ 1 ] +// The applied weights, as the kernel is mirrored both vertically and +// horizontally during the convolution: +// [ -1, -2, -1 ] [ -1 ] +// F = [ 0, 0, 0 ] = [ 0 ] * [ 1, 2, 1 ] +// [ 1, 2, 1 ] [ 1 ] template class VerticalSobel3x3; diff --git a/scripts/format.sh b/scripts/format.sh index 6ccade3c9dbda361abbe11c2de055a9f85bcb242..a4c539cb10117c0493d72050d02e3a8020b17461 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash -# -# SPDX-FileCopyrightText: 2023 Arm Limited and/or its affiliates + +# SPDX-FileCopyrightText: 2023 - 2024 Arm Limited and/or its affiliates # # SPDX-License-Identifier: Apache-2.0 -# + # Runs clang-format or checks whether the source is well-formatted. # # Options: # CHECK_ONLY: If set to 'ON', the script exists with non-zero value if source is not formatted. Defaults to 'OFF'. -# CLANG_FORMAT_BIN_PATH: Clang-format binary, defaults to 'clang-format'. +# CLANG_FORMAT_BIN_PATH: Clang-format binary, defaults to 'clang-format=17'. # VERBOSE: If set to 'ON', verbose output is printed. Defaults to 'OFF'. # ------------------------------------------------------------------------------ diff --git a/test/api/test_sobel.cpp b/test/api/test_sobel.cpp index 97d4828eaa0eb11b1f35f0d00b6ba52d4eb18fe7..431586d850d2f562b7a9ccb94f7b8519c4cba50f 100644 --- a/test/api/test_sobel.cpp +++ b/test/api/test_sobel.cpp @@ -40,7 +40,7 @@ static constexpr std::array kSupportedBorders = { INTRINSICCV_BORDER_TYPE_REPLICATE, }; -// Default test fo horizontal Sobel 3x3 operator. +// Test for Sobel 3x3 operator. template class Sobel3x3Test : public test::KernelTest { using typename test::KernelTest::InputType;