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

Rotate by 180 using pixel swapping, works for 2D only. More...

#include <processor.h>

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

Public Member Functions

string get_name () const
 Get the processor's name. More...
 
void process_inplace (EMData *image)
 
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 = "math.rotate.180"
 

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

Rotate by 180 using pixel swapping, works for 2D only.

Author
David Woolford
Date
July 29th 2008

Definition at line 2794 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::Rotate180Processor::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 2811 of file processor.h.

2812 {
2813 return "The 2D image is rotated by 180 degree by carefully swapping image pixel values. No explicit matrix multiplication is performed. If image dimensions are even will change pixels along x=0 and y=0. Works for all combinations of even and oddness.";
2814 }

◆ get_name()

string EMAN::Rotate180Processor::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 2797 of file processor.h.

2798 {
2799 return NAME;
2800 }
static const string NAME
Definition: processor.h:2816

References NAME.

◆ NEW()

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

Definition at line 2801 of file processor.h.

2802 {
2803 return new Rotate180Processor();
2804 }
Rotate by 180 using pixel swapping, works for 2D only.
Definition: processor.h:2795

◆ process_inplace()

void Rotate180Processor::process_inplace ( EMData image)
virtual
Exceptions
ImageDimensionExceptionif the image dimensions are not 2D

Implements EMAN::Processor.

Definition at line 12137 of file processor.cpp.

12137 {
12138 ENTERFUNC;
12139
12140
12141 if (image->get_ndim() != 2) {
12142 throw ImageDimensionException("2D only");
12143 }
12144
12145#ifdef EMAN2_USING_CUDA
12146 if (EMData::usecuda == 1 && image->getcudarwdata()) {
12147 //cout << "CUDA rotate 180" << endl;
12148 emdata_rotate_180(image->getcudarwdata(), image->get_xsize(), image->get_ysize());
12149 EXITFUNC;
12150 return;
12151 }
12152#endif
12153
12154 float *d = image->get_data();
12155 int nx = image->get_xsize();
12156 int ny = image->get_ysize();
12157
12158 // x and y offsets are used to handle even vs odd cases
12159 int x_offset = 0;
12160 if (nx % 2 == 1) x_offset=1;
12161 int y_offset = 0;
12162 if (ny % 2 == 1) y_offset=1;
12163
12164 bool stop = false;
12165 for (int x = 1; x <= (nx/2+x_offset); x++) {
12166 int y = 0;
12167 for (y = 1; y < (ny+y_offset); y++) {
12168 if (x == (nx / 2+x_offset) && y == (ny / 2+y_offset)) {
12169 stop = true;
12170 break;
12171 }
12172 int i = (x-x_offset) + (y-y_offset) * nx;
12173 int k = nx - x + (ny - y) * nx;
12174
12175 float t = d[i];
12176 d[i] = d[k];
12177 d[k] = t;
12178 }
12179 if (stop) break;
12180 }
12181
12182 /* Here we guard against irregularites that occur at the boundaries
12183 * of even dimensioned images. The basic policy is to replace the pixel
12184 * in row 0 and/or column 0 with those in row 1 and/or column 1, respectively.
12185 * The pixel at 0,0 is replaced with the pixel at 1,1 if both image dimensions
12186 * are even. FIXME - it may be better to use an average at the corner, in
12187 * this latter case, using pixels (1,1), (0,1) and (1,0). I am not sure. (dsawoolford)
12188 */
12189 if (x_offset == 0) {
12190 for (int y = 0; y < ny; y++) {
12191 image->set_value_at_fast(0,y,image->get_value_at(1,y));
12192 }
12193 }
12194
12195 if (y_offset == 0) {
12196 for (int x = 0; x < nx; x++) {
12197 image->set_value_at_fast(x,0,image->get_value_at(x,1));
12198 }
12199 }
12200
12201 if (y_offset == 0 && x_offset == 0) {
12202 image->set_value_at_fast(0,0,image->get_value_at(1,1));
12203 }
12204
12205 image->update();
12206 EXITFUNC;
12207}
void emdata_rotate_180(float *data, const int nx, const int ny)
Rotates by 180 degrees using memory swapping, uses shared memory for efficiency Works on 2D images - ...
#define ImageDimensionException(desc)
Definition: exception.h:166
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References emdata_rotate_180(), ENTERFUNC, EXITFUNC, ImageDimensionException, x, and y.

Member Data Documentation

◆ NAME

const string Rotate180Processor::NAME = "math.rotate.180"
static

Definition at line 2816 of file processor.h.

Referenced by get_name().


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