Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages   Examples  

Kernel.h

00001 /* Copyright (c) 2001 C. Grigorescu */
00002 
00003 #ifndef KERNEL_H
00004 #define KERNEL_H
00005 
00006 #include <stdlib.h>
00007 #include <string.h>
00008 #include <malloc.h>
00009 #include <assert.h>
00010 #include <iostream.h>
00011 #include <typeinfo>
00012 #include "imlib_io.h"
00013 #include "Exceptions.h"
00014 #include "Image.h"
00015 
00016 enum BYTE_KERNEL_TYPE { 
00017   CROSS_3x3    = 100, 
00018   DISK_3x3     = 101,
00019   KERNEL_BYTE_UNKNOWN = 102};
00020 
00021 enum INT_KERNEL_TYPE { 
00022   LAPLACIAN_1    = 200, 
00023   LAPLACIAN_2    = 201, 
00024   SOBEL_H        = 202,
00025   SOBEL_V        = 203,
00026   PREWITT_H      = 204,
00027   PREWITT_V      = 205,
00028   KIRSCH_1       = 206,
00029   KIRSCH_2       = 207,
00030   KIRSCH_3       = 208,
00031   KIRSCH_4       = 209,
00032   KIRSCH_5       = 210,
00033   KIRSCH_6       = 211,
00034   KIRSCH_7       = 212,
00035   KIRSCH_8       = 213,
00036   KERNEL_INT_UNKNOWN    = 214};
00037 
00038 enum FLOAT_KERNEL_TYPE {
00039   RECTANGULAR_PULSE    = 300,
00040   TRIANGULAR_PULSE     = 301,
00041   GAUSS                = 302,
00042   DOG                  = 303,
00043   GABOR                = 304,
00044   LOG                  = 305,
00045   KERNEL_FLOAT_UNKNOWN = 306};
00046 
00051 template< class T > class Kernel : public Image < T >
00052 {
00054  protected:
00055   int kernel_type;
00056  
00057  public:
00059   Kernel(char *name = "") : Image< T > (name){  
00060     if (typeid(T) == typeid(byte)) kernel_type = KERNEL_BYTE_UNKNOWN;
00061     if (typeid(T) == typeid(int)) kernel_type = KERNEL_INT_UNKNOWN;
00062     if (typeid(T) == typeid(float)) kernel_type = KERNEL_FLOAT_UNKNOWN;
00063   }
00064 
00066   Kernel(int w, int h, char *name = "") : Image< T >(w,h,name) {  
00067     if (typeid(T) == typeid(byte)) kernel_type = KERNEL_BYTE_UNKNOWN;
00068     if (typeid(T) == typeid(int)) kernel_type = KERNEL_INT_UNKNOWN;
00069     if (typeid(T) == typeid(float)) kernel_type = KERNEL_FLOAT_UNKNOWN;
00070   }
00071 
00073   void readKernel(char *name) {
00074     readImage(name);
00075   }
00076 
00078   void writeKernel() {
00079     writeImage();
00080   }
00082   void showKernel() {
00083     showImage();
00084   }
00085 
00096   void readKernelCoeffs(char *name);
00097 
00109   void writeKernelCoeffs(char *name, char *comment);
00110 
00139   int  getKernelType() { return kernel_type;};
00140 };
00141 
00142 #endif