34 #include <Filter/FilterNTo2N.hh>
35 #include <Filter/GradientSobel3x3.hh>
36 #include <Filter/GradientGauss.hh>
37 #include <Filter/GradientGaussAsymmetric.hh>
38 #include <Base/Image/ImageIO.hh>
39 #include <Base/Image/ImageConvert.hh>
40 #include <Base/Debug/TimeMeasure.hh>
42 #include <Base/ImageUtils/ImageDraw.hh>
43 #include "FeatureDetector/ContourDetectorSimple.hh"
44 #include <Base/Common/BIASpragma.hh>
49 #define InputImageType unsigned char
50 #define OutputImageType float
53 int main(
int argc,
char *argv[])
57 cerr <<
"usage: "<< argv[0] <<
"SegmentedImage ColorImage ContourImage" << endl;
74 std::vector<BIASContour> contour;
75 cont.
Detect(segIm, contour);
85 OutputImageType>::TBH_valid);
87 gsobel3x3.
Filter(im, gx, gy, g);
96 int dSearchLength = 20;
97 double start_x, start_y, end_x, end_y;
101 for(
unsigned int i = 0; i < ct.
length; i++){
109 int offset = (i+4)%ct.
length;
122 double distance = sqrt(pow((end_x - start_x),2) +
123 pow((end_y - start_y),2));
126 double PvectorXone = (end_y - start_y);
127 double PvectorYone = -(end_x - start_x);
129 double coefficient = dSearchLength / distance;
130 double normX = coefficient*PvectorXone;
141 while((normX+pointMiddle[0]) - (pointMiddle[0] + PvectorXone*fk) > 0 ){
142 x = pointMiddle[0] + PvectorXone*fk;
143 y = pointMiddle[1] + PvectorYone*fk;
145 if(data[y][x] > 12.0){
157 while((pointMiddle[0]-normX) - (pointMiddle[0] + PvectorXone*fk) > 0 ){
158 x = pointMiddle[0] + PvectorXone*fk;
159 y = pointMiddle[1] + PvectorYone*fk;
161 if(data[y][x] > 12.0){
180 for (
unsigned int k=0;k<ct.
length;k++){
187 for (
unsigned int k=0;k<ct_copy.
length;k++){
199 for (
unsigned int k=0;k<ct_copy.
length-1;k++){
gradient calculation with separated gauss masks
This class describes a contour using the freemancode.
base class for simple n->2n filter implementations
std::vector< BIAS::Vector2< double > > contourPixel
All pixels contained in the contour.
virtual parent class for API definition of all (future) filters
gradient calculation with sobel 3 by 3 masks
unsigned int GetWidth() const
int Detect(Image< StorageType > &image, std::vector< BIAS::BIASContour > &contour)
detect function of ContourDetectorSimple
static int Line(Image< StorageType > &im, const unsigned int start[2], const unsigned int end[2], const StorageType value[])
lines
a class for calculating the contour of a segmented region
unsigned int GetHeight() const
void SetBorderHandling(const int bh)
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
gradient calculation with separated gauss masks
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...
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &grad)
returns a 2 channel image containing gx and gy
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase