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

📄 cgrow.c

📁 This is code tutorial for image processing include:histogram,sketon....
💻 C
📖 第 1 页 / 共 2 页
字号:
                        *
                        *       Search for the first pixel of
                        *       a region.
                        *
                        ****************************************/

                if(binary[i][j] == (short)(1)){
                   sx = 0.0;
                   sy = 0.0;

                   label_and_check_neighbor(binary, lcn_stack, g_label,
                                    &stack_empty, &pointer, i, j,
                                    &max_x, &min_x, &max_y, &min_y,
                                    &sx, &sy, area, ht, wid,
                                    &stack_file_in_use, stack_file_name,
                                    &first_call);
                   object_found = TRUE;
                }


                        /***********************************************
                        *
                        *       If the stack is not empty, pop the
                        *       coordinates of the pixel off the stack
                        *       and check its 8 neighbors.
                        *
                        ***********************************************/

                /******************************************
                *
                *   This is the code to use without using
                *   the stack file
                *   17 January 1988
                *
                *while(stack_empty == FALSE){
                *   pop_i = lcn_stack[pointer][0];
                *   pop_j = lcn_stack[pointer][1];
                *   --pointer;
                *   if(pointer <= 0){
                *      pointer     =    0;
                *      stack_empty = TRUE;
                *   }
                *   label_and_check_neighbor(binary, lcn_stack, g_label,
                *                    &stack_empty, &pointer,
                *                    pop_i, pop_j,
                *                    &max_x, &min_x, &max_y,
                *                    &min_y, &sx, &sy, area, ht, wid,
                *                    &stack_file_in_use, stack_file_name);
                *}
                *
                **********************************************************/

                /****************************************************
                *
                *   The following code was inserted to use the
                *   stack file
                *   17 January 1988
                *
                *****************************************************/

                 while(stack_empty == FALSE){
                    pop_i = lcn_stack[pointer][0]; /* POP       */
                    pop_j = lcn_stack[pointer][1]; /* OPERATION */
                    --pointer;
                    if(pointer <= 0){
                       if(stack_file_in_use){
                          pop_data_off_of_stack_file(lcn_stack,
                                                     stack_file_name,
                                                     &pointer,
                                                     &stack_file_in_use);
                       }  /* ends if stack_file_in_use  */
                       else{
                          pointer     =    0;
                          stack_empty = TRUE;
                       }  /* ends else stack file is not in use  */
                    }  /*  ends if point <= 0  */

                    label_and_check_neighbor(binary, lcn_stack, g_label,
                                     &stack_empty, &pointer,
                                     pop_i, pop_j,
                                     &max_x, &min_x, &max_y,
                                     &min_y, &sx, &sy, area, ht, wid,
                                     &stack_file_in_use, stack_file_name,
                                     &first_call);
                 }  /* ends while stack_empty == FALSE */



                 if(object_found == TRUE){
                    object_found = FALSE;

/********************
printf("\n\n\nCGROW> maxx=%d minx=%d maxy=%d miny=%d sx=%f sy=%f",
    max_x,min_x,max_y,min_y,sx,sy);
printf("\nCGROW> Now calculate the principle axis");
********************/

                    compute_principle_axis(max_x, min_x, max_y, min_y,
                                             sx, sy, area, g_label,
                                             binary, alpha, x_length,
                                             y_length, whratios, ht, wid);

                /******************************************
                *
                *       If any of the following conditions
                *       hold then eliminate this region.
                *
                ********************************************/

/****************
printf("\nCGROW>Address of g_label is %u", &g_label);
printf("\nCGROW> g_label is %d",g_label);
printf("\nCGROW> angle is %f",alpha[g_label]);
printf("\nCGROW> lengths are x=%ld, y=%ld",x_length[g_label],
   y_length[g_label]);
printf("\nCGROW> area is %ld",area[g_label]);
*****************/


                    if(y_length[g_label] != 0){
                       x_to_y = ((float)x_length[g_label])/
                          ((float)y_length[g_label]);
                       if(x_to_y > 1.0){
                          printf("\nCGROW> Mistake in x_to_y ratio so invert it");
                          x_to_y            = 1.0/x_to_y;
                          temp              = y_length[g_label];
                          y_length[g_label] = x_length[g_label];
                          x_length[g_label] = temp;
                       }  /* ends if x_to_y > 1.0            */
                    }     /* ends if y_length[g_label] != 0  */

                    whratios[g_label] = x_to_y;

/************************
printf("\n\n");
printf("\nLimits area = %ld %ld",limits->max_area,limits->min_area);
printf("\nActual area=%ld", area[g_label]);
printf("\nLimits width= %ld %ld",limits->max_width,limits->min_width);
printf("\nActual x length=%ld", x_length[g_label]);
printf("\nLimits height=%ld %ld",limits->max_height,limits->min_height);
printf("\nActual y length=%ld", y_length[g_label]);
printf("\nLimits ratios=%f %f",
  limits->max_w_to_h_ratio,limits->min_w_to_h_ratio);
printf("\nActual x_to_y = %f",x_to_y);
printf("\nLimits angle= %f %f",limits->max_angle,limits->min_angle);
printf("\nActual alpha=%f", alpha[g_label]);
************************/


			/*****************************************
			*
			*   25 July 1989
			*   Replaced limits->max_area, max_width
			*   and max_hieght by just
			*   max_area, max_height, max_width
			*
			*   26 January 1990
			*   Put in if statement about max_w_to_h_
			*   ratio.  Problem with sidewalk ratio
			*   going to infinity.
			*
			******************************************/


		    removed = FALSE;
		    if(limits->max_w_to_h_ratio > 1.0)
		       whratios[g_label] = 0.0;

		    if( (area[g_label] > max_area)	    ||
			(area[g_label] < limits->min_area)	    ||
                        (x_length[g_label] < limits->min_width)     ||
			(x_length[g_label] > max_width)     ||
                        (y_length[g_label] < limits->min_height)    ||
			(y_length[g_label] > max_height)    ||
                        (whratios[g_label]>limits->max_w_to_h_ratio)||
                        (whratios[g_label]<limits->min_w_to_h_ratio)||
                        (alpha[g_label] > limits->max_angle)        ||
                        (alpha[g_label] < limits->min_angle)){


   printf("\n\n");
 if(area[g_label] > limits->max_area){
   printf("\n\tCGROW> area > max area");
   printf("\nLimits area = %ld %ld",limits->max_area,limits->min_area);
   printf("\nActual area=%ld", area[g_label]);
}
 if(area[g_label] < limits->min_area){
   printf("\n\tCGROW> area < min area");
   printf("\nLimits area = %ld %ld",limits->max_area,limits->min_area);
   printf("\nActual area=%ld", area[g_label]);
}
 if(x_length[g_label] < limits->min_width){
   printf("\n\tCGROW> x length < min width");
   printf("\nLimits width= %ld %ld",limits->max_width,limits->min_width);
   printf("\nActual x length=%ld", x_length[g_label]);
}
 if(x_length[g_label] > limits->max_width){
   printf("\n\tCGROW> x length > max width");
   printf("\nLimits width= %ld %ld",limits->max_width,limits->min_width);
   printf("\nActual x length=%ld", x_length[g_label]);
}
 if(y_length[g_label] < limits->min_height){
   printf("\n\tCGROW> y length < min height");
   printf("\nLimits height=%ld %ld",limits->max_height,limits->min_height);
   printf("\nActual y length=%ld", y_length[g_label]);
}
 if(y_length[g_label] > limits->max_height){
   printf("\n\tCGROW> y length > max height");
   printf("\nLimits height=%ld %ld",limits->max_height,limits->min_height);
   printf("\nActual y length=%ld", y_length[g_label]);
}
 if(x_to_y >  limits->max_w_to_h_ratio){
   printf("\n\tCGROW> x to y > max ratio");
   printf("\nLimits ratios=%f %f",
     limits->max_w_to_h_ratio,limits->min_w_to_h_ratio);
   printf("\nActual x_to_y = %f",x_to_y);
}
 if(x_to_y <  limits->min_w_to_h_ratio){
   printf("\n\tCGROW> x to y < min ratio");
   printf("\nLimits ratios=%f %f",
     limits->max_w_to_h_ratio,limits->min_w_to_h_ratio);
   printf("\nActual x_to_y = %f",x_to_y);
}
 if(alpha[g_label] > limits->max_angle){
   printf("\n\tCGROW>  alpha > max angle");
   printf("\nLimits angle= %f %f",limits->max_angle,limits->min_angle);
   printf("\nActual alpha=%f", alpha[g_label]);
}
 if(alpha[g_label] < limits->min_angle){
   printf("\n\tCGROW>  alpha < min angle");
   printf("\nLimits angle= %f %f",limits->max_angle,limits->min_angle);
   printf("\nActual alpha=%f", alpha[g_label]);
}



                        removed = TRUE;
printf("\nCGROW> set removed to TRUE");

                        for(ii=min_y; ii<=max_y; ii++){
                           for(jj=min_x; jj<=max_x; jj++){
                              if(binary[ii][jj] == (short)(g_label))
                                 binary[ii][jj] = 0;
                           }
                        }
                    }   /* ends large if */
                    else{       /* if the object was not removed then   */
                                /* calculate the center coordinates     */
                       coordinates[g_label][1] = (long)(i_line +
                                              (sy/(float)area[g_label]));
                       coordinates[g_label][0] = (long)(i_element +
                                              (sx/(float)area[g_label]));
                    }
/*************************
printf("\nCGROW> THE END, removed=%d",removed);
printf("\nCGROW> Coordinates are %ld %ld",
   coordinates[g_label][0],
   coordinates[g_label][1]);
**************************/

                    if(!removed){
                       ++g_label;
                    }   /* ends if !removed     */
                 }      /* ends if object_found */

           }        /* ends loop over j */ /* corresponds to 96 */
        }           /* ends loop over i */

        *number = (long)(g_label);

}       /* ends grow  */

⌨️ 快捷键说明

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