#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "filter.ccdnorm" |
width | number of pixels on either side of the seam to sample |
Definition at line 6682 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 6697 of file processor.h. 06698 { 06699 return "normalize the 4 quadrants of a CCD image"; 06700 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6687 of file processor.h. 06688 {
06689 return NAME;
06690 }
|
|
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 6702 of file processor.h. References EMAN::TypeDict::put(). 06703 { 06704 TypeDict d; 06705 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06706 return d; 06707 }
|
|
Definition at line 6692 of file processor.h. 06693 { 06694 return new CCDNormProcessor(); 06695 }
|
|
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.
Implements EMAN::Processor. Definition at line 8164 of file processor.cpp. References EMAN::Log::error(), 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::Log::set_level(), EMAN::EMData::set_value_at_fast(), x, and y. 08165 { 08166 if (!image) { 08167 Log::logger()->set_level(Log::ERROR_LOG); 08168 Log::logger()->error("Null image during call to CCDNorm\n"); 08169 return; 08170 } 08171 if (image->get_zsize() > 1) { 08172 Log::logger()->set_level(Log::ERROR_LOG); 08173 Log::logger()->error("CCDNorm does not support 3d images\n"); 08174 return; 08175 } 08176 08177 int xs = image->get_xsize(); 08178 int ys = image->get_ysize(); 08179 08180 // width of sample area on either side of the seams 08181 int width = params["width"]; 08182 08183 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 08184 if (width==0) { 08185 width=1; 08186 } 08187 08188 // get the 4 "seams" of the image 08189 float *left, *right, *top, *bottom; 08190 08191 double *temp; 08192 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 08193 if (temp==NULL) { 08194 Log::logger()->set_level(Log::ERROR_LOG); 08195 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 08196 return; 08197 } 08198 08199 int x, y, z; 08200 08201 // the mean values of each seam and the average 08202 double mL,mR,mT,mB; 08203 08204 // how much to shift each seam 08205 double nl,nr,nt,nb; 08206 08207 // quad. shifting amount 08208 double q1,q2,q3,q4; 08209 08210 // calc. the mean for each quadrant 08211 for (z=0; z<width; z++) { 08212 left = image->get_col(xs/2 -1-z)->get_data(); 08213 for (y=0; y<ys; y++) 08214 temp[z*ys+y]=left[y]; 08215 } 08216 mL=gsl_stats_mean(temp,1,ys*width); 08217 08218 for (z=0; z<width; z++) { 08219 right = image->get_col(xs/2 +z)->get_data(); 08220 for (y=0; y<ys; y++) 08221 temp[z*ys+y]=right[y]; 08222 } 08223 mR=gsl_stats_mean(temp,1,ys*width); 08224 08225 for (z=0; z<width; z++) { 08226 top = image->get_row(ys/2 -1-z)->get_data(); 08227 for (x=0; x<xs; x++) 08228 temp[z*xs+x]=top[x]; 08229 } 08230 mT=gsl_stats_mean(temp,1,xs*width); 08231 08232 for (z=0; z<width; z++) { 08233 bottom = image->get_row(ys/2 +z)->get_data(); 08234 for (x=0; x<xs; x++) 08235 temp[z*xs+x]=bottom[x]; 08236 } 08237 mB=gsl_stats_mean(temp,1,xs*width); 08238 08239 free(temp); 08240 08241 nl=(mL+mR)/2-mL; 08242 nr=(mL+mR)/2-mR; 08243 nt=(mT+mB)/2-mT; 08244 nb=(mT+mB)/2-mB; 08245 08246 q1=nl+nt; 08247 q2=nr+nt; 08248 q3=nr+nb; 08249 q4=nl+nb; 08250 08251 // change the pixel values 08252 for (x = 0; x < xs / 2; x++) 08253 for (y = 0; y < ys / 2; y++) { 08254 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 08255 } 08256 for (x = xs / 2; x < xs; x++) 08257 for (y = 0; y < ys / 2; y++) { 08258 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 08259 } 08260 for (x = xs / 2; x < xs; x++) 08261 for (y = ys / 2; y < ys; y++) { 08262 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 08263 } 08264 for (x = 0; x < xs / 2; x++) 08265 for (y = ys / 2; y < ys; y++) { 08266 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 08267 } 08268 08269 }
|
|
Definition at line 211 of file processor.cpp. |