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

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual 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::TestImageProcessor
static string get_group_desc ()
 
- 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 = "testimage.noise.fourier.profile"
 

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 Member Functions inherited from EMAN::TestImageProcessor
void preprocess (EMData *image)
 
- Protected Attributes inherited from EMAN::TestImageProcessor
int nx
 
int ny
 
int nz
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Author
David Woolford
Date
June 15th 2009

Definition at line 8182 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::TestImageFourierNoiseProfile::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 8192 of file processor.h.

8193 {
8194 return "Replace a source image with Fourier noise using amplitude information that is stored in a profile.";
8195 }

◆ get_name()

virtual string EMAN::TestImageFourierNoiseProfile::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 8187 of file processor.h.

8188 {
8189 return NAME;
8190 }

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::TestImageFourierNoiseProfile::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 8202 of file processor.h.

8203 {
8204 TypeDict d;
8205 d.put("profile", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
8206 return d;
8207 }
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::FLOATARRAY, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 8197 of file processor.h.

◆ process_inplace()

void TestImageFourierNoiseProfile::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 9180 of file processor.cpp.

9180 {
9181
9182 if (params.has_key("profile")==false) throw InvalidParameterException("You must supply the profile argument");
9183
9184 if (!image->is_complex()) {
9185 int nx = image->get_xsize();
9186 int offset = 2 - nx%2;
9187
9188 image->set_size(nx+offset,image->get_ysize(),image->get_zsize());
9189 image->set_complex(true);
9190 if (1 == offset) image->set_fftodd(true);
9191 else image->set_fftodd(false);
9192 image->set_fftpad(true);
9193 }
9194 image->to_zero();
9195 image->ri2ap();
9196
9197 vector<float> profile = params["profile"];
9198 transform(profile.begin(),profile.end(),profile.begin(),sqrtf);
9199
9200 int i = static_cast<int>(profile.size());
9201
9202 float * d = image->get_data();
9203 int nx = image->get_xsize();
9204 int ny = image->get_ysize();
9205 int nxy = image->get_ysize()*nx;
9206 int nzon2 = image->get_zsize()/2;
9207 int nyon2 = image->get_ysize()/2;
9208 float rx, ry, rz, amp, phase;
9209 int length;
9210 int twox;
9211 for (int z = 0; z< image->get_zsize(); ++z) {
9212 for (int y = 0; y < image->get_ysize(); ++y) {
9213 for (int x = 0; x < image->get_xsize()/2; ++x) {
9214 rx = (float)x;
9215 ry = (float)nyon2 - (float)y;
9216 rz = (float)nzon2 - (float)z;
9217 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
9218
9219 twox = 2*x;
9220 size_t idx1 = twox + y*nx+(size_t)z*nxy;
9221 size_t idx2 = idx1 + 1;
9222
9223
9224 if (length >= i) {
9225 d[idx1] = 0;
9226 d[idx2] = 0;
9227 continue;
9228 }
9229 amp = profile[length];
9230 phase = Util::get_frand(0,1)*2*M_PI;
9231
9232
9233 d[idx1] = amp;
9234 d[idx2] = phase;
9235
9236 }
9237 }
9238 }
9239
9240 image->ap2ri();
9241 if (image->get_ndim() == 2) {
9242 bool yodd = image->get_ysize() % 2 == 1;
9243
9244 int yit = image->get_ysize()/2-1;
9245 int offset = 1;
9246 if (yodd) {
9247 offset = 0;
9248 }
9249 for (int y = 0; y < yit; ++y) {
9250 int bot_idx = (y+offset)*nx;
9251 int top_idx = (ny-1-y)*nx;
9252 float r1 = d[bot_idx];
9253 float i1 = d[bot_idx+1];
9254 float r2 = d[top_idx];
9255 float i2 = d[top_idx+1];
9256 float r = (r1 + r2)/2.0f;
9257 float i = (i1 + i2)/2.0f;
9258 d[bot_idx] = r;
9259 d[top_idx] = r;
9260 d[bot_idx+1] = i;
9261 d[top_idx+1] = -i;
9262
9263 bot_idx = (y+offset)*nx+nx-2;
9264 top_idx = (ny-1-y)*nx+nx-2;
9265 r1 = d[bot_idx];
9266 i1 = d[bot_idx+1];
9267 r2 = d[top_idx];
9268 i2 = d[top_idx+1];
9269 r = (r1 + r2)/2.0f;
9270 i = (i1 + i2)/2.0f;
9271 d[bot_idx] = r;
9272 d[top_idx] = r;
9273 d[bot_idx+1] = i;
9274 d[top_idx+1] = -i;
9275 }
9276
9277 d[1] = 0; // 0 phase for this componenet
9278 d[nx-1] = 0; // 0 phase for this component
9279 d[ny/2*nx+nx-1] = 0;// 0 phase for this component
9280 d[ny/2*nx+1] = 0;// 0 phase for this component
9281 }
9282
9283 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
9284 image->do_ift_inplace();
9285 image->depad();
9286}
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
static float get_frand(int low, int high)
Get a float random number between low and high, [low, high)
Definition: util.cpp:725
EMData * sqrt() const
return square root of current image
EMData * phase() const
return phase part of a complex image as a real image format
#define InvalidParameterException(desc)
Definition: exception.h:361
double length(const Vector3 &v)
Definition: vecmath.h:313
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::get_frand(), EMAN::Dict::has_key(), InvalidParameterException, EMAN::length(), EMAN::TestImageProcessor::nx, EMAN::TestImageProcessor::ny, EMAN::Processor::params, phase(), sqrt(), x, and y.

Member Data Documentation

◆ NAME

const string TestImageFourierNoiseProfile::NAME = "testimage.noise.fourier.profile"
static

Definition at line 8209 of file processor.h.

Referenced by get_name().


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