int test1( char *path ) { Image *im; SeqReader *f = Seq_Open( path ); if(f) { im = Seq_Read_Image( f, 0 ); Write_Image( "test_seq_read_0.tif", im ); Free_Image(im); return 1; } return 0; }
int main(int argc, char* argv[]) { Image *im = Make_Image( FLOAT32, 101, 101); int strides[3] = {101*101,101,1}; point p = { 50.5, 50.5 }; memset( im->array, 0, im->kind * im->width * im->height ); Render_Line_Detector( 0.1, 8.0, 0.0, 2.0, p, (float*) im->array, strides ); Scale_Image_To_Range(im, 0, 0, 255); im = Translate_Image(im, GREY8, 1); Write_Image("evaltest2.tif",im); Free_Image(im); return 0; }
int main(int argc, char *argv[]) { Image *colorimg; if (argc != 3) { fprintf(stderr, "Usage: program <inputfile> <outputfile>\n"); exit(1); } if ((colorimg = Read_Bmp(argv[1])) == NULL) { exit(1); } if (Write_Bmp(argv[2], colorimg)) { exit(1); } Free_Image(colorimg); return 0; }
int main(int argc, char *argv[]) { char *whisker_file_name, *bar_file_name, *prefix; size_t prefix_len; FILE *fp; Image *bg=0, *image=0; int i,depth; char * movie; /* Process Arguments */ Process_Arguments(argc,argv,Spec,0); { char* paramfile = "default.parameters"; if(Load_Params_File("default.parameters")) { warning( "Could not load parameters from file: %s\n" "Writing %s\n" "\tTrying again\n",paramfile,paramfile); Print_Params_File(paramfile); if(Load_Params_File("default.parameters")) error("\tStill could not load parameters.\n"); } } prefix = Get_String_Arg("prefix"); prefix_len = strlen(prefix); { char *dot = strrchr(prefix,'.'); // Remove any file extension from the prefix if(dot) *dot = 0; } whisker_file_name = (char*) Guarded_Malloc( (prefix_len+32)*sizeof(char), "whisker file name"); bar_file_name = (char*) Guarded_Malloc( (prefix_len+32)*sizeof(char), "bar file name"); memset(whisker_file_name, 0, (prefix_len+32)*sizeof(char) ); memset(bar_file_name , 0, (prefix_len+32)*sizeof(char) ); sprintf( whisker_file_name, "%s.whiskers", prefix ); sprintf( bar_file_name, "%s.bar", prefix ); progress("Loading...\n"); fflush(stdout); movie = Get_String_Arg("movie"); TRY(image = load(movie,0,&depth),ErrorOpen); progress("Done.\n"); // No background subtraction (init to blank) { bg = Make_Image( image->kind, image->width, image->height ); memset(bg->array, 0, bg->width * bg->height ); } Free_Image( image ); #if 0 /* * Bar tracking */ if( !Is_Arg_Matched("--no-bar") ) { double x,y; BarFile *bfile = Bar_File_Open( bar_file_name, "w" ); progress( "Finding bar positions\n" ); for( i=0; i<depth; i++ ) { progress_meter(i, 0, depth-1, 79, "Finding post: [%5d/%5d]",i,depth); image = load(movie,i,NULL); invert_uint8( image ); Compute_Bar_Location( image, &x, // Output: x position &y, // Output: y position 15, // Neighbor distance 15, // minimum contour length 0, // minimum intensity of interest 255, // maximum intentity of interest 10.0, // minimum radius of interest 30.0 );// maximum radius of interest Bar_File_Append_Bar( bfile, Bar_Static_Cast(i,x,y) ); Free_Image(image); } Bar_File_Close( bfile ); } #endif /* * Trace whisker segments */ //if( !Is_Arg_Matched("--no-whisk") ) { int nTotalSegs = 0; Whisker_Seg *wv; int wv_n; WhiskerFile wfile = Whisker_File_Open(whisker_file_name,"whiskbin1","w"); if( !wfile ) { fprintf(stderr, "Warning: couldn't open %s for writing.", whisker_file_name); } else { //int step = (int) pow(10,round(log10(depth/100))); for( i=0; i<depth; i++ ) //for( i=450; i<460; i++ ) //for( i=0; i<depth; i+= step ) { int k; TRY(image=load(movie,i,NULL),ErrorRead); progress_meter(i, 0, depth, 79, "Finding segments: [%5d/%5d]",i,depth-1); wv = find_segments(i, image, bg, &wv_n); // Thrashing heap k = Remove_Overlapping_Whiskers_One_Frame( wv, wv_n, image->width, image->height, 2.0, // scale down by this 2.0, // distance threshold 0.5 ); // significant overlap fraction Whisker_File_Append_Segments(wfile, wv, k); Free_Whisker_Seg_Vec( wv, wv_n ); Free_Image(image); } printf("\n"); Whisker_File_Close(wfile); } } load(movie,-1,NULL); // Close (and free) if(bg) Free_Image( bg ); return 0; ErrorRead: load(movie,-1,NULL); // Close (and free) if(bg) Free_Image( bg ); error("Could not read frame %d from %s"ENDL,i,movie); return 1; ErrorOpen: error("Could not open %s"ENDL,movie); return 2; }