koehler.C

Go to the documentation of this file.
00001 /* Gnome gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  *
00005  * plugin_helper reports your answers as
00006 author          =Percy Zahl
00007 email                   =zahl@users.sf.net
00008 pluginname              =koehler
00009 pluginmenuentry         =Koehler
00010 menupath                =Math/Filter 1D/
00011 entryplace              =Filter 1D
00012 shortentryplace =F1D
00013 abouttext               =This is the Koehler filter, it does 1D edge enhancement.
00014 smallhelp               =Koehler filter
00015 longhelp                =Koehler filter
00016  * 
00017  * Gxsm Plugin Name: koehler.C
00018  * ========================================
00019  * 
00020  * Copyright (C) 1999 The Free Software Foundation
00021  *
00022  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00023  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00024  *
00025  * This program is free software; you can redistribute it and/or modify
00026  * it under the terms of the GNU General Public License as published by
00027  * the Free Software Foundation; either version 2 of the License, or
00028  * (at your option) any later version.
00029  *
00030  * This program is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00033  * GNU General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU General Public License
00036  * along with this program; if not, write to the Free Software
00037  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00038  */
00039 
00040 
00041 /* Please do not change the Begin/End lines of this comment section!
00042  * this is a LaTeX style section used for auto generation of the PlugIn Manual 
00043  * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks!
00044  * All "% PlugInXXX" commentary tags are mandatory
00045  * All "% OptPlugInXXX" tags are optional and can be removed or commented in
00046  * --------------------------------------------------------------------------------
00047 % BeginPlugInDocuSection
00048 % PlugInDocuCaption: Koehler filter
00049 % PlugInName: koehler
00050 % PlugInAuthor: Percy Zahl
00051 % PlugInAuthorEmail: zahl@users.sf.net
00052 % PlugInMenuPath: Math/Filter 1D/Koehler
00053 
00054 % PlugInDescription
00055 \label{PlugIn-F1D-Koehler}
00056 The Koehler filter differentiates the image data line by line (1D).
00057 It uses a local weightened differentation and floating averagening.
00058 
00059 Starting with the left value $Z_0$
00060 \[ V_0 = Z_0 \]
00061 and then using $0.92$ of the left and $0.08$ of the following $Z$ value:
00062 \[ V_i = 0.92 V_{i-1} + 0.08 Z_i \quad \text{for all} \quad i\in{1, 2, \dots, N_x-1}\]
00063 
00064 The next iteration doese the same starting at the right site with the current results:
00065 \[ V_i = 0.92 V_{i+1} + 0.08 V_i \quad \text{for all} \quad i\in{N_x-2, N_x-3, \dots, 0}\]
00066 
00067 Finally the difference of all $Z$ values with the weightened and averaged value is computed:
00068 \[ Z'_i = Z_i - V_i \quad \text{for all} \quad i\in{0, 1, 2, \dots, N_x-1}\]
00069 
00070 % PlugInUsage
00071 Call \GxsmMenu{Math/Filter 1D/Koehler}.
00072 
00073 % OptPlugInSources
00074 The active channel is used as data source.
00075 
00076 % OptPlugInDest
00077 The computation result is placed into an existing math channel, else
00078 into a new created math channel.
00079 
00080 % OptPlugInConfig
00081 No -- the koefficients are constants and can only be changed in the PlugIn itself.
00082 
00083 % OptPlugInRefs
00084 Filter is originated to PMSTM and Ulli Koehler?
00085 
00086 % OptPlugInNotes
00087 A similar effect (on a limited lenght) is used the the differential view now on the fly.
00088 
00089 % EndPlugInDocuSection
00090  * -------------------------------------------------------------------------------- 
00091  */
00092 
00093 #include <gtk/gtk.h>
00094 #include "config.h"
00095 #include "gxsm/plugin.h"
00096 
00097 // Plugin Prototypes
00098 static void koehler_init( void );
00099 static void koehler_about( void );
00100 static void koehler_configure( void );
00101 static void koehler_cleanup( void );
00102 
00103 // Define Type of math plugin here, only one line should be commented in!!
00104 #define GXSM_ONE_SRC_PLUGIN__DEF
00105 // #define GXSM_TWO_SRC_PLUGIN__DEF
00106 
00107 // Math-Run-Function, use only one of (automatically done :=)
00108 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00109 // "OneSrc" Prototype
00110  static gboolean koehler_run( Scan *Src, Scan *Dest );
00111 #else
00112 // "TwoSrc" Prototype
00113  static gboolean koehler_run( Scan *Src1, Scan *Src2, Scan *Dest );
00114 #endif
00115 
00116 // Fill in the GxsmPlugin Description here
00117 GxsmPlugin koehler_pi = {
00118   NULL,                   // filled in and used by Gxsm, don't touch !
00119   NULL,                   // filled in and used by Gxsm, don't touch !
00120   0,                      // filled in and used by Gxsm, don't touch !
00121   NULL,                   // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 
00122                           // filled in here by Gxsm on Plugin load, 
00123                           // just after init() is called !!!
00124   // ----------------------------------------------------------------------
00125   // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc
00126   "koehler-"
00127 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00128   "M1S"
00129 #else
00130   "M2S"
00131 #endif
00132   "-F1D",
00133   // Plugin's Category - used to autodecide on Pluginloading or ignoring
00134   // NULL: load, else
00135   // example: "+noHARD +STM +AFM"
00136   // load only, if "+noHARD: no hardware" and Instrument is STM or AFM
00137   // +/-xxxHARD und (+/-INST or ...)
00138   NULL,
00139   // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details)
00140   "Koehler filter",                   
00141   // Author(s)
00142   "Percy Zahl",
00143   // Menupath to position where it is appendet to
00144   N_("_Math/Filter _1D/"),
00145   // Menuentry
00146   N_("Koehler"),
00147   // help text shown on menu
00148   N_("Koehler filter"),
00149   // more info...
00150   "Koehler filter",
00151   NULL,          // error msg, plugin may put error status msg here later
00152   NULL,          // Plugin Status, managed by Gxsm, plugin may manipulate it too
00153   // init-function pointer, can be "NULL", 
00154   // called if present at plugin load
00155   koehler_init,  
00156   // query-function pointer, can be "NULL", 
00157   // called if present after plugin init to let plugin manage it install itself
00158   NULL, // query should be "NULL" for Gxsm-Math-Plugin !!!
00159   // about-function, can be "NULL"
00160   // can be called by "Plugin Details"
00161   koehler_about,
00162   // configure-function, can be "NULL"
00163   // can be called by "Plugin Details"
00164   koehler_configure,
00165   // run-function, can be "NULL", if non-Zero and no query defined, 
00166   // it is called on menupath->"plugin"
00167   NULL, // run should be "NULL" for Gxsm-Math-Plugin !!!
00168   // cleanup-function, can be "NULL"
00169   // called if present at plugin removeal
00170   koehler_cleanup
00171 };
00172 
00173 // special math Plugin-Strucure, use
00174 // GxsmMathOneSrcPlugin koehler_m1s_pi -> "OneSrcMath"
00175 // GxsmMathTwoSrcPlugin koehler_m2s_pi -> "TwoSrcMath"
00176 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00177  GxsmMathOneSrcPlugin koehler_m1s_pi
00178 #else
00179  GxsmMathTwoSrcPlugin koehler_m2s_pi
00180 #endif
00181  = {
00182    // math-function to run, see prototype(s) above!!
00183    koehler_run
00184  };
00185 
00186 // Text used in Aboutbox, please update!!
00187 static const char *about_text = N_("Gxsm koehler Plugin\n\n"
00188                                    "This is the Koehler filter, it does 1D edge enhancement.");
00189 
00190 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 
00191 // Essential Plugin Function!!
00192 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00193   koehler_pi.description = g_strdup_printf(N_("Gxsm MathOneArg koehler plugin %s"), VERSION);
00194   return &koehler_pi; 
00195 }
00196 
00197 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 
00198 // used to find out which Math Type the Plugin is!! 
00199 // Essential Plugin Function!!
00200 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00201 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) {
00202   return &koehler_m1s_pi; 
00203 }
00204 #else
00205 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 
00206   return &koehler_m2s_pi; 
00207 }
00208 #endif
00209 
00210 /* Here we go... */
00211 // init-Function
00212 static void koehler_init(void)
00213 {
00214   PI_DEBUG (DBG_L2, "koehler Plugin Init");
00215 }
00216 
00217 // about-Function
00218 static void koehler_about(void)
00219 {
00220   const gchar *authors[] = { koehler_pi.authors, NULL};
00221   gtk_widget_show(gnome_about_new ( koehler_pi.name,
00222                                     VERSION,
00223                                     N_("(C) 2000 the Free Software Foundation"),
00224                                     about_text,
00225                                     authors,
00226                                     NULL, NULL, NULL
00227                                     ));
00228 }
00229 
00230 // configure-Function
00231 static void koehler_configure(void)
00232 {
00233   if(koehler_pi.app)
00234     koehler_pi.app->message("koehler Plugin Configuration");
00235 }
00236 
00237 // cleanup-Function
00238 static void koehler_cleanup(void)
00239 {
00240   PI_DEBUG (DBG_L2, "koehler Plugin Cleanup");
00241 }
00242 
00243 // run-Function
00244 static gboolean koehler_run(Scan *Src, Scan *Dest)
00245 {
00246         if (Src->mem2d->GetNx () < 3) 
00247                 return MATH_SIZEERR;
00248 
00249         double Lproz = 0.92;
00250         double Rproz = 0.08;
00251 
00252         for(int line=0; line < Dest->mem2d->GetNy (); ++line){
00253                 Dest->mem2d->PutDataPkt (Src->mem2d->GetDataPkt (0, line), 0, line);
00254 
00255                 for(int col=1; col < Dest->mem2d->GetNx (); ++col)
00256                         Dest->mem2d->PutDataPkt (Lproz * Dest->mem2d->GetDataPkt (col-1, line)
00257                                                  + Rproz * Src->mem2d->GetDataPkt (col, line),
00258                                                  col, line);
00259 
00260                 for(int col=Dest->mem2d->GetNx ()-2; col >= 0; --col)
00261                         Dest->mem2d->PutDataPkt (Lproz * Dest->mem2d->GetDataPkt (col+1, line)
00262                                                  + Rproz * Dest->mem2d->GetDataPkt (col, line),
00263                                                  col, line);
00264 
00265                 for(int col=0; col < Dest->mem2d->GetNx (); ++col)
00266                         Dest->mem2d->PutDataPkt (Src->mem2d->GetDataPkt (col, line)
00267                                                  - Dest->mem2d->GetDataPkt (col, line),
00268                                                  col, line);
00269         }
00270 
00271         return MATH_OK;
00272 }
00273 
00274 

Generated on Sat Apr 1 09:04:21 2006 for GXSM by  doxygen 1.4.6