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

📄 cips.c

📁 This is code tutorial for image processing include:histogram,sketon....
💻 C
📖 第 1 页 / 共 3 页
字号:

   /***********************************************
   *
   *       file d:\cips\cips.c
   *
   *       Functions: This file contains
   *          main
   *          show_menu
   *          show_image
   *
   *       Purpose:
   *          This file contains the main calling
   *          routine in the C Image Processing System.
   *
   *       External Calls:
   *          numcvrt.c - get_integer
   *          gin.c - get_image_name
   *          rtiff.c - read_tiff_image
   *          tiff.c - read_tiff_header
   *          display.c - display_image
   *                      display_menu_for_display_image
   *          pi.c - print_image
   *          ht.c - display_using_halftoning
   *                 get_threshold_value
   *          djet.c - print_graphics_image
   *                   get_graphics_caption
   *          hist.c - display_menu_for_histogram
   *                   calculate_area_histogram
   *                   print_histogram
   *                   show_histogram
   *          edge.c - detect_edges
   *                   get_edge_options
   *                   quick_edge
   *          edge2.c - homogeneity
   *                    difference_edge
   *                    contrast_edge
   *                    range
   *                    variance
   *          edge3.c - gaussian_edge
   *                    enhance_edges
   *          filter.c - filter_image
   *                     median_filter
   *                     high_pixel
   *                     low_pixel
   *                     get_filter_options
   *          addsub.c - add_image_array
   *                     subtract_image_array
   *          cutp.c - cut_image_piece
   *                   paste_image_piece
   *                   check_cut_and_paste_limits
   *          rotate.c - rotate_flip_image_array
   *          scale.c - zoom_image_array
   *          segment.c - get_segmentation_options
   *                      get_threshold_options
   *                      manual_threshold_segmentation
   *                      peak_threshold_segmentation
   *                      valley_threshold_segmentation
   *                      adaptive_threshold_segmentation
   *          boole.c - and_image
   *                    or_image
   *                    xor_image
   *                    nand_image
   *                    nor_image
   *                    not_image
   *          overlay.c - non_zero_overlay
   *                      zero_overlay
   *                      greater_overlay
   *                      less_overlay
   *                      average_overlay
   *          ed.c - erosion
   *                 dilation
   *                 mask_erosion
   *                 mask_dilation
   *                 interior_outline
   *                 exterior_outline
   *                 copy_3_x_3
   *                 opening
   *                 closing
   *                 get_shape_options
   *          morph.c - thinning
   *                    dilate_not_join
   *                    special_opening
   *                    special_closing
   *                    edm
   *                    mat
   *          txtrsubs.c - sigma
   *                       skewness
   *                       amean
   *                       adifference
   *                       hurst
   *                       compare
   *                       get_texture_options
   *          geosubs.c - geometry
   *                      arotate
   *                      get_geometry_options
   *
   *       Modifications:
   *          26 June 1990 - created
   *
   *************************************************/

#include "cips.h"


short the_image[ROWS][COLS];
short out_image[ROWS][COLS];

main()
{

   char caption[80],
        color_transform[80],
        dir_name[80],
        er_method[80],
        low_high[80],
        method[80],
        monitor_type[80],
        name[80],
        name2[80],
        name3[80],
        rep[80],
        title[80],
        ts_method[80],
        zoom_shrink[80];

   float angle     = 45.0,
         percent   = 0.5,
         x_cross   = 0.01,
         x_stretch = 1.0,
         y_cross   = 0.01,
         y_stretch = 1.0;

   int  bilinear             = 1,
        color                = 99,
        detect_threshold     = 1,
        detect_type          = 1,
        display_colors       = 16,
        element              = 1,
        filter_type          = 1,
        high                 = 100,
        horizontal           = 3,
        i                    = 0,
        ie                   = 1,
        ie2                  = 1,
        ie3                  = 1,
        il                   = 1,
        il2                  = 1,
        il3                  = 1,
        image_colors         = 256,
        invert               = 0,
        j                    = 0,
        l                    = 0,
        length               = 3,
        le                   = COLS+1,
        le2                  = COLS+1,
        le3                  = COLS+1,
        line                 = 1,
        ll                   = ROWS+1,
        ll2                  = ROWS+1,
        ll3                  = ROWS+1,
        m                    = COLS/2,
        n                    = ROWS/2,
        not_finished         = 1,
        number               = 1,
        print                = 0,
        response             = 99,
        rotation_type        = 1,
        scale                = 2,
        show_hist            = 0,
        size                 = 7,
        threshold            = 128,
        vertical             = 3,
        width                = 3,
        x_control            = 50,
        y_control            = 50,
        x1                   = 10,
        y1                   = 10,
        x2                   = 90,
        y2                   = 10,
        x3                   = 90,
        y3                   = 90,
        x4                   = 10,
        y4                   = 90;

   long     mean_of_pixels;

   unsigned long histogram[256];

   short    diff        = 10,
            erode       = 3,
            hi          = 255,
            low         = 0,
            min_area    = 10,
            max_area    = 1000,
            value       = 200,
            x_displace  = 10,
            y_displace  = 10,
            low_hi_filter[3][3];

   struct   tiff_header_struct image_header;


   my_clear_text_screen();

   strcpy(color_transform, "Straight mode");
   strcpy(monitor_type, "VGA");
   strcpy(low_high, "l");
   strcpy(zoom_shrink, "z");
   strcpy(method, "r");
   strcpy(title, "");
   strcpy(ts_method, "manual");
   strcpy(er_method, "edge");

   strcpy(name,  "c:/pix/adam256.tif");
   strcpy(name2, "c:/pix/output.tif");
   strcpy(name3, "c:/pix/output.tif");
   strcpy(dir_name, "c:/pix");

     while(not_finished){

        show_menu();

        get_integer(&response);

        switch (response){

        case 1:/* display image header */
         get_image_name(name);
         read_tiff_header(name, &image_header);
         printf("\n\nCIPS> The image header is:");
         printf("\n\t\twidth=%ld length=%ld  start=%ld  bits=%ld",
              image_header.image_width,
              image_header.image_length,
              image_header.strip_offset,
              image_header.bits_per_pixel);
         printf("\nCIPS> Hit Enter to continue");
         gets(rep);
        break;

        case 2:/* display image numbers */
         get_image_name(name);
         get_parameters(&il, &ie, &ll, &le);
         read_tiff_image(name, the_image, il, ie, ll, le);
         show_image(the_image, il, ie);
         break;

        case 3:   /* print image numbers */
         get_image_name(name);
         get_parameters(&il, &ie, &ll, &le);
         read_tiff_image(name, the_image, il, ie, ll, le);
         print_image(the_image, name, 1, 1, 1, 100, 18,
                     il, ie);
        break;

        case 4:   /* display image */
         get_image_name(name);
         read_tiff_header(name, &image_header);
         get_parameters(&il, &ie, &ll, &le);
         display_menu_for_display_image(&image_colors,
                   &display_colors, &invert,
                   color_transform, monitor_type,
                   &show_hist);
         printf("\nEnter title>");
         gets(title);
         display_image(name, the_image, il, ie,
                   ll, le, &image_header, monitor_type,
                   color_transform, invert,
                   image_colors, display_colors,
                   show_hist, title);
        break;

        case 5:   /* display image using halftoning */
         get_image_name(name);
         read_tiff_header(name, &image_header);
         get_parameters(&il, &ie, &ll, &le);
         display_menu_for_display_image(&image_colors,
                   &display_colors, &invert,
                   color_transform, monitor_type,
                   &show_hist);
         get_threshold_value(&threshold, &print);
         display_using_halftoning(the_image, name,
                   il, ie, ll, le, threshold,
                   invert, image_colors, &image_header,
                   monitor_type, print, show_hist,
                   color_transform);
        break;

        case 6:   /* print graphics image */
         get_image_name(name);
         read_tiff_header(name, &image_header);
         get_parameters(&il, &ie, &ll, &le);
         display_menu_for_display_image(&image_colors,
                   &display_colors, &invert,
                   color_transform, monitor_type,
                   &show_hist);
         get_graphics_caption(caption);
         print_graphics_image(the_image, out_image,
                   name, il, ie, ll, le, image_colors,
                   invert, caption, show_hist,
                   color_transform);
        break;
        case 7:   /* print or display histogram numbers */
         get_image_name(name);
         read_tiff_header(name, &image_header);
         get_parameters(&il, &ie, &ll, &le);
         display_menu_for_histogram(&print, &vertical,
                   &horizontal);
         calculate_area_histogram(histogram, vertical,
                   horizontal, the_image, name,
                   il, ie, ll, le);
         if(print == 0)
            show_histogram(histogram);
         if(print == 1)
            print_histogram(histogram, name);
        break;

        case 8:  /* perform edge detection */
         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_edge_options(&detect_type,
                          &detect_threshold,
                          &high, &size);
         if(detect_type == 1  ||
            detect_type == 2  ||
            detect_type == 3)
            detect_edges(name, name2, the_image,
                         out_image, il, ie, ll, le,
                         detect_type, detect_threshold,
                         high);
         if(detect_type == 4)
            quick_edge(name, name2, the_image, out_image,
                       il, ie, ll, le, detect_threshold,
                       high);
         if(detect_type == 5)
              homogeneity(name, name2, the_image, out_image,

⌨️ 快捷键说明

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