EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::SigmaZeroEdgeProcessor Class Reference

Fill zeroes at edges with nearest horizontal/vertical value. More...

#include <processor.h>

Inheritance diagram for EMAN::SigmaZeroEdgeProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::SigmaZeroEdgeProcessor:
Collaboration graph
[legend]

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
 
string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "mask.zeroedgefill"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Fill zeroes at edges with nearest horizontal/vertical value.

Definition at line 5520 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::SigmaZeroEdgeProcessor::get_desc ( ) const
inlinevirtual

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns
The description of this processor.

Implements EMAN::Processor.

Definition at line 5534 of file processor.h.

5535 {
5536 return "Fill zeroes at edges with nearest horizontal/vertical value.";
5537 }

◆ get_name()

string EMAN::SigmaZeroEdgeProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 5525 of file processor.h.

5526 {
5527 return NAME;
5528 }
static const string NAME
Definition: processor.h:5546

References NAME.

Referenced by process_inplace().

◆ get_param_types()

TypeDict EMAN::SigmaZeroEdgeProcessor::get_param_types ( ) const
inlinevirtual

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 5539 of file processor.h.

5540 {
5541 TypeDict d;
5542 d.put("nonzero", EMObject::BOOL, "If set, will look for constant non-zero values to fill");
5543 return d;
5544 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

References EMAN::EMObject::BOOL, and EMAN::TypeDict::put().

◆ NEW()

static Processor * EMAN::SigmaZeroEdgeProcessor::NEW ( )
inlinestatic

Definition at line 5529 of file processor.h.

5530 {
5531 return new SigmaZeroEdgeProcessor();
5532 }
Fill zeroes at edges with nearest horizontal/vertical value.
Definition: processor.h:5521

◆ process_inplace()

void SigmaZeroEdgeProcessor::process_inplace ( EMData image)
virtual

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 4045 of file processor.cpp.

4046{
4047 if (!image) {
4048 LOGWARN("NULL Image");
4049 return;
4050 }
4051
4052 if (image->get_zsize() > 1) {
4053 LOGERR("%s Processor doesn't support 3D model", get_name().c_str());
4054 throw ImageDimensionException("3D model not supported");
4055 }
4056
4057 float nonzero = params.set_default("nonzero",false);
4058
4059 float *d = image->get_data();
4060 int i = 0;
4061 int j = 0;
4062
4063 int nx = image->get_xsize();
4064 int ny = image->get_ysize();
4065
4066 float zval=9.99e23f; // we're assuming we won't run into this exact value for an edge, not great programming, but good enough
4067 if (nonzero) {
4068 int x,y;
4069 size_t corn=nx*ny-1;
4070
4071 // this set of 4 tests looks for any edges with exactly the same value
4072 for (x=1; x<nx; x++) { if (d[x]!=d[0]) break;}
4073 if (x==nx) zval=d[0];
4074
4075 for (y=1; y<ny; y++) { if (d[y*nx]!=d[0]) break; }
4076 if (y==ny) zval=d[0];
4077
4078 for (x=1; x<nx; x++) { if (d[corn-x]!=d[corn]) break;}
4079 if (x==nx) zval=d[corn];
4080
4081 for (y=1; y<ny; y++) { if (d[corn-y*nx]!=d[corn]) break; }
4082 if (y==ny) zval=d[corn];
4083
4084 if (zval!=9.99e23f) {
4085 image->set_attr("hadzeroedge",1);
4086// printf("zeroedge %f\n",zval);
4087
4088 }
4089 else image->set_attr("hadzeroedge",0);
4090
4091 // This tries to detect images where the edges have been filled with the nearest non-zero value. The filter does nothing, but we set the tag.
4092 for (x=nx/2-5; x<nx/2+5; x++) {
4093 if (d[x]!=d[x+nx] || d[x]!=d[x+nx*2] ) break;
4094 }
4095 if (x==nx/2+5) image->set_attr("hadzeroedge",2);
4096
4097 for (x=nx/2-5; x<nx/2+5; x++) {
4098 if (d[corn-x]!=d[corn-x-nx] || d[corn-x]!=d[corn-x-nx*2]) break;
4099 }
4100 if (x==nx/2+5) image->set_attr("hadzeroedge",2);
4101
4102 for (y=ny/2-5; y<ny/2+5; y++) {
4103 if (d[y*nx]!=d[y*nx+1] || d[y*nx]!=d[y*nx+2] ) break;
4104 }
4105 if (y==ny/2+5) image->set_attr("hadzeroedge",2);
4106
4107 for (y=ny/2-5; y<ny/2+5; y++) {
4108 if (d[corn-y*nx]!=d[corn-y*nx-1] || d[corn-y*nx]!=d[corn-y*nx-2]) break;
4109 }
4110 if (y==ny/2+5) image->set_attr("hadzeroedge",2);
4111
4112 }
4113 if (zval==9.99e23f) zval=0;
4114
4115 for (j = 0; j < ny; j++) {
4116 for (i = 0; i < nx - 1; i++) {
4117 if (d[i + j * nx] != zval) {
4118 break;
4119 }
4120 }
4121
4122 float v = d[i + j * nx];
4123 while (i >= 0) {
4124 d[i + j * nx] = v;
4125 i--;
4126 }
4127
4128 for (i = nx - 1; i > 0; i--) {
4129 if (d[i + j * nx] != zval)
4130 break;
4131 }
4132 v = d[i + j * nx];
4133 while (i < nx) {
4134 d[i + j * nx] = v;
4135 i++;
4136 }
4137 }
4138
4139 for (i = 0; i < nx; i++) {
4140 for (j = 0; j < ny; j++) {
4141 if (d[i + j * nx] != zval)
4142 break;
4143 }
4144
4145 float v = d[i + j * nx];
4146 while (j >= 0) {
4147 d[i + j * nx] = v;
4148 j--;
4149 }
4150
4151 for (j = ny - 1; j > 0; j--) {
4152 if (d[i + j * nx] != zval)
4153 break;
4154 }
4155 v = d[i + j * nx];
4156 while (j < ny) {
4157 d[i + j * nx] = v;
4158 j++;
4159 }
4160 }
4161
4162
4163 image->update();
4164}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
string get_name() const
Get the processor's name.
Definition: processor.h:5525
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGWARN
Definition: log.h:53
#define LOGERR
Definition: log.h:51
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References get_name(), ImageDimensionException, LOGERR, LOGWARN, EMAN::Processor::params, EMAN::Dict::set_default(), x, and y.

Member Data Documentation

◆ NAME

const string SigmaZeroEdgeProcessor::NAME = "mask.zeroedgefill"
static

Definition at line 5546 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: