#include "cv.h"
#include "highgui.h"
using namespace cv;
#define PI 3.1415926
#define RADIAN(angle) ((angle)*PI/180.0)
uchar BayerPattern[8][8]={0,32,8,40,2,34,10,42,
48,16,56,24,50,18,58,26,
12,44,4,36,14,46,6,38,
60,28,52,20,62,30,54,22,
3,35,11,43,1,33,9,41,
51,19,59,27,49,17,57,25,
15,47,7,39,13,45,5,37,
63,31,55,23,61,29,53,21};
//图案法 半色调化
Mat LimbPatternM3(Mat& mat)
{
int M=mat.rows;
int N=mat.cols;
Mat ret(M,N,CV_8U);
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
{
uchar num=mat.ptr<uchar>(i)[j];
if((num>>2)>BayerPattern[i&7][j&7])
ret.ptr<uchar>(i)[j]=255;
else
ret.ptr<uchar>(i)[j]=0;
}
}
return ret;
}
//抖动法
void Steinberg(Mat& mat)
{
int M=mat.rows;
int N=mat.cols;
Mat temp(M,N,CV_32S);
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
temp.ptr<int>(i)[j]=mat.ptr<uchar>(i)[j];
for(int
图像处理之半色调化
最新推荐文章于 2023-08-05 18:06:38 发布