#include <processor.h>
Inheritance diagram for EMAN::ScaleTransformProcessor:
Public Member Functions | |
virtual string | get_name () const |
Get the processor's name. | |
virtual void | process_inplace (EMData *image) |
virtual EMData * | process (const EMData *const image) |
virtual TypeDict | get_param_types () const |
virtual string | get_desc () const |
Get the descrition of this specific processor. | |
Static Public Member Functions | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "xform.scale" |
scale | The amount by which to scale | |
cip | The length of each output dimension. Non sophisticated, output dimensions can't be different |
Definition at line 1662 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 1695 of file processor.h. 01696 { 01697 return "The image is scaled with the clip variable in mind, being sure to preserve as much pixel information as possible."; 01698 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 1665 of file processor.h. 01666 {
01667 return NAME;
01668 }
|
|
d.put("clipx", EMObject::INT, "The length of the output x dimension. Exclusive of the clip."); Reimplemented from EMAN::Processor. Definition at line 1685 of file processor.h. References EMAN::TypeDict::put(). 01686 { 01687 TypeDict d; 01688 d.put("scale", EMObject::FLOAT, "The amount by which to scale" ); 01689 d.put("clip", EMObject::INT, "The length of each output dimension. Non sophisticated, output dimensions can't be different" ); 01692 return d; 01693 }
|
|
Definition at line 1669 of file processor.h. 01670 { 01671 return new ScaleTransformProcessor(); 01672 }
|
|
Reimplemented from EMAN::Processor. Definition at line 8776 of file processor.cpp. References EMAN::EMData::clip_inplace(), EMAN::EMData::copy(), EMAN::EMData::get_clip(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), ImageDimensionException, InvalidParameterException, EMAN::EMData::process(), EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), EMAN::Transform::set_scale(), t, and UnexpectedBehaviorException. 08776 { 08777 int ndim = image->get_ndim(); 08778 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08779 08780 if ( image->get_xsize() != image->get_ysize()) { 08781 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08782 } 08783 if ( ndim == 3 ) { 08784 if ( image->get_xsize() != image->get_zsize()) { 08785 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08786 } 08787 } 08788 08789 float scale = params.set_default("scale",0.0f); 08790 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08791 08792 int clip = 0; 08793 08794 if(params.has_key("clip")) 08795 { 08796 clip = params["clip"]; 08797 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08798 } 08799 else 08800 { 08801 clip = (int)(scale*image->get_xsize()); 08802 } 08803 08804 Region r; 08805 if (ndim == 3) { 08806 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08807 } else { // ndim == 2 guaranteed by check at beginning of function 08808 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08809 } 08810 08811 EMData* ret = 0; 08812 if (scale > 1) { 08813 if ( clip != 0) { 08814 ret = image->get_clip(r); 08815 } 08816 Transform t; 08817 t.set_scale(scale); 08818 if (ret != 0) { 08819 ret->process_inplace("xform",Dict("transform",&t)); 08820 } else { 08821 ret = image->process("xform",Dict("transform",&t)); 08822 } 08823 } else if (scale < 1) { 08824 Transform t; 08825 t.set_scale(scale); 08826 ret = image->process("xform",Dict("transform",&t)); 08827 if ( clip != 0) { 08828 ret->clip_inplace(r); 08829 } 08830 } else { 08831 if ( clip != 0) { 08832 ret = image->get_clip(r); 08833 } else { 08834 ret = image->copy(); 08835 } 08836 } 08837 return ret; 08838 08839 }
|
|
Implements EMAN::Processor. Definition at line 8720 of file processor.cpp. References EMAN::EMData::clip_inplace(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), ImageDimensionException, InvalidParameterException, EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), EMAN::Transform::set_scale(), t, and UnexpectedBehaviorException. 08720 { 08721 int ndim = image->get_ndim(); 08722 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08723 08724 if ( image->get_xsize() != image->get_ysize()) { 08725 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08726 } 08727 if ( ndim == 3 ) { 08728 if ( image->get_xsize() != image->get_zsize()) { 08729 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08730 } 08731 } 08732 08733 float scale = params.set_default("scale",0.0f); 08734 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08735 08736 int clip = 0; 08737 08738 if(params.has_key("clip")) 08739 { 08740 clip = params["clip"]; 08741 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08742 } 08743 else 08744 { 08745 clip = (int)(scale*image->get_xsize()); 08746 } 08747 08748 Region r; 08749 if (ndim == 3) { 08750 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08751 } else { // ndim == 2 guaranteed by check at beginning of function 08752 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08753 } 08754 08755 if (scale > 1) { 08756 if ( clip != 0) { 08757 image->clip_inplace(r); 08758 } 08759 Transform t; 08760 t.set_scale(scale); 08761 image->process_inplace("xform",Dict("transform",&t)); 08762 } else if (scale < 1) { 08763 Transform t; 08764 t.set_scale(scale); 08765 image->process_inplace("xform",Dict("transform",&t)); 08766 if ( clip != 0) { 08767 image->clip_inplace(r); 08768 } 08769 } else { 08770 if ( clip != 0) { 08771 image->clip_inplace(r); 08772 } 08773 } 08774 }
|
|
Definition at line 88 of file processor.cpp. |