| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.7 - 14 Aug 2008 - RyanCabeen) |
Regular Discrete Data Tools User Guide | ||||||||
| Line: 24 to 24 | ||||||||
|---|---|---|---|---|---|---|---|---|
| The sampling is defined by the sampling "origin", the sampling spacing in each dimension and the number of samples in each dimension. There must be at least one sample in each dimension, but number of samples in each dimension need not be the same. The sample spacing must be positive and may differ in each dimension. | ||||||||
| Changed: | ||||||||
| < < |
Let (s1, s2, ...sN) be the sampling "origin". | |||||||
| > > |
Let (s1, s2, ..., sN) be the sampling "origin". | |||||||
| Let (dx1, dx2, ..., dxN) be the spacing between samples in each dimension. | ||||||||
| Changed: | ||||||||
| < < |
Let (K0, K1, ..., KK) be the number of samples in each dimension. | |||||||
| > > |
Let (K1, K2, ..., KN) be the number of samples in each dimension. | |||||||
| The data model then encodes the values of | ||||||||
| Line: 54 to 54 | ||||||||
|
| ||||||||
| Added: | ||||||||
| > > |
File FormatThere are routines for encoding discrete data objects to disk in a binary format. The format will be described in terms of Java primitive data types. The implementation of the format in the library uses Java DataOutputSteams, so this class should be used as a reference for binary representations of the Java primitives on file. Suppose there is a regular discrete data object with a sample dimension of N, starting point (s1, s2, ..., sN), sample spacings (dx1, dx2, ..., dxN), (K1, K2, ..., KN) in each dimension and a data dimension of M. Let the product K1 * K2 * ... * KN = L. The precision may be either double or float, and will be referred to as "pre". The format will have the following form:4 x char : a magic string, namely "RDDF" 1 x char : the floating point precision, namely 'd' for double and 'f' for single 1 x int : the data dimension N x pre : the starting point N x pre : the sample spacings N x int : the number of samples in each dimension L x M x pre : the dataThe ordering of the values of the data must be chosen in a consistent way. The data values are grouped by point, iterating over the sample indices. For example, the first M values encode the data at sample (0, 0, ..., 0); the second M values encode the data at sample (1, 0, ..., 0); the (K1 - 1)-th collection of M values encode the data at sample (K1 - 1, 0, ..., 0); the K1-th collection of M values encode the data at sample (0, 1, ..., 0); the last M values encode the data at sample (K1 - 1, K2 - 1, ..., KN - 1). | |||||||
ExampleHere is a class demonstrating use of the toolkit. Be sure the directory 'output' exists. | ||||||||
| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.6 - 12 Aug 2008 - RyanCabeen) |
| ||||||||
| Changed: | ||||||||
| < < |
Regular Discrete Data Tools User Guide | |||||||
| > > |
Regular Discrete Data Tools User Guide | |||||||
| Changed: | ||||||||
| < < |
TOC: No TOC in "CCB.RegularDiscreteDataUserGuide" | |||||||
| > > |
TOC: No TOC in "CCB.RegularDiscreteDataUserGuide" | |||||||
| Changed: | ||||||||
| < < |
Overview | |||||||
| > > |
Overview | |||||||
| This library intends to provide a comprehensive and flexible data model and implementation for arbitrary dimensional floating-point data sampled on a arbitrary dimensional regular grid. This can be used to store discretized functions or floating point image data. Both 32- and 64-bit precisions are supported. The toolkit includes operations to compute various vector and geometric quantities from the data. There are many predefined routines to convert the data objects to and from similar data structures. The toolkit allows file input and output of the data objects. | ||||||||
| Line: 12 to 14 | ||||||||
|---|---|---|---|---|---|---|---|---|
| In the ShapeTools library, there are mathematical function objects. These can be automatically sampled and encoded to this data model. Furthermore, there are classes to create the functions from the sampled data, essentially interpolating the data such that is is defined between samples. | ||||||||
| Changed: | ||||||||
| < < |
Mathematics | |||||||
| > > |
Mathematics | |||||||
| In particular, the data model encodes a sampling of a function | ||||||||
| Line: 32 to 36 | ||||||||
| for kn from [0,Kn-1]. The values kn are called the indices of a sample. Note, the indices are zero based. | ||||||||
| Changed: | ||||||||
| < < |
Types | |||||||
| > > |
Types | |||||||
| The following types constitute the data model: | ||||||||
| Line: 46 to 52 | ||||||||
| There are several implementations for most of the above interfaces. It is recommended that you use the factory classes instead of the concrete implementation constructors. | ||||||||
| Changed: | ||||||||
| < < |
Example | |||||||
| > > |
Example | |||||||
| Here is a class demonstrating use of the toolkit. Be sure the directory 'output' exists. | ||||||||
| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.5 - 12 Aug 2008 - RyanCabeen) |
Regular Discrete Data Tools User Guide | ||||||||
| Line: 46 to 46 | ||||||||
|---|---|---|---|---|---|---|---|---|
| There are several implementations for most of the above interfaces. It is recommended that you use the factory classes instead of the concrete implementation constructors. | ||||||||
| Changed: | ||||||||
| < < |
Demo | |||||||
| > > |
Example | |||||||
| Here is a class demonstrating use of the toolkit. Be sure the directory 'output' exists. | ||||||||
| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.4 - 24 Apr 2008 - RyanCabeen) |
| ||||||||
| Added: | ||||||||
| > > |
Regular Discrete Data Tools User Guide | |||||||
OverviewThis library intends to provide a comprehensive and flexible data model and implementation for arbitrary dimensional floating-point data sampled on a arbitrary dimensional regular grid. This can be used to store discretized functions or floating point image data. Both 32- and 64-bit precisions are supported. The toolkit includes operations to compute various vector and geometric quantities from the data. There are many predefined routines to convert the data objects to and from similar data structures. The toolkit allows file input and output of the data objects. | ||||||||
| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.3 - 14 Dec 2007 - RyanCabeen) |
Overview | ||||||||
| Line: 26 to 26 | ||||||||
|---|---|---|---|---|---|---|---|---|
| f(s1 + k1 * dx1, s2 + k2 * dx2, ..., sk + kN * dxN) | ||||||||
| Changed: | ||||||||
| < < |
for kn from [1,Kn]. The values kn are called the indices of a sample. | |||||||
| > > |
for kn from [0,Kn-1]. The values kn are called the indices of a sample. Note, the indices are zero based. | |||||||
Types | ||||||||
| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.2 - 13 Dec 2007 - RyanCabeen) |
Overview | ||||
| <<O>> Difference Topic RegularDiscreteDataUserGuide (r1.1 - 29 Nov 2007 - RyanCabeen) |
| Line: 1 to 1 | ||||||||
|---|---|---|---|---|---|---|---|---|
| Added: | ||||||||
| > > |
OverviewThis library intends to provide a comprehensive and flexible data model and implementation for arbitrary dimensional floating-point data sampled on a arbitrary dimensional regular grid. This can be used to store discretized functions or floating point image data. Both 32- and 64-bit precisions are supported. The toolkit includes operations to compute various vector and geometric quantities from the data. There are many predefined routines to convert the data objects to and from similar data structures. The toolkit allows file input and output of the data objects. This model is a good starting point for image processing and numerical solver applications. Additionally, the models are designed to allow special purpose implementations of data objects and operations on those objects. In the ShapeTools library, there are mathematical function objects. These can be automatically sampled and encoded to this data model. Furthermore, there are classes to create the functions from the sampled data, essentially interpolating the data such that is is defined between samples.MathematicsIn particular, the data model encodes a sampling of a function f:RN -> RM, where f(x1, x2, ..., xN) = (y1, y2, ..., yM). The sampling is defined by the sampling "origin", the sampling spacing in each dimension and the number of samples in each dimension. There must be at least one sample in each dimension, but number of samples in each dimension need not be the same. The sample spacing must be positive and may differ in each dimension. Let (s1, s2, ...sN) be the sampling "origin". Let (dx1, dx2, ..., dxN) be the spacing between samples in each dimension. Let (K0, K1, ..., KK) be the number of samples in each dimension. The data model then encodes the values of f(s1 + k1 * dx1, s2 + k2 * dx2, ..., sk + kN * dxN) for kn from [1,Kn]. The values kn are called the indices of a sample.TypesThe following types constitute the data model:
DemoHere is a class demonstrating use of the toolkit. Be sure the directory 'output' exists.
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import edu.ucla.loni.ccb.discretedata.DiscreteDataFactory;
import edu.ucla.loni.ccb.discretedata.SampleDescriptorFactory;
import edu.ucla.loni.ccb.discretedata.io.DiscreteDataIO;
import edu.ucla.loni.ccb.discretedata.models.IDataPoint;
import edu.ucla.loni.ccb.discretedata.models.IDiscreteData;
import edu.ucla.loni.ccb.discretedata.models.ISample;
import edu.ucla.loni.ccb.discretedata.models.ISampleDescriptor;
import edu.ucla.loni.ccb.discretedata.util.ImageDiscreteDataOperations;
import edu.ucla.loni.ccb.shape.math.functions.IFunction;
public class RegularDiscreteDataExample
{
private static final float X_SIZE = 2;
private static final float Y_SIZE = X_SIZE;
private static final float X_ORIGIN = -X_SIZE/2;
private static final float Y_ORIGIN = -Y_SIZE/2;
private static final int X_NUM = 512;
private static final int Y_NUM = 512;
private static final float DX = X_SIZE/(X_NUM-1);
private static final float DY = Y_SIZE/(Y_NUM-1);
private static final String DATA_FILENAME = "output/example_data.rdd";
private static final String IMAGE_FILENAME = "output/example_image.png";
private static final String IMAGE_FORMAT = "PNG";
private static final float MODULATION_FREQ = 2;
public static void main(String[] args) throws FileNotFoundException, IOException
{
/** BASIC */
System.out.println("Creating data object");
// Create the sample descriptor
double[] start = {X_ORIGIN,Y_ORIGIN};
double[] spacings = {DX,DY};
int[] nums = {X_NUM,Y_NUM};
ISampleDescriptor sampling = SampleDescriptorFactory.create(start,spacings,nums);
// Create the function that will be sampled
IFunction function = new ModulatedGaussian();
// Create the data object by sampling the function
IDiscreteData data = DiscreteDataFactory.sample(function, sampling);
/** IO */
System.out.println("Demonstrating IO");
// Write out and read in
DiscreteDataIO.write(new FileOutputStream(DATA_FILENAME),data);
data = DiscreteDataIO.read(new FileInputStream(DATA_FILENAME));
/** DATA ACCESS */
System.out.println("Demonstrating data access");
// Get a data value
ISample sample = sampling.getSamplePrototype();
sample.set(0,X_NUM/4);
sample.set(1,Y_NUM/4);
IDataPoint dp = data.getDataPrototype();
data.get(sample,dp);
// Print the data value
System.out.println("Sample: "+sample+", Data Value: "+dp);
/** IMAGE CREATION */
System.out.println("Demonstrating image creation");
// Create a grayscale image from the data
BufferedImage image = ImageDiscreteDataOperations.createNormalizedGrayscaleBufferedImage(data);
// Write the image out for viewing
ImageIO.write(image,IMAGE_FORMAT,new File(IMAGE_FILENAME));
}
/** A gaussian modulated by a sine wave */
private static class ModulatedGaussian implements IFunction
{
public void evaluate(float[] arg0, float[] arg1)
throws IllegalArgumentException
{
double radius = Math.sqrt(arg0[0] * arg0[0] + arg0[1] * arg0[1]);
arg1[0] = (float) (Math.cos(MODULATION_FREQ*2*Math.PI*radius)*Math.exp(-radius * radius));
}
public int getInputDimension()
{
return 2;
}
public int getOutputDimension()
{
return 1;
}
}
}
| |||||||
|
Revision r1.1 - 29 Nov 2007 - 02:55 - RyanCabeen Revision r1.7 - 14 Aug 2008 - 18:28 - RyanCabeen |