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

mirror an image around an axis (reverse pixels) More...

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
virtual 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...
 

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 = "xform.reverse"
 

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

mirror an image around an axis (reverse pixels)

Parameters
axis'x', 'y', or 'z' axis. 'x' means horizonal mirror; 'y' means vertical mirror;

Definition at line 6429 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::ReverseProcessor::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 6451 of file processor.h.

6452 {
6453 return "Mirrors (reverses) an image along the specified axis, preserving the center. This will NOT introduce a plane of 0's for even box sizes. Use 'xform.mirror' or 'xform.flip' processor to include the zero plane and preserve the center.";
6454 }

◆ get_name()

virtual string EMAN::ReverseProcessor::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 6434 of file processor.h.

6435 {
6436 return NAME;
6437 }
static const string NAME
Definition: processor.h:6456

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::ReverseProcessor::get_param_types ( ) const
inlinevirtual

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

6445 {
6446 TypeDict d;
6447 d.put("axis", EMObject::STRING, "'x', 'y', or 'z' axis.");
6448 return d;
6449 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

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

Definition at line 6439 of file processor.h.

6440 {
6441 return new ReverseProcessor();
6442 }
mirror an image around an axis (reverse pixels)
Definition: processor.h:6430

◆ process_inplace()

void ReverseProcessor::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 10531 of file processor.cpp.

10532{
10533 if (!image) {
10534 LOGWARN("NULL Image");
10535 return;
10536 }
10537
10538 string axis = (const char*)params["axis"];
10539
10540 float* data = image->EMData::get_data();
10541
10542 int nx = image->get_xsize();
10543 int ny = image->get_ysize();
10544 int nz = image->get_zsize();
10545 size_t nxy = nx*ny;
10546
10547 int x_start = 0;
10548 int y_start = 0;
10549 int z_start = 0;
10550
10551 if (axis == "x" || axis == "X") {
10552 int offset = 0;
10553 for (int iz = 0; iz < nz; iz++){
10554 for (int iy = 0; iy < ny; iy++) {
10555 offset = nx*iy + nxy*iz;
10556 reverse(&data[x_start+offset],&data[offset+nx]);
10557 }
10558 }
10559 } else if (axis == "y" || axis == "Y") {
10560 float *tmp = new float[nx];
10561 int nhalf = ny/2;
10562 size_t beg = 0;
10563 for (int iz = 0; iz < nz; iz++) {
10564 beg = iz*nxy;
10565 for (int iy = y_start; iy < nhalf; iy++) {
10566 memcpy(tmp, &data[beg+iy*nx], nx*sizeof(float));
10567 memcpy(&data[beg+iy*nx], &data[beg+(y_start+ny-iy-1)*nx], nx*sizeof(float));
10568 memcpy(&data[beg+(y_start+ny-iy-1)*nx], tmp, nx*sizeof(float));
10569 }
10570 }
10571 delete[] tmp;
10572 } else if (axis == "z" || axis == "Z") {
10573 if(1-z_start) {
10574 int nhalf = nz/2;
10575 float *tmp = new float[nxy];
10576 for(int iz = 0;iz<nhalf;iz++){
10577 memcpy(tmp,&data[iz*nxy],nxy*sizeof(float));
10578 memcpy(&data[iz*nxy],&data[(nz-iz-1)*nxy],nxy*sizeof(float));
10579 memcpy(&data[(nz-iz-1)*nxy],tmp,nxy*sizeof(float));
10580 }
10581 delete[] tmp;
10582 } else {
10583 float *tmp = new float[nx];
10584 int nhalf = nz/2;
10585 size_t beg = 0;
10586 for (int iy = 0; iy < ny; iy++) {
10587 beg = iy*nx;
10588 for (int iz = z_start; iz < nhalf; iz++) {
10589 memcpy(tmp, &data[beg+ iz*nxy], nx*sizeof(float));
10590 memcpy(&data[beg+iz*nxy], &data[beg+(nz-iz-1+z_start)*nxy], nx*sizeof(float));
10591 memcpy(&data[beg+(nz-iz-1+z_start)*nxy], tmp, nx*sizeof(float));
10592 }
10593 }
10594 delete[] tmp;
10595 }
10596 }
10597
10598 image->update();
10599}
#define LOGWARN
Definition: log.h:53

References LOGWARN, and EMAN::Processor::params.

Member Data Documentation

◆ NAME

const string ReverseProcessor::NAME = "xform.reverse"
static

Definition at line 6456 of file processor.h.

Referenced by get_name().


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