Browse Source

removed dependencies on deprecated Filter.h

Sven Sickert 8 years ago
parent
commit
7f13dae95b

+ 42 - 42
baselib/FastFilter.h

@@ -17,47 +17,47 @@ class FastFilter
     public:
 
 	/** calculates gradient magnitude and gradient directions quantized in a number
-	 * of bins. 
-	 * @param pointer to the input image
-	 * @param xsize width of the image
-	 * @param ysize height of the image
-	 * @param gradient pointer to the destination memory for the gradient magnitude values
-	 * @param dir pointer to the destination memory for the gradient direction values
-	 * @param numBins number of bins used for the quantization of the gradient directions
-	 * @param usesigned if set put gradient directions alpha and - alpha in the same bin
-	 **/
+         * of bins.
+         * @param pointer to the input image
+         * @param xsize width of the image
+         * @param ysize height of the image
+         * @param gradient pointer to the destination memory for the gradient magnitude values
+         * @param dir pointer to the destination memory for the gradient direction values
+         * @param numBins number of bins used for the quantization of the gradient directions
+         * @param usesigned if set put gradient directions alpha and - alpha in the same bin
+         **/
 	template <class GrayValueType, class GradientMagnitudeType, class GradientDirectionType>
-	static void calcGradient ( 
-			  const GrayValueType *gray, 
-			  int xsize, int ysize,
-			  GradientMagnitudeType *gradient, 
-			  GradientDirectionType *dir, 
-			  int numBins, 
-			  bool usesigned );
+	static void calcGradient (
+                          const GrayValueType *gray,
+                          int xsize, int ysize,
+                          GradientMagnitudeType *gradient,
+                          GradientDirectionType *dir,
+                          int numBins,
+                          bool usesigned );
 
 	/** calculates gradient magnitude and gradient directions of a color image (use
-	 * the channel with the maximum magnitude at each pixel).
-	 * The gradient direction is quantized in a number of bins. 
-	 * @param r first channel of the input image
-	 * @param g second channel of the input image
-	 * @param b third channel of the input image
-	 * @param xsize width of the image
-	 * @param ysize height of the image
-	 * @param gradient pointer to the destination memory for the gradient magnitude values
-	 * @param dir pointer to the destination memory for the gradient direction values
-	 * @param numBins number of bins used for the quantization of the gradient directions
-	 * @param usesigned if set put gradient directions alpha and - alpha in the same bin
-	 **/
+         * the channel with the maximum magnitude at each pixel).
+         * The gradient direction is quantized in a number of bins.
+         * @param r first channel of the input image
+         * @param g second channel of the input image
+         * @param b third channel of the input image
+         * @param xsize width of the image
+         * @param ysize height of the image
+         * @param gradient pointer to the destination memory for the gradient magnitude values
+         * @param dir pointer to the destination memory for the gradient direction values
+         * @param numBins number of bins used for the quantization of the gradient directions
+         * @param usesigned if set put gradient directions alpha and - alpha in the same bin
+         **/
 	template <class GrayValueType, class GradientMagnitudeType, class GradientDirectionType>
-	static void calcColorGradient ( 
-			  const GrayValueType *r, 
-			  const GrayValueType *g, 
-			  const GrayValueType *b, 
-			  int xsize, int ysize,
-			  GradientMagnitudeType *gradient, 
-			  GradientDirectionType *dir, 
-			  int numBins, 
-			  bool usesigned );
+	static void calcColorGradient (
+                          const GrayValueType *r,
+                          const GrayValueType *g,
+                          const GrayValueType *b,
+                          int xsize, int ysize,
+                          GradientMagnitudeType *gradient,
+                          GradientDirectionType *dir,
+                          int numBins,
+                          bool usesigned );
 
 	template <class SrcValueType, class DstValueType>
 	static void calcGradientY ( const SrcValueType *img, int xsize, int ysize, DstValueType *d );
@@ -68,11 +68,11 @@ class FastFilter
 	///lazy attempt for realizing fast histogram of oriented gradients
 	///since (neg.) double values are allowed, fast filtering based on look-up tables is no longer possible
 	template <class GrayValueType, class OrientedGradientHistogramType>
-	static void calcOrientedGradientHistogram ( const GrayValueType *gray, 
-						    int xsize, int ysize,
-						    OrientedGradientHistogramType *hog, 
-						    int numBins, 
-						    bool usesigned );
+	static void calcOrientedGradientHistogram ( const GrayValueType *gray,
+                                                    int xsize, int ysize,
+                                                    OrientedGradientHistogramType *hog,
+                                                    int numBins,
+                                                    bool usesigned );
 
 };
 

+ 10 - 10
baselib/FastFilter.tcc

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file FastFilter.cpp
 * @brief color gradient
 * @author Erik Rodner
@@ -26,7 +26,7 @@ void FastFilter::calcGradientX ( const SrcValueType *img, int xsize, int ysize,
 	d[k] = 0.0;
 	k++;
 	for ( int x = 1 ; x < xsize-1 ; x++,k++ )
-	    d[k] = - img[k-1] + img[k+1];
+            d[k] = - img[k-1] + img[k+1];
 	d[k] = 0.0;
 	k++;
     }
@@ -43,18 +43,18 @@ void FastFilter::calcGradientY ( const SrcValueType *img, int xsize, int ysize,
 
     for ( int y = 1 ; y < ysize-1; y++ )
 	for ( int x = 0 ; x < xsize ; x++,k++ )
-	    d[k] = - img[k-xsize] + img[k+xsize];
+            d[k] = - img[k-xsize] + img[k+xsize];
 }
 
 template <class GrayValueType, class GradientMagnitudeType, class GradientDirectionType>
-void FastFilter::calcColorGradient ( 
-			  const GrayValueType *r, 
-			  const GrayValueType *g, 
-			  const GrayValueType *b, 
+void FastFilter::calcColorGradient (
+			  const GrayValueType *r,
+			  const GrayValueType *g,
+			  const GrayValueType *b,
 			  int xsize, int ysize,
-			  GradientMagnitudeType *gradient, 
-			  GradientDirectionType *dir, 
-			  int numBins, 
+			  GradientMagnitudeType *gradient,
+			  GradientDirectionType *dir,
+			  int numBins,
 			  bool usesigned )
 {
     double *atan2Table = FastMath::getSingleton().atan2Table;

+ 11 - 16
baselib/ICETools.cpp

@@ -5,27 +5,22 @@
 * @date 03/13/2008
 
 */
-#include "core/image/ImageT.h"
+#include "core/basics/Exception.h"
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include <core/image/Filter.h>
-#include <core/image/Convert.h>
-
-#include <core/imagedisplay/ImageDisplay.h>
-
-#include <iostream>
-
-#include <core/image/RectT.h>
-
+#include "core/image/ImageT.h"
+#include "core/image/Convert.h"
+#include "core/image/RectT.h"
+#include "core/imagedisplay/ImageDisplay.h"
 #include "vislearning/baselib/ICETools.h"
 
-#include "core/basics/Exception.h"
+#include <iostream>
 
 using namespace OBJREC;
 
 using namespace std;
 
-using namespace NICE;
+//using namespace NICE;
 
 ICETools::ICETools()
 {
@@ -35,14 +30,14 @@ ICETools::~ICETools()
 {
 }
 
-void ICETools::selectRectangles ( const NICE::Image & panel, NICE::Image & overlay, vector<Vector> & x, int color )
+void ICETools::selectRectangles ( const NICE::Image & panel, NICE::Image & overlay, vector<NICE::Vector> & x, int color )
 {
-  fthrow ( Exception, "ICETools::selectRectangles -- not yet implemented due to old ICE version." );
+  fthrow ( NICE::Exception, "ICETools::selectRectangles -- not yet implemented due to old ICE version." );
 }
 
-void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay, vector<Vector> & x, int color )
+void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay, vector<NICE::Vector> & x, int color )
 {
-  fthrow ( Exception, "ICETools::selectPoints -- not yet implemented due to old ICE version." );
+  fthrow ( NICE::Exception, "ICETools::selectPoints -- not yet implemented due to old ICE version." );
 }
 
 void ICETools::convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img )

+ 60 - 18
features/gradientfeatures/Image_tools.h

@@ -1,6 +1,6 @@
-/** 
+/**
 * @file Image_tools.h
-* @author Alexander Lütz
+* @author Alexander Freytag
 * @date 18/11/2010
 * @brief Contains tools for Image_Processing
 */
@@ -9,11 +9,10 @@
 
 #include "core/image/ImageT.h"
 #include "core/image/ColorImageT.h"
-// #include "core/image/Filter.h"
 #include <utility>
 
 namespace OBJREC {
-class Image_tools 
+class Image_tools
 {
 
     protected:
@@ -26,26 +25,69 @@ class Image_tools
 	/** simple destructor */
 	~Image_tools();
 
+	/**
+         * @author Alexander Freytag
+         * @brief Calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing
+         */
+	void calculateGradients(
+            const NICE::Image & origImage,
+            NICE::ImageT<float> & grad_x_Image,
+            NICE::ImageT<float> & grad_y_Image );
 
-	/** calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing*/
-	void calculateGradients(const NICE::Image & origImage, NICE::ImageT<float> & grad_x_Image, NICE::ImageT<float> & grad_y_Image );
-	/** calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing, considering the chanel with the greatest magnitude als resulting gradient*/
-	void calculateGradients(NICE::ColorImage origColorImage, NICE::ImageT<float> & grad_x_Image, NICE::ImageT<float> & grad_y_Image );
+	/**
+         * @author Alexander Freytag
+         * @brief Calculate gradient-images for x- and y-direction, using [1 0 -1] without smoothing, considering the chanel with the greatest magnitude als resulting gradient
+         */
+	void calculateGradients(
+            NICE::ColorImage origColorImage,
+            NICE::ImageT<float> & grad_x_Image,
+            NICE::ImageT<float> & grad_y_Image );
 
-	/** calculate gradient-orientations*/
-	void calculateGradientOrientations(const NICE::ImageT<float> & grad_x_Image, const NICE::ImageT<float> & grad_y_Image , const int & number_Of_Bins, NICE::Image & gradient_orientations, const bool unsignedBins=true);
+	/**
+         * @author Alexander Freytag
+         * @brief Calculate gradient-orientations
+         */
+	void calculateGradientOrientations(
+            const NICE::ImageT<float> & grad_x_Image,
+            const NICE::ImageT<float> & grad_y_Image,
+            const int & number_Of_Bins,
+            NICE::Image & gradient_orientations,
+            const bool unsignedBins=true );
 
-	void calculateGradientOrientations(const NICE::GrayImage16s & grad_x_Image, const NICE::GrayImage16s & grad_y_Image , const int & number_Of_Bins, NICE::Image & gradient_orientations, const bool unsignedBins=true);
+	void calculateGradientOrientations(
+            const NICE::GrayImage16s & grad_x_Image,
+            const NICE::GrayImage16s & grad_y_Image,
+            const int & number_Of_Bins,
+            NICE::Image & gradient_orientations,
+            const bool unsignedBins=true );
 
-	/** calculate gradient-magnitudes*/
-	void calculateGradientMagnitudes(const NICE::ImageT<float>  & grad_x_Image, const NICE::ImageT<float> & grad_y_Image, NICE::ImageT<float> & gradient_magnitudes);
+	/**
+          *@author Alexander Freytag
+          *@brief Calculate gradient-magnitudes
+          */
+	void calculateGradientMagnitudes(
+            const NICE::ImageT<float> & grad_x_Image,
+            const NICE::ImageT<float> & grad_y_Image,
+            NICE::ImageT<float> & gradient_magnitudes );
 
-	/** Normalizes the descriptor-vector of the specified block, using L2-norm*/
-	std::vector<float> normalizeBlockDescriptor(const std::vector<float> & orig_Block_Descriptor, const float epsilon = 0.01);
+	/**
+          *@author Alexander Freytag
+          *@brief Normalizes the descriptor-vector of the specified block, using L2-norm
+          */
+	std::vector<float> normalizeBlockDescriptor(
+            const std::vector<float> & orig_Block_Descriptor,
+            const float epsilon = 0.01 );
 
-	/** calculates the resulting HoG-Features for an image by normalizing spatial blocks und storing the resulting normalized histograms in a vector - not implemented up to now*/
-	std::vector< std::vector<float> > calculateResultingHogFeatures(const NICE::Image & gradient_orientations, const NICE::ImageT<float> & gradient_magnitudes, const int & blocksize = 2, const int & cellsize = 8);
+	/**
+          *author Alexander Freytag
+          *@brief Calculates the resulting HoG-Features for an image by normalizing spatial blocks und storing the resulting normalized histograms in a vector - not implemented up to now
+          */
+	std::vector< std::vector<float> > calculateResultingHogFeatures(
+            const NICE::Image & gradient_orientations,
+            const NICE::ImageT<float> & gradient_magnitudes,
+            const int & blocksize = 2,
+            const int & cellsize = 8 );
 };
 }
 
-#endif
+#endif

+ 14 - 22
image/ImagePyramid.cpp

@@ -10,19 +10,13 @@
 #include "vislearning/image/ImagePyramid.h"
 
 using namespace OBJREC;
-
 using namespace std;
 
-using namespace NICE;
-
-
-
-
-ImagePyramid::ImagePyramid( const NICE::Image & img, 
-			    int maxLevels,
-			    double scaleSpacing,
-			    int max_xsize,
-			    int max_ysize )
+ImagePyramid::ImagePyramid( const NICE::Image & img,
+                            int maxLevels,
+                            double scaleSpacing,
+                            int max_xsize,
+                            int max_ysize )
 {
     pyramid.push_back ( NICE::Image(img) );
     for ( int i = 1 ; i < maxLevels ; i++ )
@@ -31,30 +25,28 @@ ImagePyramid::ImagePyramid( const NICE::Image & img,
 	int old_xsize = pyramid[i-1].width();
 
 	int old_ysize = pyramid[i-1].height();
-	double new_xsize = old_xsize / scaleSpacing; 
-	double new_ysize = old_ysize / scaleSpacing; 
+	double new_xsize = old_xsize / scaleSpacing;
+	double new_ysize = old_ysize / scaleSpacing;
 
 	if ( (new_xsize < max_xsize) || (new_ysize < max_ysize) )
-	    break;
+            break;
 
 
 	NICE::Image gauss (old_xsize, old_ysize);
 
-	filterGauss(pyramid[i-1], 2, &gauss);
-
+        NICE::FilterT<unsigned char, unsigned char, unsigned char> filter;
+        filter.filterGaussSigmaApproximate ( *(&pyramid[i-1]), 1.0, &gauss );
+	//deprecated: filterGauss(pyramid[i-1], 2, &gauss);
 
 	NICE::Image newLevel ((int)new_xsize, (int)new_ysize);
 
-
 	// Trafo trafo;
 	// trafo.Scale(0, 0, (new_xsize-1)/(old_xsize-1),
-	//		  (new_ysize-1)/(old_ysize-1));
+	//                   (new_ysize-1)/(old_ysize-1));
 	// Transform(trafo, gauss, newLevel);
 	NICE::scale ( gauss, &newLevel );
-
-		NICE::scale ( gauss, &newLevel );
-
-		pyramid.push_back(newLevel);
+        NICE::scale ( gauss, &newLevel );
+        pyramid.push_back(newLevel);
     }
 }
 

+ 13 - 13
image/ImagePyramid.h

@@ -1,4 +1,4 @@
-/** 
+/**
 * @file ImagePyramid.h
 * @brief gauss image pyramid
 * @author Erik Rodner
@@ -11,10 +11,10 @@
 #include "core/image/ImageT.h"
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"
-#include "core/image/Filter.h"
+#include "core/image/FilterT.h"
 
 #include "core/imagedisplay/ImageDisplay.h"
-  
+
 
 namespace OBJREC {
 
@@ -23,18 +23,18 @@ class ImagePyramid
 {
 
   protected:
-	  std::vector<NICE::Image> pyramid;
-	  double scaleSpacing;
+          std::vector<NICE::Image> pyramid;
+          double scaleSpacing;
 
     public:
-  
+
       /** simple constructor */
-      ImagePyramid ( const NICE::Image & img, 
-               int maxLevels = 10,
-               double scaleSpacing = 1.18921,
-               int max_xsize = 11,
-               int max_ysize = 11 );
-          
+      ImagePyramid ( const NICE::Image & img,
+                     int maxLevels = 10,
+                     double scaleSpacing = 1.18921,
+                     int max_xsize = 11,
+                     int max_ysize = 11 );
+
       /** simple destructor */
       virtual ~ImagePyramid();
 
@@ -43,7 +43,7 @@ class ImagePyramid
       void show() const;
       void getOriginalCoordinates ( int x, int y, int level, double & xo, double & yo ) const;
       void getLevelCoordinates ( double xo, double yo, int level, double & xl, double & yl ) const;
-     
+
 };
 
 

+ 0 - 1
math/ftransform/PCA.h

@@ -8,7 +8,6 @@
 #ifndef PCAINCLUDE
 #define PCAINCLUDE
 
-//#include "core/image/Filter.h"
 #include "core/vector/VectorT.h"
 #include "core/vector/MatrixT.h"