27 #include "Base/Image/ImageIO.hh"
28 #include "Base/Image/ImageConvert.hh"
29 #include "Filter/Rescale.hh"
30 #include "Utils/Param.hh"
41 int main(
int argc,
char *argv[])
45 params.
AddParamInt(
"tlx",
"top left insert x-position",-1,-1,10000,
'x');
46 params.
AddParamInt(
"tly",
"top left insert y-position",-1,-1,10000,
'y');
48 params.
AddParamInt(
"xsize",
"pixel size of insertion in x-direction"
49 " defaults to same",-1,-1,10000,
'X');
52 cout<<
"usage:"<<argv[0]<<
" <img> <imgToInsert> [resultimage]"<<endl;
54 " inserts the <imgToinsert> into <img> at the specified"<<
55 " position, the position can be anyone! "<<endl<<
56 " default is right next to <img>"<<endl<<
57 " [resultImg] optional mip or ppm image"
58 " , default: result is written to result.mip"<<
67 cerr<<
"error loading:"<<argv[nextParam]<<endl;
71 cerr<<
"error loading:"<<argv[nextParam]<<endl;
76 cerr<<
"only implemented for unsigned char images yet"<<endl;
80 cerr<<
"WARNING: colormodels do not match"<<endl<<
81 " converting <imgToinsert> to:"<<int(img.
GetColorModel()) <<endl;
84 cerr<<
"couldn't convert, exiting"<<endl;
91 std::string resultFile;
93 resultFile=argv[nextParam];
94 }
else resultFile=
"result.mip";
98 if (insertionSize!=-1) {
101 scaler.
Filter(resultImg,scaledImg);
104 if (insertionX==-1) insertionX=img.
GetWidth();
106 if (insertionY==-1) insertionY=0;
108 int resultXSize= insertionX + scaledImg.GetWidth();
109 if ( resultXSize<(
int)img.
GetWidth() )
111 int resultYSize= insertionY + scaledImg.GetHeight();
119 resultImg.Paste2ROI(img);
120 resultImg.SetROI(insertionX,insertionY,
121 insertionX+scaledImg.GetWidth(),
122 insertionY+scaledImg.GetHeight());
123 resultImg.Paste2ROI(scaledImg);
125 if (resultFile.find(
".ppm") != string::npos) {
127 cout<<
"resulting ppm-image written to "<<resultFile<<endl;
131 cout<<
"resulting mip-image written to "<<resultFile<<endl;
void DisableDestructorWarning()
Uses this just before end of your program to avoid error from destructor.
unsigned int GetWidth() const
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
scales the src to dst using the downsampling factor from SetFactor()
int * GetParamInt(const std::string &name) const
unsigned int GetHeight() const
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
enum EColorModel GetColorModel() const
This class Param provides generic support for parameters.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
static int Convert(BIAS::ImageBase &source, BIAS::ImageBase &dest, enum BIAS::ImageBase::EColorModel targetColorModel, bool bPlanar=false)
main general conversion function, calls desired specialized functions, always initializes the destIma...
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
This is the base class for images in BIAS.
void SetFactor(double factor)
the downsampling factor