Both images should be FFTs.
Computes a CCC excluding pixels with very small value (assumes they are missing wedge) Returns overlap amount as "fft_overlap" in "image"
- Date
- 2010-10-18
Definition at line 393 of file cmp.h.
float TomoWedgeFscCmp::cmp |
( |
EMData * |
image, |
|
|
EMData * |
with |
|
) |
| const |
|
virtual |
To compare 'image' with another image passed in through its parameters.
An optional transformation may be used to transform the 2 images.
- Parameters
-
image | The first image to be compared. |
with | The second image to be comppared. |
- Returns
- The comparison result. Smaller better by default
Implements EMAN::Cmp.
Definition at line 748 of file cmp.cpp.
753 if (!image->is_complex()) image=image->do_fft();
754 if (!with ->
is_complex()) with =with ->do_fft();
755 if (image->get_xsize()!=with->get_xsize() || image->get_ysize()!=with->get_ysize() || image->get_zsize()!=with->get_zsize())
throw InvalidCallException(
"Error: TomoWedgeFscCmp requires 2 images the same size");
757 int nx=image->get_xsize();
758 int ny=image->get_ysize();
759 int nz=image->get_zsize();
768 vector<float> sigmaimg;
772 for (
int i=0; i<nx/2; i++) sigmaimg[i]*=sigmaimg[i]*sigmaimgval;
775 vector<float> sigmawith;
779 for (
int i=0; i<nx/2; i++) sigmawith[i]*=sigmawith[i]*sigmawithval;
791 pmin=(int)floor((apix*ny)/minres);
793 pmax=(int)ceil((apix*ny)/maxres);
801 vector<float> curve(nx/2), sqcv1(nx/2), sqcv2(nx/2);
802 for (
int z=0; z<nz; z++) {
803 int za=z<nz/2?z:nz-z;
804 if (za>pmax)
continue;
805 for (
int y=0;
y<ny;
y++) {
806 int ya=
y<ny/2?
y:ny-
y;
807 if (ya>pmax)
continue;
808 for (
int x=0;
x<nx;
x+=2) {
810 int r=int(sqrtf(r2));
813 if (r<pmin || r>pmax)
continue;
815 float v1r=image->get_value_at(
x,
y,z);
816 float v1i=image->get_value_at(
x+1,
y,z);
818 if (v1<sigmaimg[r])
continue;
820 float v2r=with->get_value_at(
x,
y,z);
821 float v2i=with->get_value_at(
x+1,
y,z);
823 if (v2<sigmawith[r])
continue;
825 sum+=(v1r*v2r+v1i*v2i)/r2;
831 curve[r]+=v1r*v2r+v1i*v2i;
838 image->set_attr(
"fft_overlap",(
float)(2.0*norm/(image->get_xsize()*image->get_ysize()*image->get_zsize())));
841 for(
int i=0; i<nx/2; i++){
842 if (sqcv1[i]==0) sqcv1[i]=1;
843 if (sqcv2[i]==0) sqcv2[i]=1;
844 curve[i]=curve[i]/(
sqrt(sqcv1[i])*
sqrt(sqcv2[i]));
846 image->set_attr(
"fsc_curve", curve);
849 if (imageo!=image)
delete image;
850 if (witho!=with)
delete with;
852 if (negative) sum*=-1.0;
853 return float(sum/(
sqrt(sumsq1)*
sqrt(sumsq2)));
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...
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
EMData stores an image's data and defines core image processing routines.
vector< float > calc_radial_dist(int n, float x0, float dx, int inten)
calculates radial distribution.
static int hypot3sq(int x, int y, int z)
Euclidean distance function squared in 3D: f(x,y,z) = (x*x + y*y + z*z);.
static float square_sum(float x, float y)
Calcuate (x*x + y*y).
EMData * sqrt() const
return square root of current image
#define InvalidCallException(desc)
References EMAN::EMData::calc_radial_dist(), ENTERFUNC, EMAN::Dict::has_key(), EMAN::Util::hypot3sq(), InvalidCallException, is_complex(), EMAN::Cmp::params, EMAN::Dict::set_default(), sqrt(), EMAN::Util::square_sum(), x, and y.
TypeDict EMAN::TomoWedgeFscCmp::get_param_types |
( |
| ) |
const |
|
inlinevirtual |
Get Cmp 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.
Implements EMAN::Cmp.
Definition at line 417 of file cmp.h.
422 d.put(
"sigmaimg",
EMObject::FLOATARRAY,
"Res dependent amplitude threshold. If provided this must contain a floating point array with as many elements as the Fourier radius of the image. ");
423 d.put(
"sigmawith",
EMObject::FLOATARRAY,
"Resolution dependent coefficient for thresholding values included in the dot product in the 'with' image. Default = 0.1 and is normally fine");
424 d.put(
"sigmaimgval",
EMObject::FLOAT,
"Sigma coefficient for thresholding values included in the dot product. default = 0.5");
425 d.put(
"sigmawithval",
EMObject::FLOAT,
"Sigma coefficient for thresholding values included in the dot product in the 'with' image. Default = 0.5");
426 d.put(
"minres",
EMObject::FLOAT,
"The minimum resolution to accept (1/A) Default is 3 pixels. overwrites pmin");
427 d.put(
"maxres",
EMObject::FLOAT,
"The maximum resolution to accept (1/A) Default is axial Nyquist. overwrites pmax");
428 d.put(
"pmin",
EMObject::INT,
"The minimum resolution in pixels.");
429 d.put(
"pmax",
EMObject::INT,
"The maximum resolution in pixels.");
430 d.put(
"retcurve",
EMObject::BOOL,
"Return fsc curve in image header");
References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::EMObject::FLOATARRAY, EMAN::EMObject::INT, and EMAN::TypeDict::put().