if2_usage (const char *program)
{
std::cout << "usage: " << fileBasename(program) << " infile1 infile2 outfile [OPTIONS]\n";
if2_usage (const char *program)
{
std::cout << "usage: " << fileBasename(program) << " infile1 infile2 outfile [OPTIONS]\n";
while (1) {
char* endptr;
int c = getopt_long (argc, argv, "", my_options, NULL);
while (1) {
char* endptr;
int c = getopt_long (argc, argv, "", my_options, NULL);
in_file1 = argv[optind];
in_file2 = argv[optind + 1];
if (opt_bImageOutputFile || opt_bPlotOutputFile)
strOutFile = argv[optind + 2];
in_file1 = argv[optind];
in_file2 = argv[optind + 1];
if (opt_bImageOutputFile || opt_bPlotOutputFile)
strOutFile = argv[optind + 2];
pim_in1 = new ImageFile ();
pim_in2 = new ImageFile ();
ImageFile& im_in1 = *pim_in1;
ImageFile& im_in2 = *pim_in2;
pim_in1 = new ImageFile ();
pim_in2 = new ImageFile ();
ImageFile& im_in1 = *pim_in1;
ImageFile& im_in2 = *pim_in2;
if (! im_in1.fileRead(in_file1) || ! im_in2.fileRead(in_file2)) {
sys_error (ERR_WARNING, "Error reading an image");
return (1);
}
if (! im_in1.fileRead(in_file1) || ! im_in2.fileRead(in_file2)) {
sys_error (ERR_WARNING, "Error reading an image");
return (1);
}
if (im_in1.nx() != im_in2.nx() || im_in1.ny() != im_in2.ny()) {
sys_error (ERR_SEVERE, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match",
im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
if (im_in1.nx() != im_in2.nx() || im_in1.ny() != im_in2.ny()) {
sys_error (ERR_SEVERE, "Error: Size of image 1 (%d,%d) and image 2 (%d,%d) do not match",
im_in1.nx(), im_in1.ny(), im_in2.nx(), im_in2.ny());
ImageFileArray v1 = im_in1.getArray();
ImageFileArray v2 = im_in2.getArray();
ImageFileArray vout = NULL;
ImageFileArray v1 = im_in1.getArray();
ImageFileArray v2 = im_in2.getArray();
ImageFileArray vout = NULL;
if (opt_bImageOutputFile && opt_bPlotOutputFile) {
sys_error (ERR_SEVERE, "Both Image and Plot output files can not be selected simultaneously");
return (1);
if (opt_bImageOutputFile && opt_bPlotOutputFile) {
sys_error (ERR_SEVERE, "Both Image and Plot output files can not be selected simultaneously");
return (1);
pim_out = new ImageFile (im_in1.nx(), im_in1.ny());
vout = pim_out->getArray();
}
pim_out = new ImageFile (im_in1.nx(), im_in1.ny());
vout = pim_out->getArray();
}
if (opt_add) {
strOperation = "Add Images";
im_in1.addImages (im_in2, *pim_out);
if (opt_add) {
strOperation = "Add Images";
im_in1.addImages (im_in2, *pim_out);
im_in1.comparativeStatistics (im_in2, d, r, e);
std::cout << "d=" << d << ", r=" << r << ", e=" << e << std::endl;
}
im_in1.comparativeStatistics (im_in2, d, r, e);
std::cout << "d=" << d << ", r=" << r << ", e=" << e << std::endl;
}
plotFile.addColumn (0, plot_xaxis);
plotFile.addColumn (1, v1[opt_columnPlot]);
plotFile.addColumn (2, v2[opt_columnPlot]);
plotFile.addColumn (0, plot_xaxis);
plotFile.addColumn (1, v1[opt_columnPlot]);
plotFile.addColumn (2, v2[opt_columnPlot]);
if (opt_rowPlot > 0) {
if (opt_rowPlot >= ny || opt_rowPlot >= ny2) {
sys_error (ERR_SEVERE, "row_plot > ny");
if (opt_rowPlot > 0) {
if (opt_rowPlot >= ny || opt_rowPlot >= ny2) {
sys_error (ERR_SEVERE, "row_plot > ny");
double* plot_xaxis = new double [ny];
double* v1Row = new double [ny];
double* v2Row = new double [ny2];
double* plot_xaxis = new double [ny];
double* v1Row = new double [ny];
double* v2Row = new double [ny2];
for (i = 0; i < ny; i++)
plot_xaxis[i] = i;
for (i = 0; i < ny; i++)
v1Row[i] = v1[i][opt_rowPlot];
for (i = 0; i < ny2; i++)
v2Row[i] = v2[i][opt_rowPlot];
for (i = 0; i < ny; i++)
plot_xaxis[i] = i;
for (i = 0; i < ny; i++)
v1Row[i] = v1[i][opt_rowPlot];
for (i = 0; i < ny2; i++)
v2Row[i] = v2[i][opt_rowPlot];
plotFile.addColumn (0, plot_xaxis);
plotFile.addColumn (1, v1Row);
plotFile.addColumn (2, v2Row);
plotFile.addColumn (0, plot_xaxis);
plotFile.addColumn (1, v1Row);
plotFile.addColumn (2, v2Row);
plotFile.addEzsetCommand ("box");
plotFile.addEzsetCommand ("grid");
plotFile.addEzsetCommand ("xticks major 5");
plotFile.addEzsetCommand ("box");
plotFile.addEzsetCommand ("grid");
plotFile.addEzsetCommand ("xticks major 5");
if (opt_bImageOutputFile) {
pim_out->labelsCopy (im_in1, "if2 file 1: ");
pim_out->labelsCopy (im_in2, "if2 file 2: ");
pim_out->labelAdd (Array2dFileLabel::L_HISTORY, strOperation.c_str(), timerProgram.timerEnd());
pim_out->fileWrite (strOutFile);
}
if (opt_bImageOutputFile) {
pim_out->labelsCopy (im_in1, "if2 file 1: ");
pim_out->labelsCopy (im_in2, "if2 file 2: ");
pim_out->labelAdd (Array2dFileLabel::L_HISTORY, strOperation.c_str(), timerProgram.timerEnd());
pim_out->fileWrite (strOutFile);
}