⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 模拟图像去噪之临域平均法算法优化及实现.txt

📁 c语言的一些常见的算法以及思考和改进的文章,写的很不错,花费了很大的精力从网络了搜罗的,希望大家喜欢.
💻 TXT
字号:
模拟图像去噪之临域平均法算法优化及实现[原创] 
简单修改与模拟,见笑。

把行与列都看作循环队列,遇到0就变为N-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 + -