Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::CCDNormProcessor Class Reference

Try to normalize the 4 quadrants of a CCD image. More...

#include <processor.h>

Inheritance diagram for EMAN::CCDNormProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::CCDNormProcessor:

Collaboration graph
[legend]
List of all members.

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 ProcessorNEW ()

Static Public Attributes

static const string NAME = "filter.ccdnorm"

Detailed Description

Try to normalize the 4 quadrants of a CCD image.

Author:
Deepy Mann <dsmann@bcm.tmc.edu>
Date:
9-2005
Parameters:
width number of pixels on either side of the seam to sample

Definition at line 6599 of file processor.h.


Member Function Documentation

virtual string EMAN::CCDNormProcessor::get_desc  )  const [inline, virtual]
 

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 6614 of file processor.h.

06615                 {
06616                         return "normalize the 4 quadrants of a CCD image";
06617                 }

virtual string EMAN::CCDNormProcessor::get_name  )  const [inline, virtual]
 

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 6604 of file processor.h.

References NAME.

06605                 {
06606                         return NAME;
06607                 }

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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 6619 of file processor.h.

References EMAN::EMObject::INT, and EMAN::TypeDict::put().

06620                 {
06621                         TypeDict d;
06622                         d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample");
06623                         return d;
06624                 }

static Processor* EMAN::CCDNormProcessor::NEW  )  [inline, static]
 

Definition at line 6609 of file processor.h.

06610                 {
06611                         return new CCDNormProcessor();
06612                 }

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.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 7931 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.

07932 {
07933         if (!image) {
07934           Log::logger()->set_level(Log::ERROR_LOG);
07935           Log::logger()->error("Null image during call to CCDNorm\n");
07936           return;
07937         }
07938         if (image->get_zsize() > 1) {
07939           Log::logger()->set_level(Log::ERROR_LOG);
07940           Log::logger()->error("CCDNorm does not support 3d images\n");
07941           return;
07942         }
07943 
07944         int xs = image->get_xsize();
07945         int ys = image->get_ysize();
07946 
07947         // width of sample area on either side of the seams
07948         int width = params["width"];
07949 
07950         width%=(xs > ys ? xs/2 : ys/2);  // make sure width is a valid value
07951         if (width==0) {
07952           width=1;
07953         }
07954 
07955         // get the 4 "seams" of the image
07956         float *left, *right, *top, *bottom;
07957 
07958         double *temp;
07959         temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double));
07960         if (temp==NULL) {
07961           Log::logger()->set_level(Log::ERROR_LOG);
07962           Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n");
07963           return;
07964         }
07965 
07966         int x, y, z;
07967 
07968         // the mean values of each seam and the average
07969         double mL,mR,mT,mB;
07970 
07971         // how much to shift each seam
07972         double nl,nr,nt,nb;
07973 
07974         // quad. shifting amount
07975         double q1,q2,q3,q4;
07976 
07977         // calc. the mean for each quadrant
07978         for (z=0; z<width; z++) {
07979           left = image->get_col(xs/2 -1-z)->get_data();
07980           for (y=0; y<ys; y++)
07981             temp[z*ys+y]=left[y];
07982         }
07983         mL=gsl_stats_mean(temp,1,ys*width);
07984 
07985         for (z=0; z<width; z++) {
07986           right = image->get_col(xs/2 +z)->get_data();
07987           for (y=0; y<ys; y++)
07988             temp[z*ys+y]=right[y];
07989         }
07990         mR=gsl_stats_mean(temp,1,ys*width);
07991 
07992         for (z=0; z<width; z++) {
07993           top = image->get_row(ys/2 -1-z)->get_data();
07994           for (x=0; x<xs; x++)
07995             temp[z*xs+x]=top[x];
07996         }
07997         mT=gsl_stats_mean(temp,1,xs*width);
07998 
07999         for (z=0; z<width; z++) {
08000           bottom = image->get_row(ys/2 +z)->get_data();
08001           for (x=0; x<xs; x++)
08002             temp[z*xs+x]=bottom[x];
08003         }
08004         mB=gsl_stats_mean(temp,1,xs*width);
08005 
08006         free(temp);
08007 
08008         nl=(mL+mR)/2-mL;
08009         nr=(mL+mR)/2-mR;
08010         nt=(mT+mB)/2-mT;
08011         nb=(mT+mB)/2-mB;
08012 
08013         q1=nl+nt;
08014         q2=nr+nt;
08015         q3=nr+nb;
08016         q4=nl+nb;
08017 
08018         // change the pixel values
08019         for (x = 0; x < xs / 2; x++)
08020           for (y = 0; y < ys / 2; y++) {
08021             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1));
08022           }
08023         for (x = xs / 2; x < xs; x++)
08024           for (y = 0; y < ys / 2; y++) {
08025             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2));
08026           }
08027         for (x = xs / 2; x < xs; x++)
08028           for (y = ys / 2; y < ys; y++) {
08029             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3));
08030           }
08031         for (x = 0; x < xs / 2; x++)
08032           for (y = ys / 2; y < ys; y++) {
08033             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4));
08034           }
08035 
08036 }


Member Data Documentation

const string CCDNormProcessor::NAME = "filter.ccdnorm" [static]
 

Definition at line 6626 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 13:07:28 2010 for EMAN2 by  doxygen 1.4.4