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

06487                 {
06488                         return "normalize the 4 quadrants of a CCD image";
06489                 }

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

06477                 {
06478                         return NAME;
06479                 }

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

References EMAN::TypeDict::put().

06492                 {
06493                         TypeDict d;
06494                         d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample");
06495                         return d;
06496                 }

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

Definition at line 6481 of file processor.h.

06482                 {
06483                         return new CCDNormProcessor();
06484                 }

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

07897 {
07898         if (!image) {
07899           Log::logger()->set_level(Log::ERROR_LOG);
07900           Log::logger()->error("Null image during call to CCDNorm\n");
07901           return;
07902         }
07903         if (image->get_zsize() > 1) {
07904           Log::logger()->set_level(Log::ERROR_LOG);
07905           Log::logger()->error("CCDNorm does not support 3d images\n");
07906           return;
07907         }
07908 
07909         int xs = image->get_xsize();
07910         int ys = image->get_ysize();
07911 
07912         // width of sample area on either side of the seams
07913         int width = params["width"];
07914 
07915         width%=(xs > ys ? xs/2 : ys/2);  // make sure width is a valid value
07916         if (width==0) {
07917           width=1;
07918         }
07919 
07920         // get the 4 "seams" of the image
07921         float *left, *right, *top, *bottom;
07922 
07923         double *temp;
07924         temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double));
07925         if (temp==NULL) {
07926           Log::logger()->set_level(Log::ERROR_LOG);
07927           Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n");
07928           return;
07929         }
07930 
07931         int x, y, z;
07932 
07933         // the mean values of each seam and the average
07934         double mL,mR,mT,mB;
07935 
07936         // how much to shift each seam
07937         double nl,nr,nt,nb;
07938 
07939         // quad. shifting amount
07940         double q1,q2,q3,q4;
07941 
07942         // calc. the mean for each quadrant
07943         for (z=0; z<width; z++) {
07944           left = image->get_col(xs/2 -1-z)->get_data();
07945           for (y=0; y<ys; y++)
07946             temp[z*ys+y]=left[y];
07947         }
07948         mL=gsl_stats_mean(temp,1,ys*width);
07949 
07950         for (z=0; z<width; z++) {
07951           right = image->get_col(xs/2 +z)->get_data();
07952           for (y=0; y<ys; y++)
07953             temp[z*ys+y]=right[y];
07954         }
07955         mR=gsl_stats_mean(temp,1,ys*width);
07956 
07957         for (z=0; z<width; z++) {
07958           top = image->get_row(ys/2 -1-z)->get_data();
07959           for (x=0; x<xs; x++)
07960             temp[z*xs+x]=top[x];
07961         }
07962         mT=gsl_stats_mean(temp,1,xs*width);
07963 
07964         for (z=0; z<width; z++) {
07965           bottom = image->get_row(ys/2 +z)->get_data();
07966           for (x=0; x<xs; x++)
07967             temp[z*xs+x]=bottom[x];
07968         }
07969         mB=gsl_stats_mean(temp,1,xs*width);
07970 
07971         free(temp);
07972 
07973         nl=(mL+mR)/2-mL;
07974         nr=(mL+mR)/2-mR;
07975         nt=(mT+mB)/2-mT;
07976         nb=(mT+mB)/2-mB;
07977 
07978         q1=nl+nt;
07979         q2=nr+nt;
07980         q3=nr+nb;
07981         q4=nl+nb;
07982 
07983         // change the pixel values
07984         for (x = 0; x < xs / 2; x++)
07985           for (y = 0; y < ys / 2; y++) {
07986             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1));
07987           }
07988         for (x = xs / 2; x < xs; x++)
07989           for (y = 0; y < ys / 2; y++) {
07990             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2));
07991           }
07992         for (x = xs / 2; x < xs; x++)
07993           for (y = ys / 2; y < ys; y++) {
07994             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3));
07995           }
07996         for (x = 0; x < xs / 2; x++)
07997           for (y = ys / 2; y < ys; y++) {
07998             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4));
07999           }
08000 
08001 }


Member Data Documentation

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

Definition at line 208 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Mar 7 18:21:25 2011 for EMAN2 by  doxygen 1.3.9.1