#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 6596 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 6611 of file processor.h. 06612 { 06613 return "normalize the 4 quadrants of a CCD image"; 06614 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6601 of file processor.h. 06602 {
06603 return NAME;
06604 }
|
|
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 6616 of file processor.h. References EMAN::TypeDict::put(). 06617 { 06618 TypeDict d; 06619 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06620 return d; 06621 }
|
|
Definition at line 6606 of file processor.h. 06607 { 06608 return new CCDNormProcessor(); 06609 }
|
|
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 8012 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. 08013 { 08014 if (!image) { 08015 Log::logger()->set_level(Log::ERROR_LOG); 08016 Log::logger()->error("Null image during call to CCDNorm\n"); 08017 return; 08018 } 08019 if (image->get_zsize() > 1) { 08020 Log::logger()->set_level(Log::ERROR_LOG); 08021 Log::logger()->error("CCDNorm does not support 3d images\n"); 08022 return; 08023 } 08024 08025 int xs = image->get_xsize(); 08026 int ys = image->get_ysize(); 08027 08028 // width of sample area on either side of the seams 08029 int width = params["width"]; 08030 08031 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 08032 if (width==0) { 08033 width=1; 08034 } 08035 08036 // get the 4 "seams" of the image 08037 float *left, *right, *top, *bottom; 08038 08039 double *temp; 08040 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 08041 if (temp==NULL) { 08042 Log::logger()->set_level(Log::ERROR_LOG); 08043 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 08044 return; 08045 } 08046 08047 int x, y, z; 08048 08049 // the mean values of each seam and the average 08050 double mL,mR,mT,mB; 08051 08052 // how much to shift each seam 08053 double nl,nr,nt,nb; 08054 08055 // quad. shifting amount 08056 double q1,q2,q3,q4; 08057 08058 // calc. the mean for each quadrant 08059 for (z=0; z<width; z++) { 08060 left = image->get_col(xs/2 -1-z)->get_data(); 08061 for (y=0; y<ys; y++) 08062 temp[z*ys+y]=left[y]; 08063 } 08064 mL=gsl_stats_mean(temp,1,ys*width); 08065 08066 for (z=0; z<width; z++) { 08067 right = image->get_col(xs/2 +z)->get_data(); 08068 for (y=0; y<ys; y++) 08069 temp[z*ys+y]=right[y]; 08070 } 08071 mR=gsl_stats_mean(temp,1,ys*width); 08072 08073 for (z=0; z<width; z++) { 08074 top = image->get_row(ys/2 -1-z)->get_data(); 08075 for (x=0; x<xs; x++) 08076 temp[z*xs+x]=top[x]; 08077 } 08078 mT=gsl_stats_mean(temp,1,xs*width); 08079 08080 for (z=0; z<width; z++) { 08081 bottom = image->get_row(ys/2 +z)->get_data(); 08082 for (x=0; x<xs; x++) 08083 temp[z*xs+x]=bottom[x]; 08084 } 08085 mB=gsl_stats_mean(temp,1,xs*width); 08086 08087 free(temp); 08088 08089 nl=(mL+mR)/2-mL; 08090 nr=(mL+mR)/2-mR; 08091 nt=(mT+mB)/2-mT; 08092 nb=(mT+mB)/2-mB; 08093 08094 q1=nl+nt; 08095 q2=nr+nt; 08096 q3=nr+nb; 08097 q4=nl+nb; 08098 08099 // change the pixel values 08100 for (x = 0; x < xs / 2; x++) 08101 for (y = 0; y < ys / 2; y++) { 08102 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 08103 } 08104 for (x = xs / 2; x < xs; x++) 08105 for (y = 0; y < ys / 2; y++) { 08106 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 08107 } 08108 for (x = xs / 2; x < xs; x++) 08109 for (y = ys / 2; y < ys; y++) { 08110 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 08111 } 08112 for (x = 0; x < xs / 2; x++) 08113 for (y = ys / 2; y < ys; y++) { 08114 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 08115 } 08116 08117 }
|
|
Definition at line 210 of file processor.cpp. |