@ALDParametrizedClass
public class MTBVectorField2D
extends de.unihalle.informatik.Alida.operator.ALDData
Modifier and Type | Field and Description |
---|---|
private int |
height
Height of the image where the vector field comes from.
|
private double[] |
potential
Potential of the vector field.
|
private VectorField2DPotentialFinder |
potFinder
Helper object for reconstructing potential from vector field.
|
private double[] |
U
Vector U including the x-values of the vector field.
|
private double[] |
V
Vector V including the y-values of the vector field.
|
private int |
width
Width of the image where the vector field comes from.
|
Constructor and Description |
---|
MTBVectorField2D() |
MTBVectorField2D(double[] u,
double[] v,
int width,
int height) |
Modifier and Type | Method and Description |
---|---|
double[] |
calcPotential_approxLeastSquares(boolean ignoreBorder)
Calculates an approximation of the potential of the field by gradient
descent.
|
double[] |
calcPotential_exactLeastSquares(boolean ignoreBorder)
Calculates the potential of the field by solving a LSE with least squares.
|
double[] |
calcPotential_incrLeastSquares(boolean ignoreBorder)
Calculates a rough approximation of the potential of the field in linear
time.
|
double |
getDirection(double x,
double y)
Get direction of the vector at position (x,y) in the vector field.
|
int |
getFieldSizeX() |
int |
getFieldSizeY() |
double |
getMagnitude(double x,
double y)
Get magnitude of the vector at position (x,y) in the vector field.
|
double[] |
getPotential()
Returns a copy of the potential field (for faster access!).
|
double[] |
getU()
Get vector U of the field.
|
double[] |
getV()
Get vector V of the field.
|
double |
getValuePotential(double x,
double y)
Returns value of potential at specified position.
|
double |
getValueU(double x,
double y)
Get value from vector U at position (x,y).
|
double |
getValueV(double x,
double y)
Get value from vector V at position (x,y).
|
boolean |
readFromBinFile(String file)
Reads a vector field from a file in binary format.
|
void |
resetPotential()
Resets the potential, next access to it will enforce recalculation.
|
boolean |
saveToBinFile(String file)
Saves the vector field to a file in binary format.
|
void |
setU(double[] u,
int w,
int h)
Set vector U of the field.
|
void |
setU(double x,
double y,
double value)
Set value on (x,y) for vector U of the field.
|
void |
setV(double[] v,
int w,
int h)
Set value on (x,y) for vector V of the field.
|
void |
setV(double x,
double y,
double value)
Set value on (x,y) for vector V of the field.
|
@Parameter private double[] U
@Parameter private double[] V
@Parameter private int width
@Parameter private int height
private VectorField2DPotentialFinder potFinder
@Parameter private double[] potential
public MTBVectorField2D()
public MTBVectorField2D(double[] u, double[] v, int width, int height)
public int getFieldSizeX()
public int getFieldSizeY()
public double[] getU()
public double[] getV()
public double getValueU(double x, double y)
x
- x-coordinatey
- y-coordinatepublic double getValueV(double x, double y)
x
- x-coordinatey
- y-coordinatepublic void setU(double[] u, int w, int h) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
u
- vector to set Ude.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setU(double x, double y, double value) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Attention! Method assumes that memory for U is s already allocated.
x
- x-coordinatey
- y-coordinatevalue
- value to set on position (x,y)de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setV(double[] v, int w, int h) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
v
- vector to set Vde.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setV(double x, double y, double value) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Attention! Method assumes that memory for V is s already allocated.
x
- x-coordinatey
- y-coordinatevalue
- value to set on position (x,y)de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public double getMagnitude(double x, double y)
x
- x-coordinatey
- y-coordinatepublic double getDirection(double x, double y)
The direction is given relative to the x-axis and in radians, not in degrees. The range is from 0 to 2 * pi.
x
- x-coordinatey
- y-coordinatepublic double[] getPotential()
public double getValuePotential(double x, double y)
x
- x coordinate of position.y
- y coordinate of position.public void resetPotential()
public double[] calcPotential_exactLeastSquares(boolean ignoreBorder)
Attention! This methods takes a lot of resources. If your field is large you better use another routine for potential reconstruction.
ignoreBorder
- If true, outer rows and columns of the field are ignored.public double[] calcPotential_approxLeastSquares(boolean ignoreBorder)
ignoreBorder
- If true, outer rows and columns of the field are ignored.public double[] calcPotential_incrLeastSquares(boolean ignoreBorder)
ignoreBorder
- If true, outer rows and columns of the field are ignored.public boolean saveToBinFile(String file)
file
- Output file.public boolean readFromBinFile(String file)
file
- Input file.Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.