33 #include "../ContourDetectorSimple.hh"
34 #include "Base/Image/ImageIO.hh"
35 #include "Base/Debug/TimeMeasure.hh"
36 #include "Base/Image/ImageConvert.hh"
41 int main(
int argc,
char** argv)
50 cerr<<
"\n*********************************************************************************************************************"<<endl;
51 cerr<<
"This program detects single objects in an image with black (0) background and returns all pixel of the contour of that object.\n"<<endl;
52 cerr<<
"usage: "<< argv[0] <<
" segmentedImage distanceImage contourImage" <<endl;
53 cerr<<
"*********************************************************************************************************************"<<endl;
58 cerr <<
"error loading file " << argv[1] <<
" " << res << endl;
63 cerr <<
"wrong channel count in image"<< endl;
72 cout <<
"Set Background" << endl;
77 std::vector<BIASContour> contour;
78 cont.
Detect(image1, contour);
80 std::cout<<
"Finding the contour did take: ";
87 BIASERR(
"error writing");
89 cout<<
"Written distance image: "<<argv[2]<<endl;
91 cout<<
"Contour:"<<endl;
94 for (
unsigned int i=0;i<contour.size();i++){
95 for (
unsigned int k=0;k<contour[i].length;k++){
96 cout<<contour[i].contourPixel[k]<<
"\t ";
99 (
unsigned int)contour[i].contourPixel[k][0],
100 (
unsigned int)contour[i].contourPixel[k][1]);
108 BIASERR(
"error writing");
110 cout<<
"Written contour image: "<<argv[3]<<endl;
void CreateDistanceImage(BIAS::Image< StorageType > &dist_img, const BIASContour &contour)
returns a Borgefor distance transformed image (returned in 'dist_img') of the pixel set given by the ...
unsigned int GetWidth() const
int Detect(Image< StorageType > &image, std::vector< BIAS::BIASContour > &contour)
detect function of ContourDetectorSimple
a class for calculating the contour of a segmented region
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
void FillImageWithConstValue(StorageType Value)
fill grey images
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.
void SetBackground(StorageType backgroundColor)
Set the background color if it is different from 0.
void SetPixel(const StorageType &value, const unsigned int &x, const unsigned int &y, const unsigned short int channel=0)
Set the value of a given pixel (x,y) in channel to value.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
void PrintRealTime(std::ostream &os=std::cout, const bool &verbose=true) const
print the real time (=wall time clok)
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...
class TimeMeasure contains functions for timing real time and cpu time.