Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*rvi program
- band3:
- http://aitech.ac.jp/~y-yama/data/rvi/band3.raw.zip
- band4:
- http://aitech.ac.jp/~y-yama/data/rvi/band4.raw.zip
- 512*512
- unsigned char
- made by Yoshiyuki Yamamoto
- ver1.0 2004/5/30*/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <math.h>
- int main(int argc,char *argv[])
- {
- FILE *fpi1,*fpi2,*fpo;
- int i,j,height,width;
- unsigned char dn1,dn2;
- float dn3;
- float *file1;
- //float *file3;
- //float start,end;
- float xo,yo,zo,x1,y1,z1,x2,y2,z2;
- float vox,voy,voz,v1x,v1y,v1z;
- float cos;
- float start,end;
- start=clock();
- if(argc!=5)
- {
- fprintf(stderr,"Usage: %s\n(1)Input_points_filename\n(2)width\n(3)height(4)output_filename\n",argv[0]);
- exit(1);
- }
- printf("OPEN R FILE NAME:%s\n",argv[1]);
- //printf("OPEN NIR FILE NAME:\%s\n",argv[2]);
- //printf("OPEN OUTPUT FILE NAME:%s\n",argv[3]);
- width = atoi(argv[2]); printf("W = %d,", width);
- height = atoi(argv[3]); printf("H = %d\n", height);
- //header=atoi(argv[6]);printf("header=%d\n",header);
- file1= (float *)malloc(width*height*sizeof(float));
- //file2= (unsigned char *)malloc(width*height*sizeof(char));
- //file3= (float *)malloc(width*height*sizeof(float));
- /*----------------ì¸óÕRâÊëúÉtÉ@ÉCÉãÇÃÉIÅ[ÉvÉìäJén----------------------*/
- if((fpi1=fopen(argv[1],"rb"))==NULL)
- { /*ÉtÉ@ÉCÉãÇÃÉIÅ[ÉvÉì*/
- fprintf(stderr,"input file open error\n");
- exit(1);
- }
- fread((float *)file1,sizeof(float),width*height,fpi1);
- if((fpo=fopen(argv[4],"w"))==NULL)
- {
- fprintf(stderr,"output file open error\n");
- exit(1);
- }
- //fread((float *)file3,sizeof(float),width*height,fpo);
- for(i=0;i<height-2;i++)
- {
- for(j=0;j<1;j++)
- {
- xo=file1[i*width+j];
- yo=file1[i*width+j+1];
- zo=file1[i*width+j+2];
- x1=file1[(i+1)*width+j];
- y1=file1[(i+1)*width+j+1];
- z1=file1[(i+1)*width+j+2];
- x2=file1[(i+2)*width+j];
- y2=file1[(i+2)*width+j+1];
- z2=file1[(i+2)*width+j+2];
- //vector o
- vox=xo-x1;//a-b
- voy=yo-y1;//a-b
- voz=zo-z1;//a-b
- //vector 1
- v1x=x2-x1;
- v1y=y2-y1;
- v1z=z2-z1;
- //calculation of cos
- cos=(vox*v1x+voy*v1y)/sqrt(vox*vox+voy*voy)/sqrt(v1x*v1x+v1y*v1y);
- printf("%d cos=%f\n",i,cos);
- fprintf(fpo,"%f\n",cos);
- //dn3=(float)dn2/(float)dn1;
- //fwrite(&dn3,sizeof(float),1,fpo); /*míPà ïWçÇÉfÅ[É^ÇÃèëÇ´çûÇ›*/
- }
- }
- free(file1);
- //free(file2);
- //free(file3);
- fclose(fpi1);
- //fclose(fpi2);
- fclose(fpo);
- end=clock();
- printf("start%fïb\n",start/1000);
- printf("end%fïb\n",end/1000);
- printf("duration%fïb\n",(end-start)/1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment