#include <processor.h>
Inheritance diagram for EMAN::CCDNormProcessor:
Public Member Functions | |
virtual void | process_inplace (EMData *image) |
To process an image in-place. | |
virtual string | get_name () const |
Get the processor's name. | |
virtual string | get_desc () const |
Get the descrition of this specific processor. | |
virtual TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "filter.ccdnorm" |
width | number of pixels on either side of the seam to sample |
Definition at line 6641 of file processor.h.
virtual string EMAN::CCDNormProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 6656 of file processor.h.
virtual string EMAN::CCDNormProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6646 of file processor.h.
References NAME.
06647 { 06648 return NAME; 06649 }
virtual TypeDict EMAN::CCDNormProcessor::get_param_types | ( | ) | const [inline, virtual] |
Get processor parameter information in a dictionary.
Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor.
Definition at line 6661 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
06662 { 06663 TypeDict d; 06664 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06665 return d; 06666 }
static Processor* EMAN::CCDNormProcessor::NEW | ( | ) | [inline, static] |
void CCDNormProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
To process an image in-place.
For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 8084 of file processor.cpp.
References EMAN::Log::error(), EMAN::Log::ERROR_LOG, EMAN::EMData::get_col(), EMAN::EMData::get_data(), EMAN::EMData::get_row(), EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Log::logger(), EMAN::Processor::params, EMAN::Log::set_level(), EMAN::EMData::set_value_at_fast(), and x.
08085 { 08086 if (!image) { 08087 Log::logger()->set_level(Log::ERROR_LOG); 08088 Log::logger()->error("Null image during call to CCDNorm\n"); 08089 return; 08090 } 08091 if (image->get_zsize() > 1) { 08092 Log::logger()->set_level(Log::ERROR_LOG); 08093 Log::logger()->error("CCDNorm does not support 3d images\n"); 08094 return; 08095 } 08096 08097 int xs = image->get_xsize(); 08098 int ys = image->get_ysize(); 08099 08100 // width of sample area on either side of the seams 08101 int width = params["width"]; 08102 08103 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 08104 if (width==0) { 08105 width=1; 08106 } 08107 08108 // get the 4 "seams" of the image 08109 float *left, *right, *top, *bottom; 08110 08111 double *temp; 08112 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 08113 if (temp==NULL) { 08114 Log::logger()->set_level(Log::ERROR_LOG); 08115 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 08116 return; 08117 } 08118 08119 int x, y, z; 08120 08121 // the mean values of each seam and the average 08122 double mL,mR,mT,mB; 08123 08124 // how much to shift each seam 08125 double nl,nr,nt,nb; 08126 08127 // quad. shifting amount 08128 double q1,q2,q3,q4; 08129 08130 // calc. the mean for each quadrant 08131 for (z=0; z<width; z++) { 08132 left = image->get_col(xs/2 -1-z)->get_data(); 08133 for (y=0; y<ys; y++) 08134 temp[z*ys+y]=left[y]; 08135 } 08136 mL=gsl_stats_mean(temp,1,ys*width); 08137 08138 for (z=0; z<width; z++) { 08139 right = image->get_col(xs/2 +z)->get_data(); 08140 for (y=0; y<ys; y++) 08141 temp[z*ys+y]=right[y]; 08142 } 08143 mR=gsl_stats_mean(temp,1,ys*width); 08144 08145 for (z=0; z<width; z++) { 08146 top = image->get_row(ys/2 -1-z)->get_data(); 08147 for (x=0; x<xs; x++) 08148 temp[z*xs+x]=top[x]; 08149 } 08150 mT=gsl_stats_mean(temp,1,xs*width); 08151 08152 for (z=0; z<width; z++) { 08153 bottom = image->get_row(ys/2 +z)->get_data(); 08154 for (x=0; x<xs; x++) 08155 temp[z*xs+x]=bottom[x]; 08156 } 08157 mB=gsl_stats_mean(temp,1,xs*width); 08158 08159 free(temp); 08160 08161 nl=(mL+mR)/2-mL; 08162 nr=(mL+mR)/2-mR; 08163 nt=(mT+mB)/2-mT; 08164 nb=(mT+mB)/2-mB; 08165 08166 q1=nl+nt; 08167 q2=nr+nt; 08168 q3=nr+nb; 08169 q4=nl+nb; 08170 08171 // change the pixel values 08172 for (x = 0; x < xs / 2; x++) 08173 for (y = 0; y < ys / 2; y++) { 08174 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 08175 } 08176 for (x = xs / 2; x < xs; x++) 08177 for (y = 0; y < ys / 2; y++) { 08178 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 08179 } 08180 for (x = xs / 2; x < xs; x++) 08181 for (y = ys / 2; y < ys; y++) { 08182 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 08183 } 08184 for (x = 0; x < xs / 2; x++) 08185 for (y = ys / 2; y < ys; y++) { 08186 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 08187 } 08188 08189 }
const string CCDNormProcessor::NAME = "filter.ccdnorm" [static] |