|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectMosaicProfiler
@ThreadSafe public class MosaicProfiler
Profiles the loading of random rectangular regions using a given TileManager.
The images to load while have random locations and random sizes, constrained between
a minimal and maximal size. A
random subsampling will be requested, constrained between a minimum and maximum subsampling.
More details on the algorithm used by this class are defined in the following methods:
The example below profiles a mosaic for different subsampling values. See
MosaicImageReadParam for an explanation about why invoking
setSubsamplingChangeAllowed(true)
is strongly recommended.
MosaicProfiler profiler = new MosaicProfiler(mosaic);
profiler.setSubsamplingChangeAllowed(true); // STRONGLY RECOMMANDED
profiler.setMaxSubsampling(1);
for (int i=1; i<20; i++) {
profiler.setMinSubsampling(i);
double efficiency = profiler.estimateEfficiency(100);
System.out.println("Subsampling=" + i + ", estimated efficiency=" + efficiency);
}
| coverage/geotk-coverageio (download) | View source code for this class |
| Field Summary | |
|---|---|
TileManager |
mosaic
The mosaic to profile. |
| Constructor Summary | |
|---|---|
MosaicProfiler(TileManager mosaic)
Creates a profiler for the given mosaic. |
|
| Method Summary | |
|---|---|
Statistics |
estimateEfficiency(int numSamples)
Returns an empirical estimation of the efficiency of loading images using the mosaic. |
Dimension |
getMaxSize()
Returns the maximal size of the images to load. |
Dimension |
getMaxSubsampling()
Returns the maximal subsampling of the random rectangular regions to load. |
Dimension |
getMinSize()
Returns the minimal size of the images to load. |
Dimension |
getMinSubsampling()
Returns the minimal subsampling of the random rectangular regions to load. |
Dimension |
getMosaicSize()
Returns the size of the mosaic given to the constructor. |
Rectangle |
getQueryRegion()
Returns the region in which random rectangles will be calculated. |
boolean |
isSubsamplingChangeAllowed()
Returns true if the mosaic is allowed to change the subsampling to some more
efficient value. |
void |
setMaxSize(Dimension size)
Sets the maximal size of the images to load. |
void |
setMaxSize(int size)
Convenience method setting the maximal size to the same value along x and y axis. |
void |
setMaxSubsampling(Dimension subsampling)
Sets the maximal subsampling of the random rectangular regions to load. |
void |
setMaxSubsampling(int subsampling)
Convenience method setting the maximal subsampling to the same value along x and y axis. |
void |
setMinSize(Dimension size)
Sets the minimal size of the images to load. |
void |
setMinSize(int size)
Convenience method setting the minimal size to the same value along x and y axis. |
void |
setMinSubsampling(Dimension subsampling)
Sets the minimal subsampling of the random rectangular regions to load. |
void |
setMinSubsampling(int subsampling)
Convenience method setting the minimal subsampling to the same value along x and y axis. |
void |
setQueryRegion(Rectangle bounds)
Sets the region in which random rectangles will be calculated. |
void |
setSeed(long seed)
Sets the seed of the random number generator. |
void |
setSubsamplingChangeAllowed(boolean allowed)
Sets whatever the mosaic will be allowed to change the subsampling to some more efficient value. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final TileManager mosaic
| Constructor Detail |
|---|
public MosaicProfiler(TileManager mosaic)
throws IOException
mosaic - The mosaic to profile.
IOException - If it was necessary to fetch an image dimension from its
reader and this operation failed.| Method Detail |
|---|
public void setSeed(long seed)
seed - The seed to be given to the random number generator.public Rectangle getQueryRegion()
MosaicProfiler construction, this is set to the region covered
by the whole mosaic.
public void setQueryRegion(Rectangle bounds)
throws IOException
bounds - The region in which random rectangles will be calculated.
IOException - If it was necessary to fetch an image dimension from its
reader and this operation failed.
public Dimension getMosaicSize()
throws IOException
IOException - If it was necessary to fetch an image dimension from its
reader and this operation failed.public Dimension getMinSize()
public void setMinSize(Dimension size)
size - The minimal size of the images to load.public void setMinSize(int size)
size - The minimal width and height of the images to load.public Dimension getMaxSize()
public void setMaxSize(Dimension size)
size - The maximal size of the images to load.public void setMaxSize(int size)
size - The maximal width and height of the images to load.public Dimension getMinSubsampling()
public void setMinSubsampling(Dimension subsampling)
subsampling - The minimal subsampling of the regions to load.public void setMinSubsampling(int subsampling)
subsampling - The minimal subsampling along x and y axis.public Dimension getMaxSubsampling()
public void setMaxSubsampling(Dimension subsampling)
subsampling - The maximal subsampling of the regions to load.public void setMaxSubsampling(int subsampling)
subsampling - The maximal subsampling along x and y axis.public boolean isSubsamplingChangeAllowed()
true if the mosaic is allowed to change the subsampling to some more
efficient value. The default value is false, which means that the mosaic will
use exactly the given subsampling and may leads to very slow reading.
true if the mosaic is allowed to change the subsampling.MosaicImageReadParam.isSubsamplingChangeAllowed()public void setSubsamplingChangeAllowed(boolean allowed)
true,
which is not the default because doing so would violate the ImageReader
contract.
allowed - true if the mosaic is allowed to change the subsampling.MosaicImageReadParam.setSubsamplingChangeAllowed(boolean)
public Statistics estimateEfficiency(int numSamples)
throws IOException
The highest value that this method can return is 1, which means that optimal loading (defined below) would occur. Values lower than 1 are the average time of image loadings compared to the optimal case. For example a value of 0.5 means that the theorical image loading time (defined below) is on average two time greater than it would be if it was possible to read all images optimally.
Definition of terms
The "theorical image loading time" is defined as proportional to the amount of
pixels to read, assuming that each tile is read in a "all or nothing" fashion.
This is only a gross approximation of the reality since image compression induces non-linear
relationship between the amount of pixels and the loading time, and some image formats like
TIFF and JPEG2000 can be tiled - thus breaking the "all or nothing" assumption.
The "optimal loading" case is defined as the case where every pixels to be traversed while reading tiles are useful to the requested image, with no pixel to discart because of croping or subsampling.
numSamples - The number of rectangular region to simulate loading.
IOException - If it was necessary to fetch an image dimension from its
reader and this operation failed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||