www.pudn.com > imageFeatures_Ver3_0_source.zip > ProcessFeatures.h


// ProcessFeatures.h 
 
/* 
** Copyright (C) 1994, 2003 Tyler C. Folsom 
** 
** Permission to use, copy, modify, and distribute this software and its 
** documentation for any purpose and without fee is hereby granted, provided 
** that the above copyright notice appear in all copies and that both that 
** copyright notice and this permission notice appear in supporting 
** documentation.  This software is provided "as is" without express or 
** implied warranty. 
*/ 
#ifndef PROCESS_FEATURES_H 
#define PROCESS_FEATURES_H 
 
#ifndef IFFEATURE_H 
#include "IFFeature.h" 
#endif 
 
#ifndef IFLOCATION_H 
#include "IFLocation.h" 
#endif 
 
#ifndef IFFILTER_H 
#include "IFFilter.h" 
#endif 
 
enum grid_type 
{ 
	eReadGrid,   // get the grid by reading a file 
	eMakeGrid,	 // construct a grid based on the options. 
	eTest1D,	 // construct a grid for a 1-D test 
	eTest2D 	 // construct a grid for a 2-D test 
}; 
 
// This ties the other classes together.      
class CProcessFeatures 
{ 
	friend class COptions;  
    friend class CImageFeaturesDoc; 
 
public: 
 
    CProcessFeatures( );  // constructor 
 
    // If m_locs is empty, fill it by reading from m_gridFileName. 
    // Return "true" if succesful. 
    bool ReadGrid(); 
    bool MakeGrid();  // Return true on constructing a grid 
    bool Make1DGrid();  // Return true on constructing a 1D test grid 
    bool Make2DGrid();  // Return true on constructing a 2D test grid 
 
    // Set the grid file name to the new value. 
    // If this is the same as before, do nothing. 
    // Otherwise, read and validate the new grid file. 
    // If the new grid is not valid, retain the old one  
    // and return "false".  Otherwise return "true". 
    bool SetGrid( CString gridFileName ); 
 
    // Associate an image with this process. 
    void SetImage( CDefaultImage *pImage ) 
    { m_pImage = pImage; } 
 
    // Set the bounding rectangle for the image 
    void SetBounds( RECT bounds ) 
    { m_bounds = bounds; } 
 
    // Return the current grid file name. 
    CString GetGrid() const 
    { return m_gridFileName; } 
 
    // Detect features using the selected image and sampling grid. 
    // Create text and graphical output. 
    bool Process(grid_type grid); 
 
    // Filter the image at a particular location 
    bool Filter( CLocation& location ); 
 
    // Correlate the image at the given location with the filters. 
	// returned value is the squared sum of magnitudes at all orientations. 
    float correlate( CLocation& location, CFilter& filters, int band = 1); 
 
    // Find the features at a particular location 
    bool Interpret( CLocation& location ); 
 
	// Fill in CFeature::m_pNbr with pointers to adjacent features 
	void FindNeighbors(); 
 
 
    // Write text of features.  Return "true" if succesful. 
    bool WriteFeatureList 
    (   int verbosity = 0,  // 0 for terse, 1 or 2 for more verbose  
        int mode = ios::out,// ios::app to append to file; ios::out for new file 
        char* title = "",   // put this on first line 
        float noise = 0     // noise level of test image 
    ); 
 
    // Overlay graphics on the image 
    void MakeFeatureImage(CVisRGBAByteImage& featureImage); 
 
    // Plot the kernels for debugging. 
    void plotKernels(CVisRGBAByteImage& featureImage );  
 
    // Overlay graphics on the image 
    void drawLines(CVisRGBAByteImage& image); 
     
    // Set the correct answer for test images 
    void SetAnswer 
    (   feature_type type = eNOT_AVAILABE, 
        float x = 0, 
        float y = 0, 
        float degrees = 90, 
        float strength = 0, 
        float width = 0 
    ); 
 
	// True to supress display of bars. 
	bool m_viewEdgesOnly; 
 
 
private: 
//    CString m_imageFileName; 
    CString m_gridFileName; 
    // determines whether grid circles are displayed. 
    bool m_viewGrid; 
    // Ignore features whose intensity is less than this. 
    // Intensity ranges from 0 to 2.0 
    float m_threshold; 
	// The threshold used also includes lateral inhibition or facilitation, 
	// which is weighted by the following factor.  Should be 0 to 1.0. 
	float m_lateralFactor; 
	// If m_fixedDirection == true, do not steer; use only 0 degree orientation. 
	// This is intended for use with stereo correlation, where features 
	// in an image pair only differ in one direction. 
	bool m_fixedDirection; 
	// Extent to which small filters should overlap 
	// Used for grid construction.  Should be 1.0 to 3.0 
	float m_overlap; 
	// Diameter of small filter 
	// Used for grid construction 
	int m_filterDiam; 
    //  Any filters with a radius bigger than subSampleDiam are subsampled.	 
	int m_subSampleDiam; 
	// true if test images should be displayed. 
	bool m_displayTestImages; 
	// Contrast for test images: 0 to 256 
	int m_testImageContrast; 
	// Standard deviation for test image noise level: 0 to 256 
	float m_testImageNoise; 
 
    RECT m_bounds;  // limits of the image to be processed. 
    // The image to be processed 
    CDefaultImage *m_pImage; 
 
    // A list of filters that have been created, indexed by diameter. 
    // Use positive diameters for even filters, 
    // negative diameters for odd. 
    static CMap m_filters; 
 
    // A list of locations 
    CArray< CLocation, CLocation&> m_locs; 
 
    // A list of features 
    CArray< CFeature, CFeature&> m_features; 
 
    // For test images, the correct answer 
    Data_1D m_answer; 
 
}; 
#endif // PROCESS_FEATURES_H