- 操作系統:ubuntu22.04
- OpenCV版本:OpenCV4.9
- IDE:Visual Studio Code
- 編程語言:C++11
算法描述
對輸入的 uchar1 像素值(范圍 [0, 255]),先歸一化到 [0.0, 1.0] 浮點區間,然后計算其反正切值 atan(x),最終返回一個 float1 類型的結果。
函數原型
__device__ __forceinline__ float1 cv::cudev::atan ( const uchar1 & a )
參數
- uchar1 CUDA 向量類型,表示一個單通道 8 位無符號整型(等價于 unsigned char 或 uint8_t)。
代碼示例
#include <opencv2/cudev/functional/functional.hpp>
#include <cstdio>__global__ void test_atan() {uchar1 a = make_uchar1(128); // 輸入一個像素值float1 res = cv::cudev::atan(a);printf("atan(128 / 255) = %f\n", res.x);
}int main() {test_atan<<<1, 1>>>();cudaDeviceReset();return 0;
}
運行結果
atan(128 / 255) = 1.562984