学习DIP第45天
转载请标明本文出处:http://blog.csdn.net/tonyshengtan,欢迎大家转载,发现博客被某些论坛转载后,图像无法正常显示,无法正常表达本人观点,对此表示很不满意。有些网站转载了我的博文,很开心的是自己写的东西被更多人看到了,但不开心的是这段话被去掉了,也没标明转载来源,虽然这并没有版权保护,但感觉还是不太好,出于尊重文章作者的劳动,转载请标明出处!!!!
文章代码已托管,欢迎共同开发:https://github.com/Tony-Tan/DIPpro
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
double Prewitt(double *src,double *dst,int width,int height){
double PrewittMask1[3]={1.0/3.0,1.0/3.0,1.0/3.0};
double PrewittMask2[3]={-1.0,0.0,1.0};
double *dst_x=(double *)malloc(sizeof(double)*width*height);
double *dst_y=(double *)malloc(sizeof(double)*width*height);
RealRelevant(src, dst_x, PrewittMask1, width, height, 1, 3);
RealRelevant(dst_x, dst_x, PrewittMask2, width, height, 3, 1);
RealRelevant(src, dst_y, PrewittMask2, width, height, 1, 3);
RealRelevant(dst_y, dst_y, PrewittMask1, width, height, 3, 1);
for(int j=0;j<height;j++)
for(int i=0;i<width;i++){
dst[j*width+i]=abs(dst_x[j*width+i])+abs(dst_y[j*width+i]);
}
free(dst_x);
free(dst_y);
return findMatrixMax(dst,width,height);
}原文地址:http://blog.csdn.net/tonyshengtan/article/details/43730361