?? 模擬圖像去噪之臨域平均法算法優(yōu)化及實現(xiàn).txt
字號:
模擬圖像去噪之臨域平均法算法優(yōu)化及實現(xiàn)[原創(chuàng)]
簡單修改與模擬,見笑。
把行與列都看作循環(huán)隊列,遇到0就變?yōu)镹-1。
/*
realization of linyu lvbo method of image processing
AUTHOR:BugEyes
http://BugEyes.blog.edu.cn
*/
#define N 10
#define M 255
#i nclude <conio.h> /* for the function 'clrscr' */
#i nclude <stdlib.h> /* for the function 'random' */
void init(int arr[N][N])
{
int i,j;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
arr[i][j]=random(M);
}
int linyu1(int arr[N][N],int row,int col,int core[3][3])
{ /* to compute the current value according to its linyu,using new method*/
int result=0;
int i,j;
int count=0;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
int row1=(row-1+i+N)%N;
int col1=(col-1+j+N)%N;
result+=arr[row1][col1]*core[i][j];
count+=core[i][j];
}
return result/count;
}
void compute(int arr[N][N],int core[3][3],int result[N][N])
{ /* to compute the result image */
int row,col;
for(row=0;row<N;row++)
for(col=0;col<N;col++)
result[row][col]=linyu1(arr,row,col,core);
}
void output(int arr[N][N])
{
int i,j;
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
printf("%4d",arr[i][j]);
printf("\n\n");
}
}
void main()
{
int array[N][N];
int result[N][N];
int core[3][3]={{1,2,1},
{2,4,2},
{1,2,1}};
int core1[3][3]={{1,1,1},
{1,1,1},
{1,1,1}};
int core2[3][3]={{2,4,2},
{4,8,4},
{2,4,2}};
int core3[3][3]={{1,1,1},
{1,0,1},
{1,1,1}};
clrscr();
init(array);
compute(array,core3,result);
printf("\nThe original array is ...\n\n");
output(array);
printf("\nThe result array is....\n\n");
output(result);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -