4 #include <Base/Image/ImageIO.hh>
5 #include "Base/Image/ImageConvert.hh"
6 #include "Utils/Param.hh"
20 int main(
int argc,
char *argv[]){
22 if (argc>=2)
if (strcmp(argv[1],
"-darttest")==0){
23 std::cout<<
"started dart test: "<<argv[0]<<std::endl;
29 param.
AddParamInt(
"border",
"sets ROI", 0, 0,INT_MAX,
'b');
30 param.
AddParamBool(
"absdiff",
"if set calculates abs difference else im1-im2",
false,
'a');
32 param.
AddParamBool(
"grey",
"converts images to grey",
false,
'g');
33 param.
AddParamBool(
"zeroexclude",
"do not use zero values",
false,
'z');
34 param.
AddParamBool(
"exclude_negative",
"do not use negative values",
false,
'n');
46 BIASERR(
"error loading "<<argv[next]);
50 BIASERR(
"error loading "<<argv[next+1]);
57 BIASERR(
"image sizes do not match");
71 bool excludeNegative = *param.
GetParamBool(
"exclude_negative");
79 newfilename = fn1+
'_'+fn2+
"_diff";
89 unsigned char ucmin, ucmax;
101 for (
unsigned int y=0; y< ucim1.
GetHeight(); y++) {
102 for (
unsigned int x=0; x< ucim1.
GetWidth(); x++) {
104 if (p2[y][channels*x+c]==0 || p1[y][channels*x+c]==0)
105 p2[y][channels*x+c] = p1[y][channels*x+c] = 0;
116 fim1.ScaleShiftBetween(0.0,255.0);
122 cerr <<
"error writing diff.mip "<<endl;
125 cerr <<
"differences between "<<(int)ucmin<<
" and "<<(
int)ucmax<<endl;
126 if (ucdiff.ScaleShiftBetween(0, 255)!=0){
127 BIASERR(
"error scaling image");
131 cerr <<
"error writing diff-scaled.mip "<<endl;
138 if (zeroExclude || excludeNegative) {
140 float **p2 = fim2.GetImageDataArray();
142 for (
unsigned int y=0; y< fim1.GetHeight(); y++) {
143 for (
unsigned int x=0; x< fim1.GetWidth(); x++) {
144 if (excludeNegative){
145 if (p2[y][x]<=0.0 || p1[y][x]<=0.0){
146 p2[y][x] = p1[y][x] = 0;
149 if (p2[y][x]==0 || p1[y][x]==0){
150 p2[y][x] = p1[y][x] = 0;
157 fdiff.AbsDiff(fim1, fim2);
165 cerr <<
"error writing diff.mip "<<endl;
167 fdiff.GetMinMaxPixelValue(fmin, fmax);
168 cerr <<
"differences between "<<fmin<<
" and "<<fmax<<endl;
171 cerr <<
"unknown storage type\n";
void DisableDestructorWarning()
Uses this just before end of your program to avoid error from destructor.
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
void AbsDiff(const Image< StorageType > &im1, const Image< StorageType > &im2)
(*this) = | im1 - im2 | sets this as the absolute difference between two arg images ...
void GetMinMaxPixelValue(StorageType &min, StorageType &max, unsigned short int channel=0, unsigned int *mincoo=NULL, unsigned int *maxcoo=NULL) const
returns the minimal and maximal pixel value in channel only Finds minimum and maximum pixel value in ...
unsigned int GetWidth() const
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
bool * GetParamBool(const std::string &name) const
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
static std::string Basename(const std::string &fullname)
Get file base name without path from given path and filename.
void ** GetImageDataArray() const
Get an array of pointers to image data.
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
int * GetParamInt(const std::string &name) const
unsigned int GetHeight() const
bool SamePixelAndChannelCount(const ImageBase &Image) const
checks if data area has same "size" as Image of other type
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.
int SetROI(unsigned int UpperLeftX, unsigned int UpperLeftY, unsigned int LowerRightX, unsigned int LowerRightY)
deprecated, use SetROICorners()
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...
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.
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase
static int ToGrey(const ImageBase &source, ImageBase &dest)
wrapper for the templated function ToGrey