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

Scale the image with control over the output dimensions. More...

#include <processor.h>

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

Public Member Functions

virtual string get_name () const
 Get the processor's name. More...
 
virtual void process_inplace (EMData *image)
 
virtual EMDataprocess (const EMData *const image)
 
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 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.scale"
 

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

Scale the image with control over the output dimensions.

Author
David Woolford
Date
June 2009
Parameters
scaleThe amount by which to scale
cipThe length of each output dimension. Non sophisticated, output dimensions can't be different

Definition at line 2985 of file processor.h.

Member Function Documentation

◆ get_desc()

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

3019 {
3020 return "The image is scaled with the clip variable in mind, being sure to preserve as much pixel information as possible.";
3021 }

◆ get_name()

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

2989 {
2990 return NAME;
2991 }
static const string NAME
Definition: processor.h:3023

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::ScaleTransformProcessor::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.

d.put("clipx", EMObject::INT, "The length of the output x dimension. Exclusive of the clip.");

Reimplemented from EMAN::Processor.

Definition at line 3008 of file processor.h.

3009 {
3010 TypeDict d;
3011 d.put("scale", EMObject::FLOAT, "The amount by which to scale" );
3012 d.put("clip", EMObject::INT, "The length of each output dimension. Non sophisticated, output dimensions can't be different" );
3015 return d;
3016 }
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::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 2992 of file processor.h.

2993 {
2994 return new ScaleTransformProcessor();
2995 }
Scale the image with control over the output dimensions.
Definition: processor.h:2986

◆ process()

EMData * ScaleTransformProcessor::process ( const EMData *const  image)
virtual
Exceptions
ImageDimensionExceptionif the image is not 2D or 3D
InvalidParameterExceptionif the Transform parameter is not specified

Reimplemented from EMAN::Processor.

Definition at line 12072 of file processor.cpp.

12072 {
12073 int ndim = image->get_ndim();
12074 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images");
12075
12076 if ( image->get_xsize() != image->get_ysize()) {
12077 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data");
12078 }
12079 if ( ndim == 3 ) {
12080 if ( image->get_xsize() != image->get_zsize()) {
12081 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data");
12082 }
12083 }
12084
12085 float scale = params.set_default("scale",0.0f);
12086 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0");
12087
12088 int clip = 0;
12089
12090 if(params.has_key("clip"))
12091 {
12092 clip = params["clip"];
12093 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used
12094 }
12095 else
12096 {
12097 clip = (int)(scale*image->get_xsize());
12098 }
12099
12100 Region r;
12101 if (ndim == 3) {
12102 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip);
12103 } else { // ndim == 2 guaranteed by check at beginning of function
12104 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip);
12105 }
12106
12107 EMData* ret = 0;
12108 if (scale > 1) {
12109 if ( clip != 0) {
12110 ret = image->get_clip(r);
12111 }
12112 Transform t;
12113 t.set_scale(scale);
12114 if (ret != 0) {
12115 ret->process_inplace("xform",Dict("transform",&t));
12116 } else {
12117 ret = image->process("xform",Dict("transform",&t));
12118 }
12119 } else if (scale < 1) {
12120 Transform t;
12121 t.set_scale(scale);
12122 ret = image->process("xform",Dict("transform",&t));
12123 if ( clip != 0) {
12124 ret->clip_inplace(r);
12125 }
12126 } else {
12127 if ( clip != 0) {
12128 ret = image->get_clip(r);
12129 } else {
12130 ret = image->copy();
12131 }
12132 }
12133 return ret;
12134
12135}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMData * get_clip(const Region &area, const float fill=0) const
Get an inclusive clip.
Definition: emdata.cpp:592
void clip_inplace(const Region &area, const float &fill_value=0)
Clip the image inplace - clipping region must be smaller than the current region internally memory is...
Definition: emdata.cpp:350
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
Definition: geometry.h:497
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
void set_scale(const float &scale)
Set the scale.
Definition: transform.cpp:1123
#define InvalidParameterException(desc)
Definition: exception.h:361
#define ImageDimensionException(desc)
Definition: exception.h:166
#define UnexpectedBehaviorException(desc)
Definition: exception.h:400

References EMAN::EMData::clip_inplace(), EMAN::EMData::get_clip(), EMAN::Dict::has_key(), ImageDimensionException, InvalidParameterException, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::Transform::set_scale(), and UnexpectedBehaviorException.

◆ process_inplace()

void ScaleTransformProcessor::process_inplace ( EMData image)
virtual
Exceptions
ImageDimensionExceptionif the image is not 2D or 3D
InvalidParameterExceptionif the Transform parameter is not specified

Implements EMAN::Processor.

Definition at line 11813 of file processor.cpp.

11813 {
11814 int ndim = image->get_ndim();
11815 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images");
11816
11817 if ( image->get_xsize() != image->get_ysize()) {
11818 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data");
11819 }
11820 if ( ndim == 3 ) {
11821 if ( image->get_xsize() != image->get_zsize()) {
11822 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data");
11823 }
11824 }
11825
11826 float scale = params.set_default("scale",0.0f);
11827 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0");
11828
11829 int clip = 0;
11830
11831 if(params.has_key("clip"))
11832 {
11833 clip = params["clip"];
11834 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used
11835 }
11836 else
11837 {
11838 clip = (int)(scale*image->get_xsize());
11839 }
11840
11841 Region r;
11842 if (ndim == 3) {
11843 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip);
11844 } else { // ndim == 2 guaranteed by check at beginning of function
11845 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip);
11846 }
11847
11848 if (scale > 1) {
11849 if ( clip != 0) {
11850 image->clip_inplace(r);
11851 }
11852 Transform t;
11853 t.set_scale(scale);
11854 image->process_inplace("xform",Dict("transform",&t));
11855 } else if (scale < 1) {
11856 Transform t;
11857 t.set_scale(scale);
11858 image->process_inplace("xform",Dict("transform",&t));
11859 if ( clip != 0) {
11860 image->clip_inplace(r);
11861 }
11862 } else {
11863 if ( clip != 0) {
11864 image->clip_inplace(r);
11865 }
11866 }
11867}

References EMAN::EMData::clip_inplace(), EMAN::Dict::has_key(), ImageDimensionException, InvalidParameterException, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::Transform::set_scale(), and UnexpectedBehaviorException.

Member Data Documentation

◆ NAME

const string ScaleTransformProcessor::NAME = "xform.scale"
static

Definition at line 3023 of file processor.h.

Referenced by get_name().


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