马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
灰度共生矩阵MATLAB实现 联合概率矩阵法是对图像的所有像素进行统计调查,以便描述其灰度分布的一种方法。
- function [mat_temp]=compute(temp_m,graynum,dist)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- for i=1:graynum
- for j=1:graynum
- matH(i,j)=0;matV(i,j)=0;matRD(i,j)=0;matLD(i,j)=0;
- end
- end
- double total;total=0;
- for m=1:16
- for n=1:16
- newimage(m,n)=ceil(temp_m(m,n)/(256/graynum));
- end
- end
-
- %%% 0
- for m=1:16
- for n=1:16-dist
- matH(newimage(m,n),newimage(m,n+dist))=matH(newimage(m,n),newimage(m,n+dist))+1;
- matH(newimage(m,n+dist),newimage(m,n))=matH(newimage(m,n+dist),newimage(m,n))+1;
- end
- end
-
- %%%%%%%%%%%%%%% 90
- for m=1:16-dist
- for n=1:16
- matV(newimage(m,n),newimage(m+dist,n))=matV(newimage(m,n),newimage(m+dist,n))+1;
- matV(newimage(m+dist,n),newimage(m,n))=matV(newimage(m+dist,n),newimage(m,n))+1;
- end
- end
-
- %%%%%%%%%%%%%%%%%%% 135
- for m=1:16-dist
- for n=16-dist
- matLD(newimage(m,n),newimage(m+dist,n+dist))= matLD(newimage(m,n),newimage(m+dist,n+dist))+1;
- matLD(newimage(m+dist,n+dist),newimage(m,n))= matLD(newimage(m+dist,n+dist),newimage(m,n))+1;
- end
- end
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45
- for m=dist:16
- for n=1:16-dist
- matRD(newimage(m,n),newimage(m-dist+1,n+dist))=matRD(newimage(m,n),newimage(m-dist+1,n+dist))+1;
- matRD(newimage(m-dist+1,n+dist),newimage(m,n))=matRD(newimage(m-dist+1,n+dist),newimage(m,n))+1;
- end
- end
-
-
- %%%%%%%%%%%%%%
- for m=1:graynum
- for n=1:graynum
- total=total+matH(m,n);
- end
- end
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- for m=1:graynum
- for n=1:graynum
- mat_temp(m,n)=matH(m,n)/total;
- mat_temp(m,n)=double(mat_temp(m,n));
- end
- end
-
- %%%% over
复制代码 |