如何使用OpenCV代码将此C ++转换为普通C?
void sharpen(const Mat& src_, Mat& dst_) {
dst_.create(src_.size(),src_.type());
const int nChannels = src_.channels();
unsigned int arr_len = nChannels*(src_.cols-1);
for(int j = 1 ; j < src_.rows-1; ++j) {
const uchar* previous_0 = src_.ptr<uchar>(j - 1);
const uchar* current_0 = src_.ptr<uchar>(j );
const uchar* next_0 = src_.ptr<uchar>(j + 1);
const uchar* previous_1 = src_.ptr<uchar>(j - 1)+3;
const uchar* current_1 = src_.ptr<uchar>(j )+3;
const uchar* next_1 = src_.ptr<uchar>(j + 1)+3;
const uchar* previous_2 = src_.ptr<uchar>(j - 1)+6;
const uchar* current_2 = src_.ptr<uchar>(j )+6;
const uchar* next_2 = src_.ptr<uchar>(j + 1)+6;
uchar* output = dst_.ptr<uchar>(j);
for(unsigned int i=nChannels; i<arr_len; ++i) { // for k=2.25
*output++ = saturate_cast<uchar>((12*(*current_1++) -(*current_0++) -(*current_2++)
-(*previous_1++) -(*previous_0++) -(*previous_2++)
-(*next_1++) -(*next_0++) -(*next_2++))/4);
}
}
}
我想将图像放入uchar(0-255)数组中。 我将 saturate_cast 模板转换为C。
没有问题