int main(int argc, char* argv[]) { char *out_file = NULL; char *in_file = NULL; int c; int inx=0, iny=0; int factor=2; icv_image_t *bif; ICV_IMAGE_FORMAT format=ICV_IMAGE_AUTO; ICV_RESIZE_METHOD method = ICV_RESIZE_SHRINK; size_t index; if (argc<2) { usage(); return 1; } while ((c = bu_getopt(argc, argv, "s:w:n:M:f:o:bpdmh?")) != -1) { switch (c) { case 's': inx = iny = atoi(bu_optarg); break; case 'w': inx = atoi(bu_optarg); break; case 'n': iny = atoi(bu_optarg); break; case 'o': out_file = bu_optarg; break; case 'M': if (BU_STR_EQUAL(bu_optarg, "under_sample")) method = ICV_RESIZE_UNDERSAMPLE; else if (BU_STR_EQUAL(bu_optarg, "shrink")) method = ICV_RESIZE_SHRINK; else { usage(); bu_exit(1, "Wrong Input Argument\n"); } break; case 'f': factor = atoi(bu_optarg); break; case 'b': format = ICV_IMAGE_BW; break; case 'p': format = ICV_IMAGE_PIX; break; case 'd': format = ICV_IMAGE_DPIX; break; case 'm': format = ICV_IMAGE_PPM; break; case 'h': default: usage(); return 1; } } if (bu_optind >= argc) { if (isatty(fileno(stdin))) { usage(); return 1; } } else { in_file = argv[bu_optind]; bu_optind++; } bif = icv_read(in_file, format, inx, iny); icv_resize(bif, method, 0, 0, (unsigned int) factor); bu_log("File information width %d height%d\n", bif->width, bif->height); for (index = 0; index < 65536; index++) bu_log("index = %ld, data = %f\n", index, bif->data[index]); icv_write(bif,out_file, format); bu_log("File information width %d height%d channels = %d\n", bif->width, bif->height, bif->channels); icv_destroy(bif); return 0; }
int main(int argc, char* argv[]) { char *out_file = NULL; char *in_file = NULL; int inx=0, iny=0; icv_image_t *bif; ICV_IMAGE_FORMAT format=ICV_IMAGE_AUTO; int c; if (argc<2) { usage(); return 1; } while ((c = bu_getopt(argc, argv, "s:o:w:nbpdmh?")) != -1) { switch (c) { case 'o' : bu_log("out_file = %s\n", bu_optarg); out_file = bu_optarg; break; case 's' : inx = iny = atoi(bu_optarg); break; case 'w' : inx = atoi(bu_optarg); break; case 'n' : iny = atoi(bu_optarg); break; case 'b' : bu_log("There was in bw\n"); format = ICV_IMAGE_BW; break; case 'p' : format = ICV_IMAGE_PIX; break; case 'd' : format = ICV_IMAGE_DPIX; break; case 'm' : format = ICV_IMAGE_PPM; break; case 'h': default: usage(); return 1; } bu_log("C= %c, optind = %d\n", c, bu_optind); } if (bu_optind >= argc) { if (isatty(fileno(stdin))) { usage(); return 1; } } else { in_file = argv[bu_optind]; bu_optind++; } bu_log("in_file = %s, out_file = %s\n", in_file, out_file); bif = icv_read(in_file, format, inx, iny); icv_write(bif,out_file, format); icv_destroy(bif); return 0; }
int main(int argc, char* argv[]) { char *out_file = NULL; char *in_file = NULL; int c; int inx=0, iny=0; icv_image_t *bif; ICV_IMAGE_FORMAT format=ICV_IMAGE_AUTO; double multiplier=0.2; if (argc<2) { usage(); return 1; } while ((c = bu_getopt(argc, argv, "s:w:n:o:%:f:bpdmh?")) != -1) { switch (c) { case 's': inx = iny = atoi(bu_optarg); break; case 'w': inx = atoi(bu_optarg); break; case 'n': iny = atoi(bu_optarg); break; case 'o': out_file = bu_optarg; break; case '%': multiplier = atof(bu_optarg) / 100.0; if (multiplier < 0.0) bu_exit (1, "tester_icv_fade : percent is negative"); break; case 'f': multiplier = atof(bu_optarg); if (multiplier < 0.0) bu_exit(1,"tester_icv_fade : fraction is negative"); break; case 'b' : format = ICV_IMAGE_BW; break; case 'p' : format = ICV_IMAGE_PIX; break; case 'd' : format = ICV_IMAGE_DPIX; break; case 'm' : format = ICV_IMAGE_PPM; break; case 'h': default: usage(); return 1; } } if (bu_optind >= argc) { if (isatty(fileno(stdin))) { usage(); return 1; } } else { in_file = argv[bu_optind]; bu_optind++; } bif = icv_read(in_file, format, inx, iny); icv_fade(bif, multiplier); icv_write(bif,out_file, format); icv_destroy(bif); return 0; }