EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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:
widthnumber of pixels on either side of the seam to sample

Definition at line 7054 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 7069 of file processor.h.

                {
                        return "normalize the 4 quadrants of a CCD image";
                }
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 7059 of file processor.h.

References NAME.

                {
                        return NAME;
                }
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 7074 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("width", EMObject::INT, "number of pixels on either side of the seam to sample");
                        return d;
                }
static Processor* EMAN::CCDNormProcessor::NEW ( ) [inline, static]

Definition at line 7064 of file processor.h.

                {
                        return new CCDNormProcessor();
                }
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:
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 8602 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(), x, and y.

{
        if (!image) {
          Log::logger()->set_level(Log::ERROR_LOG);
          Log::logger()->error("Null image during call to CCDNorm\n");
          return;
        }
        if (image->get_zsize() > 1) {
          Log::logger()->set_level(Log::ERROR_LOG);
          Log::logger()->error("CCDNorm does not support 3d images\n");
          return;
        }

        int xs = image->get_xsize();
        int ys = image->get_ysize();

        // width of sample area on either side of the seams
        int width = params["width"];

        width%=(xs > ys ? xs/2 : ys/2);  // make sure width is a valid value
        if (width==0) {
          width=1;
        }

        // get the 4 "seams" of the image
        float *left, *right, *top, *bottom;

        double *temp;
        temp= (double*)malloc((xs > ys ? xs*width : ys*width)*sizeof(double));
        if (temp==NULL) {
          Log::logger()->set_level(Log::ERROR_LOG);
          Log::logger()->error("Could not allocate enough memory during call to CCDNorm\n");
          return;
        }

        int x, y, z;

        // the mean values of each seam and the average
        double mL,mR,mT,mB;

        // how much to shift each seam
        double nl,nr,nt,nb;

        // quad. shifting amount
        double q1,q2,q3,q4;

        // calc. the mean for each quadrant
        for (z=0; z<width; z++) {
          left = image->get_col(xs/2 -1-z)->get_data();
          for (y=0; y<ys; y++)
            temp[z*ys+y]=left[y];
        }
        mL=gsl_stats_mean(temp,1,ys*width);

        for (z=0; z<width; z++) {
          right = image->get_col(xs/2 +z)->get_data();
          for (y=0; y<ys; y++)
            temp[z*ys+y]=right[y];
        }
        mR=gsl_stats_mean(temp,1,ys*width);

        for (z=0; z<width; z++) {
          top = image->get_row(ys/2 -1-z)->get_data();
          for (x=0; x<xs; x++)
            temp[z*xs+x]=top[x];
        }
        mT=gsl_stats_mean(temp,1,xs*width);

        for (z=0; z<width; z++) {
          bottom = image->get_row(ys/2 +z)->get_data();
          for (x=0; x<xs; x++)
            temp[z*xs+x]=bottom[x];
        }
        mB=gsl_stats_mean(temp,1,xs*width);

        free(temp);

        nl=(mL+mR)/2-mL;
        nr=(mL+mR)/2-mR;
        nt=(mT+mB)/2-mT;
        nb=(mT+mB)/2-mB;

        q1=nl+nt;
        q2=nr+nt;
        q3=nr+nb;
        q4=nl+nb;

        // change the pixel values
        for (x = 0; x < xs / 2; x++)
          for (y = 0; y < ys / 2; y++) {
            image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q1));
          }
        for (x = xs / 2; x < xs; x++)
          for (y = 0; y < ys / 2; y++) {
            image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q2));
          }
        for (x = xs / 2; x < xs; x++)
          for (y = ys / 2; y < ys; y++) {
            image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q3));
          }
        for (x = 0; x < xs / 2; x++)
          for (y = ys / 2; y < ys; y++) {
            image->set_value_at_fast(x, y, image->get_value_at(x, y) + static_cast<float>(q4));
          }

}

Member Data Documentation

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

Definition at line 7081 of file processor.h.

Referenced by get_name().


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