#include <processor.h>


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 6488 of file processor.h.
| 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 7782 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.
07783 { 07784 if (!image) { 07785 Log::logger()->set_level(Log::ERROR_LOG); 07786 Log::logger()->error("Null image during call to CCDNorm\n"); 07787 return; 07788 } 07789 if (image->get_zsize() > 1) { 07790 Log::logger()->set_level(Log::ERROR_LOG); 07791 Log::logger()->error("CCDNorm does not support 3d images\n"); 07792 return; 07793 } 07794 07795 int xs = image->get_xsize(); 07796 int ys = image->get_ysize(); 07797 07798 // width of sample area on either side of the seams 07799 int width = params["width"]; 07800 07801 width%=(xs > ys ? xs/2 : ys/2); // make sure width is a valid value 07802 if (width==0) { 07803 width=1; 07804 } 07805 07806 // get the 4 "seams" of the image 07807 float *left, *right, *top, *bottom; 07808 07809 double *temp; 07810 temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double)); 07811 if (temp==NULL) { 07812 Log::logger()->set_level(Log::ERROR_LOG); 07813 Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n"); 07814 return; 07815 } 07816 07817 int x, y, z; 07818 07819 // the mean values of each seam and the average 07820 double mL,mR,mT,mB; 07821 07822 // how much to shift each seam 07823 double nl,nr,nt,nb; 07824 07825 // quad. shifting amount 07826 double q1,q2,q3,q4; 07827 07828 // calc. the mean for each quadrant 07829 for (z=0; z<width; z++) { 07830 left = image->get_col(xs/2 -1-z)->get_data(); 07831 for (y=0; y<ys; y++) 07832 temp[z*ys+y]=left[y]; 07833 } 07834 mL=gsl_stats_mean(temp,1,ys*width); 07835 07836 for (z=0; z<width; z++) { 07837 right = image->get_col(xs/2 +z)->get_data(); 07838 for (y=0; y<ys; y++) 07839 temp[z*ys+y]=right[y]; 07840 } 07841 mR=gsl_stats_mean(temp,1,ys*width); 07842 07843 for (z=0; z<width; z++) { 07844 top = image->get_row(ys/2 -1-z)->get_data(); 07845 for (x=0; x<xs; x++) 07846 temp[z*xs+x]=top[x]; 07847 } 07848 mT=gsl_stats_mean(temp,1,xs*width); 07849 07850 for (z=0; z<width; z++) { 07851 bottom = image->get_row(ys/2 +z)->get_data(); 07852 for (x=0; x<xs; x++) 07853 temp[z*xs+x]=bottom[x]; 07854 } 07855 mB=gsl_stats_mean(temp,1,xs*width); 07856 07857 free(temp); 07858 07859 nl=(mL+mR)/2-mL; 07860 nr=(mL+mR)/2-mR; 07861 nt=(mT+mB)/2-mT; 07862 nb=(mT+mB)/2-mB; 07863 07864 q1=nl+nt; 07865 q2=nr+nt; 07866 q3=nr+nb; 07867 q4=nl+nb; 07868 07869 // change the pixel values 07870 for (x = 0; x < xs / 2; x++) 07871 for (y = 0; y < ys / 2; y++) { 07872 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1)); 07873 } 07874 for (x = xs / 2; x < xs; x++) 07875 for (y = 0; y < ys / 2; y++) { 07876 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2)); 07877 } 07878 for (x = xs / 2; x < xs; x++) 07879 for (y = ys / 2; y < ys; y++) { 07880 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3)); 07881 } 07882 for (x = 0; x < xs / 2; x++) 07883 for (y = ys / 2; y < ys; y++) { 07884 image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4)); 07885 } 07886 07887 }
| 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 6493 of file processor.h.
References EMAN::NormalizeUnitSumProcessor::NAME.
06494 { 06495 return NAME; 06496 }
| static Processor* EMAN::CCDNormProcessor::NEW | ( | ) | [inline, static] |
| 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 6503 of file processor.h.
| 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 6508 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
06509 { 06510 TypeDict d; 06511 d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample"); 06512 return d; 06513 }
const string CCDNormProcessor::NAME = "filter.ccdnorm" [static] |
Definition at line 6515 of file processor.h.
1.5.6