DocumentationHoloJProcessorHoloJUtils

holoj
Class HoloJUtils

java.lang.Object
  extended byholoj.HoloJUtils

public final class HoloJUtils
extends java.lang.Object

Class HoloJUtils contains static methods to perform useful task such as FFT and other mathematics.


Constructor Summary
HoloJUtils()
           
 
Method Summary
static ij.process.FloatProcessor add(ij.process.ImageProcessor op1, ij.process.ImageProcessor op2)
          Add each pixel ImageProcessor to pixels of another ImageProcessor one-by-one.
static HoloJProcessor addPhase(HoloJProcessor processor, double angle)
          Add to the source HoloJProcessor the specified phase in radians.
 HoloJProcessor addPhasePlate(HoloJProcessor processor, double[] plateArray)
          Add to the specified HoloJProcessor a phase plate stored in a double array.
static double[] arrangeToComplexArray(double[] real, double[] complex)
          Arranges the two double array in a single double array with the sequence: re1,im1,re2,im2,...,reN,imN.
static double[][][] arrangeToComplexMatrix(double[] real, double[] complex, int rowWidth)
           
static double[] butterworthMask(int width, int height, int radius, double c)
          Creates a Butterworth filter mask and store it as double array.
static ij.ImagePlus butterworthMaskImage(int width, int height, int radius, double c, java.lang.String title)
          Creates an ImagePlus containing a Butterworth filter mask.
static void c2cfft(double[] data, int[] nn, int isign)
          Computes the Fast Fourier Transform of data passed as argument.
static double[] circularMask(int width, int height, int radius)
          Creates a circular mask and store it as double array.
static HoloJProcessor divide(HoloJProcessor operand, double value)
          Divide by scalar value the real and complex pixels of HoloJProcessor operand and returns the result in a new HoloJProcessor.
static HoloJProcessor divide(HoloJProcessor operand1, HoloJProcessor operand2)
          Returns the HoloJProcessor result of the complex division of operand1 by operand2.
static ij.process.FloatProcessor divide(ij.process.ImageProcessor op1, ij.process.ImageProcessor op2)
          Divide pixels of ImageProcessor by pixels of another ImageProcessor one-by-one.
static double[] extractComplexPixels(double[] input)
          Extract the complex part of the complex array arranged with arrangeToComplexArray.
static double[] extractRealPixels(double[] input)
          Extract the real part of the complex array arranged with arrangeToComplexArray.
static java.awt.Point getMaximumPosition(HoloJProcessor processor)
          Finds the maximum of the modulus of pixels of HoloJProcessor.
static java.awt.Point getMaximumPosition(HoloJProcessor processor, ij.gui.Roi selection)
          Finds the maximum of the modulus of HoloJProcessor pixels in the region specified by the selection.
static ij.process.ImageProcessor getPhaseRenormalizedProcessor(ij.process.ImageProcessor source)
          Renormalize the dynamic range of the source ImageProcessor to the range 2Pi.
static java.awt.Point getSidebandCenter(HoloJProcessor processor, int side)
          Finds the position of the maximum lateral peak of the spectrum of HoloJProcessor.
static ij.process.FloatProcessor makeCosProcessor(ij.process.ImageProcessor source)
          Calculates the cosine of pixels in source.
static ij.process.ImageProcessor makeInverseParabolicMask(int width, int height)
          Creates an inverse parabolic mask (intensity=1/(x^2+x^y)).
static ij.process.ImageProcessor makeParabolicMask(int width, int height)
          Creates a parabolic mask (intensity=x^2+x^y).
static ij.process.ImageProcessor makeSimmetricProcessor(ij.process.ImageProcessor source)
          Makes a new ImageProcessor by mirroring the source processor.
static ij.process.FloatProcessor makeSinProcessor(ij.process.ImageProcessor source)
          Calculates the sine of pixels in source.
static double modulus(double real, double imaginary)
          Calculates the modulus of complex number with real and imaginary parts passed as arguments.
static ij.process.FloatProcessor multiply(double factor, ij.process.ImageProcessor op1)
          Multiply each pixel of ImageProcessor for the specified scalar factor.
static HoloJProcessor multiply(HoloJProcessor operand, double value)
          Multiplies thbye scalar value the real and complex pixels of HoloJProcessor operand ad return the result in a new HoloJProcessor.
static HoloJProcessor multiply(HoloJProcessor operand1, HoloJProcessor operand2)
          Returns an HoloJProcessor result from the complex multiplication of operand1 pixels for operand2 pixels.
static ij.process.FloatProcessor multiply(ij.process.ImageProcessor op1, ij.process.ImageProcessor op2)
          Multiply each pixel ImageProcessor for pixels of another ImageProcessor one-by-one.
static HoloJProcessor reconstruct(int radius, int scaleFactor, java.awt.Point sideCenter, HoloJProcessor hologram, boolean useButterworth)
          Returns an HoloJProcessor containing reconstructed data.
static HoloJProcessor reconstruct(int radius, int scaleFactor, java.awt.Point sideCenter, HoloJProcessor hologram, HoloJProcessor reference, boolean useButterworth)
          Returns an HoloJProcessor containing reconstructed data from hologram and reference.
static void resetMin(ij.process.FloatProcessor ip)
          Reset the minimum of FloatProcessor to zero.
static void round(ij.process.FloatProcessor ip)
          Round each pixel to nearby integer value.
static HoloJProcessor subtract(HoloJProcessor operand, double realValue, double complexValue)
          Subtract the complex number represented by (realValue, complexValue) from real and complex pixels of HoloJProcessor operand.
static HoloJProcessor subtract(HoloJProcessor operand1, HoloJProcessor operand2)
          Subtracts the complex pixels of operand HoloJProcessor to real and complex pixels.
static ij.process.FloatProcessor subtract(ij.process.ImageProcessor op1, ij.process.ImageProcessor op2)
          Subtract each pixel ImageProcessor to pixels of another ImageProcessor one-by-one.
static HoloJProcessor sum(HoloJProcessor operand, double realValue, double complexValue)
          Adds the complex number represented by (realValue, complexValue) to real and complex pixels of HoloJProcessor operand.
static HoloJProcessor sum(HoloJProcessor operand1, HoloJProcessor operand2)
          Adds the complex pixels of operand1 HoloJProcessor to real and complex pixels of operand2 and returns the resulting HoloJProcessor.
static void swap(double[] data, int nx)
          Swap the quadrants of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HoloJUtils

public HoloJUtils()
Method Detail

modulus

public static double modulus(double real,
                             double imaginary)
Calculates the modulus of complex number with real and imaginary parts passed as arguments.

Parameters:
real - real part.
imaginary - complex part.
Returns:
the modulus.

arrangeToComplexArray

public static double[] arrangeToComplexArray(double[] real,
                                             double[] complex)
Arranges the two double array in a single double array with the sequence: re1,im1,re2,im2,...,reN,imN.

Parameters:
real - real double array.
complex - complex double array.
Returns:
the rearranged double array.

extractRealPixels

public static double[] extractRealPixels(double[] input)
Extract the real part of the complex array arranged with arrangeToComplexArray.

Parameters:
input - the input complex array.
Returns:
the extracted double real parts array.

extractComplexPixels

public static double[] extractComplexPixels(double[] input)
Extract the complex part of the complex array arranged with arrangeToComplexArray.

Parameters:
input - the input complex array.
Returns:
the extracted double complex parts array.

arrangeToComplexMatrix

public static double[][][] arrangeToComplexMatrix(double[] real,
                                                  double[] complex,
                                                  int rowWidth)

c2cfft

public static void c2cfft(double[] data,
                          int[] nn,
                          int isign)
Computes the Fast Fourier Transform of data passed as argument.

Parameters:
data - data to be transformed in row-major mode and RE1,CO1,RE2,CO2... sequence.
nn - array containing dimensions os data array.
isign - forward or reverse direction.

swap

public static void swap(double[] data,
                        int nx)
Swap the quadrants of data.

Parameters:
data - array of data to be swapped.
nx - length of a row.

butterworthMask

public static double[] butterworthMask(int width,
                                       int height,
                                       int radius,
                                       double c)
Creates a Butterworth filter mask and store it as double array.

Parameters:
width - width of the mask.
height - height of the mask.
radius - radius of the aperture.
c - value of aperture half-width.
Returns:
a double array with the mask.

butterworthMaskImage

public static ij.ImagePlus butterworthMaskImage(int width,
                                                int height,
                                                int radius,
                                                double c,
                                                java.lang.String title)
Creates an ImagePlus containing a Butterworth filter mask.

Parameters:
width - width of the mask.
height - height of the mask.
radius - radius of the aperture.
c - value of aperture half-width.
Returns:
an ImagePlus containing the mask.

circularMask

public static double[] circularMask(int width,
                                    int height,
                                    int radius)
Creates a circular mask and store it as double array.

Parameters:
width - width of the mask.
height - height of the mask.
radius - radius of the aperture.
Returns:
a double array with the mask.

getMaximumPosition

public static java.awt.Point getMaximumPosition(HoloJProcessor processor)
Finds the maximum of the modulus of pixels of HoloJProcessor.

Parameters:
processor - the HoloJProcessor.
Returns:
the maximum position as a Point.

getMaximumPosition

public static java.awt.Point getMaximumPosition(HoloJProcessor processor,
                                                ij.gui.Roi selection)
Finds the maximum of the modulus of HoloJProcessor pixels in the region specified by the selection.

Parameters:
processor - HoloJProcessor to use.
selection - selected area of the pixels.
Returns:
the maximum position.

getSidebandCenter

public static java.awt.Point getSidebandCenter(HoloJProcessor processor,
                                               int side)
Finds the position of the maximum lateral peak of the spectrum of HoloJProcessor. The method search for the maximum of the spectrum excluding a circular region of radius 20 pixels centered around the origin of the spectrum and assuming the processor is in spectrum domain.

Parameters:
processor - the HoloJProcessor.
side - the selected side of spectrum.
Returns:
the sideband center position.

sum

public static HoloJProcessor sum(HoloJProcessor operand,
                                 double realValue,
                                 double complexValue)
Adds the complex number represented by (realValue, complexValue) to real and complex pixels of HoloJProcessor operand.

Parameters:
operand - HoloJProcessor.
realValue - real part of operand.
complexValue - complex part of operand.
Returns:
the resulting HoloJProcessor.

subtract

public static HoloJProcessor subtract(HoloJProcessor operand,
                                      double realValue,
                                      double complexValue)
Subtract the complex number represented by (realValue, complexValue) from real and complex pixels of HoloJProcessor operand.

Parameters:
operand - HoloJProcessor.
realValue - real part of operand.
complexValue - complex part of operand.
Returns:
the resulting HoloJProcessor.

multiply

public static HoloJProcessor multiply(HoloJProcessor operand,
                                      double value)
Multiplies thbye scalar value the real and complex pixels of HoloJProcessor operand ad return the result in a new HoloJProcessor.

Parameters:
operand - HoloJProcessor.
value - scalar value multiplier.
Returns:
the resulting HoloJProcessor.

divide

public static HoloJProcessor divide(HoloJProcessor operand,
                                    double value)
Divide by scalar value the real and complex pixels of HoloJProcessor operand and returns the result in a new HoloJProcessor.

Parameters:
operand - HoloJProcessor.
value - scalar value multiplier.
Returns:
the resulting HoloJProcessor.

sum

public static HoloJProcessor sum(HoloJProcessor operand1,
                                 HoloJProcessor operand2)
Adds the complex pixels of operand1 HoloJProcessor to real and complex pixels of operand2 and returns the resulting HoloJProcessor.

Parameters:
operand1 - the first HoloJProcessor operand.
operand2 - the second HoloJProcessor operand.
Returns:
the resulting HoloJProcessor.

subtract

public static HoloJProcessor subtract(HoloJProcessor operand1,
                                      HoloJProcessor operand2)
Subtracts the complex pixels of operand HoloJProcessor to real and complex pixels.

Parameters:
operand1 - the HoloJProcessor first operand.
operand2 - the HoloJProcessor second operand.
Returns:
the resulting HoloJProcessor.

multiply

public static HoloJProcessor multiply(HoloJProcessor operand1,
                                      HoloJProcessor operand2)
Returns an HoloJProcessor result from the complex multiplication of operand1 pixels for operand2 pixels.

Parameters:
operand1 - the HoloJProcessor first operand.
operand2 - the HoloJProcessor second operand.
Returns:
the resulting HoloJProcessor.

divide

public static HoloJProcessor divide(HoloJProcessor operand1,
                                    HoloJProcessor operand2)
Returns the HoloJProcessor result of the complex division of operand1 by operand2.

Parameters:
operand1 - the HoloJProcessor first operand.
operand2 - the HoloJProcessor second operand.
Returns:
the resulting HoloJProcessor.

reconstruct

public static HoloJProcessor reconstruct(int radius,
                                         int scaleFactor,
                                         java.awt.Point sideCenter,
                                         HoloJProcessor hologram,
                                         boolean useButterworth)
Returns an HoloJProcessor containing reconstructed data.

Parameters:
radius - radius of reconstructed frequency region.
scaleFactor - scale factor of final reconstructed image.
hologram - hologram to be reconstructed.
useButterworth - flag for using soft aperture.
Returns:
the reconstructed image.

reconstruct

public static HoloJProcessor reconstruct(int radius,
                                         int scaleFactor,
                                         java.awt.Point sideCenter,
                                         HoloJProcessor hologram,
                                         HoloJProcessor reference,
                                         boolean useButterworth)
Returns an HoloJProcessor containing reconstructed data from hologram and reference.

Parameters:
radius - radius of reconstructed frequency region.
scaleFactor - scale factor of final reconstructed image.
hologram - hologram to be reconstructed.
reference - hologram used as reference in void.
useButterworth - flag for using soft aperture.
Returns:
the reconstructed image.

makeCosProcessor

public static ij.process.FloatProcessor makeCosProcessor(ij.process.ImageProcessor source)
Calculates the cosine of pixels in source.

Parameters:
source - the source ImaeProcessor.
Returns:
a FloatProcessor containing the cosine.

makeSinProcessor

public static ij.process.FloatProcessor makeSinProcessor(ij.process.ImageProcessor source)
Calculates the sine of pixels in source.

Parameters:
source - the source ImaeProcessor.
Returns:
a FloatProcessor containing the sine.

makeSimmetricProcessor

public static ij.process.ImageProcessor makeSimmetricProcessor(ij.process.ImageProcessor source)
Makes a new ImageProcessor by mirroring the source processor.

Parameters:
source - source ImageProcessor.
Returns:
the symmetric ImageProcessor.

getPhaseRenormalizedProcessor

public static ij.process.ImageProcessor getPhaseRenormalizedProcessor(ij.process.ImageProcessor source)
Renormalize the dynamic range of the source ImageProcessor to the range 2Pi.

Parameters:
source - source ImageProcessor.
Returns:
a renormalized ImageProcessor.

makeParabolicMask

public static ij.process.ImageProcessor makeParabolicMask(int width,
                                                          int height)
Creates a parabolic mask (intensity=x^2+x^y).

Parameters:
width - width of the mask.
height - height of the mask.
Returns:
the ImageProcessor mask.

makeInverseParabolicMask

public static ij.process.ImageProcessor makeInverseParabolicMask(int width,
                                                                 int height)
Creates an inverse parabolic mask (intensity=1/(x^2+x^y)).

Parameters:
width - width of the mask.
height - height of the mask.
Returns:
the ImageProcessor mask.

multiply

public static ij.process.FloatProcessor multiply(ij.process.ImageProcessor op1,
                                                 ij.process.ImageProcessor op2)
Multiply each pixel ImageProcessor for pixels of another ImageProcessor one-by-one.

Parameters:
op1 - ImageProcessor 1.
op2 - ImageProcessor 2.
Returns:
the resulting ImageProcessor.

multiply

public static ij.process.FloatProcessor multiply(double factor,
                                                 ij.process.ImageProcessor op1)
Multiply each pixel of ImageProcessor for the specified scalar factor.

Parameters:
factor - scalar factor.
op1 - ImageProcessor.
Returns:
the resulting FloatProcessor.

divide

public static ij.process.FloatProcessor divide(ij.process.ImageProcessor op1,
                                               ij.process.ImageProcessor op2)
Divide pixels of ImageProcessor by pixels of another ImageProcessor one-by-one.

Parameters:
op1 - ImageProcessor 1.
op2 - ImageProcessor 2.
Returns:
the resulting ImageProcessor.

add

public static ij.process.FloatProcessor add(ij.process.ImageProcessor op1,
                                            ij.process.ImageProcessor op2)
Add each pixel ImageProcessor to pixels of another ImageProcessor one-by-one.

Parameters:
op1 - ImageProcessor 1.
op2 - ImageProcessor 2.
Returns:
the resulting ImageProcessor.

subtract

public static ij.process.FloatProcessor subtract(ij.process.ImageProcessor op1,
                                                 ij.process.ImageProcessor op2)
Subtract each pixel ImageProcessor to pixels of another ImageProcessor one-by-one.

Parameters:
op1 - ImageProcessor 1.
op2 - ImageProcessor 2.
Returns:
the resulting ImageProcessor.

resetMin

public static void resetMin(ij.process.FloatProcessor ip)
Reset the minimum of FloatProcessor to zero.

Parameters:
ip - source FloatProcessor.

round

public static void round(ij.process.FloatProcessor ip)
Round each pixel to nearby integer value.

Parameters:
ip - source FloatProcessor.

addPhase

public static HoloJProcessor addPhase(HoloJProcessor processor,
                                      double angle)
Add to the source HoloJProcessor the specified phase in radians.

Parameters:
processor - an HoloJProcessor.
angle - radians to add.
Returns:
the resulting HoloJProcessor.

addPhasePlate

public HoloJProcessor addPhasePlate(HoloJProcessor processor,
                                    double[] plateArray)
Add to the specified HoloJProcessor a phase plate stored in a double array.

Parameters:
processor - the HoloJProcessor.
plateArray - a phase plate.
Returns:
the resulting HoloJProcessor.

Creative Commons License Valid XHTML 1.0! Valid CSS!

Permission to use the software and accompanying documentation provided on these pages for educational, research, and not-for-profit purposes, without fee and without a signed licensing agreement, is hereby granted, provided that the above copyright notice, this paragraph and the following two paragraphs appear in all copies. The copyright holder is free to make upgraded or improved versions of the software available for a fee or commercially only. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.