#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 6559 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 6574 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 6564 of file processor.h.
References NAME.
06565 { 06566 return NAME; 06567 }
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 6579 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
06580 { 06581 TypeDict d; 06582 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06583 return d; 06584 }
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 7824 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.
07825 { 07826 if (!image) { 07827 Log::logger()->set_level(Log::ERROR_LOG); 07828 Log::logger()->error("Null image during call to CCDNorm\n"); 07829 return; 07830 } 07831 if (image->get_zsize() > 1) { 07832 Log::logger()->set_level(Log::ERROR_LOG); 07833 Log::logger()->error("CCDNorm does not support 3d images\n"); 07834 return; 07835 } 07836 07837 int xs = image->get_xsize(); 07838 int ys = image->get_ysize(); 07839 07840 // width of sample area on either side of the seams 07841 int width = params["width"]; 07842 07843 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 07844 if (width==0) { 07845 width=1; 07846 } 07847 07848 // get the 4 "seams" of the image 07849 float *left, *right, *top, *bottom; 07850 07851 double *temp; 07852 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 07853 if (temp==NULL) { 07854 Log::logger()->set_level(Log::ERROR_LOG); 07855 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 07856 return; 07857 } 07858 07859 int x, y, z; 07860 07861 // the mean values of each seam and the average 07862 double mL,mR,mT,mB; 07863 07864 // how much to shift each seam 07865 double nl,nr,nt,nb; 07866 07867 // quad. shifting amount 07868 double q1,q2,q3,q4; 07869 07870 // calc. the mean for each quadrant 07871 for (z=0; z<width; z++) { 07872 left = image->get_col(xs/2 -1-z)->get_data(); 07873 for (y=0; y<ys; y++) 07874 temp[z*ys+y]=left[y]; 07875 } 07876 mL=gsl_stats_mean(temp,1,ys*width); 07877 07878 for (z=0; z<width; z++) { 07879 right = image->get_col(xs/2 +z)->get_data(); 07880 for (y=0; y<ys; y++) 07881 temp[z*ys+y]=right[y]; 07882 } 07883 mR=gsl_stats_mean(temp,1,ys*width); 07884 07885 for (z=0; z<width; z++) { 07886 top = image->get_row(ys/2 -1-z)->get_data(); 07887 for (x=0; x<xs; x++) 07888 temp[z*xs+x]=top[x]; 07889 } 07890 mT=gsl_stats_mean(temp,1,xs*width); 07891 07892 for (z=0; z<width; z++) { 07893 bottom = image->get_row(ys/2 +z)->get_data(); 07894 for (x=0; x<xs; x++) 07895 temp[z*xs+x]=bottom[x]; 07896 } 07897 mB=gsl_stats_mean(temp,1,xs*width); 07898 07899 free(temp); 07900 07901 nl=(mL+mR)/2-mL; 07902 nr=(mL+mR)/2-mR; 07903 nt=(mT+mB)/2-mT; 07904 nb=(mT+mB)/2-mB; 07905 07906 q1=nl+nt; 07907 q2=nr+nt; 07908 q3=nr+nb; 07909 q4=nl+nb; 07910 07911 // change the pixel values 07912 for (x = 0; x < xs / 2; x++) 07913 for (y = 0; y < ys / 2; y++) { 07914 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 07915 } 07916 for (x = xs / 2; x < xs; x++) 07917 for (y = 0; y < ys / 2; y++) { 07918 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 07919 } 07920 for (x = xs / 2; x < xs; x++) 07921 for (y = ys / 2; y < ys; y++) { 07922 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 07923 } 07924 for (x = 0; x < xs / 2; x++) 07925 for (y = ys / 2; y < ys; y++) { 07926 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 07927 } 07928 07929 }
const string CCDNormProcessor::NAME = "filter.ccdnorm" [static] |