#include <opencv2/core/core.hpp>
#include <iostream>
using namespace cv;
using namespace std;
void HorizonProjection(const Mat& src, Mat& dst)
{
// accept only char type matrices
CV_Assert(src.depth() != sizeof(uchar));
dst.create(src.rows, 1, CV_32F);
int i, j;
const uchar* p;
float* p_dst;
for(i = 0; i < src.rows; i++){
p = src.ptr<uchar>(i);
p_dst = dst.ptr<float>(i);
p_dst[0] = 0;
for(j = 0; j < src.cols; j++){
p_dst[0] += p[j];
}
}
}
void VerticalProjection(const Mat& src, Mat& dst)
{
// accept only char type matrices
CV_Assert(src.depth() != sizeof(uchar));
dst.create(1, src.cols, CV_32F);
int i, j;
const uchar* p;
float* p_dst = dst.ptr<float>(0);
for(j = 0; j < src.cols; j++){
p_dst[j] = 0;
for(i = 0; i < src.rows; i++){
p = src.ptr<uchar>(i);
p_dst[j
对OpenCV mat进行水平和垂直方向的投影
最新推荐文章于 2023-10-19 20:53:00 发布
该博客介绍了如何使用OpenCV库对单通道uchar类型的矩阵进行水平和垂直方向的投影操作,详细阐述了投影过程及其应用场景。
摘要由CSDN通过智能技术生成