27 #include <Utils/IOUtils.hh>
42 int main(
int argc,
char* argv[])
49 if(!IOUtils::ParseCommandLineEvalHelp(params, argc, argv, fup) ) {
50 cout<<argv[0]<<
" --UL=\"x y\" --LR=\"x y\" <sourceImageName> [targetImageName]\n";
51 cout<<
" while the upper left corner (UL) is contained in the cropped region, "
52 "the LR corner is excluded, as are the lower and the right rectangle border.\n";
57 cout<<argv[0]<<
" --UL=\"x y\" --LR=\"x y\" <sourceImageName> [targetImageName]\n";
58 cout<<
" while the upper left corner (UL) is contained in the cropped region, "
59 "the LR corner is excluded, as are the lower and the right rectangle border.\n";
64 string inName(argv[fup]);
67 outName = argv[fup+1];
69 outName = IOUtils::ExtendOutName(inName,
"crop");
72 int ul[2] = {(*ulIn)[0], (*ulIn)[1]};
73 int lr[2] = {(*lrIn)[0], (*lrIn)[1]};
75 if(ul[0] < 0 || ul[1] < 0) {
76 BIASERR(
"negative coordinates are nonsense! : ("<<ul[0]<<
", "<<ul[1]<<
") -> ("<<lr[0]<<
", "<<lr[1]<<
")");
79 if(ul[0] >= lr[0] || ul[1] >= lr[1]) {
80 BIASERR(
"zero area rectangel defined : ("<<ul[0]<<
", "<<ul[1]<<
") -> ("<<lr[0]<<
", "<<lr[1]<<
")");
87 if(ImageIO::Load(inName, inputImg) !=0 ) {
88 BIASERR(
"error loading src image named : "<<inName);
92 bool haveProjection =
false;
96 haveProjection = IOUtils::GetProjection(inputImg, proj);
99 static_cast<unsigned int>(ul[1]),
100 static_cast<unsigned int>(lr[0]),
101 static_cast<unsigned int>(lr[1]));
105 unsigned int newWidth =
static_cast<unsigned int>(lr[0] - ul[0]);
106 unsigned int newHeight =
static_cast<unsigned int>(lr[1] - ul[1]);
112 if(ImageIO::Save(outName, inputImg) !=0 ) {
113 BIASERR(
"error loading src image named : "<<inName);
virtual void SetPrincipal(const double x, const double y)
Set principal point (in pixels relative to top left corner).
int Cut2ROI()
reduces image to current ROI, !!! image size changes !!!
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
This class hides the underlying projection model, like projection matrix, spherical camera...
BIAS::Vector< int > * AddParamVecInt(const std::string &name, const std::string &help, const BIAS::Vector< int > &deflt, char cmdshort=0, int Group=GRP_NOSHOW)
Add a parameter that expects a string on command line like "<value0> <value1> <value2> ...
This class Param provides generic support for parameters.
int SetROICorners(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)
This is the base class for images in BIAS.