#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 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. 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::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 8477 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. 08477 { 08478 int ndim = image->get_ndim(); 08479 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08480 08481 if ( image->get_xsize() != image->get_ysize()) { 08482 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08483 } 08484 if ( ndim == 3 ) { 08485 if ( image->get_xsize() != image->get_zsize()) { 08486 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08487 } 08488 } 08489 08490 float scale = params.set_default("scale",0.0f); 08491 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08492 08493 int clip = 0; 08494 08495 if(params.has_key("clip")) 08496 { 08497 clip = params["clip"]; 08498 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08499 } 08500 else 08501 { 08502 clip = (int)(scale*image->get_xsize()); 08503 } 08504 08505 Region r; 08506 if (ndim == 3) { 08507 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08508 } else { // ndim == 2 guaranteed by check at beginning of function 08509 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08510 } 08511 08512 EMData* ret = 0; 08513 if (scale > 1) { 08514 if ( clip != 0) { 08515 ret = image->get_clip(r); 08516 } 08517 Transform t; 08518 t.set_scale(scale); 08519 if (ret != 0) { 08520 ret->process_inplace("xform",Dict("transform",&t)); 08521 } else { 08522 ret = image->process("xform",Dict("transform",&t)); 08523 } 08524 } else if (scale < 1) { 08525 Transform t; 08526 t.set_scale(scale); 08527 ret = image->process("xform",Dict("transform",&t)); 08528 if ( clip != 0) { 08529 ret->clip_inplace(r); 08530 } 08531 } else { 08532 if ( clip != 0) { 08533 ret = image->get_clip(r); 08534 } else { 08535 ret = image->copy(); 08536 } 08537 } 08538 return ret; 08539 08540 }
|
|
Implements EMAN::Processor. Definition at line 8421 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. 08421 { 08422 int ndim = image->get_ndim(); 08423 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08424 08425 if ( image->get_xsize() != image->get_ysize()) { 08426 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08427 } 08428 if ( ndim == 3 ) { 08429 if ( image->get_xsize() != image->get_zsize()) { 08430 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08431 } 08432 } 08433 08434 float scale = params.set_default("scale",0.0f); 08435 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08436 08437 int clip = 0; 08438 08439 if(params.has_key("clip")) 08440 { 08441 clip = params["clip"]; 08442 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08443 } 08444 else 08445 { 08446 clip = (int)(scale*image->get_xsize()); 08447 } 08448 08449 Region r; 08450 if (ndim == 3) { 08451 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08452 } else { // ndim == 2 guaranteed by check at beginning of function 08453 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08454 } 08455 08456 if (scale > 1) { 08457 if ( clip != 0) { 08458 image->clip_inplace(r); 08459 } 08460 Transform t; 08461 t.set_scale(scale); 08462 image->process_inplace("xform",Dict("transform",&t)); 08463 } else if (scale < 1) { 08464 Transform t; 08465 t.set_scale(scale); 08466 image->process_inplace("xform",Dict("transform",&t)); 08467 if ( clip != 0) { 08468 image->clip_inplace(r); 08469 } 08470 } else { 08471 if ( clip != 0) { 08472 image->clip_inplace(r); 08473 } 08474 } 08475 }
|
|
Definition at line 90 of file processor.cpp. |