예제 #1
0
파일: ex04.c 프로젝트: WDdoing/CodePro
int main(void)
{
  double arr1[SIZE] = {1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,0.0};

  puts("the index of the maximum value in the array:");
  printf("%d\n",index_of_max(arr1,SIZE));

  return 0;
}
예제 #2
0
image_t* remove_lines(image_t* img, params* staff_params, uint16_t numCuts, uint16_t **STAFFLINES)
{
         /*returns staff without lines, and STAFFLINES as a 5x2 array*/
         uint16_t line_thickness,height,width,line_spacing;
         uint16_t beginCut,endCut;
         projection_t* yprojection;
         projection_t* yprojection2;
         flex_array_t* ones_array;
         flex_array_t* ones_array2;
         flex_array_t* staffLines;
         uint16_t** last_stafflines;
         int16_t* array_staff;
         linked_list* stack;
         int16_t max_project;
         uint16_t i,j,lines_found;
         int16_t shift_variable;
         uint16_t vertSplice;
         image_t* fixThatImage;
         image_t* new_img;
         
         
         /*End Var Declarations*/
         line_thickness=staff_params->thickness; 
         line_spacing=staff_params->spacing;
         height=img->height;
         width=img->width;
         beginCut = 0;
         endCut = (width+numCuts/2)/numCuts;
         
         /*/ get inital staff line estimates*/
         yprojection2 = project(img,2);
         
         ones_array=array_ones(line_thickness);
         ones_array2=array_ones(1);
         yprojection = filter(ones_array,ones_array2,yprojection2); /* reduce impact of 'double peaks' (curvy lines)*/
         delete_flex_array(ones_array);
         delete_flex_array(ones_array2);
         delete_flex_array(yprojection2);
         max_project = index_of_max(yprojection);
         for (i=max_project-(line_spacing+1)/2;i<max_project+(line_spacing+1)/2;i++){
             yprojection->data[i]=0;
         }
             

         staffLines=find(yprojection,.8*max_project,greater); /*delete staff line, twiddle with the 85% later*/
         stack = group(staffLines,3);

         last_stafflines=multialloc(sizeof(uint16_t),2,5,2);
         i=0;
         while (is_list_empty( stack)==0){
               array_staff=pop_bottom(stack);
               last_stafflines[i][0]=(uint16_t)array_staff[0];
               last_stafflines[i][1]=(uint16_t)array_staff[1];
               free(array_staff);
               i++;
         }
    /* LOOP THRU VERTICAL CUTS*/
    shift_variable=0;
    for (vertSplice = 0;vertSplice<numCuts; vertSplice++){
        fixThatImage = get_sub_img(img,-1,-1,beginCut,endCut);
    
        /*pretty up staff lines*/
        /*implement this once created...*/
        /*[img(:,beginCut:endCut),shift_variable,stafflines] = ...*/
          /*  fix_lines_and_remove_smart(fixThatImage,params,last_stafflines,shift_variable,vertSplice);*/
            
        /*modify last_stafflines in place */ 
        delete_image(fixThatImage);
        if (vertSplice==1 && STAFFLINES){
           for (i=0;i<5;i++){
               for (j=0;j<2;j++){
                   STAFFLINES[i][j]=last_stafflines[i][j]+2;/*create STAFFLINES*/
               }
           }
        }
        
    
        beginCut = endCut + 1;
        endCut += (width+numCuts/2)/numCuts;
        if (endCut >= width) endCut = width-1;
    }
    
    new_img=make_image(img->height +4,img->width +4);
    for (i=0;i<(img->height +4);i++){
        for (j=0;j<(img->width +4);j++){
            if (i<2 ||j<2 ||(i>(img->height +1)) ||(j>(img->width +1))){
                setPixel(new_img,i,j,0);
            }
            else {
                 setPixel(new_img,i,j,getPixel(img,i-2,j-2));
            }
        }
    }
    return new_img;
}