| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Functions
img_polar.h File Reference

Library routines for polar and spherical transformations and calculations. More...

`#include "rwimg.h"`
`#include "symmetry.h"`

Go to the source code of this file.

## Functions
int | img_cartesian_to_spherical (Bimage *p, int nannuli, int ntheta, int nphi)
| Calculates an image with spherical coordinates. More...
int | img_cartesian_to_cylindrical (Bimage *p, int nannuli, int nphi)
| Calculates an image with cylindrical coordinates. More...
int | img_radial_shells (Bimage *p)
| Calculates an image with slices representing radial shell projections. More...
int | img_cylindrical_shells (Bimage *p)
| Calculates an image with slices representing cylindrical shell projections. More...
Bimage * | img_radial_sections (Bimage *p, double rad_start, double rad_end, double rad_step, double spherical_fraction, Bstring &symmetry_string)
| Calculates an image with slices giving the radial section projections. More...
Bimage * | img_polar_transform (Bimage *p, int nannuli, int nangles, int ann_min, int ann_max)
| Transforms a cartesian image to polar or cylindrical coordinates. More...
Bimage * | img_polar_power_spectrum (Bimage *p, int nannuli, int npsi, int transform_flag, int norm_flag)
| Calculates the polar power spectrum from a Fourier transform. More...
Bimage * | img_polar_power_spectrum (Bimage *p, double resolution, long num_angle)
| Calculates the polar power spectrum of an image. More...
Bimage * | img_polar2D (Bimage *p, int nannuli, int nseg)
| Calculates radial segment averages from an image. More...

## Detailed Description

Library routines for polar and spherical transformations and calculations.

Author
  Bernard Heymann

Date
  Created: 19990904 Modified: 20140710

Definition in file img_polar.h.

## Function Documentation

int img_cartesian_to_cylindrical | ( | Bimage * | p,
|  | int | nannuli,
|  | int | nphi
| ) |  |

Calculates an image with cylindrical coordinates.

Parameters

  *p | 3D image (converted).
  nannuli | number of annuli.
  nphi | number of phi angles.

Returns
  int 0.

      The image is converted to cylindrical form with a specified number of
      annuli and angles.
      A point vector p = {x,y,z} with respect to the image origin (typically
      the center of the image) is converted to cylindrical coordinates as follows:
          The distance from the z-origin gives the annulus:
              |p| = sqrt(x*x+y*y)
          Phi is the rotation angle around the z-axis, starting at the x-axis:
              phi = atan(y/x)
          The z-coordinate remains unchanged.
      The new dimensions are mapped as follows with their maximum ranges:
          |p|   ===> x_dimension (0 - max(x_size,y_size,z_size)
          phi   ===> y_dimension (0 - 2*PI)
          z     ===> z_dimension
      The sampling within these ranges are given by the calling function.
      The sampling must be isotropic.
      The origins within the sub-image structures are used.
      The interpolation routine actually calculates the old cartesian
      coordinates for each set of cylindrical coordinates.

Definition at line 154 of file img_polar.cpp.

int img_cartesian_to_spherical | ( | Bimage * | p,
|  | int | nannuli,
|  | int | nphi,
|  | int | ntheta
| ) |  |

Calculates an image with spherical coordinates.

Parameters

  *p | 3D image (converted).
  nannuli | number of annuli.
  nphi | number of phi angles.
  ntheta | number of theta angles.

Returns
  int 0.

      The image is converted to polar form with a specified number of annuli
      and angles in one (a 2D image) or two (a 3D map) directions. The
      angular convention is consistent with the Euler angles used for 3D
      image processing.
      A point vector p = {x,y,z} with respect to the image origin (typically
      the center of the image) is converted to polar coordinates as follows:
          The size of the vector gives the annulus:
              |p| = sqrt(x*x+y*y+z*z)
          Phi is the rotation angle around the z-axis, starting at the x-axis:
              phi = atan(y/x)
          Theta is the angle between the positive z-axis and the point vector:
              theta = acos(z/|p|)
      The new dimensions are mapped as follows with their maximum ranges:
          |p|   ===> x_dimension (0 - max(x_size,y_size,z_size)
          phi   ===> y_dimension (0 - 2*PI)
          theta ===> z_dimension (0 - PI)
      The sampling within these ranges are given by the calling function.
      The sampling must be isotropic.
      The origins within the sub-image structures are used.
      The interpolation routine actually calculates the old cartesian
      coordinates for each set of spherical coordinates.

Definition at line 50 of file img_polar.cpp.

int img_cylindrical_shells | ( | Bimage * | p | ) |

Calculates an image with slices representing cylindrical shell projections.

Parameters

  *p | 3D image (converted).

Returns
  int 0.

      The 3D image is converted so that the sections contain 2D projections
      of cylindrical shells. The projection in slice i is defined for:
          i >= sqrt(x^2 + y^2)
      The first projection is placed at the z origin and radiates out into
      both positive and negative directions.
      Sampling in x and y is not changed.
      The sampling must be isotropic.

Definition at line 327 of file img_polar.cpp.

Bimage* img_polar2D | ( | Bimage * | p,
|  | int | nannuli,
|  | int | nseg
| ) |  |

Calculates radial segment averages from an image.

Parameters

  *p | 2D image.
  nannuli | number of annuli.
  nseg | number of segments.

Returns
  Bimage* the polar 2D image.

      An integrative method is used to calculate radial segment averages.
      Restrictions: The data type may not be complex.
      The x-axis in the polar image represents the annulus and the y-axis
      represents the angle.
      A new image is returned.

Definition at line 874 of file img_polar.cpp.

Bimage* img_polar_power_spectrum | ( | Bimage * | p,
|  | int | nannuli,
|  | int | npsi,
|  | int | transform_flag,
|  | int | norm_flag
| ) |  |

Calculates the polar power spectrum from a Fourier transform.

Parameters

  *p | 2D/3D Fourier transform or power spectrum.
  nannuli | number of annuli or radii.
  npsi | number of angles.
  transform_flag | flag causing transformation first.
  norm_flag | flag to normalize each annulus by its maximum.

Returns
  Bimage* radial power spectrum in the form of a 2D image.

      A polar power spectrum of a 2D Fourier transform is calculated.
      An interpolative method is used where the value at a specific
      radius and angle is obtained from contributions of the four
      surrounding pixels in the original image. To overcome the sparse
      sampling at high annuli, a large annulus is first extracted by
      interpolation and then averaged for each segment.
      The x-axis in the polar image represents the angle and the y-axis
      represents the annulus.
      Each annulus may be normalized by the maximum in the annulus.
      The first angle is zero and the angular step size is 2*pi/npsi.

Definition at line 673 of file img_polar.cpp.

Bimage* img_polar_power_spectrum | ( | Bimage * | p,
|  | double | resolution,
|  | long | num_angle
| ) |  |

Calculates the polar power spectrum of an image.

Parameters

  *p | 2D Fourier transform.
  resolution | high resolution limit.
  num_angle | number of angles to use for interpolation.

Returns
  Bimage* polar power spectrum.

      The length of each annulus is NANG times the radial offset.
      The samples on each annulus are calculated by bilinear interpolation.
      The maximum annulus calculated depends on the resolution limit specified
      in the input image.

Definition at line 808 of file img_polar.cpp.

Bimage* img_polar_transform | ( | Bimage * | p,
|  | int | nannuli,
|  | int | nangles,
|  | int | ann_min,
|  | int | ann_max
| ) |  |

Transforms a cartesian image to polar or cylindrical coordinates.

Parameters

  *p | 2D/3D Fourier transform or power spectrum.
  nannuli | number of annuli or radii.
  nangles | number of angles.
  ann_min | first annulus to calculate.
  ann_max | last annulus to calculate.

Returns
  Bimage* polar (cylindrical) image.

      An interpolative method is used where the value at a specific
      radius and angle is obtained from contributions of the four
      surrounding pixels in the original image.
      The x-axis in the polar image represents the angle and the y-axis
      represents the annulus.
      Only the specified range of annuli is calculated to save time.
      The first angle is zero and the angular step size is 2*pi/nangles.
      The data type of the polar image is always floating point.

Definition at line 573 of file img_polar.cpp.

Bimage* img_radial_sections | ( | Bimage * | p,
|  | double | rad_start,
|  | double | rad_end,
|  | double | rad_step,
|  | double | spherical_fraction,
|  | Bstring & | symmetry_string
| ) |  |

Calculates an image with slices giving the radial section projections.

Parameters

  *p | 3D image.
  rad_start | starting radius (voxels).
  rad_end | ending radius (voxels).
  rad_step | radial step size (voxels).
  spherical_fraction | fraction of spherical section (requires symmetry).
  &symmetry_string | symmetry for non-spherical sections.

Returns
  Bimage* image with radial sections.

      The 3D image is converted so that the sections contain 2D projections
      of radial shells. The projection in slice i is defined for:
          i >= sqrt(x^2 + y^2)
      Non-spherical sections can be generated by specifying the symmetry and
      the fraction of spherical nature (1=spherical, 0=based on symmetry).
      Sampling in x and y is not changed.
      The sampling in the input map must be isotropic.

Definition at line 509 of file img_polar.cpp.

int img_radial_shells | ( | Bimage * | p | ) |

Calculates an image with slices representing radial shell projections.

Returns
  int 0.

      The 3D image is converted so that the sections contain 2D projections
      of radial shells. The projection in slice z is defined for:
          z >= sqrt((x-xo)^2 + (y-yo)^2) + zo
      The first projection is placed at the z origin and radiates out into
      both positive and negative directions.
      Sampling in x and y is not changed.
      The sampling must be isotropic.

Parameters

  *p | 3D image (converted).

Definition at line 252 of file img_polar.cpp.