#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 6527 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 6542 of file processor.h. 06543 { 06544 return "normalize the 4 quadrants of a CCD image"; 06545 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 6532 of file processor.h. 06533 {
06534 return NAME;
06535 }
|
|
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 6547 of file processor.h. References EMAN::TypeDict::put(). 06548 { 06549 TypeDict d; 06550 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06551 return d; 06552 }
|
|
Definition at line 6537 of file processor.h. 06538 { 06539 return new CCDNormProcessor(); 06540 }
|
|
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 7898 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. 07899 { 07900 if (!image) { 07901 Log::logger()->set_level(Log::ERROR_LOG); 07902 Log::logger()->error("Null image during call to CCDNorm\n"); 07903 return; 07904 } 07905 if (image->get_zsize() > 1) { 07906 Log::logger()->set_level(Log::ERROR_LOG); 07907 Log::logger()->error("CCDNorm does not support 3d images\n"); 07908 return; 07909 } 07910 07911 int xs = image->get_xsize(); 07912 int ys = image->get_ysize(); 07913 07914 // width of sample area on either side of the seams 07915 int width = params["width"]; 07916 07917 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 07918 if (width==0) { 07919 width=1; 07920 } 07921 07922 // get the 4 "seams" of the image 07923 float *left, *right, *top, *bottom; 07924 07925 double *temp; 07926 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 07927 if (temp==NULL) { 07928 Log::logger()->set_level(Log::ERROR_LOG); 07929 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 07930 return; 07931 } 07932 07933 int x, y, z; 07934 07935 // the mean values of each seam and the average 07936 double mL,mR,mT,mB; 07937 07938 // how much to shift each seam 07939 double nl,nr,nt,nb; 07940 07941 // quad. shifting amount 07942 double q1,q2,q3,q4; 07943 07944 // calc. the mean for each quadrant 07945 for (z=0; z<width; z++) { 07946 left = image->get_col(xs/2 -1-z)->get_data(); 07947 for (y=0; y<ys; y++) 07948 temp[z*ys+y]=left[y]; 07949 } 07950 mL=gsl_stats_mean(temp,1,ys*width); 07951 07952 for (z=0; z<width; z++) { 07953 right = image->get_col(xs/2 +z)->get_data(); 07954 for (y=0; y<ys; y++) 07955 temp[z*ys+y]=right[y]; 07956 } 07957 mR=gsl_stats_mean(temp,1,ys*width); 07958 07959 for (z=0; z<width; z++) { 07960 top = image->get_row(ys/2 -1-z)->get_data(); 07961 for (x=0; x<xs; x++) 07962 temp[z*xs+x]=top[x]; 07963 } 07964 mT=gsl_stats_mean(temp,1,xs*width); 07965 07966 for (z=0; z<width; z++) { 07967 bottom = image->get_row(ys/2 +z)->get_data(); 07968 for (x=0; x<xs; x++) 07969 temp[z*xs+x]=bottom[x]; 07970 } 07971 mB=gsl_stats_mean(temp,1,xs*width); 07972 07973 free(temp); 07974 07975 nl=(mL+mR)/2-mL; 07976 nr=(mL+mR)/2-mR; 07977 nt=(mT+mB)/2-mT; 07978 nb=(mT+mB)/2-mB; 07979 07980 q1=nl+nt; 07981 q2=nr+nt; 07982 q3=nr+nb; 07983 q4=nl+nb; 07984 07985 // change the pixel values 07986 for (x = 0; x < xs / 2; x++) 07987 for (y = 0; y < ys / 2; y++) { 07988 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 07989 } 07990 for (x = xs / 2; x < xs; x++) 07991 for (y = 0; y < ys / 2; y++) { 07992 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 07993 } 07994 for (x = xs / 2; x < xs; x++) 07995 for (y = ys / 2; y < ys; y++) { 07996 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 07997 } 07998 for (x = 0; x < xs / 2; x++) 07999 for (y = ys / 2; y < ys; y++) { 08000 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 08001 } 08002 08003 }
|
|
Definition at line 210 of file processor.cpp. |