cips.c

来自「This is code tutorial for image processi」· C语言 代码 · 共 1,013 行 · 第 1/3 页

C
1,013
字号
                      il3, ie3, ll3, le3);
         }
         if(strncmp("nand", low_high, 4) == 0){
            printf("\nEnter the value of ON pixel");
            printf("\n\t___\b\b\b");
            get_short(&value);
            nand_image(name, name2, name3,
                       the_image, out_image,
                       il,  ie,  ll,  le,
                       il2, ie2, ll2, le2,
                       il3, ie3, ll3, le3, value);
         }
         if(strncmp("nor", low_high, 3) == 0){
            printf("\nEnter the value of ON pixel");
            printf("\n\t___\b\b\b");
            get_short(&value);
            nor_image(name, name2, name3,
                      the_image, out_image,
                      il,  ie,  ll,  le,
                      il2, ie2, ll2, le2,
                      il3, ie3, ll3, le3, value);
         }
         if(strncmp("not", low_high, 3) == 0){
            printf("\nEnter the value of ON pixel");
            printf("\n\t___\b\b\b");
            get_short(&value);
            not_image(name, name2, name3,
                      the_image, out_image,
                      il,  ie,  ll,  le, value);
         }
        break;

        case 20: /* overlay operations */
         printf("\nCIPS> Overlay operations:"
                "\n      output = first OP second");
         printf("\nCIPS> Enter first image name\n");
         get_image_name(name);
         printf("\nCIPS> Enter second image name\n");
         get_image_name(name2);
         printf("\nCIPS> Enter output image name\n");
         get_image_name(name3);
         printf("\nCIPS> Enter parameters for first image");
         get_parameters(&il, &ie, &ll, &le);
         printf("\nCIPS> Enter parameters for second image");
         get_parameters(&il2, &ie2, &ll2, &le2);
         printf("\nCIPS> Enter parameters for output image");
         get_parameters(&il3, &ie3, &ll3, &le3);
         printf("\n\nCIPS> Enter: non-zero zero "
                "greater less average\n");
         gets(low_high);

         if(strncmp("non", low_high, 3) == 0){
            non_zero_overlay(name, name2, name3,
                             the_image, out_image,
                             il,  ie,  ll,  le,
                             il2, ie2, ll2, le2,
                             il3, ie3, ll3, le3);
         }
         if(strncmp("zero", low_high, 4) == 0){
            zero_overlay(name, name2, name3,
                         the_image, out_image,
                         il,  ie,  ll,  le,
                         il2, ie2, ll2, le2,
                         il3, ie3, ll3, le3);
         }
         if(strncmp("gre", low_high, 3) == 0){
            greater_overlay(name, name2, name3,
                            the_image, out_image,
                             il,  ie,  ll,  le,
                             il2, ie2, ll2, le2,
                            il3, ie3, ll3, le3);
         }
         if(strncmp("less", low_high, 4) == 0){
            less_overlay(name, name2, name3,
                         the_image, out_image,
                         il,  ie,  ll,  le,
                         il2, ie2, ll2, le2,
                         il3, ie3, ll3, le3);
         }
         if(strncmp("ave", low_high, 3) == 0){
            average_overlay(name, name2, name3,
                             the_image, out_image,
                            il,  ie,  ll,  le,
                            il2, ie2, ll2, le2,
                            il3, ie3, ll3, le3);
         }
        break;

        case 21: /* shape operations */
         printf("\nCIPS> Enter input image name\n");
         get_image_name(name);
         printf("\nCIPS> Enter output image name\n");
         get_image_name(name2);
         get_parameters(&il, &ie, &ll, &le);
         get_shape_options(low_high, &value,
                           &threshold, &number);
         if(strncmp("thi", low_high, 3) == 0){
            thinning(name, name2, the_image, out_image,
                     il, ie, ll, le,
                     value, threshold, 0);
         }
         if(strncmp("dnj", low_high, 3) == 0){
            dilate_not_join(name, name2, the_image,
                            out_image, il, ie, ll, le,
                            value, threshold);
         }
         if(strncmp("ero", low_high, 3) == 0){
            erosion(name, name2, the_image, out_image,
                    il, ie, ll, le, value, threshold);
         }
         if(strncmp("dil", low_high, 3) == 0){
            dilation(name, name2, the_image, out_image,
                     il, ie, ll, le, value, threshold);
         }
         if(strncmp("mer", low_high, 3) == 0){
            mask_erosion(name, name2, the_image,
                         out_image, il, ie, ll, le,
                         value, threshold);
         }
         if(strncmp("mdi", low_high, 3) == 0){
            mask_dilation(name, name2, the_image,
                          out_image, il, ie, ll, le,
                          value, threshold);
         }
         if(strncmp("int", low_high, 3) == 0){
            interior_outline(name, name2, the_image,
                             out_image, il, ie, ll, le,
                             value, threshold);
         }
         if(strncmp("ext", low_high, 3) == 0){
            exterior_outline(name, name2, the_image,
                             out_image, il, ie, ll, le,
                             value, threshold);
         }
         if(strncmp("ope", low_high, 3) == 0){
            opening(name, name2, the_image, out_image,
                    il, ie, ll, le, value, threshold,
                    number);
         }
         if(strncmp("clo", low_high, 3) == 0){
            closing(name, name2, the_image, out_image,
                    il, ie, ll, le, value, threshold,
                    number);
         }
         if(strncmp("spo", low_high, 3) == 0){
            special_opening(name, name2, the_image,
                            out_image, il, ie, ll, le,
                            value, threshold,
                            number);
         }
         if(strncmp("spc", low_high, 3) == 0){
            special_closing(name, name2, the_image,
                            out_image, il, ie, ll, le,
                            value, threshold,
                            number);
         }
         if(strncmp("edm", low_high, 3) == 0){
            edm(name, name2, the_image, out_image,
                il, ie, ll, le, value);
         }
         if(strncmp("mat", low_high, 3) == 0){
            edm(name, name2, the_image, out_image,
                il, ie, ll, le, value);
         }
        break;

        case 22: /* texture operations */
         printf("\nCIPS> Enter input image name\n");
         get_image_name(name);
         printf("\nCIPS> Enter output image name\n");
         get_image_name(name2);
         get_parameters(&il, &ie, &ll, &le);
         get_texture_options(low_high, &threshold,
                             &value, &size,
                             &line, &element);
         if(strncmp(low_high, "compare", 3) == 0)
            compare(name, name2, the_image, out_image,
                    il, ie, ll, le,
                    line, element, size);
         if(strncmp(low_high, "hurst", 3) == 0)
            hurst(name, name2, the_image, out_image,
                  il, ie, ll, le, size);
         if(strncmp(low_high, "adifference", 3) == 0)
            adifference(name, name2, the_image,
                        out_image, il+i*ROWS,
                        ie, ll, le, size);
         if(strncmp(low_high, "amean", 3) == 0)
            amean(name, name2, the_image, out_image,
                  il, ie, ll, le, size);
         if(strncmp(low_high, "skewness", 3) == 0)
            skewness(name, name2, the_image, out_image,
                     il, ie, ll, le, size, 
                     threshold, value);
         if(strncmp(low_high, "sigma", 3) == 0)
            sigma(name, name2, the_image, out_image,
                  il, ie, ll, le, size, 
                  threshold, value);

        break;

        case 23:  /* geometry operations */
         printf("\nCIPS> Enter input image name\n");
         get_image_name(name);
         printf("\nCIPS> Enter output image name\n");
         get_image_name(name2);
         get_parameters(&il, &ie, &ll, &le);
         get_geometry_options(
                     method, &angle, 
                     &x_displace, &y_displace, 
                     &x_stretch, &y_stretch, 
                     &x_cross,  &y_cross, 
                     &bilinear, &m, &n);
         if(strncmp(method, "geometry", 3) == 0)
            geometry(name, name2, 
                  the_image, out_image,
                  il, ie, ll, le, angle, 
                  x_stretch, y_stretch,
                  x_displace, y_displace,
                  x_cross, y_cross,
                  bilinear);
         if(strncmp(method, "rotate", 3) == 0)
            arotate(name, name2, 
                  the_image, out_image,
                  il, ie, ll, le,
                  angle, m, n, bilinear);
        break;

        case 24:  /* warp operations */
         printf("\nCIPS> Enter input image name\n");
         get_image_name(name);
         printf("\nCIPS> Enter output image name\n");
         get_image_name(name2);
         get_parameters(&il, &ie, &ll, &le);
         get_warp_options(method, &bilinear, 
                 &x_control, &y_control,
                 &x1, &y1, &x2, &y2, 
                 &x3, &y3, &x4, &y4);
         if(strncmp(method, "warp", 3) == 0)
            warp(name, name2, 
              the_image, out_image,
                 il, ie, ll, le,
                 x_control, y_control,
                 bilinear);
         if(strncmp(method, "object-warp", 3) == 0)
            object_warp(name, name2, 
               the_image, out_image,
                  il, ie, ll, le, 
                  x1, y1, x2, y2, 
                  x3, y3, x4, y4,
                  bilinear);
        break;

        case 30:  /* exit system */
         not_finished = 0;
        break;

        default:
         printf("\nCould not understand response, "
                "try again");
        break;

     }               /* ends switch response */
  }               /* ends while not finished */
}               /* ends main                 */






   /*************************************************
   *
   *   show_image(...
   *
   *   This function displays the image numbers on the
   *   screen as text.  It displays 20 rows  with 18
   *   columns each.
   *
   **************************************************/

show_image(image, il, ie)
   int   il, ie;
   short image[ROWS][COLS];
{
   int i, j;
   printf("\n   ");
   for(i=0; i<18; i++)
      printf("-%3d", i+ie);

   for(i=0; i<20; i++){
      printf("\n%2d>", i+il);
      for(j=0; j<18; j++)
         printf("-%3d", image[i][j]);
   }

   printf("\nPress enter to continue");
   get_integer(&i);

}  /* ends show_image  */





   /*************************************************
   *
   *   show_menu(..
   *
   *   This function displays the CIPS main menu.
   *
   **************************************************/

show_menu()
{

 printf(""
 "\n\n\t\t\tWelcome to CIPS"
 "\n\t\tThe C Image Processing System"
 "\n\t\tDwayne Phillips 1990-1993"
 "\nThese are your choices:"
 "\n1.  Display image header               13. Image rotate & flip" 
 "\n2.  Show image numbers                 14. Image scaling"    
 "\n3.  Print image numbers                15. Create blank image" 
 "\n4.  Display (EGA & VGA)                16. Image thresholding"
 "\n5.  Display or print using halftoning  17. Image segmentation"
 "\n6.  Print using dithering              18. Edge & gray segmentation"
 "\n7.  Print or display histogram         19. Boolean operations"
 "\n8.  Edge Detection                     20. Image overlay"
 "\n9.  Edge Enhancement                   21. Shape operations"  
 "\n10. Image filtering                    22. Texture operations"
 "\n11. Image add & subtract               23. Geometry operations" 
 "\n12 Image cut & paste                   24. Warp operations"
 "\n30. Exit system\n"
 "\nEnter choice __\b\b");

}  /* ends show_menu */

⌨️ 快捷键说明

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