#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 6643 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 6658 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 6648 of file processor.h.
References NAME.
06649 { 06650 return NAME; 06651 }
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 6663 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
06664 { 06665 TypeDict d; 06666 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06667 return d; 06668 }
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 8099 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.
08100 { 08101 if (!image) { 08102 Log::logger()->set_level(Log::ERROR_LOG); 08103 Log::logger()->error("Null image during call to CCDNorm\n"); 08104 return; 08105 } 08106 if (image->get_zsize() > 1) { 08107 Log::logger()->set_level(Log::ERROR_LOG); 08108 Log::logger()->error("CCDNorm does not support 3d images\n"); 08109 return; 08110 } 08111 08112 int xs = image->get_xsize(); 08113 int ys = image->get_ysize(); 08114 08115 // width of sample area on either side of the seams 08116 int width = params["width"]; 08117 08118 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 08119 if (width==0) { 08120 width=1; 08121 } 08122 08123 // get the 4 "seams" of the image 08124 float *left, *right, *top, *bottom; 08125 08126 double *temp; 08127 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 08128 if (temp==NULL) { 08129 Log::logger()->set_level(Log::ERROR_LOG); 08130 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 08131 return; 08132 } 08133 08134 int x, y, z; 08135 08136 // the mean values of each seam and the average 08137 double mL,mR,mT,mB; 08138 08139 // how much to shift each seam 08140 double nl,nr,nt,nb; 08141 08142 // quad. shifting amount 08143 double q1,q2,q3,q4; 08144 08145 // calc. the mean for each quadrant 08146 for (z=0; z<width; z++) { 08147 left = image->get_col(xs/2 -1-z)->get_data(); 08148 for (y=0; y<ys; y++) 08149 temp[z*ys+y]=left[y]; 08150 } 08151 mL=gsl_stats_mean(temp,1,ys*width); 08152 08153 for (z=0; z<width; z++) { 08154 right = image->get_col(xs/2 +z)->get_data(); 08155 for (y=0; y<ys; y++) 08156 temp[z*ys+y]=right[y]; 08157 } 08158 mR=gsl_stats_mean(temp,1,ys*width); 08159 08160 for (z=0; z<width; z++) { 08161 top = image->get_row(ys/2 -1-z)->get_data(); 08162 for (x=0; x<xs; x++) 08163 temp[z*xs+x]=top[x]; 08164 } 08165 mT=gsl_stats_mean(temp,1,xs*width); 08166 08167 for (z=0; z<width; z++) { 08168 bottom = image->get_row(ys/2 +z)->get_data(); 08169 for (x=0; x<xs; x++) 08170 temp[z*xs+x]=bottom[x]; 08171 } 08172 mB=gsl_stats_mean(temp,1,xs*width); 08173 08174 free(temp); 08175 08176 nl=(mL+mR)/2-mL; 08177 nr=(mL+mR)/2-mR; 08178 nt=(mT+mB)/2-mT; 08179 nb=(mT+mB)/2-mB; 08180 08181 q1=nl+nt; 08182 q2=nr+nt; 08183 q3=nr+nb; 08184 q4=nl+nb; 08185 08186 // change the pixel values 08187 for (x = 0; x < xs / 2; x++) 08188 for (y = 0; y < ys / 2; y++) { 08189 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 08190 } 08191 for (x = xs / 2; x < xs; x++) 08192 for (y = 0; y < ys / 2; y++) { 08193 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 08194 } 08195 for (x = xs / 2; x < xs; x++) 08196 for (y = ys / 2; y < ys; y++) { 08197 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 08198 } 08199 for (x = 0; x < xs / 2; x++) 08200 for (y = ys / 2; y < ys; y++) { 08201 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 08202 } 08203 08204 }
const string CCDNormProcessor::NAME = "filter.ccdnorm" [static] |