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

📄 utility.c

📁 This is code tutorial for image processing include:histogram,sketon....
💻 C
字号:



       /********************************************
       *
       *       file utility.c
       *
       *       Functions: This file contains
       *          fix_edges
       *          sort_elements
       *          swap
       *
       ********************************************/



#include "cips.h"




   /***********************************************
    *
    *    fix_edges(...
    *
    *    This function fixes the edges of an image
    *    array after convolution was performed.
    *    It copies the points near the edge of the
    *    array out to the edge of the array.
    *
    ***********************************************/

fix_edges(im, w, rows, cols)
      int   w;
      short **im;
      long  rows, cols;
{
   int i, j;

printf("\nFIX> rows=%ld cols=%ld w=%d",rows,cols,w);
      /* four corners */
   for(i=w; i>0; i--){
    im[i-1][i-1] = im[i][i];
    im[i-1][cols-(i-1)] = im[i][cols-1-(i-1)];
    im[rows-(i-1)][i-1] = im[rows-1-(i-1)][i];
    im[rows-(i-1)][cols-(i-1)] = im[rows-1-(i-1)][cols-1-(i-1)];
   }  /* ends four corners loop */

   for(i=0; i<rows; i++){
      for(j=w; j>0; j--){
       im[i][j-1] = im[i][j];
       im[i][cols-j] = im[i][cols-j-1];
      }
   }

   for(j=0; j<cols; j++){
      for(i=w; i>0; i--){
       im[i-1][j] = im[i][j];
       im[rows-i][j] = im[rows-i-1][j];
      }
   }

}  /* ends fix_edges */




    /***********************************************
    *
    *    sort_elements(...
    *
    *    This function performs a simple bubble
    *    sort on the elements from the median
    *    filter.
    *
    ***********************************************/

sort_elements(elements, count)
   int   *count;
   short elements[];
{
   int i, j;
   j = *count;
   while(j-- > 1){
      for(i=0; i<j; i++){
         if(elements[i] > elements[i+1])
            swap(&elements[i], &elements[i+1]);
      }
   }
}  /* ends sort_elements */




    /***********************************************
    *
    *    swap(...
    *
    *    This function swaps two shorts.
    *
    ***********************************************/

swap(a, b)
   short *a, *b;
{
   short temp;
   temp  = *a;
   *a    = *b;
   *b    = temp;
}  /* ends swap */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -