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

ProcessorNEW ()

Static Public Attributes

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 6565 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 6580 of file processor.h.

06581                 {
06582                         return "normalize the 4 quadrants of a CCD image";
06583                 }

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 6570 of file processor.h.

06571                 {
06572                         return NAME;
06573                 }

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 6585 of file processor.h.

References EMAN::TypeDict::put().

06586                 {
06587                         TypeDict d;
06588                         d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample");
06589                         return d;
06590                 }

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

Definition at line 6575 of file processor.h.

06576                 {
06577                         return new CCDNormProcessor();
06578                 }

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 7926 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.

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


Member Data Documentation

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

Definition at line 215 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:52:43 2011 for EMAN2 by  doxygen 1.3.9.1