EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::RampProcessor Class Reference

Ramp processor – Fits a least-squares plane to the picture, and subtracts the plane from the picture. More...

#include <processor.h>

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

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
 
string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "filter.ramp"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Ramp processor – Fits a least-squares plane to the picture, and subtracts the plane from the picture.

A wedge-shaped overall density profile can thus be removed from the picture.

Definition at line 5310 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::RampProcessor::get_desc ( ) const
inlinevirtual

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

5325 {
5326 return "Ramp processor -- Fits a least-squares plane "
5327 "to the picture, and subtracts the plane from "
5328 "the picture. A wedge-shaped overall density "
5329 "profile can thus be removed from the picture.";
5330 }

◆ get_name()

string EMAN::RampProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 5315 of file processor.h.

5316 {
5317 return NAME;
5318 }
static const string NAME
Definition: processor.h:5332

References NAME.

Referenced by process_inplace().

◆ NEW()

static Processor * EMAN::RampProcessor::NEW ( )
inlinestatic

Definition at line 5319 of file processor.h.

5320 {
5321 return new RampProcessor();
5322 }
Ramp processor – Fits a least-squares plane to the picture, and subtracts the plane from the picture.
Definition: processor.h:5311

◆ process_inplace()

void RampProcessor::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 10187 of file processor.cpp.

10188{
10189 if (!image) {
10190 return;
10191 }
10192
10193 int nz = image->get_zsize();
10194 if (nz > 1) {
10195 LOGERR("%s Processor doesn't support 3D model", get_name().c_str());
10196 throw ImageDimensionException("3D model not supported");
10197 }
10198
10199 int nsam = image->get_xsize();
10200 int nrow = image->get_ysize();
10201 int n1 = nsam / 2;
10202 double sx1 = double(n1)*double(nsam+1);
10203 if ( nsam % 2 == 1 )
10204 sx1 += 1 + n1;
10205 sx1 *= nrow;
10206 int n2 = nrow / 2;
10207 double sx2 = double(n2)*double(nrow+1);
10208 if ( nrow % 2 == 1 )
10209 sx2 += 1 + n2;
10210 sx2 *= nsam;
10211 float *data = image->get_data();
10212 float *row = NULL; // handy pointer for values in a specific row of the data
10213 // statistical sums
10214 double syx1 = 0, syx2 = 0, sy = 0, sx1q = 0, sx2q = 0, syq = 0;
10215 for (int j=1; j <= nrow; j++) {
10216 row = data + (j-1)*nsam - 1; // "-1" so that we can start counting at 1
10217 for (int i=1; i<=nsam; i++) {
10218 syx1 += row[i]*i;
10219 syx2 += row[i]*j;
10220 sy += row[i];
10221 sx1q += i*i;
10222 sx2q += j*j;
10223 syq += row[i]*double(row[i]);
10224 }
10225 }
10226 // least-squares
10227 float dn = float(nsam)*float(nrow);
10228 double qyx1 = syx1 - sx1*sy / dn;
10229 double qyx2 = syx2 - sx2*sy / dn;
10230 double qx1x2 = 0.0;
10231 double qx1 = sx1q - sx1*sx1 / dn;
10232 double qx2 = sx2q - sx2*sx2 / dn;
10233 double qy = syq - sy*sy / dn;
10234 double c = qx1*qx2 - qx1x2*qx1x2;
10235 if ( c > FLT_EPSILON ) {
10236 double b1 = (qyx1*qx2 - qyx2*qx1x2) / c;
10237 double b2 = (qyx2*qx1 - qyx1*qx1x2) / c;
10238 double a = (sy - b1*sx1 - b2*sx2) / dn;
10239 double d = a + b1 + b2;
10240 for (int i=1; i<=nrow; i++) {
10241 qy = d;
10242 row = data + (i-1)*nsam - 1;
10243 for (int k=1; k<=nsam; k++) {
10244 row[k] -= static_cast<float>(qy);
10245 qy += b1;
10246 }
10247 d += b2;
10248 }
10249 } // image not altered if c is zero
10250
10251 image->update();
10252}
string get_name() const
Get the processor's name.
Definition: processor.h:5315
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGERR
Definition: log.h:51

References get_name(), ImageDimensionException, and LOGERR.

Member Data Documentation

◆ NAME

const string RampProcessor::NAME = "filter.ramp"
static

Definition at line 5332 of file processor.h.

Referenced by get_name().


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