#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 1401 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 1435 of file processor.h. 01436 { 01437 return "The image is scaled with the clip variable in mind, being sure to preserve as much pixel information as possible."; 01438 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 1404 of file processor.h. 01405 {
01406 return NAME;
01407 }
|
|
d.put("clipx", EMObject::INT, "The length of the output x dimension. Exclusive of the clip."); Reimplemented from EMAN::Processor. Definition at line 1425 of file processor.h. References EMAN::TypeDict::put(). 01426 { 01427 TypeDict d; 01428 d.put("scale", EMObject::FLOAT, "The amount by which to scale" ); 01429 d.put("clip", EMObject::INT, "The length of each output dimension. Non sophisticated, output dimensions can't be different" ); 01432 return d; 01433 }
|
|
Definition at line 1408 of file processor.h. 01409 { 01410 return new ScaleTransformProcessor(); 01411 }
|
|
Reimplemented from EMAN::Processor. Definition at line 8523 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. 08523 { 08524 int ndim = image->get_ndim(); 08525 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08526 08527 if ( image->get_xsize() != image->get_ysize()) { 08528 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08529 } 08530 if ( ndim == 3 ) { 08531 if ( image->get_xsize() != image->get_zsize()) { 08532 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08533 } 08534 } 08535 08536 float scale = params.set_default("scale",0.0f); 08537 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08538 08539 int clip = 0; 08540 08541 if(params.has_key("clip")) 08542 { 08543 clip = params["clip"]; 08544 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08545 } 08546 else 08547 { 08548 clip = (int)(scale*image->get_xsize()); 08549 } 08550 08551 Region r; 08552 if (ndim == 3) { 08553 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08554 } else { // ndim == 2 guaranteed by check at beginning of function 08555 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08556 } 08557 08558 EMData* ret = 0; 08559 if (scale > 1) { 08560 if ( clip != 0) { 08561 ret = image->get_clip(r); 08562 } 08563 Transform t; 08564 t.set_scale(scale); 08565 if (ret != 0) { 08566 ret->process_inplace("xform",Dict("transform",&t)); 08567 } else { 08568 ret = image->process("xform",Dict("transform",&t)); 08569 } 08570 } else if (scale < 1) { 08571 Transform t; 08572 t.set_scale(scale); 08573 ret = image->process("xform",Dict("transform",&t)); 08574 if ( clip != 0) { 08575 ret->clip_inplace(r); 08576 } 08577 } else { 08578 if ( clip != 0) { 08579 ret = image->get_clip(r); 08580 } else { 08581 ret = image->copy(); 08582 } 08583 } 08584 return ret; 08585 08586 }
|
|
Implements EMAN::Processor. Definition at line 8467 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. 08467 { 08468 int ndim = image->get_ndim(); 08469 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images"); 08470 08471 if ( image->get_xsize() != image->get_ysize()) { 08472 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data"); 08473 } 08474 if ( ndim == 3 ) { 08475 if ( image->get_xsize() != image->get_zsize()) { 08476 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data"); 08477 } 08478 } 08479 08480 float scale = params.set_default("scale",0.0f); 08481 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0"); 08482 08483 int clip = 0; 08484 08485 if(params.has_key("clip")) 08486 { 08487 clip = params["clip"]; 08488 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used 08489 } 08490 else 08491 { 08492 clip = (int)(scale*image->get_xsize()); 08493 } 08494 08495 Region r; 08496 if (ndim == 3) { 08497 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip); 08498 } else { // ndim == 2 guaranteed by check at beginning of function 08499 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip); 08500 } 08501 08502 if (scale > 1) { 08503 if ( clip != 0) { 08504 image->clip_inplace(r); 08505 } 08506 Transform t; 08507 t.set_scale(scale); 08508 image->process_inplace("xform",Dict("transform",&t)); 08509 } else if (scale < 1) { 08510 Transform t; 08511 t.set_scale(scale); 08512 image->process_inplace("xform",Dict("transform",&t)); 08513 if ( clip != 0) { 08514 image->clip_inplace(r); 08515 } 08516 } else { 08517 if ( clip != 0) { 08518 image->clip_inplace(r); 08519 } 08520 } 08521 }
|
|
Definition at line 84 of file processor.cpp. |