ait-survey

sort segmented point cloud

Feb 1st, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. /*rvi program
  2.  
  3. band3:
  4. http://aitech.ac.jp/~y-yama/data/rvi/band3.raw.zip
  5. band4:
  6. http://aitech.ac.jp/~y-yama/data/rvi/band4.raw.zip
  7. 512*512
  8. unsigned char
  9.  
  10. made by Yoshiyuki Yamamoto
  11. ver1.0 2004/5/30*/
  12.  
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <time.h>
  18.  
  19. int main(int argc,char *argv[])
  20. {
  21.     FILE *fpi,*fpo;              
  22.         int i,j,height,width; //width:3,
  23.     unsigned char dn1,dn2,dn3;
  24.     unsigned char i_r,i_g,i_b;            
  25.     unsigned char *file;
  26.     //float *file3;          
  27.     float start,end;
  28.    
  29.     start=clock();
  30.  
  31.     if(argc!=5)
  32.     {
  33.         fprintf(stderr,"Usage: %s\n(1)Input_R_READ_filename\n(2)Input_NIR_READ_filename\n(3)width\n(4)height\n",argv[0]);
  34.         exit(1);
  35.     }
  36.  
  37.         printf("OPEN color list NAME:%s\n",argv[1]);
  38.     printf("OPEN save FILE NAME:\%s\n",argv[2]);
  39.     //printf("OPEN OUTPUT FILE NAME:%s\n",argv[3]);
  40.  
  41.     width = atoi(argv[3]); printf("W = %d,", width);    
  42.         height = atoi(argv[4]); printf("H = %d\n", height);
  43.  
  44.         file= (unsigned char *)malloc(width*height*sizeof(char));
  45.  
  46.         if((fpi=fopen(argv[1],"rb"))==NULL)
  47.     {  
  48.             fprintf(stderr,"input file open error\n");
  49.         exit(1);
  50.         }
  51.  
  52.         fread((unsigned char *)file,sizeof(char),width*height,fpi);
  53.  
  54.    
  55.         if((fpo=fopen(argv[2],"w"))==NULL)
  56.     {      
  57.             fprintf(stderr,"output file open error\n");
  58.         exit(1);
  59.         }
  60.    
  61.         //fread((float *)file3,sizeof(float),width*height,fpo);
  62.  
  63.     i_r=file[0];
  64.     i_g=file[1];
  65.     i_b=file[2];
  66.  
  67.     fprintf(fpo,"%d %d %d\n",i_r,i_g,i_b);
  68.  
  69.     for(i=0;i<height;i++)
  70.     {
  71.         for(j=0;j<1;j++)
  72.         {
  73.             dn1=file[i*width+j];
  74.             dn2=file[i*width+j+1];
  75.             dn3=file[i*width+j+2];
  76.  
  77.             if(i_r==dn1 && i_g==dn2 && i_b==dn3)
  78.             {
  79.                 printf("same\n");
  80.             }
  81.  
  82.             else
  83.             {
  84.                 i_r=dn1;
  85.                 i_g=dn2;
  86.                 i_b=dn3;
  87.                 fprintf(fpo,"%d %d %d\n",i_r,i_g,i_b); 
  88.             }
  89.         }
  90.     }
  91.  
  92.     free(file);
  93.     //free(file2);
  94.     //free(file3);
  95.     fclose(fpi);
  96.     //fclose(fpi2);
  97.     fclose(fpo);
  98.     end=clock();
  99.  
  100.     printf("start%fsecond\n",start/1000);
  101.     printf("end%fsecond\n",end/1000);
  102.     printf("duration%f\n",(end-start)/1000);
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment