#include <processor.h>
Inheritance diagram for EMAN::TestImageFourierNoiseGaussian:
Public Member Functions | |
virtual void | process_inplace (EMData *image) |
To process an image in-place. | |
virtual string | get_name () const |
Get the processor's name. | |
virtual string | get_desc () const |
Get the descrition of this specific processor. | |
virtual TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "testimage.noise.fourier.gaussian" |
sigma | sigma value for this Gaussian blob |
Definition at line 5791 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 5801 of file processor.h. 05802 { 05803 return "Replace a source image with pink Fourier noise, based on a Gaussian. Random phase."; 05804 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5796 of file processor.h. 05797 {
05798 return NAME;
05799 }
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 5811 of file processor.h. References EMAN::TypeDict::put(). 05812 { 05813 TypeDict d; 05814 d.put("sigma", EMObject::FLOAT, "sigma value"); 05815 return d; 05816 }
|
|
Definition at line 5806 of file processor.h. 05807 { 05808 return new TestImageFourierNoiseGaussian(); 05809 }
|
|
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.
Implements EMAN::Processor. Definition at line 6685 of file processor.cpp. References EMAN::EMData::ap2ri(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::get_data(), EMAN::Util::get_frand(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::is_complex(), EMAN::length(), nx, ny, phase(), EMAN::EMData::process_inplace(), EMAN::EMData::ri2ap(), EMAN::EMData::set_complex(), EMAN::Dict::set_default(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_size(), sqrt(), x, and y. 06686 { 06687 if (!image->is_complex()) { 06688 int nx = image->get_xsize(); 06689 int offset = 2 - nx%2; 06690 06691 image->set_size(nx+offset,image->get_ysize(),image->get_zsize()); 06692 image->set_complex(true); 06693 if (1 == offset) image->set_fftodd(true); 06694 else image->set_fftodd(false); 06695 image->set_fftpad(true); 06696 } 06697 image->ri2ap(); 06698 06699 float sigma = params.set_default("sigma",.25f); 06700 06701 float * d = image->get_data(); 06702 int nx = image->get_xsize(); 06703 int ny = image->get_ysize(); 06704 int nxy = image->get_ysize()*nx; 06705 int nzon2 = image->get_zsize()/2; 06706 int nyon2 = image->get_ysize()/2; 06707 float rx, ry, rz, length, amp, phase; 06708 int twox; 06709 for (int z = 0; z< image->get_zsize(); ++z) { 06710 for (int y = 0; y < image->get_ysize(); ++y) { 06711 for (int x = 0; x < image->get_xsize()/2; ++x) { 06712 rx = (float)x; 06713 ry = (float)nyon2 - (float)y; 06714 rz = (float)nzon2 - (float)z; 06715 length = sqrt(rx*rx + ry*ry + rz*rz); 06716 amp = exp(-sigma*length); 06717 phase = Util::get_frand(0,1)*2*M_PI; 06718 06719 twox = 2*x; 06720 size_t idx1 = twox + y*nx+(size_t)z*nxy; 06721 size_t idx2 = idx1 + 1; 06722 d[idx1] = amp; 06723 d[idx2] = phase; 06724 06725 } 06726 } 06727 } 06728 06729 image->ap2ri(); 06730 if (image->get_ndim() == 2) { 06731 bool yodd = image->get_ysize() % 2 == 1; 06732 06733 int yit = image->get_ysize()/2-1; 06734 int offset = 1; 06735 if (yodd) { 06736 offset = 0; 06737 } 06738 for (int y = 0; y < yit; ++y) { 06739 int bot_idx = (y+offset)*nx; 06740 int top_idx = (ny-1-y)*nx; 06741 float r1 = d[bot_idx]; 06742 float i1 = d[bot_idx+1]; 06743 float r2 = d[top_idx]; 06744 float i2 = d[top_idx+1]; 06745 float r = (r1 + r2)/2.0f; 06746 float i = (i1 + i2)/2.0f; 06747 d[bot_idx] = r; 06748 d[top_idx] = r; 06749 d[bot_idx+1] = i; 06750 d[top_idx+1] = -i; 06751 06752 bot_idx = (y+offset)*nx+nx-2; 06753 top_idx = (ny-1-y)*nx+nx-2; 06754 r1 = d[bot_idx]; 06755 i1 = d[bot_idx+1]; 06756 r2 = d[top_idx]; 06757 i2 = d[top_idx+1]; 06758 r = (r1 + r2)/2.0f; 06759 i = (i1 + i2)/2.0f; 06760 d[bot_idx] = r; 06761 d[top_idx] = r; 06762 d[bot_idx+1] = i; 06763 d[top_idx+1] = -i; 06764 } 06765 06766 d[1] = 0; // 0 phase for this componenet 06767 d[nx-1] = 0; // 0 phase for this component 06768 d[ny/2*nx+nx-1] = 0;// 0 phase for this component 06769 d[ny/2*nx+1] = 0;// 0 phase for this component 06770 } 06771 06772 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner"); 06773 image->do_ift_inplace(); 06774 image->depad(); 06775 }
|
|
Definition at line 191 of file processor.cpp. |