#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 1582 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 1616 of file processor.h. 01617 {
01618 return "The image is scaled with the clip variable in mind, being sure to preserve as much pixel information as possible.";
01619 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 1585 of file processor.h. 01586 {
01587 return NAME;
01588 }
|
|
|
d.put("clipx", EMObject::INT, "The length of the output x dimension. Exclusive of the clip."); Reimplemented from EMAN::Processor. Definition at line 1606 of file processor.h. References EMAN::TypeDict::put(). 01607 {
01608 TypeDict d;
01609 d.put("scale", EMObject::FLOAT, "The amount by which to scale" );
01610 d.put("clip", EMObject::INT, "The length of each output dimension. Non sophisticated, output dimensions can't be different" );
01613 return d;
01614 }
|
|
|
Definition at line 1589 of file processor.h. 01590 {
01591 return new ScaleTransformProcessor();
01592 }
|
|
|
Reimplemented from EMAN::Processor. Definition at line 8572 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. 08572 {
08573 int ndim = image->get_ndim();
08574 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images");
08575
08576 if ( image->get_xsize() != image->get_ysize()) {
08577 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data");
08578 }
08579 if ( ndim == 3 ) {
08580 if ( image->get_xsize() != image->get_zsize()) {
08581 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data");
08582 }
08583 }
08584
08585 float scale = params.set_default("scale",0.0f);
08586 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0");
08587
08588 int clip = 0;
08589
08590 if(params.has_key("clip"))
08591 {
08592 clip = params["clip"];
08593 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used
08594 }
08595 else
08596 {
08597 clip = (int)(scale*image->get_xsize());
08598 }
08599
08600 Region r;
08601 if (ndim == 3) {
08602 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip);
08603 } else { // ndim == 2 guaranteed by check at beginning of function
08604 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip);
08605 }
08606
08607 EMData* ret = 0;
08608 if (scale > 1) {
08609 if ( clip != 0) {
08610 ret = image->get_clip(r);
08611 }
08612 Transform t;
08613 t.set_scale(scale);
08614 if (ret != 0) {
08615 ret->process_inplace("xform",Dict("transform",&t));
08616 } else {
08617 ret = image->process("xform",Dict("transform",&t));
08618 }
08619 } else if (scale < 1) {
08620 Transform t;
08621 t.set_scale(scale);
08622 ret = image->process("xform",Dict("transform",&t));
08623 if ( clip != 0) {
08624 ret->clip_inplace(r);
08625 }
08626 } else {
08627 if ( clip != 0) {
08628 ret = image->get_clip(r);
08629 } else {
08630 ret = image->copy();
08631 }
08632 }
08633 return ret;
08634
08635 }
|
|
|
Implements EMAN::Processor. Definition at line 8516 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. 08516 {
08517 int ndim = image->get_ndim();
08518 if (ndim != 2 && ndim != 3) throw UnexpectedBehaviorException("The Scale Transform processors only works for 2D and 3D images");
08519
08520 if ( image->get_xsize() != image->get_ysize()) {
08521 throw ImageDimensionException("x size and y size of image do not match. This processor only works for uniformly sized data");
08522 }
08523 if ( ndim == 3 ) {
08524 if ( image->get_xsize() != image->get_zsize()) {
08525 throw ImageDimensionException("x size and z size of image do not match. This processor only works for uniformly sized data");
08526 }
08527 }
08528
08529 float scale = params.set_default("scale",0.0f);
08530 if (scale <= 0.0f) throw InvalidParameterException("The scale parameter must be greater than 0");
08531
08532 int clip = 0;
08533
08534 if(params.has_key("clip"))
08535 {
08536 clip = params["clip"];
08537 if (clip < 0) throw InvalidParameterException("The clip parameter must be greater than 0"); // If it's zero it's not used
08538 }
08539 else
08540 {
08541 clip = (int)(scale*image->get_xsize());
08542 }
08543
08544 Region r;
08545 if (ndim == 3) {
08546 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2,clip, clip,clip);
08547 } else { // ndim == 2 guaranteed by check at beginning of function
08548 r = Region( (image->get_xsize()-clip)/2, (image->get_xsize()-clip)/2, clip, clip);
08549 }
08550
08551 if (scale > 1) {
08552 if ( clip != 0) {
08553 image->clip_inplace(r);
08554 }
08555 Transform t;
08556 t.set_scale(scale);
08557 image->process_inplace("xform",Dict("transform",&t));
08558 } else if (scale < 1) {
08559 Transform t;
08560 t.set_scale(scale);
08561 image->process_inplace("xform",Dict("transform",&t));
08562 if ( clip != 0) {
08563 image->clip_inplace(r);
08564 }
08565 } else {
08566 if ( clip != 0) {
08567 image->clip_inplace(r);
08568 }
08569 }
08570 }
|
|
|
Definition at line 88 of file processor.cpp. |
1.3.9.1