Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

fundamentals.h File Reference

Image Fundamentals -- Loose collection of fundamental image processing tools. More...

#include <cstddef>

Include dependency graph for fundamentals.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  EMAN

Enumerations

enum  fp_flag {
  CIRCULANT = 1, CIRCULANT_NORMALIZED = 2, PADDED = 3, PADDED_NORMALIZED = 4,
  PADDED_LAG = 5, PADDED_NORMALIZED_LAG = 6
}
 Fourier Product processing flag. More...
enum  fp_type { CORRELATION, CONVOLUTION, SELF_CORRELATION, AUTOCORRELATION }
enum  kernel_shape { BLOCK = 1, CIRCULAR = 2, CROSS = 3 }
enum  morph_type { BINARY = 1, GRAYLEVEL = 2 }
 Median filter. More...

Functions

EMData * correlation (EMData *f, EMData *g, fp_flag myflag, bool center)
 Correlation of two images.
EMData * convolution (EMData *f, EMData *g, fp_flag myflag, bool center)
 Convolution of two images.
EMDatarsconvolution (EMData *f, EMData *K)
 Real-space convolution of two images.
EMData * rscp (EMData *f)
 Real-space convolution with the K-B window.
EMData * autocorrelation (EMData *f, fp_flag myflag, bool center)
 Image autocorrelation.
EMData * self_correlation (EMData *f, fp_flag myflag, bool center)
 Image self-correlation.
EMDatafilt_median_ (EMData *f, int nxk, int nyk, int nzk, kernel_shape myshape)
EMDatafilt_dilation_ (EMData *f, EMData *K, morph_type mydilation)
EMDatafilt_erosion_ (EMData *f, EMData *K, morph_type myerosion)
 Dilation filter.


Detailed Description

Image Fundamentals -- Loose collection of fundamental image processing tools.

Author:
P. A. Penczek <Pawel.A.Penczek@uth.tmc.edu>. The University of Texas. Please do not modify the contents of this document without written consent of the author.
See also:
H.R. Myler and A.R. Weeks, "The Pocket Handbook of Image Processing Algorithms in C" (Prentice Hall, Upper Saddle River, 1993), p. 129.

Definition in file fundamentals.h.


Enumeration Type Documentation

enum fp_flag
 

Fourier Product processing flag.

Should the Fourier data be treated as manifestly periodic (CIRCULANT), padded with zeros (PADDED), or padded with a lag (PADDED_LAG). Also, in each of these cases the product may be normalized or not. Pick one, as there is no default.

Enumeration values:
CIRCULANT 
CIRCULANT_NORMALIZED 
PADDED 
PADDED_NORMALIZED 
PADDED_LAG 
PADDED_NORMALIZED_LAG 

Definition at line 66 of file fundamentals.h.

00066                      {
00067                 CIRCULANT = 1,
00068                 CIRCULANT_NORMALIZED = 2,
00069                 PADDED = 3,
00070                 PADDED_NORMALIZED = 4,
00071                 PADDED_LAG = 5,
00072                 PADDED_NORMALIZED_LAG = 6
00073         };

enum fp_type
 

Enumeration values:
CORRELATION 
CONVOLUTION 
SELF_CORRELATION 
AUTOCORRELATION 

Definition at line 76 of file fundamentals.h.

00076                      {
00077                 CORRELATION,
00078                 CONVOLUTION,
00079                 SELF_CORRELATION,
00080                 AUTOCORRELATION
00081         };

enum kernel_shape
 

Enumeration values:
BLOCK 
CIRCULAR 
CROSS 

Definition at line 227 of file fundamentals.h.

00227                           {
00228                 BLOCK = 1,
00229                 CIRCULAR = 2,
00230                 CROSS = 3
00231         };

enum morph_type
 

Median filter.

Purpose: Calculate the median filtered image.
Parameters:
[in] f First real-space image object. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
[in] nxk,nyk,nzk Size of the kernel on each dimension Note: For CIRCULAR kernel, we currently only consider circle or sphere kernel, i.e., nxk==nyk for 2 dimensional image and nxk==nyk==nzk for 3 dimensional image.
[in] myshape Shape of the kernal BLOCK is for block kernal; CIRCULAR is for circular kernel; CROSS is for cross kernal; Note: For 1-dimensional image, these three kernels degenerate into the same shape.
Returns:
Median filtered image.
Enumeration values:
BINARY 
GRAYLEVEL 

Definition at line 254 of file fundamentals.h.

00254                         {
00255                 BINARY = 1,
00256                 GRAYLEVEL = 2
00257         };


Function Documentation

EMData* autocorrelation EMData *  f,
fp_flag  myflag,
bool  center
[inline]
 

Image autocorrelation.

Purpose: Calculate the autocorrelation of a 1-, 2-,
or 3-dimensional image.
Method: This function calls fourierproduct.
Parameters:
[in] f Image object, either a real-space image or a Fourier image. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
[in] myflag Processing flag (see above).
[in] center 
Returns:
Real-space autocorrelation image.

Definition at line 187 of file fundamentals.h.

References EMAN::AUTOCORRELATION, and EMAN::fourierproduct().

00187                                                                                {
00188                 return fourierproduct(f, NULL, myflag, AUTOCORRELATION, center);
00189         }

EMData* convolution EMData *  f,
EMData *  g,
fp_flag  myflag,
bool  center
[inline]
 

Convolution of two images.

Purpose: Calculate the convolution of two 1-, 2-,
or 3-dimensional images.
Method: This function calls fourierproduct.
Parameters:
[in] f First image object, either a real-space image or a Fourier image. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
[in] g Second image object, either a real-space image or a Fourier image. Image may be 1-, 2-, or 3-dimensional. The size of g must be the same as the size of f. Image g is not changed.
[in] myflag Processing flag (see above).
[in] center 
Returns:
Real-space convolution image.

Definition at line 144 of file fundamentals.h.

References EMAN::CONVOLUTION, and EMAN::fourierproduct().

Referenced by EMAN::EMData::calc_ccf().

00144                                                                                       {
00145                 return fourierproduct(f, g, myflag, CONVOLUTION, center);
00146         }

EMData* correlation EMData *  f,
EMData *  g,
fp_flag  myflag,
bool  center
[inline]
 

Correlation of two images.

Purpose: Calculate the correlation of two 1-, 2-,
or 3-dimensional images.
Method: This function calls fourierproduct.
Parameters:
[in] f First image object, either a real-space image or a Fourier image. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
[in] g Second image object, either a real-space image or a Fourier image. Image may be 1-, 2-, or 3-dimensional. The size of g must be the same as the size of f. Image g is not changed.
[in] myflag Processing flag (see above).
[in] center 
Returns:
Real-space correlation image.

Definition at line 123 of file fundamentals.h.

References EMAN::CORRELATION, and EMAN::fourierproduct().

Referenced by EMAN::EMData::calc_ccf(), EMAN::Util::constrained_helix(), and EMAN::Util::constrained_helix_test().

00123                                                                                       {
00124                 return fourierproduct(f, g, myflag, CORRELATION, center);
00125         }

EMData * EMAN::filt_dilation_ EMData f,
EMData K,
morph_type  mydilation
 

Definition at line 597 of file rsconvolution.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, EMAN::EMData::set_size(), and EMAN::EMData::to_zero().

00597                                                                         {
00598 
00599                 int nxf = f->get_xsize();
00600                 int nyf = f->get_ysize(); 
00601                 int nzf = f->get_zsize();
00602 
00603                 int nxk = K->get_xsize();
00604                 int nyk = K->get_ysize();
00605                 int nzk = K->get_zsize();
00606         
00607                 if ( nxf < nxk && nyf < nyk && nzf < nzk ) {
00608                         // whoops, f smaller than K
00609                         swap(f,K); swap(nxf,nxk); swap(nyf,nyk); swap(nzf,nzk);
00610                 } else if ( nxk > nxf || nyk > nyf || nzk > nzf ) {
00611                         // Incommensurate sizes
00612                         throw ImageDimensionException("Two input images are incommensurate.");
00613                 }
00614 
00615                 if ( nxk % 2 != 1 || nyk % 2 != 1 || nzk % 2 != 1 ) {
00616                         // Kernel needs to be odd in size
00617                         throw ImageDimensionException("Kernel should have odd nx,ny,nz so that the center is well-defined.");
00618                 }
00619 
00620                 int nxk2 = (nxk-1)/2;
00621                 int nyk2 = (nyk-1)/2;
00622                 int nzk2 = (nzk-1)/2;
00623 
00624                 if ( mydilation == BINARY ) {
00625                         // Check whether two images are truly binary.
00626                         for (int iz = 0; iz <= nzf-1; iz++) {
00627                                 for (int iy = 0; iy <= nyf-1; iy++) {
00628                                         for (int ix = 0; ix <= nxf-1; ix++) {
00629                                                 int fxyz=(int)(*f)(ix,iy,iz);
00630                                                 if ( fxyz != 0 && fxyz != 1 ) {
00631                                                         throw ImageDimensionException("One of the two images is not binary.");
00632                                                 }
00633                                         }
00634                                 }
00635                         }
00636                         for (int iz = 0; iz <= nzk-1; iz++) {
00637                                 for (int iy = 0; iy <= nyk-1; iy++) {
00638                                         for (int ix = 0; ix <= nxk-1; ix++) {
00639                                                 int kxyz=(int)(*K)(ix,iy,iz);
00640                                                 if ( kxyz != 0 && kxyz != 1 ) {
00641                                                         throw ImageDimensionException("One of the two images is not binary.");
00642                                                 }
00643                                         }
00644                                 }
00645                         }
00646                 }
00647 
00648                 EMData* result = new EMData();
00649                 result->set_size(nxf, nyf, nzf);
00650                 result->to_zero();
00651 
00652                 for (int iz = 0; iz <= nzf-1; iz++) {
00653                         for (int iy = 0; iy <= nyf-1; iy++) {
00654                                 for (int ix = 0; ix <= nxf-1; ix++) {
00655 //                                      int kzmin = iz-nzk2 < 0     ?   0   : iz-nzk2 ;
00656 //                                      int kzmax = iz+nzk2 > nzf-1 ? nzf-1 : iz+nzk2 ;
00657 //                                      int kymin = iy-nyk2 < 0     ?   0   : iy-nyk2 ;
00658 //                                      int kymax = iy+nyk2 > nyf-1 ? nyf-1 : iy+nyk2 ;
00659 //                                      int kxmin = ix-nxk2 < 0     ?   0   : ix-nxk2 ;
00660 //                                      int kxmax = ix+nxk2 > nxf-1 ? nxf-1 : ix+nxk2 ;
00661                                         if ( mydilation == BINARY ) {
00662                                                 int fxyz = (int)(*f)(ix,iy,iz);
00663                                                 if ( fxyz == 1 ) {
00664                                                         for (int jz = -nzk2; jz <= nzk2; jz++) {
00665                                                                 for (int jy = -nyk2; jy <= nyk2; jy++) {
00666                                                                         for (int jx= -nxk2; jx <= nxk2; jx++) {
00667                                                                                 if ( (int)(*K)(jx+nxk2,jy+nyk2,jz+nzk2) == 1 ) {
00668                                                                                         int fz = iz+jz;
00669                                                                                         int fy = iy+jy;
00670                                                                                         int fx = ix+jx;
00671                                                                                         if ( fz >= 0 && fz <= nzf-1 && fy >= 0 && fy <= nyf-1 && fx >= 0 && fx <= nxf-1 )
00672                                                                                                 (*result)(fx,fy,fz) = 1;
00673                                                                                         }
00674                                                                                 }
00675                                                                         }
00676                                                                 }
00677                                                         }
00678                                         } else if ( mydilation == GRAYLEVEL ) {
00679                                                         float pmax = (*f)(ix,iy,iz)+(*K)(nxk2,nyk2,nzk2); 
00680                                                         for (int jz = -nzk2; jz <= nzk2; jz++) {
00681                                                                 for (int jy = -nyk2; jy <= nyk2; jy++) {
00682                                                                         for (int jx = -nxk2; jx <= nxk2; jx++) {
00683                                                                                 int fz = iz+jz;
00684                                                                                 int fy = iy+jy;
00685                                                                                 int fx = ix+jx;
00686                                                                                 if ( fz >= 0 && fz <= nzf-1 && fy >= 0 && fy <= nyf-1 && fx >= 0 && fx <= nxf-1 ) {
00687                                                                                         float kxyz = (*K)(jx+nxk2,jy+nyk2,jz+nzk2);
00688                                                                                         float fxyz = (*f)(fx,fy,fz);                                                                                    
00689                                                                                         if ( kxyz+fxyz > pmax )  pmax = kxyz+fxyz;
00690                                                                                 }
00691                                                                         }
00692                                                                 }
00693                                                         }
00694                                                         (*result)(ix,iy,iz) = pmax;
00695                                         } else {
00696                                                 throw ImageDimensionException("Illegal dilation type!");
00697                                         }
00698                                 }
00699                         }
00700                 }               
00701                 return result;
00702     }

EMData * EMAN::filt_erosion_ EMData f,
EMData K,
morph_type  myerosion
 

Dilation filter.

Purpose: Calculate the Minkowski addition of the two images
Parameters:
[in] f First real-space image object. Image may be 2- or 3-dimensional. Image f is not changed. K Second real-space image object Image may be 2- or 3-dimentional. Image K is not changed. mydilation Type of dilation BINARY is for binary dilation. GRAYLEVEL is for graylevel dilation.
K 
myerosion 
Returns:
Dilation filtered image.

Definition at line 704 of file rsconvolution.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, EMAN::EMData::set_size(), and EMAN::EMData::to_one().

00704                                                                       {
00705 
00706                 int nxf = f->get_xsize();
00707                 int nyf = f->get_ysize(); 
00708                 int nzf = f->get_zsize();
00709 
00710                 int nxk = K->get_xsize();
00711                 int nyk = K->get_ysize();
00712                 int nzk = K->get_zsize();
00713         
00714                 if ( nxf < nxk && nyf < nyk && nzf < nzk ) {
00715                         // whoops, f smaller than K
00716                         swap(f,K); swap(nxf,nxk); swap(nyf,nyk); swap(nzf,nzk);
00717                 } else if ( nxk > nxf || nyk > nyf || nzk > nzf ) {
00718                         // Incommensurate sizes
00719                         throw ImageDimensionException("Two input images are incommensurate.");
00720                 }
00721 
00722                 if ( nxk % 2 != 1 || nyk % 2 != 1 || nzk % 2 != 1 ) {
00723                         // Kernel needs to be odd in size
00724                         throw ImageDimensionException("Kernel should have odd nx,ny,nz so that the center is well-defined.");
00725                 }
00726 
00727                 int nxk2 = (nxk-1)/2;
00728                 int nyk2 = (nyk-1)/2;
00729                 int nzk2 = (nzk-1)/2;
00730 
00731                 if ( myerosion == BINARY ) {
00732                         // Check whether two images are truly binary.
00733                         for (int iz = 0; iz <= nzf-1; iz++) {
00734                                 for (int iy = 0; iy <= nyf-1; iy++) {
00735                                         for (int ix = 0; ix <= nxf-1; ix++) {
00736                                                 int fxyz=(int)(*f)(ix,iy,iz);
00737                                                 if ( fxyz != 0 && fxyz != 1 ) {
00738                                                         throw ImageDimensionException("One of the two images is not binary.");
00739                                                 }
00740                                         }
00741                                 }
00742                         }
00743                         for (int iz = 0; iz <= nzk-1; iz++) {
00744                                 for (int iy = 0; iy <= nyk-1; iy++) {
00745                                         for (int ix = 0; ix <= nxk-1; ix++) {
00746                                                 int kxyz=(int)(*K)(ix,iy,iz);
00747                                                 if ( kxyz != 0 && kxyz != 1 ) {
00748                                                         throw ImageDimensionException("One of the two images is not binary.");
00749                                                 }
00750                                         }
00751                                 }
00752                         }
00753                 }
00754 
00755                 EMData* result = new EMData();
00756                 result->set_size(nxf, nyf, nzf);
00757                 result->to_one();
00758 
00759                 for (int iz = 0; iz <= nzf-1; iz++) {
00760                         for (int iy = 0; iy <= nyf-1; iy++) {
00761                                 for (int ix = 0; ix <= nxf-1; ix++) {
00762                                         if ( myerosion == BINARY ) {
00763                                                 int fxyz = (int)(*f)(ix,iy,iz);
00764                                                 if ( fxyz == 0 ) {
00765                                                         for (int jz = -nzk2; jz <= nzk2; jz++) {
00766                                                                 for (int jy = -nyk2; jy <= nyk2; jy++) {
00767                                                                         for (int jx= -nxk2; jx <= nxk2; jx++) {
00768                                                                                 if ( (int)(*K)(jx+nxk2,jy+nyk2,jz+nzk2) == 1 ) {
00769                                                                                         int fz = iz+jz;
00770                                                                                         int fy = iy+jy;
00771                                                                                         int fx = ix+jx;
00772                                                                                         if ( fz >= 0 && fz <= nzf-1 && fy >= 0 && fy <= nyf-1 && fx >= 0 && fx <= nxf-1 )
00773                                                                                                 (*result)(fx,fy,fz) = 0;
00774                                                                                         }
00775                                                                                 }
00776                                                                         }
00777                                                                 }
00778                                                         }
00779                                         } else if ( myerosion == GRAYLEVEL ) {
00780                                                         float pmin = (*f)(ix,iy,iz)-(*K)(nxk2,nyk2,nzk2); 
00781                                                         for (int jz = -nzk2; jz <= nzk2; jz++) {
00782                                                                 for (int jy = -nyk2; jy <= nyk2; jy++) {
00783                                                                         for (int jx = -nxk2; jx <= nxk2; jx++) {
00784                                                                                 int fz = iz+jz;
00785                                                                                 int fy = iy+jy;
00786                                                                                 int fx = ix+jx;
00787                                                                                 if ( fz >= 0 && fz <= nzf-1 && fy >= 0 && fy <= nyf-1 && fx >= 0 && fx <= nxf-1 ) {
00788                                                                                         float kxyz = (*K)(jx+nxk2,jy+nyk2,jz+nzk2);
00789                                                                                         float fxyz = (*f)(fx,fy,fz);                                                                                    
00790                                                                                         if ( fxyz-kxyz < pmin )  pmin = fxyz-kxyz;
00791                                                                                 }
00792                                                                         }
00793                                                                 }
00794                                                         }
00795                                                         (*result)(ix,iy,iz) = pmin;
00796                                         } else {
00797                                                 throw ImageDimensionException("Illegal dilation type!");
00798                                         }
00799                                 }
00800                         }
00801                 }               
00802                 return result;
00803     }

EMData * EMAN::filt_median_ EMData f,
int  nxk,
int  nyk,
int  nzk,
kernel_shape  myshape
 

Definition at line 559 of file rsconvolution.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, median(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero().

00559                                                                                      {
00560                 
00561                 int nxf = f->get_xsize();
00562                 int nyf = f->get_ysize(); 
00563                 int nzf = f->get_zsize();
00564                 
00565                 if ( nxk > nxf || nyk > nyf || nzk > nzf ) {
00566                         // Kernel should be smaller than the size of image
00567                         throw ImageDimensionException("Kernel should be smaller than the size of image.");
00568                 }       
00569 
00570                 if ( nxk % 2 != 1 || nyk % 2 != 1 || nzk % 2 != 1 ) {
00571                         // Kernel needs to be odd in size
00572                         throw ImageDimensionException("Real-space kernel must have odd size so that the center is well-defined.");
00573                 }
00574 
00575                 if ( myshape == CIRCULAR ) {
00576                         // For CIRCULAR kernal, size must be same on all dimensions
00577                         if ( (nzf != 1 && ( nxk != nyk || nxk != nzk )) || (nzf == 1 && nyf != 1 && nxk != nyk) ) {
00578                                 throw ImageDimensionException("For CIRCULAR kernal, size must be same on all dimensions.");
00579                         }
00580                 }
00581 
00582                 EMData* result = new EMData();
00583                 result->set_size(nxf, nyf, nzf);
00584                 result->to_zero();
00585 
00586                 for (int iz = 0; iz <= nzf-1; iz++) {
00587                         for (int iy = 0; iy <= nyf-1; iy++) {
00588                                 for (int ix = 0; ix <= nxf-1; ix++) {
00589                                         (*result)(ix,iy,iz) = median (*f, nxk, nyk, nzk, myshape, iz, iy, ix);                                  
00590                                 }
00591                         }
00592                 }
00593                 
00594                 return result;
00595         }

EMData * EMAN::rsconvolution EMData f,
EMData K
 

Real-space convolution of two images.

Purpose: Calculate the convolution of two 1-, 2-,
or 3-dimensional images.
Parameters:
[in] f First real-space image object. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
[in] K Second real-space image object (the convolution Kernel). Image may be 1-, 2-, or 3-dimensional. Image K is not changed.
Returns:
Real-space convolution image.

Definition at line 249 of file rsconvolution.cpp.

References EMAN::EMData::get_array_offsets(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, mult_circ(), mult_internal(), EMAN::EMData::set_array_offsets(), EMAN::EMData::set_size(), EMAN::EMData::to_zero(), and EMAN::EMData::update().

00249                                                 {//Does not work properly in 3D, corners are not done, PAP 07/16/09
00250                 // Kernel should be the smaller image
00251                 int nxf=f->get_xsize(); int nyf=f->get_ysize(); int nzf=f->get_zsize();
00252                 int nxK=K->get_xsize(); int nyK=K->get_ysize(); int nzK=K->get_zsize();
00253                 if ((nxf<nxK)&&(nyf<nyK)&&(nzf<nzK)) {
00254                         // whoops, f smaller than K
00255                         swap(f,K); swap(nxf,nxK); swap(nyf,nyK); swap(nzf,nzK);
00256                 } else if ((nxK<=nxf)&&(nyK<=nyf)&&(nzK<=nzf)) {
00257                         // that's what it should be, so do nothing
00258                         ;
00259                 } else {
00260                         // incommensurate sizes
00261                         throw ImageDimensionException("input images are incommensurate");
00262                 }
00263                 // Kernel needs to be _odd_ in size
00264                 if ((nxK % 2 != 1) || (nyK % 2 != 1) || (nzK % 2 != 1))
00265                         throw ImageDimensionException("Real-space convolution kernel"
00266                                 " must have odd nx,ny,nz (so the center is well-defined).");
00267                 EMData* result = new EMData();
00268                 result->set_size(nxf, nyf, nzf);
00269                 result->to_zero();
00270                 // kernel corners, need to check for degenerate case
00271                 int kxmin = -nxK/2; int kymin = -nyK/2; int kzmin = -nzK/2;
00272                 int kxmax = (1 == nxK % 2) ? -kxmin : -kxmin - 1;
00273                 int kymax = (1 == nyK % 2) ? -kymin : -kymin - 1;
00274                 int kzmax = (1 == nzK % 2) ? -kzmin : -kzmin - 1;
00275                 vector<int> K_saved_offsets = K->get_array_offsets();
00276                 K->set_array_offsets(kxmin,kymin,kzmin);
00277                 // interior boundaries, need to check for degenerate cases
00278                 int izmin = 0, izmax = 0, iymin = 0, iymax = 0, ixmin = 0, ixmax = 0;
00279                 if (1 != nzf) {
00280                         izmin = -kzmin;
00281                         izmax = nzf - 1 - kzmax;
00282                 }
00283                 if (1 != nyf) {
00284                         iymin = -kymin;
00285                         iymax = nyf - 1 - kymax;
00286                 }
00287                 if (1 != nxf) {
00288                         ixmin = -kxmin;
00289                         ixmax = nxf - 1 - kxmax;
00290                 }
00291                 // interior (no boundary condition issues here)
00292                 for (int iz = izmin; iz <= izmax; iz++) {
00293                         for (int iy = iymin; iy <= iymax; iy++) {
00294                                 for (int ix = ixmin; ix <= ixmax; ix++) {
00295                                         (*result)(ix,iy,iz) =
00296                                                 mult_internal(*K, *f, 
00297                                                                       kzmin, kzmax, kymin, kymax, kxmin, kxmax,
00298                                                                           iz, iy, ix);
00299                                 }
00300                         }
00301                 }
00302                 // corners
00303                 // corner sizes, with checking for degenerate cases
00304                 int sz = (1 == nzK) ? 1 : -kzmin + kzmax;
00305                 int sy = (1 == nyK) ? 1 : -kymin + kymax;
00306                 int sx = (1 == nxK) ? 1 : -kxmin + kxmax;
00307                 // corner starting locations, with checking for degenerate cases
00308                 int zstart = (0 == izmin) ? 0 : izmin - 1;
00309                 int ystart = (0 == iymin) ? 0 : iymin - 1;
00310                 int xstart = (0 == ixmin) ? 0 : ixmin - 1;
00311                 // corners
00312                 for (int cz = 0; cz < sz; cz++) {
00313                         int iz = (zstart - cz) % nzf;
00314                         if (iz < 0) iz += nzf;
00315                         for (int cy = 0; cy < sy; cy++) {
00316                                 int iy = (ystart - cy) % nyf;
00317                                 if (iy < 0) iy += nyf;
00318                                 for (int cx=0; cx < sx; cx++) {
00319                                         int ix = (xstart - cx) % nxf;
00320                                         if (ix < 0) ix += nxf;
00321                                         (*result)(ix,iy,iz) =
00322                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, 
00323                                                                  kymax, kxmin, kxmax,
00324                                                                  nzf, nyf, nxf, iz, iy, ix);
00325                                 }
00326                         }
00327                 }
00328                 // remaining stripes -- should use a more elegant (non-3D-specific) method here
00329                 // ix < ixmin
00330                 for (int ix = 0; ix < ixmin; ix++) {
00331                         for (int iy = iymin; iy <= iymax; iy++) {
00332                                 for (int iz = izmin; iz <= izmax; iz++) {
00333                                         (*result)(ix,iy,iz) =
00334                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00335                                                                  kxmin, kxmax,
00336                                                                  nzf, nyf, nxf, iz, iy, ix);
00337                                 }
00338                         }
00339                 }
00340                 // ix > ixmax
00341                 for (int ix = ixmax+1; ix < nxf; ix++) {
00342                         for (int iy = iymin; iy <= iymax; iy++) {
00343                                 for (int iz = izmin; iz <= izmax; iz++) {
00344                                         (*result)(ix,iy,iz) =
00345                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00346                                                                  kxmin, kxmax,
00347                                                                  nzf, nyf, nxf, iz, iy, ix);
00348                                 }
00349                         }
00350                 }
00351                 // iy < iymin
00352                 for (int iy = 0; iy < iymin; iy++) {
00353                         for (int ix = ixmin; ix <= ixmax; ix++) {
00354                                 for (int iz = izmin; iz <= izmax; iz++) {
00355                                         (*result)(ix,iy,iz) =
00356                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00357                                                                  kxmin, kxmax,
00358                                                                  nzf, nyf, nxf, iz, iy, ix);
00359                                 }
00360                         }
00361                 }
00362                 // iy > iymax
00363                 for (int iy = iymax+1; iy < nyf; iy++) {
00364                         for (int ix = ixmin; ix <= ixmax; ix++) {
00365                                 for (int iz = izmin; iz <= izmax; iz++) {
00366                                         (*result)(ix,iy,iz) =
00367                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00368                                                                  kxmin, kxmax,
00369                                                                  nzf, nyf, nxf, iz, iy, ix);
00370                                 }
00371                         }
00372                 }
00373                 // iz < izmin
00374                 for (int iz = 0; iz < izmin; iz++) {
00375                         for (int ix = ixmin; ix <= ixmax; ix++) {
00376                                 for (int iy = iymin; iy <= iymax; iy++) {
00377                                         (*result)(ix,iy,iz) =
00378                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00379                                                                  kxmin, kxmax,
00380                                                                  nzf, nyf, nxf, iz, iy, ix);
00381                                 }
00382                         }
00383                 }
00384                 // iz > izmax
00385                 for (int iz = izmax+1; iz < nzf; iz++) {
00386                         for (int ix = ixmin; ix <= ixmax; ix++) {
00387                                 for (int iy = iymin; iy <= iymax; iy++) {
00388                                         (*result)(ix,iy,iz) =
00389                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00390                                                                  kxmin, kxmax,
00391                                                                  nzf, nyf, nxf, iz, iy, ix);
00392                                 }
00393                         }
00394                 }
00395                 
00396                 
00397                 // ix < ixmin, iy < iymin
00398                 for (int ix = 0; ix < ixmin; ix++) {
00399                         for (int iy = 0; iy < iymin; iy++) {
00400                                 for (int iz = izmin; iz <= izmax; iz++) {
00401                                         (*result)(ix,iy,iz) =
00402                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00403                                                                  kxmin, kxmax,
00404                                                                  nzf, nyf, nxf, iz, iy, ix);
00405                                 }
00406                         }
00407                 }
00408                 
00409                 // ix < ixmin, iy > iymax
00410                 for (int ix = 0; ix < ixmin; ix++) {
00411                         for (int iy = iymax+1; iy < nyf; iy++) {
00412                                 for (int iz = izmin; iz <= izmax; iz++) {
00413                                         (*result)(ix,iy,iz) =
00414                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00415                                                                  kxmin, kxmax,
00416                                                                  nzf, nyf, nxf, iz, iy, ix);
00417                                 }
00418                         }
00419                 }
00420 
00421         // ix > ixmax, iy < iymin
00422                 for (int ix = ixmax+1; ix < nxf; ix++) {
00423                         for (int iy = 0; iy < iymin; iy++) {
00424                                 for (int iz = izmin; iz <= izmax; iz++) {
00425                                         (*result)(ix,iy,iz) =
00426                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00427                                                                  kxmin, kxmax,
00428                                                                  nzf, nyf, nxf, iz, iy, ix);
00429                                 }
00430                         }
00431                 }
00432                 
00433                 // ix > ixmax, iy > iymax
00434                 for (int ix = ixmax+1; ix < nxf; ix++) {
00435                         for (int iy = iymax+1; iy < nyf; iy++) {
00436                                 for (int iz = izmin; iz <= izmax; iz++) {
00437                                         (*result)(ix,iy,iz) =
00438                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00439                                                                  kxmin, kxmax,
00440                                                                  nzf, nyf, nxf, iz, iy, ix);
00441                                 }
00442                         }
00443                 }
00444 
00445 
00446                 
00447         // ix < ixmin, iz < izmin
00448                 for (int ix = 0; ix < ixmin; ix++) {
00449                         for (int iy = iymin; iy <= iymax; iy++) {
00450                                 for (int iz = 0; iz < izmin; iz++) {
00451                                         (*result)(ix,iy,iz) =
00452                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00453                                                                  kxmin, kxmax,
00454                                                                  nzf, nyf, nxf, iz, iy, ix);
00455                                 }
00456                         }
00457                 }
00458                 
00459                  // ix < ixmin, iz > izmax
00460                 for (int ix = 0; ix < ixmin; ix++) {
00461                         for (int iy = iymin; iy <= iymax; iy++) {
00462                                 for (int iz = izmax+1; iz < nzf; iz++) {
00463                                         (*result)(ix,iy,iz) =
00464                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00465                                                                  kxmin, kxmax,
00466                                                                  nzf, nyf, nxf, iz, iy, ix);
00467                                 }
00468                         }
00469                 }
00470 
00471 
00472          // ix > ixmin, iz < izmin
00473                 for (int ix = ixmax+1; ix < nxf; ix++) {
00474                         for (int iy = iymin; iy <= iymax; iy++) {
00475                                 for (int iz = 0; iz < izmin; iz++) {
00476                                         (*result)(ix,iy,iz) =
00477                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00478                                                                  kxmin, kxmax,
00479                                                                  nzf, nyf, nxf, iz, iy, ix);
00480                                 }
00481                         }
00482                 }
00483                 
00484                  // ix > ixmin, iz > izmax
00485                 for (int ix = ixmax+1; ix < nxf; ix++) {
00486                         for (int iy = iymin; iy <= iymax; iy++) {
00487                                 for (int iz = izmax+1; iz < nzf; iz++) {
00488                                         (*result)(ix,iy,iz) =
00489                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00490                                                                  kxmin, kxmax,
00491                                                                  nzf, nyf, nxf, iz, iy, ix);
00492                                 }
00493                         }
00494                 }
00495 
00496                 
00497 
00498        // iy < iymin, iz < izmin
00499            
00500            for (int iz = 0; iz < izmin; iz++) {
00501                         for (int ix = ixmin; ix <= ixmax; ix++) {
00502                                 for (int iy = 0; iy < iymin; iy++) {
00503                                         (*result)(ix,iy,iz) =
00504                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00505                                                                  kxmin, kxmax,
00506                                                                  nzf, nyf, nxf, iz, iy, ix);
00507                                 }
00508                         }
00509                 }
00510 
00511 
00512        // iy < iymin, iz > izmax
00513            
00514            for (int iz = izmax+1; iz < nzf; iz++) {
00515                         for (int ix = ixmin; ix <= ixmax; ix++) {
00516                                 for (int iy = 0; iy < iymin; iy++) {
00517                                         (*result)(ix,iy,iz) =
00518                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00519                                                                  kxmin, kxmax,
00520                                                                  nzf, nyf, nxf, iz, iy, ix);
00521                                 }
00522                         }
00523                 }
00524                 
00525                 
00526                 // iy > iymax, iz < izmin
00527            
00528            for (int iz = 0; iz < izmin; iz++) {
00529                         for (int ix = ixmin; ix <= ixmax; ix++) {
00530                                 for (int iy = iymax+1; iy < nyf; iy++) {
00531                                         (*result)(ix,iy,iz) =
00532                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00533                                                                  kxmin, kxmax,
00534                                                                  nzf, nyf, nxf, iz, iy, ix);
00535                                 }
00536                         }
00537                 }
00538 
00539 
00540        // iy > iymax, iz > izmax
00541            
00542            for (int iz = izmax+1; iz < nzf; iz++) {
00543                         for (int ix = ixmin; ix <= ixmax; ix++) {
00544                                 for (int iy = iymax+1; iy < nyf; iy++) {
00545                                         (*result)(ix,iy,iz) =
00546                                                 mult_circ(*K, *f, kzmin, kzmax, kymin, kymax, 
00547                                                                  kxmin, kxmax,
00548                                                                  nzf, nyf, nxf, iz, iy, ix);
00549                                 }
00550                         }
00551                 }
00552 
00553                 
00554                 K->set_array_offsets(K_saved_offsets);
00555                 result->update();
00556                 return result;
00557         }

EMData* rscp EMData *  f  ) 
 

Real-space convolution with the K-B window.

Purpose: Calculate the convolution with the K-B window.
Parameters:
[in] f First real-space image object. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
Returns:
Real-space convolution image.

EMData* self_correlation EMData *  f,
fp_flag  myflag,
bool  center
[inline]
 

Image self-correlation.

Purpose: Calculate the self-correlation of a 1-, 2-,
or 3-dimensional image.
Method: This function calls fourierproduct.
This function actually calls fourierproduct.

Parameters:
[in] f Image object, either a real-space image or a Fourier image. Image may be 1-, 2-, or 3-dimensional. Image f is not changed.
[in] myflag Processing flag (see above).
[in] center 
Returns:
Real-space self-correlation image.

Definition at line 206 of file fundamentals.h.

References EMAN::fourierproduct(), and EMAN::SELF_CORRELATION.

00206                                                                                 {
00207                 return fourierproduct(f, NULL, myflag, SELF_CORRELATION, center);
00208         }


Generated on Tue Jun 11 13:41:05 2013 for EMAN2 by  doxygen 1.3.9.1