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


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


Member Function Documentation

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

07412 {
07413         if (!image) {
07414           Log::logger()->set_level(Log::ERROR_LOG);
07415           Log::logger()->error("Null image during call to CCDNorm\n");
07416           return;
07417         }
07418         if (image->get_zsize() > 1) {
07419           Log::logger()->set_level(Log::ERROR_LOG);
07420           Log::logger()->error("CCDNorm does not support 3d images\n");
07421           return;
07422         }
07423 
07424         int xs = image->get_xsize();
07425         int ys = image->get_ysize();
07426 
07427         // width of sample area on either side of the seams
07428         int width = params["width"];
07429 
07430         width%=(xs > ys ? xs/2 : ys/2);  // make sure width is a valid value
07431         if (width==0) {
07432           width=1;
07433         }
07434 
07435         // get the 4 "seams" of the image
07436         float *left, *right, *top, *bottom;
07437 
07438         double *temp;
07439         temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double));
07440         if (temp==NULL) {
07441           Log::logger()->set_level(Log::ERROR_LOG);
07442           Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n");
07443           return;
07444         }
07445 
07446         int x, y, z;
07447 
07448         // the mean values of each seam and the average
07449         double mL,mR,mT,mB;
07450 
07451         // how much to shift each seam
07452         double nl,nr,nt,nb;
07453 
07454         // quad. shifting amount
07455         double q1,q2,q3,q4;
07456 
07457         // calc. the mean for each quadrant
07458         for (z=0; z<width; z++) {
07459           left = image->get_col(xs/2 -1-z)->get_data();
07460           for (y=0; y<ys; y++)
07461             temp[z*ys+y]=left[y];
07462         }
07463         mL=gsl_stats_mean(temp,1,ys*width);
07464 
07465         for (z=0; z<width; z++) {
07466           right = image->get_col(xs/2 +z)->get_data();
07467           for (y=0; y<ys; y++)
07468             temp[z*ys+y]=right[y];
07469         }
07470         mR=gsl_stats_mean(temp,1,ys*width);
07471 
07472         for (z=0; z<width; z++) {
07473           top = image->get_row(ys/2 -1-z)->get_data();
07474           for (x=0; x<xs; x++)
07475             temp[z*xs+x]=top[x];
07476         }
07477         mT=gsl_stats_mean(temp,1,xs*width);
07478 
07479         for (z=0; z<width; z++) {
07480           bottom = image->get_row(ys/2 +z)->get_data();
07481           for (x=0; x<xs; x++)
07482             temp[z*xs+x]=bottom[x];
07483         }
07484         mB=gsl_stats_mean(temp,1,xs*width);
07485 
07486         free(temp);
07487 
07488         nl=(mL+mR)/2-mL;
07489         nr=(mL+mR)/2-mR;
07490         nt=(mT+mB)/2-mT;
07491         nb=(mT+mB)/2-mB;
07492 
07493         q1=nl+nt;
07494         q2=nr+nt;
07495         q3=nr+nb;
07496         q4=nl+nb;
07497 
07498         // change the pixel values
07499         for (x = 0; x < xs / 2; x++)
07500           for (y = 0; y < ys / 2; y++) {
07501             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1));
07502           }
07503         for (x = xs / 2; x < xs; x++)
07504           for (y = 0; y < ys / 2; y++) {
07505             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2));
07506           }
07507         for (x = xs / 2; x < xs; x++)
07508           for (y = ys / 2; y < ys; y++) {
07509             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3));
07510           }
07511         for (x = 0; x < xs / 2; x++)
07512           for (y = ys / 2; y < ys; y++) {
07513             image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4));
07514           }
07515 
07516 }

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

06171                 {
06172                         return "filter.ccdnorm";
06173                 }

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

Definition at line 6175 of file processor.h.

06176                 {
06177                         return new CCDNormProcessor();
06178                 }

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

06181                 {
06182                         return "normalize the 4 quadrants of a CCD image";
06183                 }

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

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

06186                 {
06187                         TypeDict d;
06188                         d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample");
06189                         return d;
06190                 }


The documentation for this class was generated from the following files:

Generated on Sat Nov 21 02:20:39 2009 for EMAN2 by  doxygen 1.5.6