public class QuimPArrayUtils extends Object
Constructor and Description |
---|
QuimPArrayUtils() |
Modifier and Type | Method and Description |
---|---|
static double |
array2dMax(double[][] a)
Array max.
|
static double |
array2dMin(double[][] a)
Array min.
|
static double |
arrayMax(double[] a)
Array max.
|
static int |
arrayMax(int[] a)
Array max.
|
static double |
arrayMin(double[] a)
Array min.
|
static void |
arrayToFile(double[][] a,
String delim,
File outFile)
Array to file.
|
static Number[] |
castToNumber(ij.process.ImageProcessor input)
Convert ImageProcessor pixel data to array of objects.
|
static double[][] |
copy2darray(double[][] source,
double[][] dest)
Make deep copy of 2D array.
|
static float[][] |
double2dfloat(double[][] input)
Convert 2D double array to float.
|
static float[] |
double2float(double[] input)
Convert 1d double array to float.
|
static double[][] |
file2Array(String delim,
File inFile)
Load map file produced by arrayToFile.
|
static <T> void |
fill2Darray(double[][] array,
double d)
Fill 2D array with given value.
|
static <T> void |
fill2Darray(int[][] array,
int d)
Fill 2D array with given value.
|
static int |
findNumPeaks(double[] data,
int peakWidth)
Find num peaks.
|
static double[][] |
float2ddouble(float[][] input)
Convert 2D float array to double.
|
static double[] |
float2double(float[] input)
Deprecated.
Use ij.Tools.toDouble
|
static int |
getArraySize(Object object)
Get size of array across all dimensions.
|
static double |
getMax(RealMatrix input)
Find maximum in 2D RealMatrix.
|
static double[] |
getMeanC(double[][] map)
Calculate mean of map for every column.
|
static double[] |
getMeanR(double[][] map)
Calculate mean of map for every row.
|
static double |
getMin(RealMatrix input)
Find minimum in 2D RealMatrix.
|
static int |
getNumberOfLinesinFile(File file)
Return number of lines in file.
|
static double[] |
getVarR(double[][] map)
Calculate variance of map for every row.
|
static RealMatrix |
imageProcessor2RealMatrix(ij.process.ImageProcessor ip)
Create RealMatrix 2D from image.
|
static double[][] |
initDouble2dArray(int rows,
int cols)
Create 2D array of doubles.
|
static int[][] |
initInteger2dArray(int rows,
int cols)
Create 2D array of integers.
|
static short[] |
int2short(int[] input)
Convert integer array to short.
|
static int |
minArrayIndex(double[] a)
Find index of minimal element.
|
static double[] |
minArrayIndexElement(double[] a)
Find index of minimal element and the element itself.
|
static <T extends Comparable<T>> |
minListIndex(List<T> a)
Find index of minimal element in Collection.
|
static Double[] |
object2double(Number[] input)
Convert 1d double array to Double.
|
static void |
print(double[] a)
Prints the.
|
static void |
print(double[][] a)
Prints the.
|
static void |
realMatrix2D2File(RealMatrix matrix,
String outFile)
Save RelaMatrix 2D to file.
|
static ij.process.FloatProcessor |
realMatrix2ImageProcessor(RealMatrix rm)
Create FloatProcessor 2D from RealMatrix.
|
static <T> List<T> |
removeDuplicates(List<T> in)
Remove duplicated elements from input list.
|
static void |
reverseIntArray(int[] input)
reverse the given array in place.
|
static int |
sumArray(int[] a)
Sum array.
|
public static double[] float2double(float[] input)
input
- array to convertpublic static float[] double2float(double[] input)
input
- array to convertpublic static Double[] object2double(Number[] input)
input
- array to convertpublic static double[][] float2ddouble(float[][] input)
input
- Array to convertpublic static float[][] double2dfloat(double[][] input)
input
- Array to convertpublic static double[] getMeanR(double[][] map)
map
- mappublic static double[] getMeanC(double[][] map)
map
- mappublic static double[] getVarR(double[][] map)
map
- mappublic static <T> List<T> removeDuplicates(List<T> in)
in
- inpublic static void reverseIntArray(int[] input)
input
- inputpublic static short[] int2short(int[] input)
input
- inputpublic static double[][] initDouble2dArray(int rows, int cols)
rows
- Number of rowscols
- Number of columnspublic static int[][] initInteger2dArray(int rows, int cols)
rows
- Number of rowscols
- Number of columnspublic static double[][] copy2darray(double[][] source, double[][] dest)
If destination matrix is already initialized it must have correct size.
source
- source matrixdest
- destination matrix, if dest is null the matrix is initialized
in place.public static void arrayToFile(double[][] a, String delim, File outFile) throws IOException
Can be imported e.g. in Matlab image=importdata('/tmp/image.txt');
a
- the adelim
- the delimoutFile
- the out fileIOException
- Signals that an I/O exception has occurred.file2Array(String, File)
public static void realMatrix2D2File(RealMatrix matrix, String outFile) throws IOException
Use the code in Matlab:
data = importdata('/tmp/testRealMatrix2D2File.txt')
matrix
- matrix to saveoutFile
- output fileIOException
- on file errorpublic static double[][] file2Array(String delim, File inFile) throws IOException
Array must have equal number of columns in every row.
delim
- Delimiter, should be the same used in arrayToFileinFile
- inFileIOException
- on file errorarrayToFile(double[][], String, File)
public static int getNumberOfLinesinFile(File file) throws IOException
file
- fileIOException
- on file errorpublic static int findNumPeaks(double[] data, int peakWidth)
data
- the datapeakWidth
- the peak widthpublic static int arrayMax(int[] a)
a
- the apublic static double arrayMax(double[] a)
a
- the apublic static double array2dMax(double[][] a)
a
- the apublic static int minArrayIndex(double[] a)
a
- array to search inpublic static double[] minArrayIndexElement(double[] a)
a
- array to search inpublic static double arrayMin(double[] a)
a
- the apublic static double array2dMin(double[][] a)
a
- the apublic static int sumArray(int[] a)
a
- the apublic static void print(double[] a)
a
- the apublic static void print(double[][] a)
a
- the apublic static int getArraySize(Object object)
object
- Arraypublic static <T> void fill2Darray(double[][] array, double d)
Assumes regular array.
array
- arrayd
- value to fill withpublic static <T> void fill2Darray(int[][] array, int d)
Assumes regular array.
array
- arrayd
- value to fill withpublic static <T extends Comparable<T>> int minListIndex(List<T> a)
a
- collection to search inpublic static double getMax(RealMatrix input)
input
- Matrix to processpublic static double getMin(RealMatrix input)
input
- Matrix to processpublic static Number[] castToNumber(ij.process.ImageProcessor input)
input
- ImageProcessorpublic static ij.process.FloatProcessor realMatrix2ImageProcessor(RealMatrix rm)
rm
- input matrixpublic static RealMatrix imageProcessor2RealMatrix(ij.process.ImageProcessor ip)
ip
- input imageCopyright © 2002–2019 Department of Computer Science, Warwick University. All rights reserved.