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

Try to eliminate beamstop in electron diffraction patterns. More...

#include <processor.h>

Inheritance diagram for EMAN::BeamstopProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::BeamstopProcessor:
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.beamstop"
 

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

Try to eliminate beamstop in electron diffraction patterns.

If value1<0 also does radial subtract.

Parameters
value1sig multiplier
value2x of center
value3y of center

Definition at line 5589 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::BeamstopProcessor::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 5604 of file processor.h.

5605 {
5606 return "Try to eliminate beamstop in electron diffraction patterns. value1=sig multiplier; value2,value3 are x,y of center, if value1<0 also does radial subtract.";
5607 }

◆ get_name()

string EMAN::BeamstopProcessor::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 5594 of file processor.h.

5595 {
5596 return NAME;
5597 }
static const string NAME
Definition: processor.h:5618

References NAME.

◆ get_param_types()

TypeDict EMAN::BeamstopProcessor::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 5609 of file processor.h.

5610 {
5611 TypeDict d;
5612 d.put("value1", EMObject::FLOAT, "sig multiplier");
5613 d.put("value2", EMObject::FLOAT, "x of center");
5614 d.put("value3", EMObject::FLOAT, "y of center");
5615 return d;
5616 }
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::FLOAT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 5599 of file processor.h.

5600 {
5601 return new BeamstopProcessor();
5602 }
Try to eliminate beamstop in electron diffraction patterns.
Definition: processor.h:5590

◆ process_inplace()

void BeamstopProcessor::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 4227 of file processor.cpp.

4228{
4229 if (!image) {
4230 LOGWARN("NULL Image");
4231 return;
4232 }
4233 if (image->get_zsize() > 1) {
4234 LOGERR("BeamstopProcessor doesn't support 3D model");
4235 throw ImageDimensionException("3D model not supported");
4236 }
4237
4238 float value1 = params["value1"];
4239 float value2 = params["value2"];
4240 float value3 = params["value3"];
4241
4242 float thr = fabs(value1);
4243 float *data = image->get_data();
4244 int cenx = (int) value2;
4245 int ceny = (int) value3;
4246
4247 int nx = image->get_xsize();
4248 int ny = image->get_ysize();
4249
4250 if (cenx <= 0) {
4251 cenx = nx / 2;
4252 }
4253
4254 if (ceny <= 0) {
4255 ceny = ny / 2;
4256 }
4257
4258 int mxr = (int) floor(sqrt(2.0f) * nx / 2);
4259
4260 float *mean_values = new float[mxr];
4261 float *sigma_values = new float[mxr];
4262 double sum = 0;
4263 int count = 0;
4264 double square_sum = 0;
4265
4266 for (int i = 0; i < mxr; i++) {
4267 sum = 0;
4268 count = 0;
4269 square_sum = 0;
4270 int nitems = 6 * i + 2;
4271
4272 for (int j = 0; j < nitems; j++) {
4273 float ang = j * 2 * M_PI / nitems;
4274 int x0 = (int) floor(cos(ang) * i + cenx);
4275 int y0 = (int) floor(sin(ang) * i + ceny);
4276
4277 if (x0 < 0 || y0 < 0 || x0 >= nx || y0 >= ny) {
4278 continue;
4279 }
4280
4281 float f = data[x0 + y0 * nx];
4282 sum += f;
4283 square_sum += f * f;
4284 count++;
4285 }
4286
4287 mean_values[i] = (float)sum / count;
4288 sigma_values[i] = (float) sqrt(square_sum / count - mean_values[i] * mean_values[i]);
4289 }
4290
4291
4292 for (int k = 0; k < 5; k++) {
4293 for (int i = 0; i < mxr; i++) {
4294 sum = 0;
4295 count = 0;
4296 square_sum = 0;
4297 int nitems = 6 * i + 2;
4298 double thr1 = mean_values[i] - sigma_values[i] * thr;
4299 double thr2 = mean_values[i] + sigma_values[i];
4300
4301 for (int j = 0; j < nitems; j++) {
4302 float ang = j * 2 * M_PI / nitems;
4303 int x0 = (int) floor(cos(ang) * i + cenx);
4304 int y0 = (int) floor(sin(ang) * i + ceny);
4305
4306 if (x0 < 0 || y0 < 0 || x0 >= nx || y0 >= ny ||
4307 data[x0 + y0 * nx] < thr1 || data[x0 + y0 * nx] > thr2) {
4308 continue;
4309 }
4310
4311 sum += data[x0 + y0 * nx];
4312 square_sum += data[x0 + y0 * nx] * data[x0 + y0 * nx];
4313 count++;
4314 }
4315
4316 mean_values[i] = (float) sum / count;
4317 sigma_values[i] = (float) sqrt(square_sum / count - mean_values[i] * mean_values[i]);
4318 }
4319 }
4320
4321 for (int i = 0; i < nx; i++) {
4322 for (int j = 0; j < ny; j++) {
4323
4324 int r = Util::round(hypot((float) i - cenx, (float) j - ceny));
4325
4326 if (value1 < 0) {
4327 if (data[i + j * nx] < (mean_values[r] - sigma_values[r] * thr)) {
4328 data[i + j * nx] = 0;
4329 }
4330 else {
4331 data[i + j * nx] -= mean_values[r];
4332 }
4333 continue;
4334 }
4335 if (data[i + j * nx] > (mean_values[r] - sigma_values[r] * thr)) {
4336 continue;
4337 }
4338 data[i + j * nx] = mean_values[r];
4339 }
4340 }
4341
4342 if( mean_values )
4343 {
4344 delete[]mean_values;
4345 mean_values = 0;
4346 }
4347
4348 if( sigma_values )
4349 {
4350 delete[]sigma_values;
4351 sigma_values = 0;
4352 }
4353
4354 image->update();
4355}
static int round(float x)
Get ceiling round of a float number x.
Definition: util.h:465
EMData * sqrt() const
return square root of current image
#define ImageDimensionException(desc)
Definition: exception.h:166
#define LOGWARN
Definition: log.h:53
#define LOGERR
Definition: log.h:51

References ImageDimensionException, LOGERR, LOGWARN, EMAN::Processor::params, EMAN::Util::round(), and sqrt().

Member Data Documentation

◆ NAME

const string BeamstopProcessor::NAME = "mask.beamstop"
static

Definition at line 5618 of file processor.h.

Referenced by get_name().


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