#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 1620 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 1654 of file processor.h. 01655 { 01656 return "The image is scaled with the clip variable in mind, being sure to preserve as much pixel information as possible."; 01657 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 1623 of file processor.h. 01624 {
01625 return NAME;
01626 }
|
|
d.put("clipx", EMObject::INT, "The length of the output x dimension. Exclusive of the clip."); Reimplemented from EMAN::Processor. Definition at line 1644 of file processor.h. References EMAN::TypeDict::put(). 01645 { 01646 TypeDict d; 01647 d.put("scale", EMObject::FLOAT, "The amount by which to scale" ); 01648 d.put("clip", EMObject::INT, "The length of each output dimension. Non sophisticated, output dimensions can't be different" ); 01651 return d; 01652 }
|
|
Definition at line 1627 of file processor.h. 01628 { 01629 return new ScaleTransformProcessor(); 01630 }
|
|
Reimplemented from EMAN::Processor. Definition at line 8603 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. 08603 { 08604 int ndim = image->get_ndim(); 08605 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08606 08607 if ( image->get_xsize() != image->get_ysize()) { 08608 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08609 } 08610 if ( ndim == 3 ) { 08611 if ( image->get_xsize() != image->get_zsize()) { 08612 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08613 } 08614 } 08615 08616 float scale = params.set_default("scale",0.0f); 08617 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08618 08619 int clip = 0; 08620 08621 if(params.has_key("clip")) 08622 { 08623 clip = params["clip"]; 08624 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08625 } 08626 else 08627 { 08628 clip = (int)(scale*image->get_xsize()); 08629 } 08630 08631 Region r; 08632 if (ndim == 3) { 08633 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08634 } else { // ndim == 2 guaranteed by check at beginning of function 08635 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08636 } 08637 08638 EMData* ret = 0; 08639 if (scale > 1) { 08640 if ( clip != 0) { 08641 ret = image->get_clip(r); 08642 } 08643 Transform t; 08644 t.set_scale(scale); 08645 if (ret != 0) { 08646 ret->process_inplace("xform",Dict("transform",&t)); 08647 } else { 08648 ret = image->process("xform",Dict("transform",&t)); 08649 } 08650 } else if (scale < 1) { 08651 Transform t; 08652 t.set_scale(scale); 08653 ret = image->process("xform",Dict("transform",&t)); 08654 if ( clip != 0) { 08655 ret->clip_inplace(r); 08656 } 08657 } else { 08658 if ( clip != 0) { 08659 ret = image->get_clip(r); 08660 } else { 08661 ret = image->copy(); 08662 } 08663 } 08664 return ret; 08665 08666 }
|
|
Implements EMAN::Processor. Definition at line 8547 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. 08547 { 08548 int ndim = image->get_ndim(); 08549 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08550 08551 if ( image->get_xsize() != image->get_ysize()) { 08552 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08553 } 08554 if ( ndim == 3 ) { 08555 if ( image->get_xsize() != image->get_zsize()) { 08556 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08557 } 08558 } 08559 08560 float scale = params.set_default("scale",0.0f); 08561 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08562 08563 int clip = 0; 08564 08565 if(params.has_key("clip")) 08566 { 08567 clip = params["clip"]; 08568 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08569 } 08570 else 08571 { 08572 clip = (int)(scale*image->get_xsize()); 08573 } 08574 08575 Region r; 08576 if (ndim == 3) { 08577 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08578 } else { // ndim == 2 guaranteed by check at beginning of function 08579 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08580 } 08581 08582 if (scale > 1) { 08583 if ( clip != 0) { 08584 image->clip_inplace(r); 08585 } 08586 Transform t; 08587 t.set_scale(scale); 08588 image->process_inplace("xform",Dict("transform",&t)); 08589 } else if (scale < 1) { 08590 Transform t; 08591 t.set_scale(scale); 08592 image->process_inplace("xform",Dict("transform",&t)); 08593 if ( clip != 0) { 08594 image->clip_inplace(r); 08595 } 08596 } else { 08597 if ( clip != 0) { 08598 image->clip_inplace(r); 08599 } 08600 } 08601 }
|
|
Definition at line 93 of file processor.cpp. |