EMAN2
processor_template.cpp
Go to the documentation of this file.
00001 /*
00002  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00003  * Copyright (c) 2000-2006 Baylor College of Medicine
00004  * 
00005  * This software is issued under a joint BSD/GNU license. You may use the
00006  * source code in this file under either license. However, note that the
00007  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00008  * so you are responsible for compliance with the licenses of these packages
00009  * if you opt to use BSD licensing. The warranty disclaimer below holds
00010  * in either instance.
00011  * 
00012  * This complete copyright notice must be included in any revised version of the
00013  * source code. Additional authorship citations may be added, but existing
00014  * author citations must be preserved.
00015  * 
00016  * This program is free software; you can redistribute it and/or modify
00017  * it under the terms of the GNU General Public License as published by
00018  * the Free Software Foundation; either version 2 of the License, or
00019  * (at your option) any later version.
00020  * 
00021  * This program is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00024  * GNU General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU General Public License
00027  * along with this program; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00029  * 
00030  * */
00031 
00032 #include "processor_template.h"
00033 
00034 using namespace EMAN;
00035 
00036 
00037 const string XYZProcessor::NAME = "xyz";
00038 
00041 void XYZProcessor::process_inplace(EMData * image)
00042 {
00043         if (!image) {
00044                 return;
00045         }
00046 
00047 
00048         // The following are the sample code to get your parameters. Then
00049         // go through the image data pixel.
00050 #if 0
00051         int value1 = params["value1"];
00052         float value2 = params["value2"];
00053 
00054         float *data = image->get_data();
00055         int size = image->get_xsize() * image->get_ysize() * image->get_zsize();
00056         for (int i = 0; i < size; i++) {
00057                 if (data[i] <= value1 && data[i] >= value2) {
00058                         data[i] = 0;
00059                 }
00060         }
00061 #endif
00062 
00063 }
00064 
00065 
00066 // void SubstituteZeroPixelsProcessor::process_inplace(EMData* image)
00067 // {
00068 //      EMData* null = 0;
00069 //      EMData* other_image = params.set_default("image", null);
00070 //      
00071 //      if (other_image == 0 ) throw NullPointerException("Error, the EMData pointer set in the params was null");
00072 //      
00073 //      int nx = image->get_xsize();
00074 //      int ny = image->get_ysize();
00075 //      int nz = image->get_zsize();
00076 //      
00077 //      if ( nx != other_image->get_xsize() ) throw ImageDimensionException("Error, the parameter image's x dimension did not match the argument image's x dimension");
00078 //      if ( ny != other_image->get_ysize() ) throw ImageDimensionException("Error, the parameter image's y dimension did not match the argument image's y dimension");
00079 //      if ( nz != other_image->get_zsize() ) throw ImageDimensionException("Error, the parameter image's z dimension did not match the argument image's z dimension");
00080 //      
00081 //      if ( image->is_complex() != other_image->is_complex() ) throw ImageFormatException("Error, the image formats did not match - only one of the images is complex");
00082 //      
00083 //      int size = nx*ny*nz;
00084 //      float* image_data = image->get_data();
00085 //      float* other_image_data = other_image->get_data();
00086 //      
00087 //      
00088 //      if ( image->is_complex() ) {
00089 //              for(int i = 0; i < size/2; ++i ) {
00090 //                      if ( fabs(image_data[2*i]) < 0.00001 && fabs(image_data[2*i+1]) < 0.00001 ) {
00091 //                              image_data[2*i] = other_image_data[2*i];
00092 //                              image_data[2*i+1] = other_image_data[2*i+1];
00093 //                      }
00094 //              }
00095 //      }
00096 //      else {
00097 //              
00098 //              for(int i = 0; i < size; ++i ) {
00099 //                      if ( image_data[i] == 0 ) {
00100 //                              image_data[i] = other_image_data[i];
00101 //                      }
00102 //              }
00103 //      }
00104 // }