#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 | |||||||
static Processor * | NEW () | ||||||
Static Public Attributes | |||||||
static 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 1611 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 1645 of file processor.h. 01646 { 01647 return "The image is scaled with the clip variable in mind, being sure to preserve as much pixel information as possible."; 01648 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 1614 of file processor.h. References NAME. 01615 { 01616 return NAME; 01617 }
|
|
d.put("clipx", EMObject::INT, "The length of the output x dimension. Exclusive of the clip."); Reimplemented from EMAN::Processor. Definition at line 1635 of file processor.h. References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put(). 01636 { 01637 TypeDict d; 01638 d.put("scale", EMObject::FLOAT, "The amount by which to scale" ); 01639 d.put("clip", EMObject::INT, "The length of each output dimension. Non sophisticated, output dimensions can't be different" ); 01642 return d; 01643 }
|
|
Definition at line 1618 of file processor.h. 01619 { 01620 return new ScaleTransformProcessor(); 01621 }
|
|
Reimplemented from EMAN::Processor. Definition at line 8508 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::Processor::params, EMAN::EMData::process(), EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), EMAN::Transform::set_scale(), t, and UnexpectedBehaviorException. 08508 { 08509 int ndim = image->get_ndim(); 08510 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08511 08512 if ( image->get_xsize() != image->get_ysize()) { 08513 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08514 } 08515 if ( ndim == 3 ) { 08516 if ( image->get_xsize() != image->get_zsize()) { 08517 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08518 } 08519 } 08520 08521 float scale = params.set_default("scale",0.0f); 08522 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08523 08524 int clip = 0; 08525 08526 if(params.has_key("clip")) 08527 { 08528 clip = params["clip"]; 08529 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08530 } 08531 else 08532 { 08533 clip = (int)(scale*image->get_xsize()); 08534 } 08535 08536 Region r; 08537 if (ndim == 3) { 08538 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08539 } else { // ndim == 2 guaranteed by check at beginning of function 08540 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08541 } 08542 08543 EMData* ret = 0; 08544 if (scale > 1) { 08545 if ( clip != 0) { 08546 ret = image->get_clip(r); 08547 } 08548 Transform t; 08549 t.set_scale(scale); 08550 if (ret != 0) { 08551 ret->process_inplace("xform",Dict("transform",&t)); 08552 } else { 08553 ret = image->process("xform",Dict("transform",&t)); 08554 } 08555 } else if (scale < 1) { 08556 Transform t; 08557 t.set_scale(scale); 08558 ret = image->process("xform",Dict("transform",&t)); 08559 if ( clip != 0) { 08560 ret->clip_inplace(r); 08561 } 08562 } else { 08563 if ( clip != 0) { 08564 ret = image->get_clip(r); 08565 } else { 08566 ret = image->copy(); 08567 } 08568 } 08569 return ret; 08570 08571 }
|
|
Implements EMAN::Processor. Definition at line 8452 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::Processor::params, EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), EMAN::Transform::set_scale(), t, and UnexpectedBehaviorException. 08452 { 08453 int ndim = image->get_ndim(); 08454 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08455 08456 if ( image->get_xsize() != image->get_ysize()) { 08457 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08458 } 08459 if ( ndim == 3 ) { 08460 if ( image->get_xsize() != image->get_zsize()) { 08461 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08462 } 08463 } 08464 08465 float scale = params.set_default("scale",0.0f); 08466 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08467 08468 int clip = 0; 08469 08470 if(params.has_key("clip")) 08471 { 08472 clip = params["clip"]; 08473 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08474 } 08475 else 08476 { 08477 clip = (int)(scale*image->get_xsize()); 08478 } 08479 08480 Region r; 08481 if (ndim == 3) { 08482 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08483 } else { // ndim == 2 guaranteed by check at beginning of function 08484 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08485 } 08486 08487 if (scale > 1) { 08488 if ( clip != 0) { 08489 image->clip_inplace(r); 08490 } 08491 Transform t; 08492 t.set_scale(scale); 08493 image->process_inplace("xform",Dict("transform",&t)); 08494 } else if (scale < 1) { 08495 Transform t; 08496 t.set_scale(scale); 08497 image->process_inplace("xform",Dict("transform",&t)); 08498 if ( clip != 0) { 08499 image->clip_inplace(r); 08500 } 08501 } else { 08502 if ( clip != 0) { 08503 image->clip_inplace(r); 08504 } 08505 } 08506 }
|
|
Definition at line 1650 of file processor.h. Referenced by get_name(). |