Bsoft  1.9
Bernard's software package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
img_complex.h File Reference

Functions to handle complex data sets. More...

#include "rwimg.h"
#include "kernel.h"
#include "Complex.h"

Go to the source code of this file.

Functions

int img_complex_product (Bimage *p, Bimage *p2)
 Calculates the complex product of two complex images. More...
 
int img_complex_conjugate_product (Bimage *p, Bimage *p2)
 Calculates the product of a complex image with the conjugate of a second. More...
 
int img_complex_apply_mask (Bimage *p, Bimage *pmask)
 Applies a mask to a complex image. More...
 
int img_complex_apply_negative_mask (Bimage *p, Bimage *pmask)
 Applies a mask to a complex image. More...
 
int img_complex_apply_dual_mask (Bimage *p, Bimage *pmask)
 Applies a dual mask to a complex image. More...
 
int img_complex_bandpass (Bimage *p, float hires, float lores)
 Bandpasses a Fourier transform. More...
 
Bimage * img_pack_two_in_complex (Bimage *p1, Bimage *p2)
 Packs two real images into one complex image. More...
 
Bimage * img_unpack_combined_transform (Bimage *p)
 Unpacks a complex transform obtained from two real images. More...
 
int img_combined_complex_product (Bimage *p)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int img_combined_masked_complex_product (Bimage *p, Bimage *pmask)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int img_combined_bandpass_complex_product (Bimage *p, float hires, float lores)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
int img_combined_bandpass_masked_complex_product (Bimage *p, float hires, float lores, Bimage *pmask)
 Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images. More...
 
double img_merge_amplitudes_and_phases (Bimage *pamp, Bimage *p)
 Merges the amplitudes from one map with the phases of another. More...
 
double img_merge_amplitudes_and_phases (Bimage *p, Bimage *pref, float res_hi, float res_lo)
 Keeps selected phases and replaces amplitudes and other phases from a reference transform. More...
 

Detailed Description

Functions to handle complex data sets.

Author
Bernard Heymann
Date
Created: 19990424 Modified: 20120214

Definition in file img_complex.h.

Function Documentation

int img_combined_bandpass_complex_product ( Bimage *  p,
float  hires,
float  lores 
)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
*pimage (replaced by new image).
hireshigh resolution limit.
loreslow resolution limit.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function img_pack_two_in_complex and then
    transformed with the function img_fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms within
the resolution limits, yielding the correlation coefficient when
the product is backtransformed into the cross-correlation map.

Definition at line 589 of file img_complex.cpp.

int img_combined_bandpass_masked_complex_product ( Bimage *  p,
float  hires,
float  lores,
Bimage *  pmask 
)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
*pimage (replaced by new image).
hireshigh resolution limit.
loreslow resolution limit.
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function img_pack_two_in_complex and then
    transformed with the function img_fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms within
the resolution limits, yielding the correlation coefficient when
the product is backtransformed into the cross-correlation map.

Definition at line 712 of file img_complex.cpp.

int img_combined_complex_product ( Bimage *  p)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
*pimage (replaced by new image).
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function img_pack_two_in_complex and then
    transformed with the function img_fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms, yielding 
the correlation coefficient when the product is backtransformed into 
the cross-correlation map.

Definition at line 404 of file img_complex.cpp.

int img_combined_masked_complex_product ( Bimage *  p,
Bimage *  pmask 
)

Calculates the complex conjugate product of a complex image resulting from combining and Fourier transforming two real space images.

Parameters
*pimage (replaced by new image).
*pmaskbinary mask (only 0 and 1), NULL if not desired.
Returns
int error code.
Requirement: Fourier transform of two images packed into one complex
    data block with the function img_pack_two_in_complex and then
    transformed with the function img_fft.
The Friedel relationships in transforms from real space images are
exploited to transform two images simultaneously and then extract
the individual transforms from the complex data set.
This function extracts the individual transforms and calculates the 
complex conjugate product used in cross-correlation.
The result is scaled by the total power of the two transforms, yielding 
the correlation coefficient when the product is backtransformed into 
the cross-correlation map.

Definition at line 494 of file img_complex.cpp.

int img_complex_apply_dual_mask ( Bimage *  p,
Bimage *  pmask 
)

Applies a dual mask to a complex image.

Parameters
*pcomplex image (replaced by new image).
*pmaskmask (converted to floating point).
Returns
int error code.
The mask is applied to an image, generating two images, the first 
with values retained where the mask is positive, and the second with
values where the mask is negative.
The input image is replaced and the second is created and linked to
the first.
Requirement: The two input images must be the same size.
No statistics are calculated.

Definition at line 155 of file img_complex.cpp.

int img_complex_apply_mask ( Bimage *  p,
Bimage *  pmask 
)

Applies a mask to a complex image.

Parameters
*pcomplex image (replaced by new image).
*pmaskmask (converted to floating point).
Returns
int error code.
Wherever the mask is <= 0, the data is set to zero.
Requirement: The two images must be the same size.
No statistics are calculated.

Definition at line 91 of file img_complex.cpp.

int img_complex_apply_negative_mask ( Bimage *  p,
Bimage *  pmask 
)

Applies a mask to a complex image.

Parameters
*pcomplex image (replaced by new image).
*pmaskmask (converted to floating point).
Returns
int error code.
Wherever the mask is >= 0, the data is set to zero.
Requirement: The two images must be the same size.
No statistics are calculated.

Definition at line 121 of file img_complex.cpp.

int img_complex_bandpass ( Bimage *  p,
float  hires,
float  lores 
)

Bandpasses a Fourier transform.

Parameters
*pimage (replaced by new image).
hireshigh resolution limit.
loreslow resolution limit.
Returns
int error code.
Requirement: a complex Fourier transform.
All data outside the band limits are set to zero.

Definition at line 190 of file img_complex.cpp.

int img_complex_conjugate_product ( Bimage *  p,
Bimage *  p2 
)

Calculates the product of a complex image with the conjugate of a second.

Parameters
*pfirst complex image (replaced by new image).
*p2second complex image.
Returns
int error code.
Complex conjugate product:
    (a + ib)*(c - id) = (a*c + b*d) + i(b*c - a*d).
Requirement: The two images must be the same size.
No statistics are calculated.

Definition at line 61 of file img_complex.cpp.

int img_complex_product ( Bimage *  p,
Bimage *  p2 
)

Calculates the complex product of two complex images.

Parameters
*pfirst complex image (replaced by new image).
*p2second complex image.
Returns
int error code.
Complex product:
    (a + ib)*(c + id) = (a*c - b*d) + i(b*c + a*d).
Requirement: The two images must be the same size.
No statistics are calculated.

Definition at line 30 of file img_complex.cpp.

double img_merge_amplitudes_and_phases ( Bimage *  pamp,
Bimage *  p 
)

Merges the amplitudes from one map with the phases of another.

Parameters
*pampamplitude image (simple or complex).
*pimage (amplitudes replaced by new image).
Returns
double RMSD of amplitudes.
The amplitude image can be a floating point image or a complex image.
The phase image must be complex and its amplitudes are replaced by
the values from the amplitude image.
No statistics are calculated.

Definition at line 830 of file img_complex.cpp.

double img_merge_amplitudes_and_phases ( Bimage *  p,
Bimage *  pref,
float  res_hi,
float  res_lo 
)

Keeps selected phases and replaces amplitudes and other phases from a reference transform.

Parameters
*pFourier transform (replaced by new image).
*prefreference Fourier transform.
res_hihigh resolution limit.
res_lolow resolution limit.
Returns
double RMSD of amplitudes.
The input transform is considered to be modified in some way (such as solvent flattening).
Only the phases in the specified resolution shell are kept, while all
the other phases and amplitudes within the high resolution limit is
retrieved from the reference transform.
No statistics are calculated.

Definition at line 879 of file img_complex.cpp.

Bimage* img_pack_two_in_complex ( Bimage *  p1,
Bimage *  p2 
)

Packs two real images into one complex image.

Parameters
*p1first image.
*p2second image.
Returns
Bimage* the new complex image, NULL on error.
Two real space images are packed into the real and imaginary parts
of a new data block with conversion from the original non-complex type.
The header values of the first image are adopted for the new image.
No statistics are calculated.

Definition at line 255 of file img_complex.cpp.

Bimage* img_unpack_combined_transform ( Bimage *  p)

Unpacks a complex transform obtained from two real images.

Parameters
*pcombined transform, modified to hold transform of first image.
Returns
Bimage* transform of second image.
The complex image must be a Fourier transform obtained from two real 
space images which were packed into the real and imaginary parts
of the complex image before Fourier transformation.
The input image is used to hold the transform of the first image.
A new image is created to hold the transform of the second image.
Both these images are complex floating point.
Note: Images with even dimensions cannot be unpacked exactly because
    the inverse is not present when x=nx/2 or y=ny/2 or z=nz/2.

Definition at line 331 of file img_complex.cpp.