Ejemplo n.º 1
0
void Output_Neurons(int numneur, Region **neurons, int do_brighten)
{ Array  *stack, *proj;
  int     i, k;

#ifdef PROGRESS
  printf("\nGenerating %d individual neuron stacks\n",numneur);
  fflush(stdout);
#endif

  stack = Make_Array(RGB_KIND,UINT16_TYPE,3,Images[0]->dims);
  proj  = Make_Array(RGB_KIND,UINT16_TYPE,2,Images[0]->dims);

  for (i = 0; i < numneur; i++)
    { Array_Op_Scalar(stack,SET_OP,UVAL,VALU(0));

      for (k = 0; k < NumChans; k++)
        { Array_Bundle plane = *stack;
          Draw_Region_Image(Get_Array_Plane(&plane,k%3),Images[k],neurons[i]);
        }

      if (do_brighten)
        Scale_Array_To_Range(stack,VALU(0),VALU(4095));

      if (!Is_Arg_Matched("-pj"))
        { sprintf(NameBuf,"%s/%s.neuron%d.tif",RezFolder,CoreName,i);
          Write_Image(NameBuf,stack,LZW_PRESS);
        }

#ifdef PROGRESS
      printf("*"); fflush(stdout);
#endif

      Z_Projection(stack,proj);
      sprintf(NameBuf,"%s/%s.PR.neuron%d.tif",RezFolder,CoreName,i);
      Write_Image(NameBuf,proj,LZW_PRESS);
    }

  // Kill_Array(proj); these are causing a glib.c memory error in Linux
  // Kill_Array(stack);

#ifdef PROGRESS
  printf("\n"); fflush(stdout);
#endif
}
Ejemplo n.º 2
0
 void RasterizedImage::ScaleTo8bit(){
   Scale_Array_To_Range((*image_),ValU(0),ValU(255));
   Convert_Array_Inplace((*image_),PLAIN_KIND,UINT8_TYPE,8,0);
 }
Ejemplo n.º 3
0
 /*
  Method that presents the image arr with a grid overlap
  
  @param image:   input image stack
  @param imgPara: input parameter
  @param name:    name of the output file
  @param arr:     image which should be plotted
  */
 void ShowArray(RasterizedImage & img, ParaSet & imgPara, char * name, Array * arr)
 {
   Dimn_Type x, y, z;
   Array    * a, * b;
 
   if (imgPara.grid == false){
     Write_Image((char *) name, arr, DONT_PRESS);
     return;
   }
 
   // Conversion of the image arr into an RGB-Kind image
   if (arr->type != UINT8_TYPE){
     b = Copy_Array(arr);
     Scale_Array_To_Range(b,ValU(0),ValU(255));
     Convert_Array_Inplace(b,b->kind,UINT8_TYPE,8,0);
   } else {
     b = arr;
   }
 
   if (b->kind != RGB_KIND){
     if (b == arr){
       a = Convert_Array(b,RGB_KIND,b->type,b->scale,0);
     } else {
       a = Convert_Array_Inplace(b,RGB_KIND,b->type,b->scale,0);
     }
   } else {
     a = b;
   }
 
   // Plotting of the image grid
   if (a->ndims == 4)
     for (z = 0; z < img.GetDepth(); z++){
       for (y = 0; y < img.GetGridY(); y++) {
         if (y % 50 == 0 && y != 0){
           Draw_Line(a,&YELLOW,Coord3(z,y*imgPara.radius,0),Coord3(z,y*imgPara.radius,img.GetGridX()*imgPara.radius-1));
         } else if (y % 10 == 0 && y != 0){
           Draw_Line(a,&PURPLE,Coord3(z,y*imgPara.radius,0),Coord3(z,y*imgPara.radius,img.GetGridX()*imgPara.radius-1));
         } else {
           Draw_Line(a,&CYAN,Coord3(z,y*imgPara.radius,0),Coord3(z,y*imgPara.radius,img.GetGridX()*imgPara.radius-1));
         }
         for (x = 0; x < img.GetGridX(); x++){
           if (x % 50 == 0 && x != 0){
             Draw_Line(a,&YELLOW,Coord3(z,0,x*imgPara.radius),Coord3(z,img.GetGridY()*imgPara.radius-1,x*imgPara.radius));
           } else if (x % 10 == 0 && x != 0){
             Draw_Line(a,&PURPLE,Coord3(z,0,x*imgPara.radius),Coord3(z,img.GetGridY()*imgPara.radius-1,x*imgPara.radius));
           } else {
             Draw_Line(a,&CYAN,Coord3(z,0,x*imgPara.radius),Coord3(z,img.GetGridY()*imgPara.radius-1,x*imgPara.radius));
           }
         }
       }
     }
   else{
     for (y = 0; y < img.GetGridY(); y++){
       if (y % 50 == 0 && y != 0){
         Draw_Line(a,&YELLOW,Coord2(y*imgPara.radius,0),Coord2(y*imgPara.radius,img.GetGridX()*imgPara.radius-1));
       } else if (y % 10 == 0 && y != 0){
         Draw_Line(a,&PURPLE,Coord2(y*imgPara.radius,0),Coord2(y*imgPara.radius,img.GetGridX()*imgPara.radius-1));
       } else{
         Draw_Line(a,&CYAN,Coord2(y*imgPara.radius,0),Coord2(y*imgPara.radius,img.GetGridX()*imgPara.radius-1));
       }
       for (x = 0; x < img.GetGridX(); x++){
         if (x % 50 == 0 && x != 0){
           Draw_Line(a,&YELLOW,Coord2(0,x*imgPara.radius),Coord2(img.GetGridY()*imgPara.radius-1,x*imgPara.radius));
         } else if (x % 10 == 0 && x != 0){
           Draw_Line(a,&PURPLE,Coord2(0,x*imgPara.radius),Coord2(img.GetGridY()*imgPara.radius-1,x*imgPara.radius));
         } else{
           Draw_Line(a,&CYAN,Coord2(0,x*imgPara.radius),Coord2(img.GetGridY()*imgPara.radius-1,x*imgPara.radius));
         }
       }
     }
   }
   
   Write_Image(name, a, DONT_PRESS);
   
   if (arr != a)
     Free_Array(a);
 }