image_warp [--num NUM_IMAGES] [--dir DIR] [--type TYPE] [--out OUT_DIR] [--stub OUT_STUB]
./dir/warp_TO_FROM.jpg
. You need to create the output directory yourself.By flipping through the images with the same value of TO, you can see the quality of alignment within a dataset.
Definition in file image_warp.cc.
#include <iostream>
#include <cvd/image_io.h>
#include <cvd/image_interpolate.h>
#include <gvars3/instances.h>
#include <tag/printf.h>
#include <tag/stdpp.h>
#include "load_data.h"
#include "utility.h"
Go to the source code of this file.
Functions | |
Image< byte > | warp_image (const Image< byte > &in, const Image< array< float, 2 > > &warp) |
int | main (int argc, char **argv) |
Image<byte> warp_image | ( | const Image< byte > & | in, | |
const Image< array< float, 2 > > & | warp | |||
) |
Warp one image to look like another, using bilinear interpolation.
in | The image to warp | |
warp | The warp to use to warp the image |
Definition at line 60 of file image_warp.cc.
Referenced by main().
00061 { 00062 Image<byte> ret(in.size(), 0); 00063 00064 image_interpolate<Interpolate::Bilinear, byte> interp(in); 00065 00066 for(int y=0; y < ret.size().y; y++) 00067 for(int x=0; x < ret.size().x; x++) 00068 { 00069 if(warp[y][x][0] != -1 && interp.in_image(Vec(warp[y][x]))) 00070 ret[y][x] = interp[Vec(warp[y][x])]; 00071 } 00072 00073 return ret; 00074 }
int main | ( | int | argc, | |
char ** | argv | |||
) |
Driving function.
argc | Number of command line arguments | |
argv | Commandline argument list |
Definition at line 79 of file image_warp.cc.
References load_data(), and warp_image().
00080 { 00081 try 00082 { 00083 //Load command line arguments 00084 GUI.parseArguments(argc, argv); 00085 00086 vector<Image<byte> > images; 00087 vector<vector<Image<array<float, 2> > > > warps; 00088 00089 //Extract arguments relavent to loading a dataset 00090 int n = GV3::get<int>("num", 2, 1); 00091 string dir = GV3::get<string>("dir", "./", 1); 00092 string format = GV3::get<string>("type", "cambridge", 1); 00093 00094 //Load the dataset 00095 rpair(images, warps) = load_data(dir, n, format); 00096 00097 //Generate the output printf string 00098 string out = GV3::get<string>("out", "./out/", 1) + "/" + GV3::get<string>("stub", "warped_%i_%i.jpg", 1); 00099 00100 //Warp every image to look like every other image 00101 //where this makes sense. 00102 for(int to = 0; to < n; to++) 00103 for(int from=0; from < n; from ++) 00104 if(from != to) 00105 { 00106 Image<byte> w = warp_image(images[from], warps[to][from]); 00107 img_save(w, sPrintf(out, to, from)); 00108 00109 cout << "Done " << from << " -> " << to << endl; 00110 } 00111 else 00112 { 00113 img_save(images[from], sPrintf(out, to, from)); 00114 } 00115 } 00116 catch(Exceptions::All e) 00117 { 00118 cerr << "Error: " << e.what << endl; 00119 } 00120 }