pax_global_header00006660000000000000000000000064131644775470014534gustar00rootroot0000000000000052 comment=768a5b563dbe7ffacdfcd771535537d3357640d4 imglib2-imglib2-4.5.0/000077500000000000000000000000001316447754700144125ustar00rootroot00000000000000imglib2-imglib2-4.5.0/.gitignore000066400000000000000000000002051316447754700163770ustar00rootroot00000000000000**/.classpath **/.project **/.settings **/target .DS_Store .classpath .project .settings target *.class *~ *.orig # For Fiji # *.jar imglib2-imglib2-4.5.0/.mailmap000066400000000000000000000046011316447754700160340ustar00rootroot00000000000000Albert Cardona Albert Cardona Barry DeZonia Barry DeZonia Barry DeZonia Barry DeZonia Barry DeZonia Christian Dietz Christian Dietz Christian Dietz Christian Dietz Christian Dietz Curtis Rueden Grant Harris Jean-Yves Tinevez Jean-Yves Tinevez Johannes Schindelin Jonathan Hale Larry Lindsey Lee Kamentsky Mark Hiner Martin Horn Martin Horn Michael Zinsmaier Stefan Helfrich Stefan Helfrich Stephan Preibisch Stephan Preibisch Stephan Preibisch Stephan Preibisch Stephan Saalfeld Stephan Saalfeld Stephan Saalfeld Tobias Pietzsch Tobias Pietzsch Tobias Pietzsch Tobias Pietzsch imglib2-imglib2-4.5.0/.travis.yml000066400000000000000000000011061316447754700165210ustar00rootroot00000000000000language: java jdk: oraclejdk8 branches: only: master install: true script: ".travis/build.sh" after_success: ".travis/notify.sh Travis-Success" after_failure: ".travis/notify.sh Travis-Failure" env: global: - secure: fUjzJT4FxWloAnNxmVu+zIFKffChGebeoj2AhCEeKNm8iQgMSrDCmFuyBaGcg9+ytUQFsyl5mp+BTkhcrKdw7UXxAwaQ058uKFBQk77/VyVcxOqijE8rOwinlUHAKb7VuUDwjzlrEUUQ3tAInbhDFmHcnY2cWuU3C3hMUjrHHPY= - secure: dPoZjE0ue+jBXPcm8u688AX4bl0OGQITpO/VgulAazO5dXBA5s0jTOoIKg23L+nE5LUa0K4vrJU6fbbbMZPffot8GPppq/EJymzXHiJ5jWozb5D8tysGTxfEr6Q3hvKAfvV1XOto57VVEh9x8jqdLixBpc9Ry8iAg9slbZ4mZcY= imglib2-imglib2-4.5.0/.travis/000077500000000000000000000000001316447754700160005ustar00rootroot00000000000000imglib2-imglib2-4.5.0/.travis/build.sh000077500000000000000000000003511316447754700174350ustar00rootroot00000000000000#!/bin/sh dir="$(dirname "$0")" if [ "$TRAVIS_SECURE_ENV_VARS" = true \ -a "$TRAVIS_PULL_REQUEST" = false \ -a "$TRAVIS_BRANCH" = master ] then mvn -Pdeploy-to-imagej deploy --settings "$dir/settings.xml" else mvn install fi imglib2-imglib2-4.5.0/.travis/notify.sh000077500000000000000000000002421316447754700176450ustar00rootroot00000000000000#!/bin/sh curl -fs "https://jenkins.imagej.net/job/$1/buildWithParameters?token=$TOKEN_NAME&repo=$TRAVIS_REPO_SLUG&commit=$TRAVIS_COMMIT&pr=$TRAVIS_PULL_REQUEST" imglib2-imglib2-4.5.0/.travis/settings.xml000066400000000000000000000005031316447754700203600ustar00rootroot00000000000000 imagej.releases travis ${env.MAVEN_PASS} imagej.snapshots travis ${env.MAVEN_PASS} imglib2-imglib2-4.5.0/LICENSE.txt000066400000000000000000000032311316447754700162340ustar00rootroot00000000000000Copyright (c) 2009 - 2016, Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, Jean-Yves Tinevez and Michael Zinsmaier. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. imglib2-imglib2-4.5.0/README.md000066400000000000000000000070511316447754700156740ustar00rootroot00000000000000[![](https://img.shields.io/maven-central/v/net.imglib2/imglib2.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22net.imglib2%22%20AND%20a%3A%22imglib2%22) [![](https://travis-ci.org/imglib/imglib2.svg?branch=master)](https://travis-ci.org/imglib/imglib2) [![Join the chat at https://gitter.im/imglib/imglib2](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/imglib/imglib2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ImgLib2 is a general-purpose, multidimensional image processing library. It provides an interface-driven design that supports numeric and non-numeric data types (8-bit unsigned integer, 32-bit floating point, etc.) in an extensible way. It implements several data sources and sample organizations, including one single primitive array, one array per plane, N-dimensional array "cells" cached to and from disk on demand, and planes read on demand from disk. Benefits -------- 1. By avoiding unnecessarily complex syntax (such as nested loops) ImgLib2 allows developers to concentrate on the essence of the algorithm. 2. By being conciser, ImgLib2 makes it much harder to write buggy code. 3. ImgLib2 is dimension-independent. That means that you usually express your code in a way that can be applied to 2-, 3- or even 100-dimensional data. 4. ImgLib2 has no limit on channels. You can have a fine-grained spectrum for every single pixel, if your hardware allows for that. 5. ImgLib2 is actually not limited to images; e.g., we have examples working on RNA sequences. 6. ImgLib2 provides transparent data access. The algorithm does not need to know that it is working on a virtual stack, and the data can actually be generated on the fly. Think about a fractal and being able to zoom in indefinitely; this is an image that you can use with any ImgLib algorithm. 7. ImgLib2 makes it an ultra-cheap operation to work on sections of images. There is no need to copy data around. 8. ImgLib2 is so self-contained that it could serve as the underlying data handling library for every Java-based project. Applications ------------ * ImgLib2 provides the [core data model for ImageJ2](http://imagej.net/ImageJ2). * ImgLib2 is bundled with the [Fiji](http://fiji.sc/) distribution of ImageJ. * The [SCIFIO](http://scif.io/) library utilizes ImgLib2's N-dimensional image API. * ImgLib2 is a key component of the [SciJava software initiative](http://scijava.org/). Resources --------- * [ImgLib2 source code on GitHub](https://github.com/imglib/imglib2) * [Documentation on how to use ImgLib2](http://imglib2.net/) * [ImgLib2 Examples](http://imagej.net/ImgLib2_Examples) * [Online Javadoc](http://javadoc.imagej.net/ImgLib2/) * [Performance benchmarks](http://developer.imagej.net/imglib-benchmarks) Building the source code ------------------------ You can build the source from the command line using Maven: mvn You can also import the source into Eclipse using the m2e plugin. Download Eclipse IDE for Java Developers (3.7 Indigo or later), which comes with m2e preinstalled. Then run: File > Import > Existing Maven Projects Select the toplevel folder of your ImgLib working copy, and Eclipse will find all the ImgLib projects. Both NetBeans and IntelliJ IDEA also have built-in support for Maven projects. ImgLib1 ------- The previous incarnation of the library, known as ImgLib1, is still available as [part of Fiji](https://github.com/fiji/legacy-imglib1). However, we strongly encourage developers to use ImgLib2 instead, and migrate existing ImgLib1 programs to ImgLib2 whenever possible. imglib2-imglib2-4.5.0/doc/000077500000000000000000000000001316447754700151575ustar00rootroot00000000000000imglib2-imglib2-4.5.0/doc/Class Diagram Color.png000066400000000000000000015672231316447754700213360ustar00rootroot00000000000000PNG  IHDR0sBITO pHYsN N } IDATx{|Ix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kBw}wS I3o„ |Y=#_m۶^e˖N:e< rw80PYYyUW5$SO}ߏW_}gݴ%@%h:'p„ 6l_ٳM***Ν۳gd+Zj5gΜmۆ>K.dmjرcGiiĉ_W˳W+dK"Mׯ_4ԩS^3|׊B[N]v͝;wvڼyн{^pa.2UJ ħo֯_?z7>ӧO>gqƒ%K:v {tp>};SL9֣G^ziY ,w6mL:uϞ=?O/nݺ/ 0`ĉ/֭[,hl 8BhӦu]wumٲ3!oWUu@f.{ 9;Ȏ4 W8l[.Y,4@Xw( ;|!w9l7Iq\;yKwh$e!w @Z8o9K o%p @v]7J2! @J;eNߐswp rfw W \f]wh"3p\; '_3tp.>}@3X]Disl5VuprXwa2'_1 9e@pQ(yUJwعsgYYY#wj˖-@Rf.̀{r6m <: S͈#:wZ mO?ŋEEE#Gܽ{wz 0{IW4lCeeei*Li^| o ,@[7yKf!{LH|Yi ilh} 8bjbj55 4f__0ZZ=,o1iL0000000$U35F11)1 0 0 2.|/LQKN.0?10o1.=6=6$/=6/0 11 o1=6Z c:The Generic Java Image Processing Library Stephan Preibisch, Stephan Saalfeld, Johannes Schindelin, Pavel Tomancak The purpose of the Generic Java Image Processing Library is to provide an abstract system enabling Java developers to design and implement data processing algorithms without having to consider the type of data (e.g. byte, float, complex float), its dimensionality or storage type (e.g. array, cubes, paged cubes). Types The developer therefore uses different kinds of abstract cursors (e.g. mpi.imglib.cursor.LocalizableCursor) that an image (mpi.imglib.image.Image) can create based on its own type, dimensionality and storage strategy. To ensure type safety cursors as well as images are typed using Java Generics (e.g. LocalizableCursor, Image). Types supported so far comprise: ByteType (mpi.imglib.type.ByteType), 8 bit signed integer ShortType (mpi.imglib.type.ShortType) 16 bit signed integer IntType (mpi.imglib.type.IntType) 32 bit signed integer LongType (mpi.imglib.type.LongType) 64 bit signed integer FloatType (mpi.imglib.type.FloatType) 32 bit signed floating point DoubleType (mpi.imglib.type.DoubleType) 64 bit signed floating point RGBALegacyType (mpi.imglib.type.imagej.RGBALegacyType) 4 channel, 8bit signed stored as 32 bit signed integer All of the types support basic math functions, which can be called independent of their actual type using Java generics (see mpi.imglib.type.Type): Image img; ... Type type = img.createType(); type.inc(); type.mul( Math.PI ); Images To instantiate an image, the developer can load an image, create an image of a certain type or create a new image based on an existing instance which will have the same type. To load or create an image the developer has to define the storage strategy (mpi.imglib.container.ContainerFactory) that defines in which way memory is allocated. Currently the following storage strategies are supported: ArrayContainer (mpi.imglib.container.array.ArrayContainerFactory), stores all values in one single array, fast but limited to 2 billion pixels (231 pixels) CubeContainer (mpi.imglib.container.cube.CubeContainerFactory), stores the values in cubes, i.e. the data will be stored in many small arrays of fixed dimensions (e.g. 64x64x64 for 3d). This strategy is slower but not limited in size ImagePlusContainer (mpi.imglib.container.imageplus.ImagePlusContainerFactory), supported to edit ImageJ images directly, limited to 3 dimensions Images can be instantiated in the following ways: Loading an image Image img = LOCI.openLOCI(D:/Temp/img.tif, new ArrayContainerFactory()); Here, the LOCI reader decides which Type the Image will be loaded as. This image, however, can be used to call any generic method (see section Generic Classes and Methods) The developer can also try to load an image as a certain Type, this is very useful if the algorithm for example is written for a certain type only Image img = LOCI.openLOCIFloatType(D:/Temp/img.tif, new ArrayContainerFactory()); Not all Types are supported yet Creating a new image When creating an Image, the developer has to decide which Type to use ImageFactory imageFactory = new ImageFactory(new FloatType(), new CubeContainerFactory()); Image img = factory.createImage(new int[]{100,50,10,2}); This creates a 4-dimensional image of float using cubes for storage Creating a new image from an existing one If an image instance is given already, a new image of the same type and storage strategy can be instantiated Image img; Image img2 = img.createNewImage(); This creates an image of the same size Image img2 = img.createNewImage(new int[]{100,100}); This creates a 2d image of the same type and storage strategy Cursors Once images are loaded or created the developer performs computation using the already mentioned cursors. Each cursor has a Type available through cursor.getType(). This Type contains the value of the pixel pointed to by the cursor. To this end, five types of cursors are available: Cursor (mpi.imglib.cursor.Cursor), iterates over all pixels of the image with no predefined order. The order depends on the storage strategy but will be the same for image with same dimensions and exactly the same storage strategy (Image img2 = img.createNewImage()). This is the fastest cursor but also the most limited one; it is useful to compute the average of an image or subtract two images, for example. To instantiate call: Cursor cursor = img.createCursor(); LocalizableCursor (mpi.imglib.cursor.LocalizableCursor), behaves exactly as the simple Cursor, but knows its position inside the image which makes it slightly slower. This cursor can be used to compute algorithms such as the center of mass or to link positions between two images of different storage strategies. To instantiate call: LocalizableCursor cursor = img.createLocalizableCursor(); LocalizableCursorByDim (mpi.imglib.cursor.LocalizableCursor), can iterate over the image as well but is further able to move around freely inside or even outside of the image. This is the most flexible cursor that can basically do anything but is therefore also the slowest one. To instantiate call: LocalizableCursorByDim cursor = img.createLocalizbleCursorByDim(); or LocalizableCursorByDim cursor = img.createLocalizbleCursorByDim( new OutsideStrategyFactory() ); The OutsideStrategyFactory defines the behavior of the cursor when moving outside of the image, it can currently return a constant value or mirror the image content. If called without any OutsideStrategyFactory it will perform no check whether the coordinate is inside the image (crashes or gives wrong results if not!). This version is more optimized but should only be used if the developer is sure that the cursor will not move out of the image. Interpolation The image can also create interpolators which are needed to iterate over the image off the pixel grid. To this end, Nearest Neighbor InterpolatorFactory interpolatorFactory = new NearestNeighborInterpolatorFactory( outsideStrategyFactory ); and Linear Interpolation InterpolatorFactory interpolatorFactory = new LinearInterpolatorFactory( outsideStrategyFactory ); are supported. The final interpolator is then created as follows: Interpolator interpolator = img.createInterpolator( interpolatorFactory ); Developing algorithms The introduction showed how computation in general works using the library. Here is example code of a simple algorithm: Open image and add an increasing value (which will visualize the way the cursor moves over the image): Image img = LOCI.openLOCI(D:/Temp/img.tif, new ArrayContainerFactory()); addValues( img ); Or ImageFactory imageFactory = new ImageFactory(new FloatType(), new CubeContainerFactory()); Image img2 = factory.createImage(new int[]{100,50,10,2}); addValues( img2 ); Implementation of the algorithm as generic method public > void addValues( Image image ) { // create cursor final Cursor c = image.createCursor(); // create variable of same type and set to one final T type = image.createType(); type.setOne(); // iterate over image while ( c.hasNext() ) { // move iterator forward c.fwd(); // set cursor to the value of type c.getType().add( type ); // increase type type.inc(); } // close the cursor c.close(); } Writing algorithms for one specific Type (e.g. only FloatType) will look like this: Image img=LOCI.openLOCIFloatType(D:/Temp/img.tif,new ArrayContainerFactory()); computeAverage( img ); public FloatType computeAverage( Image img ) { // create cursor final Cursor c = image.createCursor(); // create variable of same type and set to one final float sum = 0; // the number of pixels in the image final int numPixels = img.getNumPixels(); // iterate over image while ( c.hasNext() ) { // move iterator forward c.fwd(); // set cursor to the value of type // division not outside loop to prevent overflow // correctly one would have to use BigInteger here sum += c.getType().get() / numPixels; } // close the cursor c.close(); return new FloatType( sum ); } To display images there are currently two methods, displaying them as ImageJ Virtual Stacks (preferred) which does not use any more memory or copying them to ImageJ ImagePlus instances which can then be displayed. In any case, the dimensionality might be reduced as only 3 dimensions can be displayed. Image img = LOCI.openLOCI(D:/Temp/img.tif, new ArrayContainerFactory()); img.getDisplay().setMinMax(); ImageJFunctions.displayAsVirtualStack( img ).show(); ImageJFunctions.copyToImagePlus( img ).show(); There are more details to the whole library which will become more obvious once one starts using it. One major issue is not solved yet, which is how to deal generically with Multi-Channel images. The current design is, however, almost finished; it will be implemented on top of the Image class and will integrate seamlessly into the current processing structure. Multichannel images will simply create different cursors. More example code can be found in the Test.java class located here: mpi.imglib.Test. For developing we suggest using the 32-bit version of Eclipse IDE for Java Developers (JDT) (HYPERLINK "http://www.eclipse.org/downloads/"http://www.eclipse.org/downloads/) which can also run 64-bit Java Virtual Machines. Necessary libraries are: LOCI Bioformats library standalone for import of images (bio-formats.jar, HYPERLINK "http://www.loci.wisc.edu/ome/formats-download.html"http://www.loci.wisc.edu/ome/formats-download.html) Fiji/ImageJ (ij.jar,  HYPERLINK "http://rsbweb.nih.gov/ij/download/zips/ij142.zip" http://rsbweb.nih.gov/ij/download/zips/ij142.zip) The source of this library should be added as a new project which is then added as necessary project for the development of the own source code. All JAR imports as well as necessary projects are configured by right clicking on Referenced Libraries -> Build Path -> Configure Build path. Please consider that this library is still alpha stage, it has been tested but there will be still some errors. The most stable container is the ArrayContainer, use it whenever possible but also the ImagePlusContainer should work properly. The algorithms in there (Gaussian Convolution, Affine Transformation (needs the mpicbg packa;ge available through Fiji, HYPERLINK "http://pacific.mpi-cbg.de/"http://pacific.mpi-cbg.de/), Linear Interpolation, Nearest Neighbor Interpolation) are all written completely generically. Therefore their performance is not optimal. We added some implementations for optimized speed, currently for 3d and ArrayStorage. This optimization is still not available for the Linear Interpolator which will be added soon. There is a compatibility layer to ImageJ using the ImagePlusContainer. To work on an existing ImagePlus it has to be wrapped into an Image of the library; this works without copying the data. ImagePlus imp = new Opener().openImage("D:/Temp/img.tif"); // converts it into an image of unknown type Image img = ImagePlusAdapter.wrap( imp ); // converts it into an image of FloatType Image img = ImagePlusAdapter.wrapFloat( imp ); Generic Classes and Methods Generic classes or methods can be called with any instance of Image. It ensures that inside that class or method all occurrences of are of the same Type, allowing generic programming. A generic class will look like this: public class GaussianConvolution< T extends Type > { Cursor cursor; public GaussianConvolution( Image img ) { ... } } All in this class will be of the same type, and any Image, Image or specialized version e.g. Image can be given as parameter. To instantiate a typed class, a typed method is, however, necessary, see the example below. public class UnTypedClass { pulic void untypedMethod() { Image img = LOCI.openLOCI(D:/Temp/img.tif, new ArrayContainerFactory()); // here we cannot instantiate the typed class, but a typed method which can typedMethod( img ); } public > void typedMethod( Image img ) { // inside here, all are the same, thats why it works GaussianConvolution convol = new GaussianConvolution( img ); } } *  ! * / 0 1 < G H  ǿ{sg[{[{sShNVmH sH hX0h 6mH sH hX0hX06mH sH hX0mH sH h mH sH )hX0hNVB*CJOJQJmH phsH #hNVB*CJOJQJmH phsH hNV6mH sH hYThYT6mH sH hYTmH sH htht5CJ mH sH h@mH sH h`_h`_6mH sH h`_mH sH h`_h`_5CJ,mH sH  *st & `  Q   $ & Fa$gd"X^gd@ $ & Fa$gd/} $ & Fa$gdX0$a$gdYT$a$gd`_$a$gd`_  % & / 0 I j k {    ) . 3 \ ] m s x  ȳȳȳȳȳȳȳȳȳȳȳ⨠yy)hX0h/}B*CJOJQJmH phsH #h/}B*CJOJQJmH phsH h/}mH sH hX0hX0mH sH )hX0hX0B*CJOJQJmH phsH #hX0B*CJOJQJmH phsH h mH sH hX0mH sH )hX0hNVB*CJOJQJmH phsH +    g h |  ',8=`eîî홇|nffZfNNNhNVhNV6mH sH h h 6mH sH h mH sH htht5CJ mH sH h@h@mH sH #h@B*CJOJQJmH phsH )h@h@B*CJOJQJmH phsH )hX0h7NB*CJOJQJmH phsH #h7NB*CJOJQJmH phsH hNVmH sH h7NmH sH h@mH sH hkmH sH h/}hX0mH sH D*,6@EYZx%/9RSVޯޯޯɋh"Xh"XmH sH hs]mH sH hMmH sH h>3mH sH h@h@H*mH sH #h:B*CJOJQJmH phsH hYTmH sH )hX0h"XB*CJOJQJmH phsH #h"XB*CJOJQJmH phsH h@mH sH h"XmH sH 1()MQV[syij˹peZRIhs]h.0Jhs]mH sH h.hkdmH sH hkdhkdmH sH #hkdB*CJOJQJmH phsH hfc^mH sH hkdmH sH h,mH sH h.h.6mH sH h.mH sH h.hNVmH sH #h.B*CJOJQJmH phsH #hNVB*CJOJQJmH phsH h mH sH hNVmH sH h"Xh"XmH sH h(%jmH sH )jMNx $ & Fa$gds] $ & Fa$gds] $^a$gda $ & Fa$gd. $^a$gdkd $ & Fa$gdkd $ & Fa$gd. $ & Fa$gdNV $ & Fa$gd $a$gd"XM~*KMNx@cuwxپ٬뤜딜wf_fQf_IhymH sH haB*CJOJQJph haha!hahaB*CJOJQJphhahamH sH #haB*CJOJQJmH phsH hs]mH sH hamH sH hE[mH sH #hwB*CJOJQJmH phsH #hE[B*CJOJQJmH phsH h#h.0J#h.B*CJOJQJmH phsH h.mH sH h.h.6mH sH @xXA+!-!C!!""""gddP$a$gdp'$a$gd L1 & Fgd{*X $ & Fa$gd$a$gdy $^a$gdy $ & Fa$gda $^a$gda(Ue./vμ޴ph`Xh L1mH sH hf,mH sH h8{mH sH )hhB*CJOJQJmH phsH hpmH sH )hX0hB*CJOJQJmH phsH #hB*CJOJQJmH phsH hmH sH #hwB*CJOJQJmH phsH hwmH sH hEmH sH hymH sH htht5CJ mH sH h.@5CJ mH sH SXs:CWXrtuȶȑȑ~i~~~a~ihj-KmH sH )h L1h L1B*CJOJQJmH phsH h L1h L1mH sH hmH sH h*mH sH h6|mH sH )hX0h6|B*CJOJQJmH phsH #h6|B*CJOJQJmH phsH h L1mH sH hymH sH )hh L1B*CJOJQJmH phsH #h L1B*CJOJQJmH phsH @AxzŽ嵭|t_M#hn~B*CJOJQJmH phsH )hn~hn~B*CJOJQJmH phsH hfc^mH sH hvu mH sH h8FmH sH hn~mH sH h8Fh8F5CJ mH sH ht5CJ mH sH h.mH sH hp'mH sH h L1mH sH h L1h L1mH sH )h L1h L1B*CJOJQJmH phsH h{*XmH sH #h{*XB*CJOJQJmH phsH     ) + 6 X \ { | !!&!'!)!*!+!ƴƴ}}}}uƴƴjbhjumH sH hn~hn~mH sH hV($mH sH )hn~hfc^B*CJOJQJmH phsH hn~mH sH hfc^mH sH #h8FB*CJOJQJmH phsH #hV($B*CJOJQJmH phsH #hn~B*CJOJQJmH phsH )hn~hn~B*CJOJQJmH phsH #hfc^B*CJOJQJmH phsH #+!-!C!D!Z!!!!!!!!! """o"q"z""""""""##>#?#H#R##޾޾ޡ}k֏bPPP}P#h0 gB*CJOJQJmH phsH h#hdP0J#hjuB*CJOJQJmH phsH #h8FB*CJOJQJmH phsH #hdPB*CJOJQJmH phsH )hjuhjuB*CJOJQJmH phsH h8FmH sH hdPmH sH hn~mH sH hV($mH sH h emH sH hjumH sH hV($hV($5CJ mH sH h8F5CJ mH sH "R##$h$$%'%J%L%M%%&&&,''=(@(a(() **,,,$a$gdfc^gdJDgdf$a$gdfgddP###########/$0$S$c$~$$$$$$$$$$$%%%#%&%;%<%G%H%I%J%L%M%T%d%g%h%u%v%%%%ƴƴآh.mH sH h.@mH sH hfmH sH h emH sH #h.B*CJOJQJmH phsH #h8FB*CJOJQJmH phsH #hdPB*CJOJQJmH phsH )hdPhdPB*CJOJQJmH phsH #hV($B*CJOJQJmH phsH /%%%%%%&N&_&`&n&w&&&&&&+'B'C'Y'Z'\']'w'''(1(;(?(T(U(`(((((((()ررررررررر؟رر؅zrjrjrh0mH sH h.mH sH hfhfmH sH hfmH sH #h3B*CJOJQJmH phsH #h"B*CJOJQJmH phsH )hdPhfB*CJOJQJmH phsH #hFB*CJOJQJmH phsH #hfB*CJOJQJmH phsH )hfhfB*CJOJQJmH phsH )))4)>)H)M)Z)))**L+T+o+x+++,,,p,,,,, - -.-/-z-{-|---..:.;.=.wlawh"XhW}xmH sH hW}xhW}xmH sH hJwhW}x0JmH sH h@h!mH sH jh!UhW}xmH sH #h8 B*CJOJQJmH phsH h"<mH sH h8 mH sH hfc^mH sH #h"<B*CJOJQJmH phsH )hjuh"<B*CJOJQJmH phsH h.mH sH h0mH sH $,|-=../2344456 78gdk$a$gd}=gd-]egd}=$a$gdY!$ $ & Fa$gdW}x$a$gdW}x =.R.S._.......U//00111L1M1s1t111w222223333}}rjbM)hU.[hU.[B*CJOJQJmH phsH h]mH sH hU.[mH sH h]h]mH sH h06B* mH phI}sH hJwhY!$0J6mH sH h@h!mH sH hY D6B* mH phI}sH hY!$6B* mH phI}sH  hY!$hY!$6B* mH phI}sH hY!$mH sH hY!$hY!$mH sH hJwhW}x0JhW}xjh!U hW}xhW}x33)4U4Z4e44444444L5j5l5555556 7Y7øm[m[SA#h}=B*CJOJQJmH phsH h}=mH sH #h-]eB*CJOJQJmH phsH )h-]eh-]eB*CJOJQJmH phsH hW}xmH sH h-]emH sH humH sH h<mH sH hbmH sH h8Fh<5CJ mH sH h e5CJ mH sH )h}=h<B*CJOJQJmH phsH )hU.[hU.[B*CJOJQJmH phsH #hU.[B*CJOJQJmH phsH Y7788)h}=hkB*CJOJQJmH phsH #h}=B*CJOJQJmH phsH )hjuh}=B*CJOJQJmH phsH 21h:p%D. A!"#$n% j 666666666vvvvvvvvv666666>6666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~ OJPJQJ_HmHnHsHtHJ`J %DNormal dCJ_HaJmHsHtH DA`D Default Paragraph FontRiR 0 Table Normal4 l4a (k ( 0No List @@@  List Paragraph ^m$NN #Code ^`a$B*CJOJQJmH phsH :: s]Style1  & Fa$mH sH >O!> # List Paragraph CharHO"1H # Code CharB*CJOJQJmH phsH 6O"A6 s] Style1 CharmH sH 6U@Q6 W}x0 Hyperlink >*B*phPK![Content_Types].xmlj0Eжr(΢Iw},-j4 wP-t#bΙ{UTU^hd}㨫)*1P' ^W0)T9<l#$yi};~@(Hu* Dנz/0ǰ $ X3aZ,D0j~3߶b~i>3\`?/[G\!-Rk.sԻ..a濭?PK!֧6 _rels/.relsj0 }Q%v/C/}(h"O = C?hv=Ʌ%[xp{۵_Pѣ<1H0ORBdJE4b$q_6LR7`0̞O,En7Lib/SeеPK!kytheme/theme/themeManager.xml M @}w7c(EbˮCAǠҟ7՛K Y, e.|,H,lxɴIsQ}#Ր ֵ+!,^$j=GW)E+& 8PK!Ptheme/theme/theme1.xmlYOo6w toc'vuر-MniP@I}úama[إ4:lЯGRX^6؊>$ !)O^rC$y@/yH*񄴽)޵߻UDb`}"qۋJחX^)I`nEp)liV[]1M<OP6r=zgbIguSebORD۫qu gZo~ٺlAplxpT0+[}`jzAV2Fi@qv֬5\|ʜ̭NleXdsjcs7f W+Ն7`g ȘJj|h(KD- dXiJ؇(x$( :;˹! I_TS 1?E??ZBΪmU/?~xY'y5g&΋/ɋ>GMGeD3Vq%'#q$8K)fw9:ĵ x}rxwr:\TZaG*y8IjbRc|XŻǿI u3KGnD1NIBs RuK>V.EL+M2#'fi ~V vl{u8zH *:(W☕ ~JTe\O*tHGHY}KNP*ݾ˦TѼ9/#A7qZ$*c?qUnwN%Oi4 =3ڗP 1Pm \\9Mؓ2aD];Yt\[x]}Wr|]g- eW )6-rCSj id DЇAΜIqbJ#x꺃 6k#ASh&ʌt(Q%p%m&]caSl=X\P1Mh9MVdDAaVB[݈fJíP|8 քAV^f Hn- "d>znNJ ة>b&2vKyϼD:,AGm\nziÙ.uχYC6OMf3or$5NHT[XF64T,ќM0E)`#5XY`פ;%1U٥m;R>QD DcpU'&LE/pm%]8firS4d 7y\`JnίI R3U~7+׸#m qBiDi*L69mY&iHE=(K&N!V.KeLDĕ{D vEꦚdeNƟe(MN9ߜR6&3(a/DUz<{ˊYȳV)9Z[4^n5!J?Q3eBoCM m<.vpIYfZY_p[=al-Y}Nc͙ŋ4vfavl'SA8|*u{-ߟ0%M07%<ҍPK! ѐ'theme/theme/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6 +_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!Ptheme/theme/theme1.xmlPK-! ѐ' theme/theme/_rels/themeManager.xml.relsPK] 0 f  +!#%)=.3Y78 !"$&'()*,-.012",8#%+/$ %.%%&:&R&&&L)s))0XXXX\(# AA@0(  B S  ? 1G&.0H`ik2Q[]w)+Y   R  $ p y { ~ M Y Z c e q ~ Uc,9TXns%;E[ +>BU^w|&+.1>Vkqz| %*-?H@PU`=D  $%3;DFInw}  (LUgo   ' 2 ; V ] n w *!3!!!!!!!"""" "E"G"J"U"t"v"y"p$$%%=&R&u(((($)*)+)3)d*p*++/+8+++++, , ,!,K,T,[,d,f,i,l,,,,----..../#/(/-/3/@/S/V/Y/f/~//////'020=0@0000000000[bUd1?@Q!=E)JU ( V ^ c i !! "F"=&&0)3),,--03333333333333333333333333*t&  @x> A b%|%,,l--0g,i. 94ZV4lK(3F b 0ONdlڅ)P)gR ^`OJQJo(^`OJQJ^Jo(o p^p`OJQJo( @ ^@ `OJQJo(^`OJQJ^Jo(o ^`OJQJo( ^`OJQJo(^`OJQJ^Jo(o P^P`OJQJo( ^`OJQJo(^`OJQJ^Jo(o p^p`OJQJo( @ ^@ `OJQJo(^`OJQJ^Jo(o ^`OJQJo( ^`OJQJo(^`OJQJ^Jo(o P^P`OJQJo( ^`OJQJo(^`OJQJ^Jo(o p^p`OJQJo( @ ^@ `OJQJo(^`OJQJ^Jo(o ^`OJQJo( ^`OJQJo(^`OJQJ^Jo(o P^P`OJQJo( ^`OJQJo(^`OJQJ^Jo(o p^p`OJQJo( @ ^@ `OJQJo(^`OJQJ^Jo(o ^`OJQJo( ^`OJQJo(^`OJQJ^Jo(o P^P`OJQJo( ^`OJQJo(^`OJQJ^Jo(o p^p`OJQJo( @ ^@ `OJQJo(^`OJQJ^Jo(o ^`OJQJo( ^`OJQJo(^`OJQJ^Jo(o P^P`OJQJo( ^`OJQJo(p^p`OJQJ^Jo(o @ ^@ `OJQJo( ^`OJQJo(^`OJQJ^Jo(o ^`OJQJo( ^`OJQJo(P^P`OJQJ^Jo(o  ^ `OJQJo(. 9ONdg,3F b)P)g4lKxF,Cvu * .@#Y!$V($p'X0 L1>3"<@.@%DY D8Fj-K7NdPYTNV"X{*XU.[s]fc^`_bkd e-]ef0 g(%jjuW}x8{6|/}f,p8 03awu!EE[:JDt]n~".<Mkk,}= yF00@,,@ ,,0h@UnknownG* Times New Roman5Symbol3. * Arial9=K @Consolas7.{ @Calibri?= * Courier New;WingdingsACambria Math"qKkFKkFb&*Y*Y20002HX  $P`_2!xxStephanStephan$      Oh+'0  0 < H T`hpxStephan Normal.dotmStephan2Microsoft Office Word@@OK@z6K@z6K*՜.+,D՜.+,8 hp  MPI-CBG DresdenY0  Titled 8@ _PID_HLINKSA2v http://pacific.mpi-cbg.de/e V1http://rsbweb.nih.gov/ij/download/zips/ij142.zipe !43http://www.loci.wisc.edu/ome/formats-download.htmle PR"http://www.eclipse.org/downloads/e   !"#$%&'()*+,-./012356789:;=>?@ABCDEFGHIJKLMNOPQRSTUVWYZ[\]^_abcdefgjknRoot Entry FxXKmData 41Table<a6WordDocument 4fSummaryInformation(XDocumentSummaryInformation8`MsoDataStore9>KLQKIJNXYUOUCC==29>KLQKItem  PropertiesUCompObj y   F'Microsoft Office Word 97-2003 Document MSWordDocWord.Document.89qimglib2-imglib2-4.5.0/doc/The Generic Java Image Processing Library.pdf000066400000000000000000002610201316447754700252570ustar00rootroot00000000000000%PDF-1.4 %쏢 5 0 obj <> stream x=ێ=#gI3lKc'vdtx,%ޒ}"8@s{[d7YEvu{,ئ"YwVk'v")p)v~0O݇}ۥbF\/wR4bj?~?h'{1xhm'PKo0P2ޞV%i kקP^ ` /]4a#>^W<@,!*t - 78&M_zz&=hh} -& o+O$o:QĦ\` H*I~f5^>ZhvBXp%t/_Ai+iǝ0xBrPae)i+8+6PF,,рPQh8RJK2 |H]:11tb1xi%"Z-L R J瘎z2NC!uH|HgiC,jX5|tP &Mhv zcJ;ga2wv;i3/W̧} lt7d0HmCY9Wy}NGzoF{륅-2/!/a`ش΃@*V 5q M/?0o%.D,(5 [4ENȷp V).J9`f R"ka2ˁ| 1b0ҏ穏rB& 8Xn\Jc&&ݭr#JG=K1ۡvҶ{t,FyhK$ҍik;N3kzRq򌙛Lx 2eGK;YK)F68ėc#s#1R&" @A3 |0ҦSKSʿ`Bg8;ڋD 6*:ob".B?E툤 aAduOތ#=E06Ȏ7at҂DjG?^ʌT1gwD=&Ɩ|w dLi)}RKg7 bb\*ʌlBނ'y/r>}yGg f3>{+V!]c(r Z^2d֗'%GOoP:ǵ {?`ז>&Tke 6@ 8Y3F`3&kw2[IK!'!KHFRڭΓZzZK]0]xb0QS\3C~AgOhm5o $=9ݒ &.rOA7 j߈^ݯ ǍkebkG*ͰGz,-FwS0Z߀VʙȟW4XIGfazwumx],kUI]5YlkLZܨ|Ǭ.@ O1dBkQ1حMoVă͆jTC :Q@ Ԁ##>Ǻo'D^5js{ 0X7$w=պpǮ~cҙ1͘& < -YGcX.#qVN+q]z4U؂0 NN )۪k' D!FE:)\[03ES=ZY?H#uϱ$ 6B`j zOvubAB1%^r"#lTE4()<-W5N* ZD^X9׻DT0w|w ]`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Ӑ'eH~]n(\[KG't4E,Zէ" L]䳆xhaϜSmZ];\%}R:mO}}ˏ1ŧM[iڸSwk֗K|Y[BPlmsgRǻŒ!\3@uc9]I-:A83xrF)<&|ZmuS`\#:SGocosA͏tJ5=o342^RWiη VM|iJr$߀In 4g[ XovgEVxZ*m'A8ĩb6"l΂^F\~Z_6_œ0V q :cXk?endstream endobj 37 0 obj 4686 endobj 40 0 obj <> stream x]o ut2NȖJz>wfGE_S(gwgM!9עj- R~X/wW߹uhw^:`iډگN-ݏKjwX}ZlVmx>;/luFPDpv^7z EuA4S@6RuV.KQ%6[[ +DP j-\kk+8A|5p[`yR5MTw3pf oO"aU ҩ A 4Olw`S6[_Zc7.x듌z6NVoG eid<Qu@a "^ NYt#MES B1g:X xidi.|σklrD$Auz1$XS6 5d(ݿ R h7aƪR34tn;^B+mC[#\SLl:H&Y7^`2|)h. 1D20T=DaLx"z-<LL<.6j]p֖0GqSh#i-i5):p$C5y“d$~Cz+8 .'Q4vTKPSD%RAủ'QPؖ-\XgkZ|TdN"yȕ"'IΩ% 4V6SuH7իs0{ńo:N4 iRL0eE'>$d4CtVQ4"}ml !(ebk1G'nR]w}ZnAFک|qxNphoPc4#֪M{OE~#"6C"p:p Gة9:̔c! Bp|[18A>/ZH)!&; lʹu<[?0cˑB$2". 㙏gy@O $9b$-gHu z!"@ ?'A2DSdC&Č8kSyJ(Mu3d肁>E~#Lα|l 040딱-W-潲w|3\܁eRVvDCp[;℀ɲ=Ղ1łA#p a'#QdjΣ%[p9&wyy8vLfS`bq q;L{}?~ٟendstream endobj 41 0 obj 2493 endobj 4 0 obj <> /Contents 5 0 R >> endobj 18 0 obj <> /Contents 19 0 R >> endobj 23 0 obj <> /Contents 24 0 R >> endobj 27 0 obj <> /Contents 28 0 R >> endobj 31 0 obj <> /Contents 32 0 R >> endobj 35 0 obj <> /Contents 36 0 R >> endobj 39 0 obj <> /Contents 40 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ 4 0 R 18 0 R 23 0 R 27 0 R 31 0 R 35 0 R 39 0 R ] /Count 7 /Rotate 0>> endobj 1 0 obj <> endobj 17 0 obj <> endobj 22 0 obj <> endobj 26 0 obj <> endobj 30 0 obj <> endobj 34 0 obj <> endobj 38 0 obj <> endobj 42 0 obj <> endobj 47 0 obj <>stream x]0{70YiVU `V 6{wf&l|~yM?Ym>jsov2oumt~:~ um|ݠ,nsǩVO)e)].uyjEdSAIږH=kW")W־DହDR~bJ$R"SndK$ecH2T"s<IY4H9a-\]Xae02`oZx)2XMށ ֊&1XM޾cYjͰZxUa5yV,&@j:7@ĕt˛ΉV;V7v r1UauyΥsX]^‚`d`uy{RȰ-E-}/i)zf> endobj 48 0 obj <> endobj 49 0 obj <>stream x]1r0^ Ikƃi\$Ir=*LihG"h(_^n{w_ޭmskwo`->Ǘ[С6|/֞KMsݧS*Zu[ky}tҒҒee.-iY%yb94,,ҒF>4XJKfU:˹QXTZZAˤ9Ac hXBc` I\AceИD1(9I y8p"Z&C1Xy96[KX]̉Vo'Hauy3Oa^9޼g JX]ޞ밺CqX]ެV%7auyCuu՛5d6# ksk4:j5 zh^h^uk!﨑a y3`</ !!T+!sΗQ0Za:WXD\3^{uGU;qtG /VMOu& endstream endobj 13 0 obj <> endobj 50 0 obj <> endobj 15 0 obj <> endobj 21 0 obj <> endobj 16 0 obj <> endobj 51 0 obj <>stream x]=n0 Fw70R\%C> endobj 52 0 obj <> endobj 53 0 obj <>stream x]An0нO&dѢh{Y/";3 0I/_^}]>t҇c;o;t^.u:__ko{>\N:/6oo}wHֵvoq\_Icn"i*ERYK)-kmTujT;S$I"irc̺H=H"-|A5QUXMZYa5y+[fVXM޺jN ;j.+&o=jN> endobj 54 0 obj <> endobj 12 0 obj <> endobj 43 0 obj <>stream x}|\ŵ-{wnEڢծʪwYW[umUrq1`001 5b1ZBbZRh! &;sgW6q};:9S̙3] !-ڃXٛ[5ơ-4_q[^x B׭޲f]{BHe^ajZ׀PkW u3}m|TӵIԵwC/ W tK)m:g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ѵ,ѵRkIU3ig)$q4U@F/l`!L"gOh`Khs/E!_8kQ\L~TM'*7?>׵+ZWY/p侜֚IAUmsV9Bz *rAOpq ҁ3W3qslRMr1"%2ً eH i!d$95I% R,qTHO$=&lqPG07#Ĺ#9F6IȶTw㣒R`=rdRU(z6|I 3e: Rp[n&LsN /aR5t#;Vb /s&L`;m8\0LuvђJ209P`Wt e8iδi5}lGı)!ӜBXVQ"ͨ5FWS[`D#*gEϹv'_W2j-dR٭>C5sߴ k+OMMOU}6]0B΢\7fqvs)XAX~y*PJD sE ԩN nK!CFl' ngU/%=h&ijPA:+UW6U*LaMh;ț&j&2al58Dt1sٸ)T9Q:xg?^6MWܚ5F7Ekէ:/heTh 5˛)2TR޵*19فug=,)ygi)p +; fqb(=$7zF`rΙaeZNY4\rG!LK_%M6f(Np xpH4Pa';pĎ#6∀8Mc,Z+3Vv'{@v4Н $;Rrrѓ /!'!iKL[ /HFm 01,!;d'G,`Y,(`VWpD9OSC5M z5J|&[^.9?W#l \=o&M9x' qQq ED’៉MoE:.؏1U6Tt4"'J79LRs y$MH19|ڴ䏓/*|b4Ӝ"(ccdLQVPrldjA[5zjz;RRm:9Z{ N0HGs/=pks &/Ӄo=˱O6gƳ{Cfq*_<ޡCcZ׷?Cׯ;~桿Y{MgKOyݿ!<G1UǦځ,7]Hv\÷a>W^lb«p:vrM7~g .I[_GsU ѭ4+pkPQTM@tŀ@Kx {s pP,_gODc( );Q|~#Fg |o-ŷXG3Qɥ&aNn@l֡ +ХJ7c\ N_ $j@毾CO?8G.:r[%z6p2/N}@y|W endstream endobj 55 0 obj <>stream PDFCreator Version 0.9.5 The Generic Java Image Processing LibraryStephan Preibisch endstream endobj 2 0 obj <>endobj xref 0 56 0000000000 65535 f 0000028871 00000 n 0000089108 00000 n 0000028761 00000 n 0000027755 00000 n 0000000015 00000 n 0000005271 00000 n 0000032642 00000 n 0000059760 00000 n 0000033742 00000 n 0000069786 00000 n 0000029917 00000 n 0000034550 00000 n 0000031215 00000 n 0000047400 00000 n 0000032049 00000 n 0000032174 00000 n 0000028936 00000 n 0000027897 00000 n 0000005291 00000 n 0000010069 00000 n 0000032111 00000 n 0000029019 00000 n 0000028041 00000 n 0000010090 00000 n 0000014052 00000 n 0000029113 00000 n 0000028185 00000 n 0000014073 00000 n 0000016435 00000 n 0000029185 00000 n 0000028329 00000 n 0000016456 00000 n 0000020369 00000 n 0000029235 00000 n 0000028473 00000 n 0000020390 00000 n 0000025148 00000 n 0000029276 00000 n 0000028617 00000 n 0000025169 00000 n 0000027734 00000 n 0000029350 00000 n 0000034760 00000 n 0000047601 00000 n 0000059965 00000 n 0000069989 00000 n 0000029400 00000 n 0000030278 00000 n 0000030588 00000 n 0000031650 00000 n 0000032239 00000 n 0000032923 00000 n 0000033139 00000 n 0000034159 00000 n 0000087627 00000 n trailer << /Size 56 /Root 1 0 R /Info 2 0 R /ID [<8040F3E2F9088A1A58BA600F5C1600EE><8040F3E2F9088A1A58BA600F5C1600EE>] >> startxref 89366 %%EOF imglib2-imglib2-4.5.0/doc/changelog.madison.txt000066400000000000000000000015161316447754700213030ustar00rootroot00000000000000Stephan Saalfeld, Tobias Pietzsch, Stephan Preibisch: * redesigned ImgLib core gaining the following improvements: * separation of access to the domain and codomain (position vs. type-access) * separation of iteration and random access * separation of real and integer coordinate access * virtualization of how data sets can be accessed, thus allowing generative functions, views on virtually transformed data, unevenly sampled data, and much more * improved performance * simplified generalized display * added interactive panorama viewer as aplugin to Fiji (thanks Albert for doing the infrastructure) * added integral images as a library component to the mpicbg submodule of Fiji with the following examplary applications: * rapid mean filter * rapid averaging downscaling * rapid difference of mean filter imglib2-imglib2-4.5.0/doc/imglib2-eclipse-clean-up-formatter-style.xml000066400000000000000000000736301316447754700255220ustar00rootroot00000000000000 imglib2-imglib2-4.5.0/doc/imglib2-eclipse-clean-up-style.xml000066400000000000000000000072501316447754700235140ustar00rootroot00000000000000 imglib2-imglib2-4.5.0/doc/imglib2-eclipse-mars-clean-up-formatter-style.xml000066400000000000000000000744651316447754700264710ustar00rootroot00000000000000 imglib2-imglib2-4.5.0/doc/imglib2-logo-inverse.svg000066400000000000000000000060661316447754700216440ustar00rootroot00000000000000 image/svg+xml ImgLib2 imglib2-imglib2-4.5.0/doc/imglib2-logo-poster.svg000066400000000000000000000313041316447754700214760ustar00rootroot00000000000000 image/svg+xml ImgLib2 http://imglib2.net imglib2-imglib2-4.5.0/doc/imglib2-logo.svg000066400000000000000000000060141316447754700201640ustar00rootroot00000000000000 image/svg+xml ImgLib2 imglib2-imglib2-4.5.0/doc/imglib2-qr-black.svg000066400000000000000000000267751316447754700207400ustar00rootroot00000000000000 image/svg+xml http://imglib2.net imglib2-imglib2-4.5.0/doc/imglib2-qr.svg000066400000000000000000000260401316447754700176470ustar00rootroot00000000000000 image/svg+xml http://imglib2.net imglib2-imglib2-4.5.0/doc/imglib2.dia000066400000000000000000012702731316447754700171770ustar00rootroot00000000000000 #Letter# ## ## #IterableRealInterval# ## #iterate all elements in a real interval# #cursor# ## #RealCursor<T># ## #localizingCursor# ## #RealCursor<T># ## #size# ## #long# ## #T# #Object# #RandomAccessible# ## #random access at integer coordinates# #randomAccess# ## #RandomAccess<T># ## #randomAccess# ## #RandomAccess<T># ## #interval# #Interval# ## ## #T# #Object# ## ## #Sampler# ## ## #get# ## #T# ## #T# #Object# #RealPositionable# ## ## #move# ## ## ## #distance# #float# ## ## #d# #int# ## ## #move# ## ## ## #distance# #double# ## ## #d# #int# ## ## #move# ## ## ## #l# #RealLocalizable# ## ## #move# ## ## ## #vector# #float[]# ## ## #move# ## ## ## #vector# #double[]# ## ## #setPosition# ## ## ## #l# #RealLocalizable# ## ## #setPosition# ## ## ## #position# #float[]# ## ## #setPosition# ## ## ## #position# #double[]# ## ## #setPosition# ## ## ## #position# #float# ## ## #d# #int# ## ## #setPosition# ## ## ## #position# #double# ## ## #d# #int# ## ## #Positionable# ## ## #inc# ## ## ## #d# #int# ## ## #dec# ## ## ## #d# #int# ## ## #move# ## ## ## #distance# #int# ## ## #d# #int# ## ## #move# ## ## ## #distance# #long# ## ## #d# #int# ## ## #move# ## ## ## #l# #Localizable# ## ## #move# ## ## ## #vector# #int[]# ## ## #move# ## ## ## #vector# #long[]# ## ## #setPosition# ## ## ## #l# #Localizable# ## ## #setPosition# ## ## ## #position# #int[]# ## ## #setPosition# ## ## ## #position# #long[]# ## ## #setPosition# ## ## ## #position# #int# ## ## #d# #int# ## ## #setPosition# ## ## ## #position# #long# ## ## #d# #int# ## ## ## ## ## ## #RealLocalizable# ## ## #localize# ## ## ## #position# #float[]# ## ## #localize# ## ## ## #position# #double[]# ## ## #getFloatPosition# ## #float# ## #d# #int# ## ## #getDoublePosition# ## #double# ## #d# #int# ## ## #Localizable# ## ## #localize# ## ## ## #position# #int[]# ## ## #localize# ## ## ## #position# #long[]# ## ## #getIntPosition# ## #int# ## #d# #int# ## ## #getLongPosition# ## #long# ## #d# #int# ## ## ## ## #RealRandomAccessible# ## #random access at real coordinates# #realRandomAccess# ## #RealRandomAccess<T># ## #T# #Object# #RealRandomAccessibleRealInterval# ## #random access at real coordinates of a real interval# #realRandomAccess# ## #RealRandomAccess<T># ## #factory# #OutOfBoundsFactory<T,F># ## ## #T# #Object# #F# #Object# ## ## #RandomAccessibleInterval# ## #random access at integer coordinates of an integer interval# #T# #Object# #F# #Object# ## ## ## ## ## ## #RealInterval# ## ## #realMin# ## #double# #size of a dimension# #d# #int# ## ## #realMin# ## ## ## #realMin# #double[]# ## ## #realMax# ## #double# ## #d# #int# ## ## #realMax# ## ## ## #realMax# #double[]# ## ## #Interval# ## ## #min# ## #long# #size of a dimension# #d# #int# ## ## #min# ## ## ## #min# #long[]# ## ## #max# ## #long# ## #d# #int# ## ## #max# ## ## # # #max# #long[]# ## ## #dimension# ## #long# ## #d# #int# ## ## #dimensions# ## ## ## #size# #long[]# ## ## ## ## #Img# ## #zero min positive integer interval filled with elements# #factory# ## #ImgFactory<T># ## #T# #Object# ## ## #InterpolatedRandomAccessible# ## #A RealRandomAccessible that provides access to real coordinates through interpolation.# #T# #Object# ## ## #RandomAccess# ## ## #T# #Object# ## ## ## ## ## ## #RealRandomAccess# ## ## #T# #Object# ## ## ## ## ## ## #Iterator# ## ## #fwd# ## ## ## #fwd# ## ## ## #steps# #long# ## ## #reset# ## ## ## #hasNext# ## #boolean# ## ## ## #RealCursor# ## ## #T# #Object# ## ## ## ## #Cursor# ## ## #T# #Object# ## ## ## ## #IterableInterval# ## #iterate all elements in an integer interval# #cursor# ## #Cursor<T># ## #localizingCursor# ## #Cursor<T># ## #T# #Object# ## ## ## ## #NativeImg# ## #Default entry point for pixel data stored in a raster, provides iterators and access to discrete pixel values.# #T# #NativeType<T># #A# #DataAccess# ## ## #ArrayImg# ## #single linear array of basic types# #T# #NativeType<T># #A# #DataAccess# #CellImg# ## #list of cells being linear arrays of basic types# #T# #NativeType<T># #A# #DataAccess# #PlanarImg# ## #list of x,y-planes being linear arrays of basic types# #T# #Type<T># #A# #DataAccess# ## ## ## ## ## ## #ListImg# ## #list of pixels stored as objects# #T# #Type<T># ## ## #EuclideanSpace# ## ## #numDimensions# ## #int# #number of dimensions# #Axes# ## ## #axis# ## #Axis# #number of dimensions# ## ## ## ## #Affine# ## ## #Similarity# ## ## #Rigid# ## ## #Translation# ## ## #AbstractAffineTransform# ## ## #AbstractSimilarityTransform# ## ## #AbstractRigidTransform# ## ## #AbstractTranslationTransform# ## ## #Concatenable# ## ## #concatenate# ## #Concatenable<A># ## #a# #A# ## ## #A# #Object# #PreConcatenable# ## ## #preConcatenate# ## #PreConcatenable<A># ## #a# #A# ## ## #A# #Object# #AffineTransform# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #SimilarityTransform# ## ## #RigidTransform# ## ## #TranslationTransform# ## ## ## ## ## ## ## ## ## ## ## #A:Affine# ## #A:Similarity# ## ## ## ## ## #A:Rigid# ## #A:Translation# ## ## imglib2-imglib2-4.5.0/doc/imglib2.svg000066400000000000000000014301161316447754700172330ustar00rootroot00000000000000 imglib2-imglib2-4.5.0/doc/net.imglib2.interpolation.randomaccess.LanczosInterpolator.LUT.bsh000066400000000000000000000034601316447754700317770ustar00rootroot00000000000000double piSquare = Math.PI * Math.PI; int preCalculationScale = 10; int a = 5; double[] sinc = new double[ a * preCalculationScale + 2 ];; int scale = 100; red = 0x00ff0000; green = 0x0000ff00; double[] preCalculateSinc( int max, int scale ) { double[] sinc = new double[ max * scale + 2 ]; for ( int i = 0; i < sinc.length; ++i ) { double x = ( double )i / ( double )preCalculationScale; sinc[ i ] = sinc( x, max ); } return sinc; } double sinc( double x, double a ) { if ( x == 0 ) return 1; else return (( a * Math.sin( Math.PI * x ) * Math.sin( Math.PI * x / a ) ) / ( piSquare * x * x )); } double sinc2( double x ) { double y = x < 0 ? -preCalculationScale * x : preCalculationScale * x; int yi = ( int )y; double d = y - yi; return ( sinc[ yi + 1 ] - sinc[ yi ] ) * d + sinc[ yi ]; } sinc = preCalculateSinc( a, preCalculationScale ); ip = new ColorProcessor( a * scale, 2 * scale ); for ( int x = 0; x < ip.getWidth(); ++x ) { v = sinc( ( double )x / scale, a ); ip.putPixel( x, scale - ( int )Math.round( v * scale ), green ); v = sinc2( ( double )x / scale ); yi = scale - ( int )Math.round( v * scale ); ip.putPixel( x, yi, ip.get( x, yi ) | red ); } new ImagePlus( "Lanczos kernel", ip ).show(); ipKernel = new ColorProcessor( 2 * a * scale, 2 * a * scale ); impKernel = new ImagePlus( "Lanczos Kernel", ipKernel ); impKernel.show(); for ( int y = 0; y < ipKernel.getHeight(); ++y ) { vSinc = sinc( ( double )y / scale - a, a ); vSinc2 = sinc2( ( double )y / scale - a ); for ( int x = 0; x < ipKernel.getWidth(); ++x ) { v = vSinc * sinc( ( double )x / scale - a, a ); rgb = ( int )Math.round( 127 + v * 127 ) << 8; v = vSinc2 * sinc2( ( double )x / scale - a ); rgb |= ( int )Math.round( 127 + v * 127 ) << 16; ipKernel.putPixel( x, y, rgb ); } impKernel.updateAndDraw(); } imglib2-imglib2-4.5.0/pom.xml000066400000000000000000000156411316447754700157360ustar00rootroot00000000000000 4.0.0 net.imglib2 pom-imglib2 9.0.0 imglib2 4.5.0 ImgLib2 Core Library A multidimensional, type-agnostic image processing library. http://imglib2.net/ 2009 ImgLib2 http://imglib2.net/ Simplified BSD License repo ImageJ Forum http://forum.imagej.net/ scm:git:git://github.com/imglib/imglib2 scm:git:git@github.com:imglib/imglib2 imglib2-4.5.0 https://github.com/imglib/imglib2 GitHub https://github.com/imglib/imglib2/issues Travis CI https://travis-ci.org/imglib/imglib2 net.imglib2 bsd_2 ImgLib2: a general-purpose, multidimensional image processing library. ImgLib2 authors Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, Jean-Yves Tinevez and Michael Zinsmaier. tpietzsch Tobias Pietzsch http://imagej.net/User:Pietzsch lead developer debugger reviewer support maintainer axtimwalde Stephan Saalfeld http://imagej.net/User:Saalfeld founder lead developer debugger reviewer support maintainer StephanPreibisch Stephan Preibisch http://imagej.net/User:StephanP founder lead developer debugger reviewer support maintainer ctrueden Curtis Rueden http://imagej.net/User:Rueden maintainer Barry DeZonia http://imagej.net/User:Bdezonia bdezonia Albert Cardona http://imagej.net/User:Albertcardona acardona Christian Dietz http://imagej.net/User:Dietzc dietzc Jean-Yves Tinevez http://imagej.net/User:JeanYvesTinevez tinevez Johannes Schindelin http://imagej.net/User:Schindelin dscho Jonathan Hale Squareys Lee Kamentsky http://imagej.net/User:Leek LeeKamentsky Larry Lindsey http://imagej.net/User:Lindsey larrylindsey Ellen T Arena http://imagej.net/User:Etarena etarena John Bogovic http://imagej.net/User:Bogovic bogovicj Jan Funke http://imagej.net/User:Funke funkey Aivar Grislis http://imagej.net/User:Grislis grislis Philipp Hanslovsky hanslovsky Grant Harris http://imagej.net/User:Harris tnargsirrah Stefan Helfrich http://imagej.net/User:Stelfrich stelfrich Mark Hiner http://imagej.net/User:Hinerm hinerm Martin Horn hornm Steffen Jaensch Melissa Linkert http://imagej.net/User:Linkert melissalinkert Mark Longair http://imagej.net/User:Mark mhl Nick Perry http://imagej.net/User:NicholasPerry nickp Alison Walter http://imagej.net/User:Awalter2 awalter17 Michael Zinsmaier MichaelZinsmaier junit junit test gov.nist.math jama test imglib2-imglib2-4.5.0/src/000077500000000000000000000000001316447754700152015ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/000077500000000000000000000000001316447754700161255ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/000077500000000000000000000000001316447754700170465ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/000077500000000000000000000000001316447754700176345ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/000077500000000000000000000000001316447754700211615ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractCursor.java000066400000000000000000000100321316447754700247610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import net.imglib2.util.Util; /** * Abstract implementation of {@link Cursor}. Java's {@link java.util.Iterator} * interface is implemented by mapping to abstract {@link #fwd()} and * {@link #get()}. * *

* For localization, default implementations are available that all build on the * abstract long variant. For particular cursors, this may be implemented more * efficiently saving at least one loop over n. * * @param * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractCursor< T > extends AbstractEuclideanSpace implements Cursor< T > { /** * used internally to forward all localize() versions to the (abstract) * long[] version. */ final private long[] tmp; /** * @param n * number of dimensions in the {@link net.imglib2.img.Img}. */ public AbstractCursor( final int n ) { super( n ); tmp = new long[ n ]; } @Override public void remove() { // NB: no action. } @Override public T next() { fwd(); return get(); } /** * Highly recommended to override this with a more efficient version. * * @param steps */ @Override public void jumpFwd( final long steps ) { for ( long j = 0; j < steps; ++j ) fwd(); } @Override public void localize( final float[] pos ) { localize( this.tmp ); for ( int d = 0; d < n; d++ ) pos[ d ] = this.tmp[ d ]; } @Override public void localize( final double[] pos ) { localize( this.tmp ); for ( int d = 0; d < n; d++ ) pos[ d ] = this.tmp[ d ]; } @Override public void localize( final int[] pos ) { localize( this.tmp ); for ( int d = 0; d < n; d++ ) pos[ d ] = ( int ) this.tmp[ d ]; } @Override public float getFloatPosition( final int d ) { return getLongPosition( d ); } @Override public double getDoublePosition( final int d ) { return getLongPosition( d ); } @Override public int getIntPosition( final int d ) { return ( int ) getLongPosition( d ); } @Override public String toString() { localize( tmp ); return Util.printCoordinates( tmp ) + " = " + get(); } @Override abstract public AbstractCursor< T > copy(); @Override abstract public AbstractCursor< T > copyCursor(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractCursorInt.java000066400000000000000000000102541316447754700254420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import net.imglib2.util.Util; /** * Abstract implementation of {@link Cursor}. Java's {@link java.util.Iterator} * interface is implemented by mapping to abstract {@link #fwd()} and * {@link #get()}. * *

* For localization, default implementations are available that all build on the * abstract int variant. For particular cursors, this may be implemented more * efficiently saving at least one loop over n. * *

* This is identical to {@link AbstractCursor}, except that default * implementations build on the abstract int instead of long variant here. * * @param * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractCursorInt< T > extends AbstractEuclideanSpace implements Cursor< T > { /** * used internally to forward all localize() versions to the (abstract) * int[] version. */ final private int[] tmp; /** * @param n * number of dimensions in the {@link net.imglib2.img.Img}. */ public AbstractCursorInt( final int n ) { super( n ); tmp = new int[ n ]; } @Override public void remove() { // NB: no action. } @Override public T next() { fwd(); return get(); } /** * Highly recommended to override this with a more efficient version. * * @param steps */ @Override public void jumpFwd( final long steps ) { for ( long j = 0; j < steps; ++j ) fwd(); } @Override public void localize( final float[] pos ) { localize( this.tmp ); for ( int d = 0; d < n; d++ ) pos[ d ] = this.tmp[ d ]; } @Override public void localize( final double[] pos ) { localize( this.tmp ); for ( int d = 0; d < n; d++ ) pos[ d ] = this.tmp[ d ]; } @Override public void localize( final long[] pos ) { localize( this.tmp ); for ( int d = 0; d < n; d++ ) pos[ d ] = this.tmp[ d ]; } @Override public float getFloatPosition( final int d ) { return getIntPosition( d ); } @Override public double getDoublePosition( final int d ) { return getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return getIntPosition( d ); } @Override public String toString() { localize( tmp ); return Util.printCoordinates( tmp ) + " = " + get(); } @Override abstract public AbstractCursorInt< T > copy(); @Override abstract public AbstractCursorInt< T > copyCursor(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractEuclideanSpace.java000066400000000000000000000046331316447754700263630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Superclass of abstract EuclideanSpace implementations (accessors, containers, * etc). Does nothing but store the number of dimensions of the underlying * function. * * Stephan Saalfeld * * @author Tobias Pietzsch * @author Stephan Preibisch */ public abstract class AbstractEuclideanSpace implements EuclideanSpace { /** * the number of dimensions. */ final protected int n; /** * @param n * number of dimensions. */ public AbstractEuclideanSpace( final int n ) { this.n = n; } @Override public int numDimensions() { return n; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractInterval.java000066400000000000000000000131201316447754700252710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Implementation of the {@link Interval} interface. * * * @author Tobias Pietzsch * @author Stephan Preibisch */ public abstract class AbstractInterval extends AbstractEuclideanSpace implements Interval { final protected long[] min; final protected long[] max; /** * Creates an n-dimensional {@link AbstractInterval} with min and * max = 0n. * * @param n * number of dimensions */ public AbstractInterval( final int n ) { super( n ); this.min = new long[ n ]; this.max = new long[ n ]; } /** * Creates a {@link AbstractInterval} from another {@link Interval} * * @param interval * - another {@link Interval} */ public AbstractInterval( final Interval interval ) { this( interval.numDimensions() ); interval.min( min ); interval.max( max ); } /** * Creates an Interval with the boundaries [0, dimensions-1] * * @param dimensions * - the size of the interval */ public AbstractInterval( final Dimensions dimensions ) { this( dimensions.numDimensions() ); for ( int d = 0; d < n; ++d ) this.max[ d ] = dimensions.dimension( d ) - 1; } /** * Creates an Interval with the boundaries [min, max] (both including) * * @param min * - the position of the first elements in each dimension * @param max * - the position of the last elements in each dimension */ public AbstractInterval( final long[] min, final long[] max ) { this( min.length ); assert min.length == max.length; for ( int d = 0; d < n; ++d ) { this.min[ d ] = min[ d ]; this.max[ d ] = max[ d ]; } } /** * Creates an Interval with the boundaries [0, dimensions-1] * * @param dimensions * - the size of the interval */ public AbstractInterval( final long[] dimensions ) { this( dimensions.length ); for ( int d = 0; d < n; ++d ) this.max[ d ] = dimensions[ d ] - 1; } @Override public double realMin( final int d ) { assert d >= 0; assert d < n; return min[ d ]; } @Override public void realMin( final double[] minimum ) { assert minimum.length == n; for ( int d = 0; d < n; ++d ) minimum[ d ] = this.min[ d ]; } @Override public void realMin( final RealPositionable minimum ) { assert minimum.numDimensions() == n; minimum.setPosition( this.min ); } @Override public double realMax( final int d ) { assert d >= 0; assert d < n; return max[ d ]; } @Override public void realMax( final double[] maximum ) { assert maximum.length == n; for ( int d = 0; d < n; ++d ) maximum[ d ] = this.max[ d ]; } @Override public void realMax( final RealPositionable m ) { assert m.numDimensions() == n; m.setPosition( this.max ); } @Override public long min( final int d ) { assert d >= 0; assert d < n; return min[ d ]; } @Override public void min( final long[] minimum ) { assert minimum.length == n; for ( int d = 0; d < n; ++d ) minimum[ d ] = this.min[ d ]; } @Override public void min( final Positionable m ) { assert m.numDimensions() == n; m.setPosition( this.min ); } @Override public long max( final int d ) { assert d >= 0; assert d < n; return max[ d ]; } @Override public void max( final long[] maximum ) { assert maximum.length == n; for ( int d = 0; d < n; ++d ) maximum[ d ] = this.max[ d ]; } @Override public void max( final Positionable m ) { assert m.numDimensions() == n; m.setPosition( this.max ); } @Override public void dimensions( final long[] dimensions ) { assert dimensions.length == n; for ( int d = 0; d < n; ++d ) dimensions[ d ] = max[ d ] - min[ d ] + 1; } @Override public long dimension( final int d ) { assert d >= 0; assert d < n; return max[ d ] - min[ d ] + 1; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractLocalizable.java000066400000000000000000000072351316447754700257400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An abstract class that implements the {@link Localizable} interface using a * long[] array to maintain position. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractLocalizable extends AbstractEuclideanSpace implements Localizable { /** * The {@link Localizable} interface is implemented using the position * stored here. {@link Positionable} subclasses, such as {@link Point}, * modify this array. */ protected final long[] position; /** * @param n * number of dimensions. */ public AbstractLocalizable( final int n ) { super( n ); position = new long[ n ]; } /** * Protected constructor that re-uses the passed position array. This is * intended to allow subclasses to provide a way to wrap a long[] array. * * @param position * position array to use. */ protected AbstractLocalizable( final long[] position ) { super( position.length ); this.position = position; } @Override public void localize( final float[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public void localize( final int[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = ( int ) position[ d ]; } @Override public void localize( final long[] pos ) { for ( int d = 0; d < n; d++ ) pos[ d ] = position[ d ]; } @Override public float getFloatPosition( final int d ) { return position[ d ]; } @Override public double getDoublePosition( final int d ) { return position[ d ]; } @Override public int getIntPosition( final int d ) { return ( int ) position[ d ]; } @Override public long getLongPosition( final int d ) { return position[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractLocalizableInt.java000066400000000000000000000074521316447754700264140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An abstract class that implements the {@link Localizable} interface using an * int[] array to maintain position. * *

* This is identical to {@link AbstractLocalizable}, except that the position is * limited to {@link Integer#MAX_VALUE} in every dimension. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractLocalizableInt extends AbstractEuclideanSpace implements Localizable { /** * The {@link Localizable} interface is implemented using the position * stored here. {@link Positionable} subclasses, such as {@link Point}, * modify this array. */ protected final int[] position; /** * @param n * number of dimensions. */ public AbstractLocalizableInt( final int n ) { super( n ); position = new int[ n ]; } /** * Protected constructor that re-uses the passed position array. This is * intended to allow subclasses to provide a way to wrap a int[] array. * * @param position * position array to use. */ protected AbstractLocalizableInt( final int[] position ) { super( position.length ); this.position = position; } @Override public void localize( final float[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public void localize( final int[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public void localize( final long[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public float getFloatPosition( final int d ) { return position[ d ]; } @Override public double getDoublePosition( final int d ) { return position[ d ]; } @Override public int getIntPosition( final int d ) { return position[ d ]; } @Override public long getLongPosition( final int d ) { return position[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractLocalizingCursor.java000066400000000000000000000053551316447754700270110ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Abstract base class for localizing {@link Cursor}s. The current position is * maintained in the inherited long[] {@link AbstractLocalizable#position * position} field. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractLocalizingCursor< T > extends AbstractLocalizable implements Cursor< T > { /** * @param n * number of dimensions in the {@link net.imglib2.img.Img}. */ public AbstractLocalizingCursor( final int n ) { super( n ); } @Override public void remove() { // NB: no action. } @Override public T next() { fwd(); return get(); } @Override public void jumpFwd( final long steps ) { for ( long j = 0; j < steps; ++j ) fwd(); } @Override abstract public AbstractLocalizingCursor< T > copy(); @Override abstract public AbstractLocalizingCursor< T > copyCursor(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractLocalizingCursorInt.java000066400000000000000000000053761316447754700274670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Abstract base class for localizing {@link Cursor}s. The current position is * maintained in the inherited int[] {@link AbstractLocalizableInt#position * position} field. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractLocalizingCursorInt< T > extends AbstractLocalizableInt implements Cursor< T > { /** * @param n * number of dimensions in the {@link net.imglib2.img.Img}. */ public AbstractLocalizingCursorInt( final int n ) { super( n ); } @Override public void remove() { // NB: no action. } @Override public T next() { fwd(); return get(); } @Override public void jumpFwd( final long steps ) { for ( long j = 0; j < steps; ++j ) fwd(); } @Override abstract public AbstractLocalizingCursorInt< T > copy(); @Override abstract public AbstractLocalizingCursorInt< T > copyCursor(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractRealInterval.java000066400000000000000000000071461316447754700261100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Implementation of the {@link RealInterval} interface. * * * @author Stephan Preibisch */ public class AbstractRealInterval extends AbstractEuclideanSpace implements RealInterval { final protected double[] min; final protected double[] max; /** * Creates an n-dimensional {@link AbstractInterval} with min and * max = 0n. * * @param n * number of dimensions */ public AbstractRealInterval( final int n ) { super( n ); this.min = new double[ n ]; this.max = new double[ n ]; } /** * Creates a new {@link AbstractRealInterval} using an existing * {@link RealInterval} * * @param interval */ public AbstractRealInterval( final RealInterval interval ) { this( interval.numDimensions() ); interval.realMin( min ); interval.realMax( max ); } /** * Creates a new {@link AbstractRealInterval} from min and max coordinates * * @param min * @param max */ public AbstractRealInterval( final double[] min, final double[] max ) { super( min.length ); this.min = min.clone(); this.max = max.clone(); } @Override public double realMin( final int d ) { return min[ d ]; } @Override public void realMin( final double[] realMin ) { for ( int d = 0; d < n; ++d ) realMin[ d ] = this.min[ d ]; } @Override public void realMin( final RealPositionable realMin ) { for ( int d = 0; d < n; ++d ) realMin.setPosition( this.min[ d ], d ); } @Override public double realMax( final int d ) { return max[ d ]; } @Override public void realMax( final double[] realMax ) { for ( int d = 0; d < n; ++d ) realMax[ d ] = this.max[ d ]; } @Override public void realMax( final RealPositionable realMax ) { for ( int d = 0; d < n; ++d ) realMax.setPosition( this.max[ d ], d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractRealLocalizable.java000066400000000000000000000064611316447754700265440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An abstract class that implements the {@link RealLocalizable} interface using * an array of doubles to maintain position * * @author Lee Kamentsky * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractRealLocalizable extends AbstractEuclideanSpace implements RealLocalizable { /** * The {@link RealLocalizable} interface is implemented using the position * stored here. {@link RealPositionable} subclasses, such as * {@link RealPoint}, modify this array. */ protected final double[] position; /** * @param n * number of dimensions. */ protected AbstractRealLocalizable( final int n ) { super( n ); position = new double[ n ]; } /** * Protected constructor that re-uses the passed position array. This is * intended to allow subclasses to provide a way to wrap a double[] array. * * @param position * position array to use. */ protected AbstractRealLocalizable( final double[] position ) { super( position.length ); this.position = position; } @Override public void localize( final float[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = ( float ) position[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = position[ d ]; } @Override public float getFloatPosition( final int d ) { return ( float ) position[ d ]; } @Override public double getDoublePosition( final int d ) { return position[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractWrappedInterval.java000066400000000000000000000060011316447754700266140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Convenient base class for {@link IterableInterval IterableIntervals}, * {@link RandomAccessibleInterval RandomAccessibleIntervals}, etc that forward * the {@link Interval} interface to, for example, their source accessible. * * @author Tobias Pietzsch */ public abstract class AbstractWrappedInterval< I extends Interval > extends AbstractWrappedRealInterval< I > implements Interval { public AbstractWrappedInterval( final I source ) { super( source ); } @Override public void dimensions( final long[] dimensions ) { sourceInterval.dimensions( dimensions ); } @Override public long dimension( final int d ) { return sourceInterval.dimension( d ); } @Override public long min( final int d ) { return sourceInterval.min( d ); } @Override public void min( final long[] min ) { sourceInterval.min( min ); } @Override public void min( final Positionable min ) { sourceInterval.min( min ); } @Override public long max( final int d ) { return sourceInterval.max( d ); } @Override public void max( final long[] max ) { sourceInterval.max( max ); } @Override public void max( final Positionable max ) { sourceInterval.max( max ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/AbstractWrappedRealInterval.java000066400000000000000000000057471316447754700274400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Convenient base class for {@link IterableRealInterval IterableRealIntervals}, * etc that forward the {@link RealInterval} interface to, for example, their * source accessible. * * @author Tobias Pietzsch */ public abstract class AbstractWrappedRealInterval< I extends RealInterval > implements RealInterval { protected final I sourceInterval; public AbstractWrappedRealInterval( final I source ) { this.sourceInterval = source; } @Override public double realMin( final int d ) { return sourceInterval.realMin( d ); } @Override public void realMin( final double[] min ) { sourceInterval.realMin( min ); } @Override public void realMin( final RealPositionable min ) { sourceInterval.realMin( min ); } @Override public double realMax( final int d ) { return sourceInterval.realMax( d ); } @Override public void realMax( final double[] max ) { sourceInterval.realMax( max ); } @Override public void realMax( final RealPositionable max ) { sourceInterval.realMax( max ); } @Override public int numDimensions() { return sourceInterval.numDimensions(); } public I getSource() { return sourceInterval; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Cursor.java000066400000000000000000000075261316447754700233130ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * A Cursor iterates over a set of Localizable elements, for example the image * values at the (integer) pixel positions of an image. * *

* Cursor is a combination of several interfaces to achieve this. The * {@link Iterator} interface is used to iterate the set. Use * {@link Iterator#fwd()} to advance the cursor and {@link Iterator#hasNext()} * to check whether there are more elements. Note, that the Cursor starts * before the first element, i.e., you have to call {@code fwd()} once * to move to the first element. *

* *

* The {@link Localizable} interface provides access to the position of the * current element. The {@link Sampler#get()} method of the {@link Sampler} * interface provides access to the value of the current element. *

* *

* For convenience, Cursor also extends the {@link java.util.Iterator} interface * so that you are able to use Cursors in for-each loops. Calling the * {@link java.util.Iterator#next()} method is equivalent to calling * {@code fwd()} and {@code get()}. That is, after {@code next()} the Cursor is * on the element returned by {@code next()}. {@code get()} can be used to * obtain that element (again), and {@code getPosition()} to obtain its * position. The {@link java.util.Iterator#remove()} method is not supported by * imglib Cursors, in general. *

* * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Cursor< T > extends RealCursor< T >, Localizable { // NB: Ideally, we would utilize covariant inheritance to narrow the return // type of a single copy() method here, rather than needing separate methods // copy(), copyCursor(), copyRandomAccess() and copyRealRandomAccess(). // Unfortunately, due to a Javac bug with multiple interface inheritance, // we must avoid doing so for now. For details, see: // http://bugs.sun.com/view_bug.do?bug_id=6656332 // The bug is fixed in JDK7. @Override public Cursor< T > copyCursor(); // @Override // public Cursor< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Dimensions.java000066400000000000000000000044651316447754700241450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Defines an extent in n-dimensional discrete space. * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Dimensions extends EuclideanSpace { /** * Write the number of pixels in each dimension into long[]. * * @param dimensions */ public void dimensions( long[] dimensions ); /** * Get the number of pixels in a given dimension d. * * @param d */ public long dimension( int d ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Dirty.java000066400000000000000000000041011316447754700231130ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Interface for objects that can be flagged dirty (useful for access * objects that track if their content was modified) * * @author Stephan Saalfeld */ public interface Dirty { public boolean isDirty(); public void setDirty(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/EuclideanSpace.java000066400000000000000000000041061316447754700246720ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * {Rn}: an N-dimensional Euclidean space. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface EuclideanSpace { /** Gets the space's number of dimensions. */ public int numDimensions(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/FinalDimensions.java000066400000000000000000000071171316447754700251140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An implementation of dimensionality that can wrap a long[] array. The same * principle for wrapping as in Point is used. * * @author Stephan Preibisch */ public final class FinalDimensions implements Dimensions { final long[] dimensions; /** * Protected constructor that can re-use the passed position array. * * @param dimensions * array used to store the position. * @param copy * flag indicating whether position array should be duplicated. */ protected FinalDimensions( final long[] dimensions, final boolean copy ) { if ( copy ) this.dimensions = dimensions.clone(); else this.dimensions = dimensions; } /** * Create a FinalDimensions with a defined size * * @param dimensions * the size */ public FinalDimensions( final long... dimensions ) { this( dimensions, true ); } /** * Create a FinalDimensions with a defined size * * @param dimensions * the size */ public FinalDimensions( final int... dimensions ) { this.dimensions = new long[ dimensions.length ]; for ( int d = 0; d < dimensions.length; ++d ) this.dimensions[ d ] = dimensions[ d ]; } @Override public int numDimensions() { return dimensions.length; } @Override public void dimensions( final long[] dims ) { for ( int d = 0; d < dims.length; ++d ) dims[ d ] = this.dimensions[ d ]; } @Override public long dimension( final int d ) { return dimensions[ d ]; } /** * Create a FinalDimensions object that stores its coordinates in the * provided position array. * * @param dimensions * array to use for storing the position. */ public static FinalDimensions wrap( final long[] dimensions ) { return new FinalDimensions( dimensions, false ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/FinalInterval.java000066400000000000000000000113531316447754700245650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Implementation of the {@link Interval} interface. * * * @author Tobias Pietzsch * @author Stephan Preibisch */ public final class FinalInterval extends AbstractInterval { /** * Creates an Interval from another {@link Interval} * * @param interval * another {@link Interval} */ public FinalInterval( final Interval interval ) { super( interval ); } /** * Creates an Interval with the boundaries [0, dimensions-1] * * @param dimensions * the size of the interval */ public FinalInterval( final Dimensions dimensions ) { super( dimensions ); } /** * Creates an Interval with the boundaries [min, max] (both including) * * @param min * the position of the first elements in each dimension * @param max * the position of the last elements in each dimension */ public FinalInterval( final long[] min, final long[] max ) { super( min, max ); } /** * Creates an Interval with the boundaries [0, dimensions-1] * * @param dimensions * the size of the interval */ public FinalInterval( final long... dimensions ) { super( dimensions ); } /** * Create a {@link FinalInterval} from a parameter list comprising minimum * coordinates and size. For example, to create a 2D interval from (10, 10) * to (20, 40) use createMinSize( 10, 10, 11, 31 ). * * @param minsize * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the dimensions of the interval. * @return interval with the specified boundaries */ public static FinalInterval createMinSize( final long... minsize ) { final int n = minsize.length / 2; final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = minsize[ d ]; max[ d ] = min[ d ] + minsize[ d + n ] - 1; } return new FinalInterval( min, max ); } /** * Create a {@link FinalInterval} from a parameter list comprising minimum * and maximum coordinates. For example, to create a 2D interval from (10, * 10) to (20, 40) use createMinMax( 10, 10, 20, 40 ). * * @param minmax * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the maximum of the interval. * @return interval with the specified boundaries */ public static FinalInterval createMinMax( final long... minmax ) { final int n = minmax.length / 2; final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = minmax[ d ]; max[ d ] = minmax[ d + n ]; } return new FinalInterval( min, max ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/FinalRealInterval.java000066400000000000000000000110411316447754700253630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Implementation of the {@link RealInterval} interface. * * * @author Stephan Preibisch */ public final class FinalRealInterval extends AbstractRealInterval { /** * Creates a new {@link AbstractRealInterval} using an existing * {@link RealInterval} * * @param interval */ public FinalRealInterval( final RealInterval interval ) { super( interval ); } /** * Creates a new {@link AbstractRealInterval} from min and max coordinates * * @param min * @param max */ public FinalRealInterval( final double[] min, final double[] max ) { super( min, max ); } /** * THIS METHOD WILL BE REMOVED IN A FUTURE RELEASE. It was mistakenly * introduced, analogous to {@link FinalInterval#createMinSize(long...)} for * integer intervals. Dimension is not defined for {@link RealInterval} and * computing the max as min + dim - 1 does not make sense. * *

* Create a {@link FinalRealInterval} from a parameter list comprising * minimum coordinates and size. For example, to create a 2D interval from * (10, 10) to (20, 40) use createMinSize( 10, 10, 11, 31 ). * * @param minsize * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the dimensions of the interval. * @return interval with the specified boundaries */ @Deprecated public static FinalRealInterval createMinSize( final double... minsize ) { final int n = minsize.length / 2; final double[] min = new double[ n ]; final double[] max = new double[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = minsize[ d ]; max[ d ] = min[ d ] + minsize[ d + n ] - 1; } return new FinalRealInterval( min, max ); } /** * Create a {@link FinalRealInterval} from a parameter list comprising * minimum and maximum coordinates. For example, to create a 2D interval * from (10, 10) to (20, 40) use createMinMax( 10, 10, 20, 40 ). * * @param minmax * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the maximum of the interval. * @return interval with the specified boundaries */ public static FinalRealInterval createMinMax( final double... minmax ) { final int n = minmax.length / 2; final double[] min = new double[ n ]; final double[] max = new double[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = minmax[ d ]; max[ d ] = minmax[ d + n ]; } return new FinalRealInterval( min, max ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/FlatIterationOrder.java000066400000000000000000000077611316447754700256000ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import java.util.ArrayList; import java.util.List; /** * A flat iteration order on an {@link IterableInterval}. Flat iteration order * means that cursors iterate line by line, plane by plane, etc. For instance a * 3D interval ranging from (0,0,0) to (1,1,1) is iterated * like * (0,0,0), (1,0,0), (0,1,0), (1,1,0), (0,0,1), (1,0,1), (0,1,1), (1,1,1) * * * * @author Tobias Pietzsch * @author Christian Dietz */ public class FlatIterationOrder { private final Interval interval; public FlatIterationOrder( final Interval interval ) { this.interval = interval; } /** * Two {@link Interval}s are considered to have same iteration order if two * {@link Cursor}s return the same position in each iteration step, * excluding dimensions of size 1. * *

* In some cases the equals method is too restrictive, i.e. we have false * negatives: e.g., both objects must be instances of * {@link FlatIterationOrder} in order to be reported as equal. *

* *

* TODO: consider improving this definition *

* * @return true, if obj is a compatible {@link FlatIterationOrder}. */ @Override public boolean equals( final Object obj ) { if ( !( obj instanceof FlatIterationOrder ) ) return false; final Interval i = ( ( FlatIterationOrder ) obj ).interval; final List< Integer > l1 = validIndices( i ); final List< Integer > l2 = validIndices( interval ); // if the number of valid dims diverges, the intervals can't have same // iteration order if ( l1.size() != l2.size() ) return false; for ( int d = 0; d < l1.size(); d++ ) { if ( i.min( l1.get( d ) ) != interval.min( l2.get( d ) ) || i.dimension( l1.get( d ) ) != interval.dimension( l2.get( d ) ) ) return false; } return true; } // create a list with all valid dimension indices. // a dimension is considered to be valid iff its larger than 1. private List< Integer > validIndices( final Interval i ) { final List< Integer > indices = new ArrayList< Integer >( i.numDimensions() ); for ( int j = 0; j < i.numDimensions(); j++ ) { if ( i.dimension( j ) > 1 ) indices.add( j ); } return indices; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Interval.java000066400000000000000000000067321316447754700236200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** *

* {x∈Zn|mind≤ * xdmaxd;d∈{0… * n-1}} *

* *

* An {@link Interval} over the discrete source domain. Note that this * does not imply that for all coordinates in the * {@link Interval} function values exist or can be generated. It only defines * where the minimum and maximum source coordinates are. E.g. an * {@link IterableInterval} has a limited number of values and a source * coordinate for each. By that, minimum and maximum are defined but the * {@link Interval} does not define a value for all coordinates in between. *

* * @author Stephan Saalfeld * @author Stephan Preibisch */ public interface Interval extends RealInterval, Dimensions { /** * Get the minimum in dimension d. * * @param d * dimension * @return minimum in dimension d. */ public long min( final int d ); /** * Write the minimum of each dimension into long[]. * * @param min */ public void min( long[] min ); /** * Sets a {@link Positionable} to the minimum of this {@link Interval} * * @param min */ public void min( Positionable min ); /** * Get the maximum in dimension d. * * @param d * dimension * @return maximum in dimension d. */ public long max( final int d ); /** * Write the maximum of each dimension into long[]. * * @param max */ public void max( long[] max ); /** * Sets a {@link Positionable} to the maximum of this {@link Interval} * * @param max */ public void max( Positionable max ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/IterableInterval.java000066400000000000000000000042771316447754700252720ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An {@link IterableRealInterval} whose elements are located at integer * coordinates. * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface IterableInterval< T > extends IterableRealInterval< T >, Interval { @Override public Cursor< T > cursor(); @Override public Cursor< T > localizingCursor(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/IterableRealInterval.java000066400000000000000000000111471316447754700260700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** *

* f:Rn∈[0,s]→T *

* *

* A function over real space and a finite set of elements in the target domain * T. All target elements T can be accessed through Iterators. * There is an iterator that tracks its source location at each move and one * that calculates it on request only. Depending on the frequency of requesting * the source location, either of them is optimal in terms of speed. Iteration * order is constant for an individual {@link IterableRealInterval} but not * further specified. *

* * @param * * @author Stephan Saalfeld */ public interface IterableRealInterval< T > extends RealInterval, Iterable< T > { /** *

* Returns a {@link RealCursor} that iterates with optimal speed without * calculating the location at each iteration step. Localization is * performed on demand. *

* *

* Use this where localization is required rarely/ not for each iteration. *

* * @return fast iterating iterator */ public RealCursor< T > cursor(); /** *

* Returns a {@link RealLocalizable} {@link Iterator} that calculates its * location at each iteration step. That is, localization is performed with * optimal speed. *

* *

* Use this where localization is required often/ for each iteration. *

* * @return fast localizing iterator */ public RealCursor< T > localizingCursor(); /** *

* Returns the number of elements in this {@link IterableRealInterval * Function}. *

* * @return number of elements */ public long size(); /** * Get the first element of this {@link IterableRealInterval}. This is a * shortcut for cursor().next(). * * This can be used to create a new variable of type T using * firstElement().createVariable(), which is useful in generic * methods to store temporary results, e.g., a running sum over pixels in * the {@link IterableRealInterval}. * * @return the first element in iteration order. */ public T firstElement(); /** * Returns the iteration order of this {@link IterableRealInterval}. If the * returned object equals ({@link Object#equals(Object)}) the iteration * order of another {@link IterableRealInterval} f then they can be * copied by synchronous iteration. That is, having an {@link Iterator} on * this and another {@link Iterator} on f, moving both in synchrony * will point both of them to corresponding locations in their source * domain. In other words, this and f have the same iteration order * and means and the same number of elements. * * @see FlatIterationOrder * * @return the iteration order of this {@link IterableRealInterval}. */ public Object iterationOrder(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Iterator.java000066400000000000000000000051441316447754700236210ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * The {@link Iterator} interface provides basic functionality for iterating * over a set of elements. The iteration order depends on the {@link Iterator} * implementation. * * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Iterator { /** * Move steps × forward. * * @param steps * number of steps to move forward */ public void jumpFwd( long steps ); /** * Move forward. */ public void fwd(); /** * Reset the {@link Iterator}, that is put it to where it would be if newly * created. */ public void reset(); /** * Returns true if another step forward is possible. * * @return true, if there is another step forward is possible, otherwise * false */ public boolean hasNext(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/KDTree.java000066400000000000000000000470421316447754700231510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.ListIterator; import net.imglib2.util.KthElement; /** * KDTree to access values at RealLocalizable positions. * * @param * type of values stored in the tree. * * @author Tobias Pietzsch */ public class KDTree< T > implements EuclideanSpace, IterableRealInterval< T > { /** * the number of dimensions. */ final protected int n; final protected KDTreeNode< T > root; /** * the number of nodes in the tree. */ final protected long size; /** * minimum of each dimension. */ final protected double[] min; /** * maximum of each dimension. */ final protected double[] max; /** * A KDTreeNode that stores it's value as a reference. */ protected final static class ValueNode< T > extends KDTreeNode< T > { protected final T value; /** * @param value * reference to the node's value * @param position * coordinates of this node * @param dimension * dimension along which this node divides the space * @param left * left child node * @param right * right child node */ public ValueNode( final T value, final RealLocalizable position, final int dimension, final ValueNode< T > left, final ValueNode< T > right ) { super( position, dimension, left, right ); this.value = value; } protected ValueNode( final ValueNode< T > node ) { super( node ); this.value = node.value; } @Override public T get() { return value; } @Override public ValueNode< T > copy() { return new ValueNode< T >( this ); } @Override public String toString() { return "node " + getSplitDimension() + " ? " + getSplitCoordinate() + " | " + value; } } /** * A KDTreeNode that stores it's value as a Sampler. */ protected static final class SamplerNode< T > extends KDTreeNode< T > { protected final Sampler< T > sampler; /** * @param sampler * a sampler providing the node's value * @param position * coordinates of this node * @param dimension * dimension along which this node divides the space * @param left * left child node * @param right * right child node */ public SamplerNode( final Sampler< T > sampler, final RealLocalizable position, final int dimension, final SamplerNode< T > left, final SamplerNode< T > right ) { super( position, dimension, left, right ); this.sampler = sampler; } protected SamplerNode( final SamplerNode< T > node ) { super( node ); this.sampler = node.sampler.copy(); } @Override public T get() { return sampler.get(); } @Override public SamplerNode< T > copy() { return new SamplerNode< T >( this ); } @Override public String toString() { return "node " + getSplitDimension() + " ? " + getSplitCoordinate() + " | " + sampler.get(); } } /** * Construct a KDTree from the elements in the given list. * *

* Note that the constructor can be called with the same list for both * {@code values == positions} if {@code T extends RealLocalizable}. *

* * @param values * a list of values * @param positions * a list of positions corresponding to the values */ public < L extends RealLocalizable > KDTree( final List< T > values, final List< L > positions ) { assert values.size() == positions.size(); this.n = positions.get( 0 ).numDimensions(); this.size = positions.size(); // test that dimensionality is preserved assert ( verifyDimensions( positions, n ) ); this.min = new double[ n ]; this.max = new double[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Double.MAX_VALUE; max[ d ] = -Double.MAX_VALUE; } for ( final L position : positions ) { for ( int d = 0; d < n; ++d ) { final double x = position.getDoublePosition( d ); if ( x < min[ d ] ) min[ d ] = x; if ( x > max[ d ] ) max[ d ] = x; } } if ( values == positions ) { if ( positions instanceof java.util.RandomAccess ) root = makeNode( positions, 0, positions.size() - 1, 0 ); else root = makeNode( positions.listIterator(), positions.listIterator( positions.size() ), 0 ); } else { final int[] permutation = new int[ positions.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; if ( positions instanceof java.util.RandomAccess ) root = makeNode( positions, 0, positions.size() - 1, 0, values, permutation ); else root = makeNode( positions.listIterator(), positions.listIterator( positions.size() ), 0, values, permutation ); } } /** * Construct a KDTree from the elements of the given * {@link IterableRealInterval}. * * @param interval * elements in the tree are obtained by iterating this */ public KDTree( final IterableRealInterval< T > interval ) { this.n = interval.numDimensions(); this.size = interval.size(); this.min = new double[ n ]; interval.realMin( this.min ); this.max = new double[ n ]; interval.realMax( this.max ); final ArrayList< RealCursor< T > > values = new ArrayList< RealCursor< T > >( ( int ) interval.size() ); final RealCursor< T > cursor = interval.localizingCursor(); while ( cursor.hasNext() ) { cursor.next(); values.add( cursor.copyCursor() ); } root = makeSamplerNode( values, 0, values.size() - 1, 0 ); } /** * Check whether all positions in the positions list have dimension n. * * @return true, if all positions have dimension n. */ protected static < L extends RealLocalizable > boolean verifyDimensions( final List< L > positions, final int n ) { for ( final L position : positions ) if ( position.numDimensions() != n ) return false; return true; } /** * Compare RealLocalizables by comparing their coordinates in dimension d. */ public static final class DimComparator< L extends RealLocalizable > implements Comparator< L > { final int d; public DimComparator( final int d ) { this.d = d; } @Override public int compare( final L o1, final L o2 ) { final float diff = o1.getFloatPosition( d ) - o2.getFloatPosition( d ); return ( diff < 0 ) ? -1 : ( diff > 0 ? 1 : 0 ); } } /** * Construct the tree by recursively adding nodes. The sublist of positions * between indices i and j (inclusive) is split at the median element with * respect to coordinates in the given dimension d. The median becomes the * new node which is returned. The left and right partitions of the sublist * are processed recursively and form the left and right subtrees of the * node. * * @param positions * list of positions * @param i * start index of sublist to process * @param j * end index of sublist to process * @param d * dimension along which to split the sublist * @param values * list of values corresponding to permuted positions * @param permutation * the index of the values element at index k is permutation[k] * @return a new node containing the subtree of the given sublist of * positions. */ protected < L extends RealLocalizable > ValueNode< T > makeNode( final List< L > positions, final int i, final int j, final int d, final List< T > values, final int[] permutation ) { if ( j > i ) { final int k = i + ( j - i ) / 2; KthElement.kthElement( i, j, k, positions, permutation, new DimComparator< L >( d ) ); final int dChild = ( d + 1 == n ) ? 0 : d + 1; return new ValueNode< T >( values.get( permutation[ k ] ), positions.get( k ), d, makeNode( positions, i, k - 1, dChild, values, permutation ), makeNode( positions, k + 1, j, dChild, values, permutation ) ); } else if ( j == i ) { return new ValueNode< T >( values.get( permutation[ i ] ), positions.get( i ), d, null, null ); } else { return null; } } /** * Construct the tree by recursively adding nodes. The sublist of positions * between iterators first and last is split at the median element with * respect to coordinates in the given dimension d. The median becomes the * new node which is returned. The left and right partitions of the sublist * are processed recursively and form the left and right subtrees of the * node. * * @param first * first element of the sublist of positions * @param last * last element of the sublist of positions * @param d * dimension along which to split the sublist * @param values * list of values corresponding to permuted positions * @param permutation * the index of the values element at index k is permutation[k] * @return a new node containing the subtree of the given sublist of * positions. */ protected < L extends RealLocalizable > ValueNode< T > makeNode( final ListIterator< L > first, final ListIterator< L > last, final int d, final List< T > values, final int[] permutation ) { final int i = first.nextIndex(); final int j = last.previousIndex(); if ( j > i ) { final int k = i + ( j - i ) / 2; KthElement.kthElement( first, last, k, permutation, new DimComparator< L >( d ) ); first.previous(); final L current = first.next(); final int dChild = ( d + 1 == n ) ? 0 : d + 1; // Node< T > right = makeNode( elements, k + 1, j, dChild ); for ( int c = j - last.previousIndex(); c > 0; --c ) last.next(); final ValueNode< T > right = makeNode( first, last, dChild, values, permutation ); // Node< T > left = makeNode( elements, i, k - 1, dChild ); for ( int c = first.nextIndex() - i; c > 0; --c ) first.previous(); for ( int c = last.nextIndex() - k; c > 0; --c ) last.previous(); final ValueNode< T > left = makeNode( first, last, dChild, values, permutation ); return new ValueNode< T >( values.get( permutation[ k ] ), current, d, left, right ); } else if ( j == i ) { final L current = first.next(); return new ValueNode< T >( values.get( permutation[ i ] ), current, d, null, null ); } else { return null; } } /** * See {@link #makeNode(List, int, int, int, List, int[])}. Here, no values are * attached to the nodes (or rather the positions are the values). * * @param elements * list of elements (positions and values at the same time) * @param i * start index of sublist to process * @param j * end index of sublist to process * @param d * dimension along which to split the sublist */ @SuppressWarnings( "unchecked" ) protected < L extends RealLocalizable > ValueNode< T > makeNode( final List< L > elements, final int i, final int j, final int d ) { if ( j > i ) { final int k = i + ( j - i ) / 2; KthElement.kthElement( i, j, k, elements, new DimComparator< L >( d ) ); final int dChild = ( d + 1 == n ) ? 0 : d + 1; return new ValueNode< T >( ( T ) elements.get( k ), elements.get( k ), d, makeNode( elements, i, k - 1, dChild ), makeNode( elements, k + 1, j, dChild ) ); } else if ( j == i ) { return new ValueNode< T >( ( T ) elements.get( i ), elements.get( i ), d, null, null ); } else { return null; } } /** * See {@link #makeNode(ListIterator, ListIterator, int, List, int[])}. Here, no * values are attached to the nodes (or rather the positions are the * values). * * @param first * first element of the sublist to process * @param last * last element of the sublist to process * @param d * dimension along which to split the sublist */ @SuppressWarnings( "unchecked" ) protected < L extends RealLocalizable > ValueNode< T > makeNode( final ListIterator< L > first, final ListIterator< L > last, final int d ) { final int i = first.nextIndex(); final int j = last.previousIndex(); if ( j > i ) { final int k = i + ( j - i ) / 2; KthElement.kthElement( first, last, k, new DimComparator< L >( d ) ); first.previous(); final L current = first.next(); final int dChild = ( d + 1 == n ) ? 0 : d + 1; // Node< T > right = makeNode( elements, k + 1, j, dChild ); for ( int c = j - last.previousIndex(); c > 0; --c ) last.next(); final ValueNode< T > right = makeNode( first, last, dChild ); // Node< T > left = makeNode( elements, i, k - 1, dChild ); for ( int c = first.nextIndex() - i; c > 0; --c ) first.previous(); for ( int c = last.nextIndex() - k; c > 0; --c ) last.previous(); final ValueNode< T > left = makeNode( first, last, dChild ); return new ValueNode< T >( ( T ) current, current, d, left, right ); } else if ( j == i ) { final L current = first.next(); return new ValueNode< T >( ( T ) current, current, d, null, null ); } else { return null; } } /** * Construct the tree by recursively adding nodes. The sublist of elements * between indices i and j (inclusive) is split at the median element with * respect to coordinates in the given dimension d. The median becomes the * new node which is returned. The left and right partitions of the sublist * are processed recursively and form the left and right subtrees of the * node. (The elements of the list are RealCursors which provide coordinates * and values.) * * @param elements * list of elements (positions and values at the same time) * @param i * start index of sublist to process * @param j * end index of sublist to process * @param d * dimension along which to split the sublist * @return a new node containing the subtree of the given sublist of * elements */ protected SamplerNode< T > makeSamplerNode( final List< RealCursor< T > > elements, final int i, final int j, final int d ) { if ( j > i ) { final int k = i + ( j - i ) / 2; KthElement.kthElement( i, j, k, elements, new DimComparator< RealCursor< T > >( d ) ); final int dChild = ( d + 1 == n ) ? 0 : d + 1; return new SamplerNode< T >( elements.get( k ), elements.get( k ), d, makeSamplerNode( elements, i, k - 1, dChild ), makeSamplerNode( elements, k + 1, j, dChild ) ); } else if ( j == i ) { return new SamplerNode< T >( elements.get( i ), elements.get( i ), d, null, null ); } else { return null; } } /** * Get the root node. * * @return the root node. */ public KDTreeNode< T > getRoot() { return root; } @Override public int numDimensions() { return n; } public String toString( final KDTreeNode< T > left, final String indent ) { if ( left == null ) return ""; return indent + "- " + left.toString() + "\n" + toString( left.left, indent + " " ) + toString( left.right, indent + " " ); } @Override public String toString() { return toString( root, "" ); } @Override public double realMin( final int d ) { return min[ d ]; } @Override public void realMin( final double[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = min[ d ]; } @Override public void realMin( final RealPositionable m ) { m.setPosition( min ); } @Override public double realMax( final int d ) { return max[ d ]; } @Override public void realMax( final double[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = max[ d ]; } @Override public void realMax( final RealPositionable m ) { m.setPosition( max ); } @Override public long size() { return size; } @Override public Object iterationOrder() { return this; // iteration order is only compatible with ourselves } public final class KDTreeCursor implements RealCursor< T > { private final KDTree< T > tree; private final ArrayDeque< KDTreeNode< T > > nodes; private KDTreeNode< T > currentNode; public KDTreeCursor( final KDTree< T > kdtree ) { this.tree = kdtree; final int capacity = 2 + ( int ) ( Math.log( kdtree.size() ) / Math.log( 2 ) ); this.nodes = new ArrayDeque< KDTreeNode< T > >( capacity ); reset(); } public KDTreeCursor( final KDTreeCursor c ) { this.tree = c.tree; this.nodes = c.nodes.clone(); this.currentNode = c.currentNode; } @Override public void localize( final float[] position ) { currentNode.localize( position ); } @Override public void localize( final double[] position ) { currentNode.localize( position ); } @Override public float getFloatPosition( final int d ) { return currentNode.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return currentNode.getDoublePosition( d ); } @Override public int numDimensions() { return n; } @Override public T get() { return currentNode.get(); } @Override public KDTreeCursor copy() { return new KDTreeCursor( this ); } @Override public void jumpFwd( final long steps ) { for ( long i = 0; i < steps; ++i ) fwd(); } @Override public void fwd() { if ( nodes.isEmpty() ) currentNode = null; else { currentNode = nodes.pop(); if ( currentNode.left != null ) nodes.push( currentNode.left ); if ( currentNode.right != null ) nodes.push( currentNode.right ); } } @Override public void reset() { nodes.clear(); nodes.push( tree.getRoot() ); currentNode = null; } @Override public boolean hasNext() { return !nodes.isEmpty(); } @Override public T next() { fwd(); return get(); } @Override public void remove() { // NB: no action. } @Override public KDTreeCursor copyCursor() { return copy(); } } @Override public KDTreeCursor iterator() { return new KDTreeCursor( this ); } @Override public KDTreeCursor cursor() { return new KDTreeCursor( this ); } @Override public KDTreeCursor localizingCursor() { return new KDTreeCursor( this ); } @Override public T firstElement() { return iterator().next(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/KDTreeNode.java000066400000000000000000000124761316447754700237620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Abstract base class for nodes in a KDTree. A KDTreeNode has coordinates and a * value. It provides the coordinates via the {@link RealLocalizable} interface. * It provides the value via {@link Sampler#get()}. * * @param * value type. * * * @author Tobias Pietzsch */ public abstract class KDTreeNode< T > implements RealLocalizable, Sampler< T > { /** * number of dimensions of the space (that is, k). */ protected final int n; /** * coordinates of the node. */ protected final double[] pos; /** * dimension along which this node divides the space. */ protected final int splitDimension; /** * Left child of this node. All nodes x in the left subtree have * {@code x.pos[splitDimension] <= this.pos[splitDimension]}. */ public final KDTreeNode< T > left; /** * Right child of this node. All nodes x in the right subtree have * {@code x.pos[splitDimension] >= this.pos[splitDimension]}. */ public final KDTreeNode< T > right; /** * @param position * coordinates of this node * @param dimension * dimension along which this node divides the space * @param left * left child node * @param right * right child node */ public KDTreeNode( final RealLocalizable position, final int dimension, final KDTreeNode< T > left, final KDTreeNode< T > right ) { this.n = position.numDimensions(); this.pos = new double[ n ]; position.localize( pos ); this.splitDimension = dimension; this.left = left; this.right = right; } protected KDTreeNode( final KDTreeNode< T > node ) { this.n = node.n; this.pos = node.pos.clone(); this.splitDimension = node.splitDimension; this.left = node.left; this.right = node.right; } /** * Get the dimension along which this node divides the space. * * @return splitting dimension. */ public final int getSplitDimension() { return splitDimension; } /** * Get the position along {@link KDTreeNode#getSplitDimension()} where this * node divides the space. * * @return splitting position. */ public final double getSplitCoordinate() { return pos[ splitDimension ]; } @Override public final int numDimensions() { return n; } @Override public final void localize( final float[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = ( float ) pos[ d ]; } @Override public final void localize( final double[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = pos[ d ]; } @Override public final float getFloatPosition( final int d ) { return ( float ) pos[ d ]; } @Override public final double getDoublePosition( final int d ) { return pos[ d ]; } @Override public abstract KDTreeNode< T > copy(); /** * Compute the squared distance from p to this node. */ public final float squDistanceTo( final float[] p ) { float sum = 0; for ( int d = 0; d < n; ++d ) { sum += ( pos[ d ] - p[ d ] ) * ( pos[ d ] - p[ d ] ); } return sum; } /** * Compute the squared distance from p to this node. */ public final double squDistanceTo( final double[] p ) { double sum = 0; for ( int d = 0; d < n; ++d ) { sum += ( pos[ d ] - p[ d ] ) * ( pos[ d ] - p[ d ] ); } return sum; } /** * Compute the squared distance from p to this node. */ public final double squDistanceTo( final RealLocalizable p ) { double sum = 0; for ( int d = 0; d < n; ++d ) { sum += ( pos[ d ] - p.getDoublePosition( d ) ) * ( pos[ d ] - p.getDoublePosition( d ) ); } return sum; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Localizable.java000066400000000000000000000057031316447754700242520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * The {@link Localizable} interface can localize itself in an n-dimensional * discrete space. Not only {@link Cursor}s can use this interface, it might be * used by much more classes as {@link RandomAccess}s can take any * {@link Localizable} as input for where they should move to. * * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Localizable extends RealLocalizable { /** * Write the current position into the passed array. * * @param position * receives current position */ public void localize( int[] position ); /** * Write the current position into the passed array. * * @param position * receives current position */ public void localize( long[] position ); /** * Return the current position in a given dimension. * * @param d * dimension * @return dimension of current position */ public int getIntPosition( int d ); /** * Return the current position in a given dimension. * * @param d * dimension * @return dimension of current position */ public long getLongPosition( int d ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Point.java000066400000000000000000000136551316447754700231270ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * A Point is a position in Euclidean space specified in integer coordinates. * * @author Lee Kamentsky * @author Tobias Pietzsch */ public class Point extends AbstractLocalizable implements Positionable { /** * Protected constructor that can re-use the passed position array. * * @param position * array used to store the position. * @param copy * flag indicating whether position array should be duplicated. */ protected Point( final long[] position, final boolean copy ) { super( copy ? position.clone() : position ); } /** * Create a point in nDimensional space initialized to 0,0,... * * @param n * number of dimensions of the space */ public Point( final int n ) { super( n ); } /** * Create a point at a definite location in a space of the dimensionality of * the position. * * @param position * the initial position. The length of the array determines the * dimensionality of the space. */ public Point( final long... position ) { this( position, true ); } /** * Create a point at a definite location in a space of the dimensionality of * the position. * * @param position * the initial position. The length of the array determines the * dimensionality of the space. */ public Point( final int... position ) { super( position.length ); setPosition( position ); } /** * Create a point using the position and dimensionality of a * {@link Localizable} * * @param localizable * the initial position. Its dimensionality determines the * dimensionality of the space. */ public Point( final Localizable localizable ) { super( localizable.numDimensions() ); localizable.localize( position ); } @Override public void fwd( final int d ) { ++position[ d ]; } @Override public void bck( final int d ) { --position[ d ]; } @Override public void move( final int distance, final int d ) { position[ d ] += distance; } @Override public void move( final long distance, final int d ) { position[ d ] += distance; } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; d++ ) position[ d ] += localizable.getLongPosition( d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; d++ ) position[ d ] += distance[ d ]; } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; d++ ) position[ d ] += distance[ d ]; } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; d++ ) position[ d ] = localizable.getLongPosition( d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < n; d++ ) this.position[ d ] = position[ d ]; } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < n; d++ ) this.position[ d ] = position[ d ]; } @Override public void setPosition( final int position, final int d ) { this.position[ d ] = position; } @Override public void setPosition( final long position, final int d ) { this.position[ d ] = position; } @Override public String toString() { final StringBuilder sb = new StringBuilder(); char c = '('; for ( int i = 0; i < numDimensions(); i++ ) { sb.append( c ); sb.append( position[ i ] ); c = ','; } sb.append( ")" ); return sb.toString(); } @Override public boolean equals( final Object obj ) { if ( obj instanceof RealLocalizable && ( ( RealLocalizable ) obj ).numDimensions() == numDimensions() ) { final RealLocalizable asLocalizable = ( ( RealLocalizable ) obj ); for ( int d = 0; d < numDimensions(); d++ ) { if ( asLocalizable.getDoublePosition( d ) != getDoublePosition( d ) ) return false; } return true; } return false; } /** * Create a point that stores its coordinates in the provided position * array. * * @param position * array to use for storing the position. */ public static Point wrap( final long[] position ) { return new Point( position, false ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/PointSampleList.java000066400000000000000000000126611316447754700251210ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import java.util.ArrayList; import java.util.Iterator; /** * A list of data samples at explicit {@link Localizable integer coordinates}. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class PointSampleList< T > extends AbstractInterval implements IterableInterval< T > { public class PointSampleListCursor implements Cursor< T > { protected int index = -1; protected Point position = null; protected T sample = null; @Override public Cursor< T > copy() { final PointSampleListCursor copy = new PointSampleListCursor(); copy.index = index; copy.position = position; copy.sample = sample; return copy; } @Override final public Cursor< T > copyCursor() { return copy(); } @Override public double getDoublePosition( final int d ) { return position.getDoublePosition( d ); } @Override public float getFloatPosition( final int d ) { return position.getFloatPosition( d ); } @Override public int getIntPosition( final int d ) { return position.getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return position.getLongPosition( d ); } @Override public void localize( final float[] pos ) { position.localize( pos ); } @Override public void localize( final double[] pos ) { position.localize( pos ); } @Override public void localize( final int[] pos ) { position.localize( pos ); } @Override public void localize( final long[] pos ) { position.localize( pos ); } @Override public int numDimensions() { return n; } @Override public T get() { return sample; } @Override public void fwd() { ++index; position = coordinates.get( index ); sample = samples.get( index ); } @Override public boolean hasNext() { return index < lastIndex; } @Override public void jumpFwd( final long steps ) { index += steps; position = coordinates.get( index ); sample = samples.get( index ); } @Override public void reset() { index = -1; position = null; sample = null; } @Override public T next() { fwd(); return sample; } @Override public void remove() { /* Not yet implemented */ } } final protected ArrayList< Point > coordinates = new ArrayList< Point >(); final protected ArrayList< T > samples = new ArrayList< T >(); protected int lastIndex = -1; private static Interval initInterval( final int n ) { final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Long.MAX_VALUE; max[ d ] = Long.MIN_VALUE; } return new FinalInterval( min, max ); } /** * @param n * - number of dimensions */ public PointSampleList( final int n ) { super( initInterval( n ) ); } public void add( final Point position, final T sample ) { coordinates.add( position ); samples.add( sample ); lastIndex = samples.size() - 1; for ( int d = 0; d < n; ++d ) { final long x = position.getLongPosition( d ); if ( x < min[ d ] ) min[ d ] = x; if ( x > max[ d ] ) max[ d ] = x; } } @Override public Cursor< T > cursor() { return new PointSampleListCursor(); } @Override public Object iterationOrder() { return this; // iteration order is only compatible with ourselves } @Override public T firstElement() { return samples.get( 0 ); } @Override public Cursor< T > localizingCursor() { return new PointSampleListCursor(); } @Override public long size() { return samples.size(); } @Override public Iterator< T > iterator() { return cursor(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Positionable.java000066400000000000000000000111501316447754700244520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An element that can be positioned in n-dimensional discrete space. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface Positionable extends EuclideanSpace { /** * Move by 1 in one dimension. * * @param d * dimension */ public void fwd( int d ); /** * Move by -1 in one dimension. * * @param d * dimension */ public void bck( int d ); /** * Move the element in one dimension for some distance. * * @param distance * relative offset in dimension d * @param d * dimension */ public void move( int distance, int d ); /** * Move the element in one dimension for some distance. * * @param distance * relative offset in dimension d * @param d * dimension */ public void move( long distance, int d ); /** * Move the element relative to its current location using an * {@link Localizable} as distance vector. * * @param localizable * relative offset, {@link Localizable#numDimensions()} must be * ≥ {@link #numDimensions()} */ public void move( Localizable localizable ); /** * Move the element relative to its current location using an int[] as * distance vector. * * @param distance * relative offset, length must be ≥ {@link #numDimensions()} */ public void move( int[] distance ); /** * Move the element relative to its current location using a long[] as * distance vector. * * @param distance * relative offset, length must be ≥ {@link #numDimensions()} */ public void move( long[] distance ); /** * Place the element at the same location as a given {@link Localizable} * * @param localizable * absolute position, {@link Localizable#numDimensions()} must be * ≥ {@link #numDimensions()} */ public void setPosition( Localizable localizable ); /** * Set the position of the element. * * @param position * absolute position, length must be ≥ * {@link #numDimensions()} */ public void setPosition( int[] position ); /** * Set the position of the element. * * @param position * absolute position, length must be ≥ * {@link #numDimensions()} */ public void setPosition( long[] position ); /** * Set the position of the element for one dimension. * * @param position * absolute position in dimension d * @param d * dimension */ public void setPosition( int position, int d ); /** * Set the position of the element for one dimension. * * @param position * absolute position in dimension d * @param d * dimension */ public void setPosition( long position, int d ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RandomAccess.java000066400000000000000000000050241316447754700243670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface RandomAccess< T > extends Localizable, Positionable, Sampler< T > { // NB: Ideally, we would utilize covariant inheritance to narrow the return // type of a single copy() method here, rather than needing separate methods // copy(), copyCursor(), copyRandomAccess() and copyRealRandomAccess(). // Unfortunately, due to a Javac bug with multiple interface inheritance, // we must avoid doing so for now. For details, see: // http://bugs.sun.com/view_bug.do?bug_id=6656332 // The bug is fixed in JDK7. RandomAccess< T > copyRandomAccess(); // @Override // RandomAccess< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RandomAccessible.java000066400000000000000000000115131316447754700252230ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import net.imglib2.view.Views; /** *

* f:Zn→T *

* *

* A function over integer space that can create a random access {@link Sampler}. *

* *

* If your algorithm takes a RandomAccessible, this usually means that you * expect that the domain is infinite. (In contrast to this, * {@link RandomAccessibleInterval}s have a finite domain.) *

* * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface RandomAccessible< T > extends EuclideanSpace { /** * Create a random access sampler for integer coordinates. * *

* The returned random access covers as much of the domain as possible. *

* * * Please note: {@link RandomAccessibleInterval}s have a finite domain (their {@link Interval}), * so {@link #randomAccess()} is only guaranteed to cover this finite domain. * This may lead to unexpected results when using {@link Views}. In * the following code * *
	 * RandomAccessible<T> extended = Views.extendBorder( img )
	 * RandomAccessibleInterval<T> cropped = Views.interval( extended, img );
	 * RandomAccess<T> a1 = extended.randomAccess();
	 * RandomAccess<T> a2 = cropped.randomAccess();
	 * 
* * The {@link RandomAccess access} {@code a1} on the extended image is valid * everywhere. However, somewhat counter-intuitively, the * {@link RandomAccess access} {@code a2} on the extended and cropped image * is only valid on the interval {@code img} to which the extended image was * cropped. The access is only required to cover this interval, because it * is the domain of the cropped image. {@link Views} attempts to provide the * fastest possible access that meets this requirement, and will therefore * strip the extension. * * To deal with this, if you know that you need to access pixels outside the * domain of the {@link RandomAccessibleInterval}, and you know that the * {@link RandomAccessibleInterval} is actually defined beyond its interval * boundaries, then use the {@link #randomAccess(Interval)} variant and * specify which interval you actually want to access. In the above example, * *
	 * RandomAccess<T> a2 = cropped.randomAccess( Intervals.expand( img, 10 ) );
	 * 
* * will provide the extended access as expected. * * @return random access sampler */ public RandomAccess< T > randomAccess(); /** * Create a random access sampler for integer coordinates. * *

* The returned random access is intended to be used in the specified * interval only. Thus, the RandomAccessible may provide optimized versions. * If the interval is completely contained in the domain, the random access * is guaranteed to provide the same values as that obtained by * {@link #randomAccess()} within the interval. *

* * @param interval * in which interval you intend to use the random access. * * @return random access sampler */ public RandomAccess< T > randomAccess( Interval interval ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RandomAccessibleInterval.java000066400000000000000000000042321316447754700267300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** *

* f:{x∈Zn|[min,max]→T} *

* *

* A function over an n-dimensional integer interval that can create a random * access {@link Sampler}. *

* * @author Stephan Saalfeld */ public interface RandomAccessibleInterval< T > extends RandomAccessible< T >, Interval {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealCursor.java000066400000000000000000000076261316447754700241200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * A RealCursor iterates over a set of RealLocalizable elements, for example * intensity values sampled at a finite set of arbitrary real positions. * *

* RealCursor is a combination of several interfaces to achieve this. The * {@link Iterator} interface is used to iterate the set. Use * {@link Iterator#fwd()} to advance the cursor and {@link Iterator#hasNext()} * to check whether there are more elements. Note, that the Cursor starts * before the first element, i.e., you have to call {@code fwd()} once * to move to the first element. *

* *

* The {@link RealLocalizable} interface provides access to the position of the * current element. The {@link Sampler#get()} method of the {@link Sampler} * interface provides access to the value of the current element. *

* *

* For convenience, Cursor also extends the {@link java.util.Iterator} interface * so that you are able to use Cursors in for-each loops. Calling the * {@link java.util.Iterator#next()} method is equivalent to calling * {@code fwd()} and {@code get()}. That is, after {@code next()} the Cursor is * on the element returned by {@code next()}. {@code get()} can be used to * obtain that element (again), and {@code getPosition()} to obtain its * position. The {@link java.util.Iterator#remove()} method is not supported by * imglib Cursors, in general. *

* * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface RealCursor< T > extends RealLocalizable, Sampler< T >, Iterator, java.util.Iterator< T > { // NB: Ideally, we would utilize covariant inheritance to narrow the return // type of a single copy() method here, rather than needing separate methods // copy(), copyCursor(), copyRandomAccess() and copyRealRandomAccess(). // Unfortunately, due to a Javac bug with multiple interface inheritance, // we must avoid doing so for now. For details, see: // http://bugs.sun.com/view_bug.do?bug_id=6656332 // The bug is fixed in JDK7. public RealCursor< T > copyCursor(); //@Override //public RealCursor< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealInterval.java000066400000000000000000000067421316447754700244250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** *

* {x∈Rn|mind≤ * xdmaxd;d∈{0… * n-1}} *

* * An {@link RealInterval} over the real source domain. Note that this * does not imply that for all coordinates in the * {@link RealInterval} function values exist or can be generated. It only * defines where the minimum and maximum source coordinates are. E.g. an * {@link IterableRealInterval} has a limited number of values and a source * coordinate for each. By that, minimum and maximum are defined but the * {@link RealInterval} does not define a value for all coordinates in between. * * @author Stephan Saalfeld */ public interface RealInterval extends EuclideanSpace { /** * Get the minimum in dimension d. * * @param d * dimension * @return minimum in dimension d. */ public double realMin( int d ); /** * Write the minimum of each dimension into double[]. * * @param min */ public void realMin( double[] min ); /** * Sets a {@link RealPositionable} to the minimum of this {@link Interval} * * @param min */ public void realMin( RealPositionable min ); /** * Get the maximum in dimension d. * * @param d * dimension * @return maximum in dimension d. */ public double realMax( final int d ); /** * Write the maximum of each dimension into double[]. * * @param max */ public void realMax( double[] max ); /** * Sets a {@link RealPositionable} to the maximum of this {@link Interval} * * @param max */ public void realMax( RealPositionable max ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealLocalizable.java000066400000000000000000000054231316447754700250550ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * The {@link RealLocalizable} interface can localize itself in an n-dimensional * real space. * * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface RealLocalizable extends EuclideanSpace { /** * Write the current position into the passed array. * * @param position * receives current position */ public void localize( float[] position ); /** * Write the current position into the passed array. * * @param position * receives current position */ public void localize( double[] position ); /** * Return the current position in a given dimension. * * @param d * dimension * @return dimension of current position */ public float getFloatPosition( int d ); /** * Return the current position in a given dimension. * * @param d * dimension * @return dimension of current position */ public double getDoublePosition( int d ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealPoint.java000066400000000000000000000155121316447754700237250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * A point is a location in EuclideanSpace. * * @author Lee Kamentsky * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class RealPoint extends AbstractRealLocalizable implements RealPositionable { /** * Protected constructor that can re-use the passed position array. * * @param position * array used to store the position. * @param copy * flag indicating whether position array should be duplicated. */ protected RealPoint( final double[] position, final boolean copy ) { super( copy ? position.clone() : position ); } /** * Create a point in nDimensional space initialized to 0,0,... * * @param n * number of dimensions of the space */ public RealPoint( final int n ) { super( n ); } /** * Create a point at a definite location in a space of the dimensionality of * the position. * * @param position * the initial position. The length of the array determines the * dimensionality of the space. */ public RealPoint( final double... position ) { this( position, true ); } /** * Create a point at a definite location in a space of the dimensionality of * the position. * * @param position * the initial position. The length of the array determines the * dimensionality of the space. */ public RealPoint( final float... position ) { super( position.length ); setPosition( position ); } /** * Create a point using the position and dimensionality of a * {@link RealLocalizable} * * @param localizable * the initial position. Its dimensionality determines the * dimensionality of the space. */ public RealPoint( final RealLocalizable localizable ) { super( localizable.numDimensions() ); localizable.localize( position ); } @Override public void fwd( final int d ) { ++position[ d ]; } @Override public void bck( final int d ) { --position[ d ]; } @Override public void move( final int distance, final int d ) { position[ d ] += distance; } @Override public void move( final long distance, final int d ) { position[ d ] += distance; } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; d++ ) position[ d ] += localizable.getDoublePosition( d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; d++ ) position[ d ] += distance[ d ]; } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; d++ ) position[ d ] += distance[ d ]; } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; d++ ) position[ d ] = localizable.getDoublePosition( d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < n; d++ ) this.position[ d ] = position[ d ]; } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < n; d++ ) this.position[ d ] = position[ d ]; } @Override public void setPosition( final int position, final int d ) { this.position[ d ] = position; } @Override public void setPosition( final long position, final int d ) { this.position[ d ] = position; } @Override public void move( final float distance, final int d ) { position[ d ] += distance; } @Override public void move( final double distance, final int d ) { position[ d ] += distance; } @Override public void move( final RealLocalizable localizable ) { for ( int d = 0; d < n; ++d ) position[ d ] += localizable.getDoublePosition( d ); } @Override public void move( final float[] distance ) { for ( int d = 0; d < n; ++d ) position[ d ] += distance[ d ]; } @Override public void move( final double[] distance ) { for ( int d = 0; d < n; ++d ) position[ d ] += distance[ d ]; } @Override public void setPosition( final RealLocalizable localizable ) { for ( int d = 0; d < n; d++ ) position[ d ] = localizable.getDoublePosition( d ); } @Override public void setPosition( final float[] position ) { for ( int d = 0; d < n; ++d ) this.position[ d ] = position[ d ]; } @Override public void setPosition( final double[] position ) { for ( int d = 0; d < n; ++d ) this.position[ d ] = position[ d ]; } @Override public void setPosition( final float position, final int d ) { this.position[ d ] = position; } @Override public void setPosition( final double position, final int d ) { this.position[ d ] = position; } @Override public String toString() { final StringBuilder sb = new StringBuilder(); char c = '('; for ( int i = 0; i < numDimensions(); i++ ) { sb.append( c ); sb.append( position[ i ] ); c = ','; } sb.append( ")" ); return sb.toString(); } /** * Create a point that stores its coordinates in the provided position * array. * * @param position * array to use for storing the position. */ public static RealPoint wrap( final double[] position ) { return new RealPoint( position, false ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealPointSampleList.java000066400000000000000000000131331316447754700257200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import java.util.ArrayList; import java.util.Iterator; /** * A list of data samples at explicit {@link RealLocalizable real coordinates}. * * @author Stephan Saalfeld */ public class RealPointSampleList< T > implements IterableRealInterval< T > { public class RealPointSampleListCursor implements RealCursor< T > { protected int index = -1; protected RealPoint position = null; protected T sample = null; @Override public RealCursor< T > copy() { final RealPointSampleListCursor copy = new RealPointSampleListCursor(); copy.index = index; copy.position = position; copy.sample = sample; return copy; } @Override final public RealCursor< T > copyCursor() { return copy(); } @Override public double getDoublePosition( final int d ) { return position.getDoublePosition( d ); } @Override public float getFloatPosition( final int d ) { return position.getFloatPosition( d ); } @Override public void localize( final float[] pos ) { position.localize( pos ); } @Override public void localize( final double[] pos ) { position.localize( pos ); } @Override public int numDimensions() { return n; } @Override public T get() { return sample; } @Override public void fwd() { ++index; position = coordinates.get( index ); sample = samples.get( index ); } @Override public boolean hasNext() { return index < lastIndex; } @Override public void jumpFwd( final long steps ) { index += steps; position = coordinates.get( index ); sample = samples.get( index ); } @Override public void reset() { index = -1; position = null; sample = null; } @Override public T next() { fwd(); return sample; } @Override public void remove() { /* Not yet implemented */ } } final protected int n; final protected ArrayList< RealPoint > coordinates = new ArrayList< RealPoint >(); final protected ArrayList< T > samples = new ArrayList< T >(); protected int lastIndex = -1; final protected double[] min, max; /** * @param n * - number of dimensions */ public RealPointSampleList( final int n ) { this.n = n; min = new double[ n ]; max = new double[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Double.MAX_VALUE; max[ d ] = -Double.MAX_VALUE; } } public void add( final RealPoint position, final T sample ) { coordinates.add( position ); samples.add( sample ); lastIndex = samples.size() - 1; for ( int d = 0; d < n; ++d ) { final double x = position.getDoublePosition( d ); if ( x < min[ d ] ) min[ d ] = x; if ( x > max[ d ] ) max[ d ] = x; } } @Override public RealCursor< T > cursor() { return new RealPointSampleListCursor(); } @Override public Object iterationOrder() { return this; // iteration order is only compatible with ourselves } @Override public T firstElement() { return samples.get( 0 ); } @Override public RealCursor< T > localizingCursor() { return new RealPointSampleListCursor(); } @Override public long size() { return samples.size(); } @Override public double realMax( final int d ) { return max[ d ]; } @Override public void realMax( final double[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = max[ d ]; } @Override public void realMax( final RealPositionable m ) { m.setPosition( max ); } @Override public double realMin( final int d ) { return min[ d ]; } @Override public void realMin( final double[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = min[ d ]; } @Override public void realMin( final RealPositionable m ) { m.setPosition( min ); } @Override public int numDimensions() { return n; } @Override public Iterator< T > iterator() { return cursor(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealPositionable.java000066400000000000000000000101421316447754700252560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An element that can be positioned in n-dimensional real space. * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface RealPositionable extends Positionable { /** * Move the element in one dimension for some distance. * * @param distance * @param d */ public void move( float distance, int d ); /** * Move the element in one dimension for some distance. * * @param distance * @param d */ public void move( double distance, int d ); /** * Move the element relative to its current location using a * {@link RealLocalizable} as distance vector. * * @param distance * relative offset, {@link RealLocalizable#numDimensions()} must * be ≥ {@link #numDimensions()} */ public void move( RealLocalizable distance ); /** * Move the element relative to its current location using a float[] as * distance vector. * * @param distance, * length must be ≥ {@link #numDimensions()} */ public void move( float[] distance ); /** * Move the element relative to its current location using a float[] as * distance vector. * * @param distance, * length must be ≥ {@link #numDimensions()} */ public void move( double[] distance ); /** * Place the element at the same location as a given {@link RealLocalizable} * * @param position * absolute position, {@link RealLocalizable#numDimensions()} * must be ≥ {@link #numDimensions()} */ public void setPosition( RealLocalizable position ); /** * Set the position of the element. * * @param position * absolute position, length must be ≥ * {@link #numDimensions()} */ public void setPosition( float position[] ); /** * Set the position of the element. * * @param position * absolute position, length must be ≥ * {@link #numDimensions()} */ public void setPosition( double position[] ); /** * Set the position of the element for one dimension. * * @param position * @param d */ public void setPosition( float position, int d ); /** * Set the position of the element for one dimension. * * @param position * @param d */ public void setPosition( double position, int d ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealRandomAccess.java000066400000000000000000000050631316447754700251760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface RealRandomAccess< T > extends RealLocalizable, RealPositionable, Sampler< T > { // NB: Ideally, we would utilize covariant inheritance to narrow the return // type of a single copy() method here, rather than needing separate methods // copy(), copyCursor(), copyRandomAccess() and copyRealRandomAccess(). // Unfortunately, due to a Javac bug with multiple interface inheritance, // we must avoid doing so for now. For details, see: // http://bugs.sun.com/view_bug.do?bug_id=6656332 // The bug is fixed in JDK7. RealRandomAccess< T > copyRealRandomAccess(); // @Override // public RealRandomAccess< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealRandomAccessible.java000066400000000000000000000050351316447754700260310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** *

* f:Rn→T *

* *

* A function over real space that can create a random access {@link Sampler}. *

* *

* If your algorithm takes a RealRandomAccessible, this usually means that you * expect that the domain is infinite. (In contrast to this, * {@link RealRandomAccessibleRealInterval}s have a finite domain.) *

* * @author Stephan Saalfeld */ public interface RealRandomAccessible< T > extends EuclideanSpace { /** * Create a random access sampler for real coordinates. * * @return random access sampler */ public RealRandomAccess< T > realRandomAccess(); public RealRandomAccess< T > realRandomAccess( RealInterval interval ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/RealRandomAccessibleRealInterval.java000066400000000000000000000042471316447754700303460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** *

* f:{x∈Rn|[min,max]→T} *

* *

* A function over an n-dimensional real interval that can create a random * access {@link Sampler}. *

* * @author Stephan Saalfeld */ public interface RealRandomAccessibleRealInterval< T > extends RealRandomAccessible< T >, RealInterval {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Sampler.java000066400000000000000000000061711316447754700234340ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import java.util.Collection; import net.imglib2.img.array.ArrayCursor; import net.imglib2.type.NativeType; /** *

* The {@link Sampler} interface provides access to a value whose type is * specified by the generic parameter T. This T may point to an actual * {@link Object} as stored in a {@link Collection}, a proxy {@link Object} that * allows reading and writing pixel data of an image (e.g. all * {@link NativeType NativeTypes}), or a proxy {@link Object} whose content is * generated otherwise and may only be readable (e.g. ShapeList2D). *

* * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Sampler< T > { /** * Access the actual T instance providing access to a pixel, * sub-pixel or integral region value the {@link Sampler} points at. */ public T get(); /** * @return - A new {@link Sampler} in the same state accessing the same * values. * * It does NOT copy T, just the state of the {@link Sampler}. * Otherwise use T.copy() if available. * * Sampler.copy().get() == Sampler.get(), i.e. both hold the same * value, not necessarily the same instance (this is the case for an * {@link ArrayCursor} for example) */ public Sampler< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/View.java000066400000000000000000000047551316447754700227510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * An interface which marks an object that is a lightweight wrapper or "view" * around actual data. *

* This is useful to introspect at runtime whether a data object might benefit * from being copied to "burn in" the information, for reasons such as: *

*
    *
  • To avoid costly recomputation, at the expense of more memory use.
  • *
  • To avoid corrupting the wrapped data structure when the object is * mutated.
  • *
* * @author Curtis Rueden * @author Tobias Pietzsch * @author Christian Dietz * @see net.imglib2.view.Views * @see net.imglib2.converter.Converters */ public interface View { // NB: Marker interface. } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/Volatile.java000066400000000000000000000045061316447754700236100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Something volatile that has a value and is either VALID or INVALID. * * @author Stephan Saalfeld */ public class Volatile< T > { final protected T t; protected boolean valid; public Volatile( final T t, final boolean valid ) { this.t = t; this.valid = valid; } public Volatile( final T t ) { this( t, false ); } public T get() { return t; } public boolean isValid() { return valid; } public void setValid( final boolean valid ) { this.valid = valid; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/concatenate/000077500000000000000000000000001316447754700234455ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/concatenate/Concatenable.java000066400000000000000000000054711316447754700266750ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.concatenate; /** * If T implements {@link Concatenable}{@code} that means you can concatenate it * with an A, usually resulting in another T. The conventional meaning for * concatenating transformations is the following: Let * ba = b.concatenate(a). Applying ba to x is * equivalent to first applying a to x and then applying * b to the result. * * @author Tobias Pietzsch * @author Stephan Saalfeld */ public interface Concatenable< A > { /** * Concatenate this object with a. The result will be an object * that can be concatenated with another A. The conventional * meaning for concatenating transformations is the following: Let * ba = b.concatenate(a). Applying ba to x is * equivalent to first applying a to x and then applying * b to the result. */ public Concatenable< A > concatenate( A a ); public Class< A > getConcatenableClass(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/concatenate/ConcatenateUtils.java000066400000000000000000000072541316447754700275650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.concatenate; import java.util.List; import java.util.ListIterator; /** * Utilities for manipulating lists of (pre-)concatenable objects. * * * @author Tobias Pietzsch */ public class ConcatenateUtils { public static void print( final List< ? > concatenatables ) { final ListIterator< ? > iterator = concatenatables.listIterator(); System.out.print( " ==== " ); while ( iterator.hasNext() ) { final Object a = iterator.next(); System.out.print( a ); if ( iterator.hasNext() ) System.out.print( " x " ); } System.out.println(); } /** * Reduce a list of objects by iteratively pre/concatenating neighboring * objects if they support it. * * @param objects * list of objects that will be reduced in place */ @SuppressWarnings( { "unchecked", "rawtypes" } ) public static < T > void join( final List< T > objects ) { int oldConcatenablesSize; do { oldConcatenablesSize = objects.size(); if ( oldConcatenablesSize >= 2 ) { final ListIterator< T > iterator = objects.listIterator(); T c1 = null; T c2 = iterator.next(); while ( iterator.hasNext() ) { c1 = c2; c2 = iterator.next(); if ( Concatenable.class.isInstance( c1 ) && ( ( Concatenable ) c1 ).getConcatenableClass().isInstance( c2 ) ) { c2 = ( T ) ( ( Concatenable ) c1 ).concatenate( c2 ); iterator.remove(); iterator.previous(); iterator.set( c2 ); iterator.next(); } else if ( PreConcatenable.class.isInstance( c2 ) && ( ( PreConcatenable ) c2 ).getPreConcatenableClass().isInstance( c1 ) ) { c2 = ( T ) ( ( PreConcatenable ) c2 ).preConcatenate( c1 ); iterator.previous(); iterator.previous(); iterator.remove(); iterator.next(); iterator.set( c2 ); } } } } while ( oldConcatenablesSize != objects.size() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/concatenate/PreConcatenable.java000066400000000000000000000055351316447754700273450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.concatenate; /** * If T implements {@link PreConcatenable}{@code} that means you can * pre-concatenate it with an A, usually resulting in another T. The * conventional meaning for concatenating transformations is the following: Let * ba = a.preConcatenate(b). Applying ba to x is * equivalent to first applying a to x and then applying * b to the result. * * * @author Tobias Pietzsch * @author Stephan Saalfeld */ public interface PreConcatenable< A > { /** * Pre-concatenate this object with a. The result will be an object * that can be pre-concatenated with another A. The conventional * meaning for concatenating transformations is the following: Let * ba = a.preConcatenate(b). Applying ba to x is * equivalent to first applying a to x and then applying * b to the result. */ public PreConcatenable< A > preConcatenate( A a ); public Class< A > getPreConcatenableClass(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/000077500000000000000000000000001316447754700231705ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ARGBARGBDoubleConverter.java000066400000000000000000000046441316447754700302350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.AbstractARGBDoubleType; /** * * * @author Stephan Saalfeld */ public class ARGBARGBDoubleConverter< T extends AbstractARGBDoubleType< ? > > implements Converter< ARGBType, T > { final static protected double scale = 1.0 / 255.0; @Override public void convert( final ARGBType input, final T output ) { final int argb = input.get(); output.set( ( ( argb >> 24 ) & 0xff ) * scale, ( ( argb >> 16 ) & 0xff ) * scale, ( ( argb >> 8 ) & 0xff ) * scale, ( argb & 0xff ) * scale ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ARGBDoubleARGBConverter.java000066400000000000000000000043211316447754700302250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.AbstractARGBDoubleType; /** * * * @author Stephan Saalfeld */ public class ARGBDoubleARGBConverter< T extends AbstractARGBDoubleType< ? > > implements Converter< T, ARGBType > { @Override public void convert( final T input, final ARGBType output ) { output.set( input.toARGBInt() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/AbstractConvertedCursor.java000066400000000000000000000067431316447754700306600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.Cursor; /** * TODO * */ abstract public class AbstractConvertedCursor< A, B > implements Cursor< B > { final protected Cursor< A > source; public AbstractConvertedCursor( final Cursor< A > source ) { this.source = source; } @Override public void localize( final int[] position ) { source.localize( position ); } @Override public void localize( final long[] position ) { source.localize( position ); } @Override public int getIntPosition( final int d ) { return source.getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return source.getLongPosition( d ); } @Override public void localize( final float[] position ) { source.localize( position ); } @Override public void localize( final double[] position ) { source.localize( position ); } @Override public float getFloatPosition( final int d ) { return source.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return source.getDoublePosition( d ); } @Override public int numDimensions() { return source.numDimensions(); } @Override public void jumpFwd( final long steps ) { source.jumpFwd( steps ); } @Override public void fwd() { source.fwd(); } @Override public void reset() { source.reset(); } @Override public boolean hasNext() { return source.hasNext(); } @Override public B next() { fwd(); return get(); } @Override public void remove() { source.remove(); } @Override abstract public AbstractConvertedCursor< A, B > copy(); @Override public AbstractConvertedCursor< A, B > copyCursor() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/AbstractConvertedIterableInterval.java000066400000000000000000000053111316447754700326250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import java.util.Iterator; import net.imglib2.AbstractWrappedInterval; import net.imglib2.IterableInterval; import net.imglib2.View; /** * TODO * */ abstract public class AbstractConvertedIterableInterval< A, B > extends AbstractWrappedInterval< IterableInterval< A > > implements IterableInterval< B >, View { public AbstractConvertedIterableInterval( final IterableInterval< A > source ) { super( source ); } @Override public long size() { return sourceInterval.size(); } @Override public Object iterationOrder() { return sourceInterval.iterationOrder(); } @Override public Iterator< B > iterator() { return cursor(); } @Override public B firstElement() { return cursor().next(); } @Override abstract public AbstractConvertedCursor< A, B > cursor(); @Override abstract public AbstractConvertedCursor< A, B > localizingCursor(); } AbstractConvertedIterableRandomAccessibleInterval.java000066400000000000000000000061071316447754700356710ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import java.util.Iterator; import net.imglib2.AbstractWrappedInterval; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; /** * TODO * */ abstract public class AbstractConvertedIterableRandomAccessibleInterval< A, B, S extends RandomAccessible< A > & IterableInterval< A > > extends AbstractWrappedInterval< S > implements IterableInterval< B >, RandomAccessibleInterval< B >, View { public AbstractConvertedIterableRandomAccessibleInterval( final S source ) { super( source ); } @Override abstract public AbstractConvertedRandomAccess< A, B > randomAccess(); @Override abstract public AbstractConvertedRandomAccess< A, B > randomAccess( final Interval interval ); @Override public long size() { return sourceInterval.size(); } @Override public Object iterationOrder() { return sourceInterval.iterationOrder(); } @Override public Iterator< B > iterator() { return cursor(); } @Override public B firstElement() { return cursor().next(); } @Override abstract public AbstractConvertedCursor< A, B > cursor(); @Override abstract public AbstractConvertedCursor< A, B > localizingCursor(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/AbstractConvertedRandomAccess.java000066400000000000000000000105011316447754700317300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.Localizable; import net.imglib2.RandomAccess; /** * TODO * */ abstract public class AbstractConvertedRandomAccess< A, B > implements RandomAccess< B > { final protected RandomAccess< A > source; public AbstractConvertedRandomAccess( final RandomAccess< A > source ) { this.source = source; } @Override public void localize( final int[] position ) { source.localize( position ); } @Override public void localize( final long[] position ) { source.localize( position ); } @Override public int getIntPosition( final int d ) { return source.getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return source.getLongPosition( d ); } @Override public void localize( final float[] position ) { source.localize( position ); } @Override public void localize( final double[] position ) { source.localize( position ); } @Override public float getFloatPosition( final int d ) { return source.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return source.getDoublePosition( d ); } @Override public int numDimensions() { return source.numDimensions(); } @Override public void fwd( final int d ) { source.fwd( d ); } @Override public void bck( final int d ) { source.bck( d ); } @Override public void move( final int distance, final int d ) { source.move( distance, d ); } @Override public void move( final long distance, final int d ) { source.move( distance, d ); } @Override public void move( final Localizable localizable ) { source.move( localizable ); } @Override public void move( final int[] distance ) { source.move( distance ); } @Override public void move( final long[] distance ) { source.move( distance ); } @Override public void setPosition( final Localizable localizable ) { source.setPosition( localizable ); } @Override public void setPosition( final int[] position ) { source.setPosition( position ); } @Override public void setPosition( final long[] position ) { source.setPosition( position ); } @Override public void setPosition( final int position, final int d ) { source.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { source.setPosition( position, d ); } @Override abstract public AbstractConvertedRandomAccess< A, B > copy(); @Override public AbstractConvertedRandomAccess< A, B > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/AbstractConvertedRandomAccessible.java000066400000000000000000000050471316447754700325750ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.View; /** * TODO * */ abstract public class AbstractConvertedRandomAccessible< A, B > implements RandomAccessible< B >, View { final protected RandomAccessible< A > source; public AbstractConvertedRandomAccessible( final RandomAccessible< A > source ) { this.source = source; } @Override public int numDimensions() { return source.numDimensions(); } public RandomAccessible< A > getSource() { return source; } @Override abstract public AbstractConvertedRandomAccess< A, B > randomAccess(); @Override abstract public AbstractConvertedRandomAccess< A, B > randomAccess( final Interval interval ); } AbstractConvertedRandomAccessibleInterval.java000066400000000000000000000051311316447754700342150ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.AbstractWrappedInterval; import net.imglib2.Interval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; /** * @author Philipp Hanslovsky * */ abstract public class AbstractConvertedRandomAccessibleInterval< A, B > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< B >, View { protected final RandomAccessibleInterval< A > source; public AbstractConvertedRandomAccessibleInterval( final RandomAccessibleInterval< A > source ) { super( source ); this.source = source; } @Override abstract public AbstractConvertedRandomAccess< A, B > randomAccess(); @Override abstract public AbstractConvertedRandomAccess< A, B > randomAccess( final Interval interval ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/AbstractConvertedRealRandomAccess.java000066400000000000000000000117111316447754700325400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.Localizable; import net.imglib2.RealLocalizable; import net.imglib2.RealRandomAccess; /** * TODO * */ abstract public class AbstractConvertedRealRandomAccess< A, B > implements RealRandomAccess< B > { final protected RealRandomAccess< A > source; public AbstractConvertedRealRandomAccess( final RealRandomAccess< A > source ) { this.source = source; } @Override public void localize( final float[] position ) { source.localize( position ); } @Override public void localize( final double[] position ) { source.localize( position ); } @Override public float getFloatPosition( final int d ) { return source.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return source.getDoublePosition( d ); } @Override public int numDimensions() { return source.numDimensions(); } @Override public void fwd( final int d ) { source.fwd( d ); } @Override public void bck( final int d ) { source.bck( d ); } @Override public void move( final int distance, final int d ) { source.move( distance, d ); } @Override public void move( final long distance, final int d ) { source.move( distance, d ); } @Override public void move( final Localizable localizable ) { source.move( localizable ); } @Override public void move( final int[] distance ) { source.move( distance ); } @Override public void move( final long[] distance ) { source.move( distance ); } @Override public void setPosition( final Localizable localizable ) { source.setPosition( localizable ); } @Override public void setPosition( final int[] position ) { source.setPosition( position ); } @Override public void setPosition( final long[] position ) { source.setPosition( position ); } @Override public void setPosition( final int position, final int d ) { source.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { source.setPosition( position, d ); } @Override abstract public AbstractConvertedRealRandomAccess< A, B > copy(); @Override public AbstractConvertedRealRandomAccess< A, B > copyRealRandomAccess() { return copy(); } @Override public void move( float distance, int d ) { source.move( distance, d ); } @Override public void move( double distance, int d ) { source.move( distance, d ); } @Override public void move( RealLocalizable localizable ) { source.move( localizable ); } @Override public void move( float[] distance ) { source.move( distance ); } @Override public void move( double[] distance ) { source.move( distance ); } @Override public void setPosition( RealLocalizable localizable ) { source.setPosition( localizable ); } @Override public void setPosition( float[] position ) { source.setPosition( position ); } @Override public void setPosition( double[] position ) { source.setPosition( position ); } @Override public void setPosition( float position, int d ) { source.setPosition( position, d ); } @Override public void setPosition( double position, int d ) { source.setPosition( position, d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/AbstractConvertedRealRandomAccessible.java000066400000000000000000000051311316447754700333730ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.RealInterval; import net.imglib2.RealRandomAccessible; import net.imglib2.View; /** * TODO * */ abstract public class AbstractConvertedRealRandomAccessible< A, B > implements RealRandomAccessible< B >, View { final protected RealRandomAccessible< A > source; public AbstractConvertedRealRandomAccessible( final RealRandomAccessible< A > source ) { this.source = source; } @Override public int numDimensions() { return source.numDimensions(); } public RealRandomAccessible< A > getSource() { return source; } @Override abstract public AbstractConvertedRealRandomAccess< A, B > realRandomAccess(); @Override abstract public AbstractConvertedRealRandomAccess< A, B > realRandomAccess( final RealInterval interval ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ChannelARGBConverter.java000066400000000000000000000072301316447754700277310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import static net.imglib2.converter.ChannelARGBConverter.Channel.A; import static net.imglib2.converter.ChannelARGBConverter.Channel.B; import static net.imglib2.converter.ChannelARGBConverter.Channel.G; import static net.imglib2.converter.ChannelARGBConverter.Channel.R; import java.util.ArrayList; import net.imglib2.display.projector.composite.CompositeXYProjector; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.integer.UnsignedByteType; /** * Convert UnsignedByteType into one channel of {@link ARGBType}. * * {@link #converterListRGBA} can be used in {@link CompositeXYProjector} to * convert a 4-channel (R,G,B,A) {@link UnsignedByteType} into composite * {@link ARGBType}. * * @author Tobias Pietzsch */ public final class ChannelARGBConverter implements Converter< UnsignedByteType, ARGBType > { public ChannelARGBConverter( final Channel channel ) { this.shift = channel.shift; } /** * {@link #converterListRGBA} can be used in {@link CompositeXYProjector} to * convert a 4-channel {@link UnsignedByteType} into composite * {@link ARGBType}. */ public static final ArrayList< Converter< UnsignedByteType, ARGBType > > converterListRGBA; static { converterListRGBA = new ArrayList< Converter< UnsignedByteType, ARGBType > >(); converterListRGBA.add( new ChannelARGBConverter( R ) ); converterListRGBA.add( new ChannelARGBConverter( G ) ); converterListRGBA.add( new ChannelARGBConverter( B ) ); converterListRGBA.add( new ChannelARGBConverter( A ) ); } public static enum Channel { A( 24 ), R( 16 ), G( 8 ), B( 0 ); private final int shift; Channel( final int shift ) { this.shift = shift; } } final private int shift; @Override public void convert( final UnsignedByteType input, final ARGBType output ) { output.set( input.get() << shift ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ComplexImaginaryFloatConverter.java000066400000000000000000000044021316447754700321610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ComplexType; import net.imglib2.type.numeric.real.FloatType; /** * Returns the imaginary value of a complex value * * @author Stephan Preibisch */ public class ComplexImaginaryFloatConverter< R extends ComplexType< R > > implements Converter< R, FloatType > { @Override public void convert( final R input, final FloatType output ) { output.set( input.getImaginaryFloat() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ComplexPhaseFloatConverter.java000066400000000000000000000043731316447754700313100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ComplexType; import net.imglib2.type.numeric.real.FloatType; /** * Computes the phase spectrum for a complex value * * @author Stephan Preibisch */ public class ComplexPhaseFloatConverter< R extends ComplexType< R > > implements Converter< R, FloatType > { @Override public void convert( final R input, final FloatType output ) { output.set( input.getPhaseFloat() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ComplexPowerFloatConverter.java000066400000000000000000000043731316447754700313440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ComplexType; import net.imglib2.type.numeric.real.FloatType; /** * Computes the power spectrum for a complex value * * @author Stephan Preibisch */ public class ComplexPowerFloatConverter< R extends ComplexType< R > > implements Converter< R, FloatType > { @Override public void convert( final R input, final FloatType output ) { output.set( input.getPowerFloat() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ComplexPowerGLogFloatConverter.java000066400000000000000000000045041316447754700321110ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ComplexType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.Util; /** * Computes the generalized log of the power spectrum for a complex value * * @author Stephan Preibisch */ public class ComplexPowerGLogFloatConverter< R extends ComplexType< R > > implements Converter< R, FloatType > { @Override public void convert( final R input, final FloatType output ) { output.set( Util.gLog( input.getPowerFloat(), 2 ) ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/ComplexRealFloatConverter.java000066400000000000000000000043651316447754700311340ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ComplexType; import net.imglib2.type.numeric.real.FloatType; /** * Returns the real value for of complex value * * @author Stephan Preibisch */ public class ComplexRealFloatConverter< R extends ComplexType< R > > implements Converter< R, FloatType > { @Override public void convert( final R input, final FloatType output ) { output.set( input.getRealFloat() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/CompositeChannelConverter.java000066400000000000000000000045241316447754700311630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.converter; import net.imglib2.type.Type; import net.imglib2.view.composite.Composite; /** * A converter to extract one channel of a {@link Composite}. * * @author Stephan Saalfeld * */ public class CompositeChannelConverter< T extends Type< T >, A extends Composite< T > > implements Converter< A, T > { final protected long i; public CompositeChannelConverter( final long i ) { this.i = i; } @Override public void convert( A input, T output ) { output.set( input.get( i ) ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/Converter.java000066400000000000000000000037231316447754700260070ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; /** * @author Stephan Preibisch */ public interface Converter< A, B > { public void convert( A input, B output ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/Converters.java000066400000000000000000000344131316447754700261720ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import java.util.ArrayList; import net.imglib2.Cursor; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; import net.imglib2.RealRandomAccessibleRealInterval; import net.imglib2.Sampler; import net.imglib2.converter.read.ConvertedIterableInterval; import net.imglib2.converter.read.ConvertedRandomAccessible; import net.imglib2.converter.read.ConvertedRandomAccessibleInterval; import net.imglib2.converter.read.ConvertedRealRandomAccessible; import net.imglib2.converter.read.ConvertedRealRandomAccessibleRealInterval; import net.imglib2.converter.readwrite.ARGBChannelSamplerConverter; import net.imglib2.converter.readwrite.SamplerConverter; import net.imglib2.converter.readwrite.WriteConvertedIterableInterval; import net.imglib2.converter.readwrite.WriteConvertedIterableRandomAccessibleInterval; import net.imglib2.converter.readwrite.WriteConvertedRandomAccessible; import net.imglib2.converter.readwrite.WriteConvertedRandomAccessibleInterval; import net.imglib2.type.Type; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.view.Views; /** * Convenience factory methods for sample conversion. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class Converters { /** * Create a {@link RandomAccessible} whose {@link RandomAccess * RandomAccesses} {@link RandomAccess#get()} you a converted sample. * Conversion is done on-the-fly when reading values. Writing to the * converted {@link RandomAccessibleInterval} has no effect. * * @param source * @param converter * @param b * @return a converted {@link RandomAccessible} whose {@link RandomAccess * RandomAccesses} perform on-the-fly value conversion using the * provided converter. */ @SuppressWarnings( "unchecked" ) final static public < A, B extends Type< B > > RandomAccessible< B > convert( final RandomAccessible< A > source, final Converter< ? super A, ? super B > converter, final B b ) { if ( TypeIdentity.class.isInstance( converter ) ) return ( RandomAccessible< B > ) source; return new ConvertedRandomAccessible< A, B >( source, converter, b ); } /** * Create a {@link RandomAccessible} whose {@link RandomAccess * RandomAccesses} {@link RandomAccess#get()} you a converted sample. * Conversion is done on-the-fly both when reading and writing values. * * @param source * @param converter * @return a converted {@link RandomAccessible} whose {@link RandomAccess * RandomAccesses} perform on-the-fly value conversion using the * provided converter. */ final static public < A, B extends Type< B > > WriteConvertedRandomAccessible< A, B > convert( final RandomAccessible< A > source, final SamplerConverter< ? super A, B > converter ) { return new WriteConvertedRandomAccessible< A, B >( source, converter ); } /** * Create a {@link RandomAccessibleInterval} whose {@link RandomAccess * RandomAccesses} {@link RandomAccess#get()} you a converted sample. * Conversion is done on-the-fly when reading values. Writing to the * converted {@link RandomAccessibleInterval} has no effect. * * @param source * @param converter * @param b * @return a converted {@link RandomAccessibleInterval} whose * {@link RandomAccess RandomAccesses} perform on-the-fly value * conversion using the provided converter. */ @SuppressWarnings( "unchecked" ) final static public < A, B extends Type< B > > RandomAccessibleInterval< B > convert( final RandomAccessibleInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { if ( TypeIdentity.class.isInstance( converter ) ) return ( RandomAccessibleInterval< B > ) source; return new ConvertedRandomAccessibleInterval< A, B >( source, converter, b ); } /** * Create a {@link RandomAccessibleInterval} whose {@link RandomAccess * RandomAccesses} {@link RandomAccess#get()} you a converted sample. * Conversion is done on-the-fly both when reading and writing values. * * @param source * @param converter * @return a converted {@link RandomAccessibleInterval} whose * {@link RandomAccess RandomAccesses} perform on-the-fly value * conversion using the provided converter. */ final static public < A, B extends Type< B > > WriteConvertedRandomAccessibleInterval< A, B > convert( final RandomAccessibleInterval< A > source, final SamplerConverter< ? super A, B > converter ) { return new WriteConvertedRandomAccessibleInterval< A, B >( source, converter ); } /** * Create a {@link IterableInterval} whose {@link Cursor Cursors} * {@link Cursor#get()} you a converted sample. Conversion is done * on-the-fly when reading values. Writing to the converted * {@link IterableInterval} has no effect. * * @param source * @param converter * @param b * @return a converted {@link IterableInterval} whose {@link Cursor Cursors} * perform on-the-fly value conversion using the provided converter. */ @SuppressWarnings( "unchecked" ) final static public < A, B extends Type< B > > IterableInterval< B > convert( final IterableInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { if ( TypeIdentity.class.isInstance( converter ) ) return ( IterableInterval< B > ) source; return new ConvertedIterableInterval< A, B >( source, converter, b ); } /** * Create an {@link IterableInterval} whose {@link Cursor Cursors} * {@link Cursor#get()} you a converted sample. Conversion is done * on-the-fly both when reading and writing values. * * @param source * @param converter * @return a converted {@link IterableInterval} whose {@link Cursor Cursors} * perform on-the-fly value conversion using the provided converter. */ final static public < A, B extends Type< B > > WriteConvertedIterableInterval< A, B > convert( final IterableInterval< A > source, final SamplerConverter< ? super A, B > converter ) { return new WriteConvertedIterableInterval< A, B >( source, converter ); } /** * Create an {@link WriteConvertedIterableRandomAccessibleInterval} whose * {@link RandomAccess RandomAccesses} and {@link Cursor Cursors} * {@link Cursor#get()} you a converted sample. Conversion is done * on-the-fly both when reading and writing values. * * @param source * @param converter * @return a {@link WriteConvertedIterableRandomAccessibleInterval} whose * {@link Sampler Samplers} perform on-the-fly value conversion * using the provided converter. */ final static public < A, B extends Type< B >, S extends RandomAccessible< A > & IterableInterval< A > > WriteConvertedIterableRandomAccessibleInterval< A, B, S > convertRandomAccessibleIterableInterval( final S source, final SamplerConverter< ? super A, B > converter ) { return new WriteConvertedIterableRandomAccessibleInterval< A, B, S >( source, converter ); } /** * Create a {@link RealRandomAccessibleRealInterval} whose {@link RealRandomAccess * RealRandomAccesses} {@link RealRandomAccess#get()} you a converted sample. * Conversion is done on-the-fly when reading values. Writing to the * converted {@link RealRandomAccessibleRealInterval} has no effect. * * @param source * @param converter * @param b * @return a converted {@link RealRandomAccessibleRealInterval} whose * {@link RealRandomAccess RealRandomAccesses} perform on-the-fly value * conversion using the provided converter. */ @SuppressWarnings( "unchecked" ) final static public < A, B extends Type< B > > RealRandomAccessibleRealInterval< B > convert( final RealRandomAccessibleRealInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { if ( TypeIdentity.class.isInstance( converter ) ) return ( RealRandomAccessibleRealInterval< B > ) source; return new ConvertedRealRandomAccessibleRealInterval< A, B >( source, converter, b ); } /** * Create a {@link RealRandomAccessible} whose {@link RealRandomAccess * RealRandomAccesses} {@link RealRandomAccess#get()} you a converted sample. * Conversion is done on-the-fly when reading values. Writing to the * converted {@link RandomAccessibleInterval} has no effect. * * @param source * @param converter * @param b * @return a converted {@link RealRandomAccessible} whose {@link RealRandomAccess * RealRandomAccesses} perform on-the-fly value conversion using the * provided converter. */ @SuppressWarnings( "unchecked" ) final static public < A, B extends Type< B > > RealRandomAccessible< B > convert( final RealRandomAccessible< A > source, final Converter< ? super A, ? super B > converter, final B b ) { if ( TypeIdentity.class.isInstance( converter ) ) return ( RealRandomAccessible< B > ) source; return new ConvertedRealRandomAccessible< A, B >( source, converter, b ); } /** * Create a {@link WriteConvertedRandomAccessibleInterval} to one of the * four channels encoded in a {@link RandomAccessibleInterval} of * {@link ARGBType}. The source is being modified as expected by writing * into the converted channels. * * @param source * @param channel 0 = alpha, 1 = red, 2 = green, 3 = blue * * @return a converted {@link WriteConvertedRandomAccessibleInterval} whose * {@link Sampler Samplers} perform on-the-fly value conversion * into and from one channel of the original {@link ARGBType}. */ final static public WriteConvertedRandomAccessibleInterval< ARGBType, UnsignedByteType > argbChannel( final RandomAccessibleInterval< ARGBType > source, final int channel ) { return convert( source, new ARGBChannelSamplerConverter( channel ) ); } /** * Create a {@link WriteConvertedRandomAccessible} to one of the four * channels encoded in a {@link RandomAccessible} of {@link ARGBType}. * The source is being modified as expected by writing into the converted * channels. * * @param source * @param channel 0 = alpha, 1 = red, 2 = green, 3 = blue * * @return a converted {@link WriteConvertedRandomAccessible} whose * {@link Sampler Samplers} perform on-the-fly value conversion * into and from one channel of the original {@link ARGBType}. */ final static public WriteConvertedRandomAccessible< ARGBType, UnsignedByteType > argbChannel( final RandomAccessible< ARGBType > source, final int channel ) { return convert( source, new ARGBChannelSamplerConverter( channel ) ); } /** * Create an (n+1)-dimensional {@link RandomAccessible} of an * n-dimensional {@link RandomAccessible} that maps the four * channels encoded in {@link ARGBType} into a dimension. The source is * being modified as expected by writing into the converted channels. * * @param source * * @return a converted {@link RandomAccessibleInterval} whose * {@link Sampler Samplers} perform on-the-fly value conversion * into and from the corresponding channels of the original * {@link ARGBType}. */ final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source ) { return Views.stack( argbChannel( source, 0 ), argbChannel( source, 1 ), argbChannel( source, 2 ), argbChannel( source, 3 ) ); } /** * Create an (n+1)-dimensional {@link RandomAccessible} of an * n-dimensional {@link RandomAccessible} that maps the four * channels encoded in {@link ARGBType} into a dimension. The order * of the channels passed as arguments is preserved. The source is being * modified as expected by writing into the converted channels. * * @param source * @param channels 0 = alpha, 1 = red, 2 = green, 3 = blue * * @return a converted {@link RandomAccessibleInterval} whose * {@link Sampler Samplers} perform on-the-fly value conversion * into and from the corresponding channels of the original * {@link ARGBType}. */ final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source, final int... channels ) { final ArrayList< RandomAccessibleInterval< UnsignedByteType > > hyperSlices = new ArrayList<>(); for ( final int c : channels ) hyperSlices.add( argbChannel( source, channels[ c ] ) ); return Views.stack( hyperSlices ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/RealARGBConverter.java000066400000000000000000000051021316447754700272400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.display.AbstractLinearRange; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.RealType; /** * * @author Stephan Saalfeld */ public class RealARGBConverter< R extends RealType< ? > > extends AbstractLinearRange implements Converter< R, ARGBType > { public RealARGBConverter() { super(); } public RealARGBConverter( final double min, final double max ) { super( min, max ); } @Override public void convert( final R input, final ARGBType output ) { final double a = input.getRealDouble(); final int b = Math.min( 255, roundPositive( Math.max( 0, ( ( a - min ) / scale * 255.0 ) ) ) ); final int argb = 0xff000000 | ( ( ( b << 8 ) | b ) << 8 ) | b; output.set( argb ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/RealDoubleConverter.java000066400000000000000000000045331316447754700277460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.DoubleType; /** * Converts any {@link RealType} to a {@link DoubleType}. * * If the input type is complex, it loses the imaginary part without complaining * further. * * @author Johannes Schindelin */ public class RealDoubleConverter< R extends RealType< R > > implements Converter< R, DoubleType > { @Override public void convert( final R input, final DoubleType output ) { output.set( input.getRealDouble() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/RealFloatConverter.java000066400000000000000000000043311316447754700275750ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; /** * * * @author Stephan Saalfeld * @author Stephan Preibisch */ public class RealFloatConverter< R extends RealType< R > > implements Converter< R, FloatType > { @Override public void convert( final R input, final FloatType output ) { output.set( input.getRealFloat() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/RealLUTConverter.java000066400000000000000000000061731316447754700272020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.display.AbstractLinearRange; import net.imglib2.display.ColorTable; import net.imglib2.display.ColorTable8; import net.imglib2.display.projector.composite.CompositeXYProjector; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.RealType; /** * RealLUTConverter contains a {@link ColorTable8}, through which samples are * filtered. Input values are interpreted as indices into the color table. * * @see CompositeXYProjector * @see RealARGBConverter for the code upon which this class was based. * * @author Stephan Saalfeld * @author Grant Harris * @author Curtis Rueden */ public class RealLUTConverter< R extends RealType< R >> extends AbstractLinearRange implements Converter< R, ARGBType > { private ColorTable lut = null; public RealLUTConverter() { super(); } public RealLUTConverter( final double min, final double max, final ColorTable lut ) { super( min, max ); setLUT( lut ); } public ColorTable getLUT() { return lut; } public void setLUT( final ColorTable lut ) { this.lut = lut == null ? new ColorTable8() : lut; } @Override public void convert( final R input, final ARGBType output ) { final double a = input.getRealDouble(); final int argb = lut.lookupARGB( min, max, a ); output.set( argb ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/RealUnsignedByteConverter.java000066400000000000000000000050471316447754700311350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.display.AbstractLinearRange; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.UnsignedByteType; /** * * * @author Stephan Saalfeld */ public class RealUnsignedByteConverter< R extends RealType< R > > extends AbstractLinearRange implements Converter< R, UnsignedByteType > { public RealUnsignedByteConverter() { super(); } public RealUnsignedByteConverter( final double min, final double max ) { super( min, max ); } @Override public void convert( final R input, final UnsignedByteType output ) { final double a = input.getRealDouble(); output.set( Math.min( 255, roundPositive( Math.max( 0, ( ( a - min ) / scale * 255.0 ) ) ) ) ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/RealUnsignedShortConverter.java000066400000000000000000000050611316447754700313250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.display.AbstractLinearRange; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.UnsignedShortType; /** * * * @author Stephan Saalfeld */ public class RealUnsignedShortConverter< R extends RealType< R > > extends AbstractLinearRange implements Converter< R, UnsignedShortType > { public RealUnsignedShortConverter() { super(); } public RealUnsignedShortConverter( final double min, final double max ) { super( min, max ); } @Override public void convert( final R input, final UnsignedShortType output ) { final double a = input.getRealDouble(); output.set( Math.min( 65535, roundPositive( Math.max( 0, ( ( a - min ) / scale * 65535.0 ) ) ) ) ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/TypeIdentity.java000066400000000000000000000041341316447754700264700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.Type; /** * TODO * * @author Stephan Preibisch */ public class TypeIdentity< T extends Type< T > > implements Converter< T, T > { @Override public void convert( final T input, final T output ) { output.set( input ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/VolatileRealTypeARGBConverter.java000066400000000000000000000055401316447754700316100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.volatiles.VolatileRealType; /** * Converts a {@link VolatileRealType} to an {@link ARGBType}. * * @author Stephan Saalfeld */ public class VolatileRealTypeARGBConverter extends RealARGBConverter< VolatileRealType< ? > > { final protected ARGBType background; public VolatileRealTypeARGBConverter( final ARGBType background ) { super(); this.background = background; } public VolatileRealTypeARGBConverter() { this( new ARGBType( 0xff000040 ) ); } public VolatileRealTypeARGBConverter( final double min, final double max, final ARGBType background ) { super( min, max ); this.background = background; } public VolatileRealTypeARGBConverter( final double min, final double max ) { this( min, max, new ARGBType( 0xff000040 ) ); } @Override public void convert( final VolatileRealType< ? > input, final ARGBType output ) { if ( input.isValid() ) super.convert( input, output ); else output.set( background ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/000077500000000000000000000000001316447754700241035ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/ConvertedCursor.java000066400000000000000000000054531316447754700301040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.Cursor; import net.imglib2.converter.AbstractConvertedCursor; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ public class ConvertedCursor< A, B extends Type< B > > extends AbstractConvertedCursor< A, B > { final protected Converter< ? super A, ? super B > converter; final protected B converted; /** * Creates a copy of b for conversion that can be accessed through * {@link #get()}. * * @param source * @param converter * @param b */ public ConvertedCursor( final Cursor< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public B get() { converter.convert( source.get(), converted ); return converted; } @Override public ConvertedCursor< A, B > copy() { return new ConvertedCursor< A, B >( ( Cursor< A > ) source.copy(), converter, converted ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/ConvertedIterableInterval.java000066400000000000000000000061071316447754700320600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.IterableInterval; import net.imglib2.converter.AbstractConvertedIterableInterval; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ public class ConvertedIterableInterval< A, B extends Type< B > > extends AbstractConvertedIterableInterval< A, B > { final protected Converter< ? super A, ? super B > converter; final protected B converted; /** * Creates a copy of b for conversion. * * @param source * @param converter * @param b */ public ConvertedIterableInterval( final IterableInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public ConvertedCursor< A, B > cursor() { return new ConvertedCursor< A, B >( sourceInterval.cursor(), converter, converted ); } @Override public ConvertedCursor< A, B > localizingCursor() { return new ConvertedCursor< A, B >( sourceInterval.localizingCursor(), converter, converted ); } /** * @return an instance of the destination {@link Type}. */ public B getDestinationType() { return converted.copy(); } public Converter< ? super A, ? super B > getConverter() { return converter; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/ConvertedRandomAccess.java000066400000000000000000000053021316447754700311620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.RandomAccess; import net.imglib2.converter.AbstractConvertedRandomAccess; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ final public class ConvertedRandomAccess< A, B extends Type< B > > extends AbstractConvertedRandomAccess< A, B > { final protected Converter< ? super A, ? super B > converter; final protected B converted; public ConvertedRandomAccess( final RandomAccess< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public B get() { converter.convert( source.get(), converted ); return converted; } @Override public ConvertedRandomAccess< A, B > copy() { return new ConvertedRandomAccess< A, B >( source.copyRandomAccess(), converter, converted ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/ConvertedRandomAccessible.java000066400000000000000000000060541316447754700320230ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.converter.AbstractConvertedRandomAccessible; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ public class ConvertedRandomAccessible< A, B extends Type< B > > extends AbstractConvertedRandomAccessible< A, B > { final protected Converter< ? super A, ? super B > converter; final protected B converted; public ConvertedRandomAccessible( final RandomAccessible< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public ConvertedRandomAccess< A, B > randomAccess() { return new ConvertedRandomAccess< A, B >( source.randomAccess(), converter, converted ); } @Override public ConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { return new ConvertedRandomAccess< A, B >( source.randomAccess( interval ), converter, converted ); } /** * @return an instance of the destination {@link Type}. */ public B getDestinationType() { return converted.copy(); } public Converter< ? super A, ? super B > getConverter() { return converter; } } ConvertedRandomAccessibleInterval.java000066400000000000000000000062371316447754700334540ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.AbstractWrappedInterval; import net.imglib2.Interval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ public class ConvertedRandomAccessibleInterval< A, B extends Type< B > > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< B >, View { final protected Converter< ? super A, ? super B > converter; final protected B converted; public ConvertedRandomAccessibleInterval( final RandomAccessibleInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public ConvertedRandomAccess< A, B > randomAccess() { return new ConvertedRandomAccess< A, B >( sourceInterval.randomAccess(), converter, converted ); } @Override public ConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { return new ConvertedRandomAccess< A, B >( sourceInterval.randomAccess( interval ), converter, converted ); } /** * @return an instance of the destination {@link Type}. */ public B getDestinationType() { return converted.copy(); } public Converter< ? super A, ? super B > getConverter() { return converter; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/ConvertedRealRandomAccess.java000066400000000000000000000053461316447754700317760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.RealRandomAccess; import net.imglib2.converter.AbstractConvertedRealRandomAccess; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ final public class ConvertedRealRandomAccess< A, B extends Type< B > > extends AbstractConvertedRealRandomAccess< A, B > { final protected Converter< ? super A, ? super B > converter; final protected B converted; public ConvertedRealRandomAccess( final RealRandomAccess< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public B get() { converter.convert( source.get(), converted ); return converted; } @Override public ConvertedRealRandomAccess< A, B > copy() { return new ConvertedRealRandomAccess< A, B >( source.copyRealRandomAccess(), converter, converted ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/ConvertedRealRandomAccessible.java000066400000000000000000000061541316447754700326300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.RealInterval; import net.imglib2.RealRandomAccessible; import net.imglib2.converter.AbstractConvertedRealRandomAccessible; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ public class ConvertedRealRandomAccessible< A, B extends Type< B > > extends AbstractConvertedRealRandomAccessible< A, B > { final protected Converter< ? super A, ? super B > converter; final protected B converted; public ConvertedRealRandomAccessible( final RealRandomAccessible< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public ConvertedRealRandomAccess< A, B > realRandomAccess() { return new ConvertedRealRandomAccess< A, B >( source.realRandomAccess(), converter, converted ); } @Override public ConvertedRealRandomAccess< A, B > realRandomAccess( final RealInterval interval ) { return new ConvertedRealRandomAccess< A, B >( source.realRandomAccess( interval ), converter, converted ); } /** * @return an instance of the destination {@link Type}. */ public B getDestinationType() { return converted.copy(); } public Converter< ? super A, ? super B > getConverter() { return converter; } } ConvertedRealRandomAccessibleRealInterval.java000066400000000000000000000063771316447754700350710ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/read/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.read; import net.imglib2.AbstractWrappedRealInterval; import net.imglib2.RealInterval; import net.imglib2.RealRandomAccessibleRealInterval; import net.imglib2.View; import net.imglib2.converter.Converter; import net.imglib2.type.Type; /** * TODO * */ public class ConvertedRealRandomAccessibleRealInterval< A, B extends Type< B > > extends AbstractWrappedRealInterval< RealRandomAccessibleRealInterval< A > > implements RealRandomAccessibleRealInterval< B >, View { final protected Converter< ? super A, ? super B > converter; final protected B converted; public ConvertedRealRandomAccessibleRealInterval( final RealRandomAccessibleRealInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); } @Override public ConvertedRealRandomAccess< A, B > realRandomAccess() { return new ConvertedRealRandomAccess< A, B >( sourceInterval.realRandomAccess(), converter, converted ); } @Override public ConvertedRealRandomAccess< A, B > realRandomAccess( final RealInterval interval ) { return new ConvertedRealRandomAccess< A, B >( sourceInterval.realRandomAccess( interval ), converter, converted ); } /** * @return an instance of the destination {@link Type}. */ public B getDestinationType() { return converted.copy(); } public Converter< ? super A, ? super B > getConverter() { return converter; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/000077500000000000000000000000001316447754700251565ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/ARGBChannelSamplerConverter.java000066400000000000000000000066651316447754700332560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Sampler; import net.imglib2.img.basictypeaccess.ByteAccess; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.integer.UnsignedByteType; /** * Access the on channel of an {@link ARGBType} as an UnsignedByteType. * */ public final class ARGBChannelSamplerConverter implements SamplerConverter< ARGBType, UnsignedByteType > { static final private int[] masks = new int[]{ 0x00ffffff, 0xff00ffff, 0xffff00ff, 0x00ffff00 }; static final private int[] shifts = new int[]{ 24, 16, 8, 0 }; final private int mask, shift; public ARGBChannelSamplerConverter( final int channel ) { mask = masks[ channel ]; shift = shifts[ channel ]; } @Override public UnsignedByteType convert( final Sampler< ? extends ARGBType > sampler ) { return new UnsignedByteType( new ARGBChannelConvertingAccess( sampler ) ); } final private class ARGBChannelConvertingAccess implements ByteAccess { final private Sampler< ? extends ARGBType > sampler; private ARGBChannelConvertingAccess( final Sampler< ? extends ARGBType > sampler ) { this.sampler = sampler; } /** * This is only intended to work with UnsignedByteType! We ignore index!!! */ @Override public byte getValue( final int index ) { return ( byte )( ( sampler.get().get() >> shift ) & 0xff ); } /** * This is only intended to work with UnsignedByteType! We ignore index!!! */ @Override public void setValue( final int index, final byte value ) { final ARGBType t = sampler.get(); t.set( ( t.get() & mask ) | ( value << shift ) ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/RealDoubleSamplerConverter.java000066400000000000000000000057301316447754700332600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Sampler; import net.imglib2.img.basictypeaccess.DoubleAccess; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.DoubleType; /** * TODO * */ public final class RealDoubleSamplerConverter< R extends RealType< R > > implements SamplerConverter< R, DoubleType > { @Override public DoubleType convert( final Sampler< ? extends R > sampler ) { return new DoubleType( new RealConvertingDoubleAccess< R >( sampler ) ); } private static final class RealConvertingDoubleAccess< R extends RealType< R > > implements DoubleAccess { private final Sampler< ? extends R > sampler; private RealConvertingDoubleAccess( final Sampler< ? extends R > sampler ) { this.sampler = sampler; } /** * This is only intended to work with DoubleType! We ignore index!!! */ @Override public double getValue( final int index ) { return sampler.get().getRealDouble(); } /** * This is only intended to work with DoubleType! We ignore index!!! */ @Override public void setValue( final int index, final double value ) { sampler.get().setReal( value ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/RealFloatSamplerConverter.java000066400000000000000000000057111316447754700331120ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Sampler; import net.imglib2.img.basictypeaccess.FloatAccess; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; /** * TODO * */ public final class RealFloatSamplerConverter< R extends RealType< R > > implements SamplerConverter< R, FloatType > { @Override public FloatType convert( final Sampler< ? extends R > sampler ) { return new FloatType( new RealConvertingFloatAccess< R >( sampler ) ); } private static final class RealConvertingFloatAccess< R extends RealType< R > > implements FloatAccess { private final Sampler< ? extends R > sampler; private RealConvertingFloatAccess( final Sampler< ? extends R > sampler ) { this.sampler = sampler; } /** * This is only intended to work with FloatType! We ignore index!!! */ @Override public float getValue( final int index ) { return sampler.get().getRealFloat(); } /** * This is only intended to work with FloatType! We ignore index!!! */ @Override public void setValue( final int index, final float value ) { sampler.get().setReal( value ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/SamplerConverter.java000066400000000000000000000037721316447754700313250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Sampler; /** * TODO * */ public interface SamplerConverter< A, B > { public B convert( Sampler< ? extends A > sampler ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/WriteConvertedCursor.java000066400000000000000000000050301316447754700321610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Cursor; import net.imglib2.converter.AbstractConvertedCursor; /** * TODO * */ public class WriteConvertedCursor< A, B > extends AbstractConvertedCursor< A, B > { private final SamplerConverter< ? super A, B > converter; private final B converted; public WriteConvertedCursor( final Cursor< A > source, final SamplerConverter< ? super A, B > converter ) { super( source ); this.converter = converter; this.converted = converter.convert( source ); } @Override public B get() { return converted; } @Override public WriteConvertedCursor< A, B > copy() { return new WriteConvertedCursor< A, B >( ( Cursor< A > ) source.copy(), converter ); } } WriteConvertedIterableInterval.java000066400000000000000000000051621316447754700340670ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.IterableInterval; import net.imglib2.converter.AbstractConvertedIterableInterval; /** * TODO * */ public class WriteConvertedIterableInterval< A, B > extends AbstractConvertedIterableInterval< A, B > { private final SamplerConverter< ? super A, B > converter; public WriteConvertedIterableInterval( final IterableInterval< A > source, final SamplerConverter< ? super A, B > converter ) { super( source ); this.converter = converter; } @Override public WriteConvertedCursor< A, B > cursor() { return new WriteConvertedCursor< A, B >( sourceInterval.cursor(), converter ); } @Override public WriteConvertedCursor< A, B > localizingCursor() { return new WriteConvertedCursor< A, B >( sourceInterval.localizingCursor(), converter ); } } WriteConvertedIterableRandomAccessibleInterval.java000066400000000000000000000062211316447754700372030ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessible; import net.imglib2.converter.AbstractConvertedIterableRandomAccessibleInterval; /** * TODO * */ public class WriteConvertedIterableRandomAccessibleInterval< A, B, S extends RandomAccessible< A > & IterableInterval< A > > extends AbstractConvertedIterableRandomAccessibleInterval< A, B, S > { private final SamplerConverter< ? super A, B > converter; public WriteConvertedIterableRandomAccessibleInterval( final S source, final SamplerConverter< ? super A, B > converter ) { super( source ); this.converter = converter; } @Override public WriteConvertedRandomAccess< A, B > randomAccess() { return new WriteConvertedRandomAccess< A, B >( sourceInterval.randomAccess(), converter ); } @Override public WriteConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { return new WriteConvertedRandomAccess< A, B >( sourceInterval.randomAccess( interval ), converter ); } @Override public WriteConvertedCursor< A, B > cursor() { return new WriteConvertedCursor< A, B >( sourceInterval.cursor(), converter ); } @Override public WriteConvertedCursor< A, B > localizingCursor() { return new WriteConvertedCursor< A, B >( sourceInterval.localizingCursor(), converter ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/WriteConvertedRandomAccess.java000066400000000000000000000051241316447754700332520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.RandomAccess; import net.imglib2.converter.AbstractConvertedRandomAccess; /** * TODO * */ public final class WriteConvertedRandomAccess< A, B > extends AbstractConvertedRandomAccess< A, B > { private final SamplerConverter< ? super A, B > converter; private final B converted; public WriteConvertedRandomAccess( final RandomAccess< A > source, final SamplerConverter< ? super A, B > converter ) { super( source ); this.converter = converter; this.converted = converter.convert( source ); } @Override public B get() { return converted; } @Override public WriteConvertedRandomAccess< A, B > copy() { return new WriteConvertedRandomAccess< A, B >( ( RandomAccess< A > ) source.copy(), converter ); } } WriteConvertedRandomAccessible.java000066400000000000000000000052761316447754700340370ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.converter.AbstractConvertedRandomAccessible; /** * TODO * */ public class WriteConvertedRandomAccessible< A, B > extends AbstractConvertedRandomAccessible< A, B > { private final SamplerConverter< ? super A, B > converter; public WriteConvertedRandomAccessible( final RandomAccessible< A > source, final SamplerConverter< ? super A, B > converter ) { super( source ); this.converter = converter; } @Override public WriteConvertedRandomAccess< A, B > randomAccess() { return new WriteConvertedRandomAccess< A, B >( source.randomAccess(), converter ); } @Override public WriteConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { return new WriteConvertedRandomAccess< A, B >( source.randomAccess( interval ), converter ); } } WriteConvertedRandomAccessibleInterval.java000066400000000000000000000054221316447754700355350ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/converter/readwrite/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter.readwrite; import net.imglib2.AbstractWrappedInterval; import net.imglib2.Interval; import net.imglib2.RandomAccessibleInterval; /** * TODO * */ public class WriteConvertedRandomAccessibleInterval< A, B > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< B > { private final SamplerConverter< ? super A, B > converter; public WriteConvertedRandomAccessibleInterval( final RandomAccessibleInterval< A > source, final SamplerConverter< ? super A, B > converter ) { super( source ); this.converter = converter; } @Override public WriteConvertedRandomAccess< A, B > randomAccess() { return new WriteConvertedRandomAccess< A, B >( sourceInterval.randomAccess(), converter ); } @Override public WriteConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { return new WriteConvertedRandomAccess< A, B >( sourceInterval.randomAccess( interval ), converter ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/000077500000000000000000000000001316447754700226265ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/AbstractArrayColorTable.java000066400000000000000000000067441316447754700302150ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; import net.imglib2.type.numeric.ARGBType; import net.imglib2.util.Binning; /** * Abstract superclass for array-based color lookup tables. * * @author Stephan Saalfeld * @author Curtis Rueden * @author Mark Hiner */ public abstract class AbstractArrayColorTable< T > implements ArrayColorTable< T > { // -- Fields -- /** * Actual color table values. */ protected final T[] values; // -- Constructor -- /** * Initializes a color table with the given table values. */ public AbstractArrayColorTable( final T... values ) { this.values = values; } // -- ArrayColorTable methods -- @Override public T[] getValues() { return values.clone(); } @Override public int argb( final int i ) { final int r = values.length > 0 ? get( ColorTable.RED, i ) : 0; final int g = values.length > 1 ? get( ColorTable.GREEN, i ) : 0; final int b = values.length > 2 ? get( ColorTable.BLUE, i ) : 0; final int a = values.length > 3 ? get( ColorTable.ALPHA, i ) : 0xff; return ARGBType.rgba( r, g, b, a ); } // -- ColorTable methods -- @Override public int lookupARGB( final double min, final double max, final double value ) { final int bins = getLength(); final int bin = Binning.valueToBin( bins, min, max, value ); return argb( bin ); } @Override public int getComponentCount() { return values.length; } /** * {@inheritDoc} *

* Value is unsigned 8 bits. *

*/ @Override public abstract int get( final int comp, final int bin ); /** * {@inheritDoc} *

* Value is unsigned 8 bits. *

*/ @Override public abstract int getResampled( final int comp, final int bins, final int bin ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/AbstractLinearRange.java000066400000000000000000000051201316447754700273420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; /** * * * @author Stephan Saalfeld */ public class AbstractLinearRange implements LinearRange { protected double min = 0; protected double max = 1; protected double scale = 1; public AbstractLinearRange() {} public AbstractLinearRange( final double min, final double max ) { this.min = min; this.max = max; scale = max - min; } final static protected int roundPositive( final double a ) { return ( int ) ( a + 0.5 ); } @Override public double getMin() { return min; } @Override public double getMax() { return max; } @Override public void setMax( final double max ) { this.max = max; scale = max - min; } @Override public void setMin( final double min ) { this.min = min; scale = max - min; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/ArrayColorTable.java000066400000000000000000000055171316447754700265260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; /** * Interface for all {@link ColorTable} implementations that use an array to * store their color table information. This interface provides an accessor to * that value array and other conveniences, and the generic type of this table * corresponds to the array type that is returned. * * @author Mark Hiner * @author Curtis Rueden */ public interface ArrayColorTable< T > extends ColorTable { /** * Gets a copy of the entire color table. */ T[] getValues(); /** * Converts the tuple at the given position into a packed ARGB value. */ int argb( int i ); /** * Gets the number of bits in each color component value. */ int getBits(); /** * Gets an individual value from the color table. *

* Value is unsigned with {@link #getBits} bits. * * @param comp * The color component to query. * @param bin * The index into the color table. * @return The value of the table at the specified position. */ int getNative( int comp, int bin ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/ColorTable.java000066400000000000000000000061131316447754700255200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; /** * * @author Aivar Grislis */ public interface ColorTable { // TODO ARG What about C,M,Y,K? public static final int RED = 0; public static final int GREEN = 1; public static final int BLUE = 2; public static final int ALPHA = 3; public int lookupARGB( double min, double max, double value ); /** * Gets the number of color components in the table (typically 3 for RGB or * 4 for RGBA). */ public int getComponentCount(); /** * Gets the number of elements for each color component in the table. */ public int getLength(); /** * Gets an individual value from the color table. * * @param comp * The color component to query. * @param bin * The index into the color table. * @return The value of the table at the specified position. */ public int get( final int comp, final int bin ); /** * Gets an individual value from a color table with given number of bins. * * @param comp * The color component to query. * @param bins * The total number of bins. * @param bin * The index into the color table. * @return The value of the table at the specified position. */ public int getResampled( final int comp, final int bins, final int bin ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/ColorTable16.java000066400000000000000000000063251316447754700256740ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; /** * 16-bit color lookup table. * * @author Stephan Saalfeld * @author Curtis Rueden */ public class ColorTable16 extends AbstractArrayColorTable< short[] > { /** * Initializes a 16-bit color table with a linear grayscale ramp. */ public ColorTable16() { super( gray() ); } /** * Initializes a 16-bit color table with the given table values. */ public ColorTable16( final short[]... values ) { super( values ); } @Override public int getLength() { return values[ 0 ].length; } @Override public int getBits() { return 16; } @Override public int get( final int comp, final int bin ) { // convert 0xffff to 0xff return getNative( comp, bin ) >> 8; } @Override public int getNative( final int c, final int i ) { // returns short value as unsigned, expressed as int return values[ c ][ i ] & 0xffff; } @Override public int getResampled( final int comp, final int bins, final int bin ) { final int newBin = ( int ) ( ( long ) getLength() * bin / bins ); return get( comp, newBin ); } // -- Helper methods -- /** * Creates a linear grayscale ramp with 3 components and 65536 values. */ private static short[][] gray() { final short[][] gray = new short[ 3 ][ 65536 ]; for ( int j = 0; j < gray.length; j++ ) { for ( int i = 0; i < gray[ j ].length; i++ ) { gray[ j ][ i ] = ( short ) i; } } return gray; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/ColorTable8.java000066400000000000000000000061551316447754700256160ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; /** * 8-bit color lookup table. * * @author Stephan Saalfeld * @author Curtis Rueden */ public class ColorTable8 extends AbstractArrayColorTable< byte[] > { /** Initializes an 8-bit color table with a linear grayscale ramp. */ public ColorTable8() { super( gray() ); } /** Initializes an 8-bit color table with the given table values. */ public ColorTable8( final byte[]... values ) { super( values ); } @Override public int getLength() { return values[ 0 ].length; } @Override public int getBits() { return 8; } @Override public int get( final int comp, final int bin ) { return getNative( comp, bin ); } @Override public int getNative( final int comp, final int bin ) { return values[ comp ][ bin ] & 0xff; } @Override public int getResampled( final int comp, final int bins, final int bin ) { final int newBin = ( int ) ( ( long ) getLength() * bin / bins ); return getNative( comp, newBin ); } // -- Helper methods -- /** Creates a linear grayscale ramp with 3 components and 256 values. */ private static byte[][] gray() { final byte[][] gray = new byte[ 3 ][ 256 ]; for ( int j = 0; j < gray.length; j++ ) { for ( int i = 0; i < gray[ j ].length; i++ ) { gray[ j ][ i ] = ( byte ) i; } } return gray; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/LinearRange.java000066400000000000000000000040421316447754700256600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; /** * * * @author Stephan Saalfeld */ public interface LinearRange { public double getMin(); public double getMax(); public void setMin( double min ); public void setMax( double max ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/awt/000077500000000000000000000000001316447754700234215ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/awt/SignedByteDataBuffer.java000066400000000000000000000061041316447754700302460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.awt; import java.awt.image.DataBuffer; /** * DataBuffer that stores signed bytes. * * @author Melissa Linkert */ public class SignedByteDataBuffer extends DataBuffer { private final byte[][] bankData; /** Construct a new buffer of signed bytes using the given byte array. */ public SignedByteDataBuffer( final byte[] dataArray, final int size ) { super( DataBuffer.TYPE_BYTE, size ); bankData = new byte[ 1 ][]; bankData[ 0 ] = dataArray; } /** Construct a new buffer of signed bytes using the given 2D byte array. */ public SignedByteDataBuffer( final byte[][] dataArray, final int size ) { super( DataBuffer.TYPE_BYTE, size ); bankData = dataArray; } public byte[] getData() { return bankData[ 0 ]; } public byte[] getData( final int bank ) { return bankData[ bank ]; } @Override public int getElem( final int i ) { return getElem( 0, i ); } @Override public int getElem( final int bank, final int i ) { return bankData[ bank ][ i + getOffsets()[ bank ] ]; } @Override public void setElem( final int i, final int val ) { setElem( 0, i, val ); } @Override public void setElem( final int bank, final int i, final int val ) { bankData[ bank ][ i + getOffsets()[ bank ] ] = ( byte ) val; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/awt/SignedShortDataBuffer.java000066400000000000000000000075151316447754700304510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.awt; import java.awt.image.DataBuffer; import java.awt.image.DataBufferShort; /** * DataBuffer that stores signed shorts. SignedShortBuffer serves the same * purpose as java.awt.image.DataBufferShort; the only difference is that * SignedShortBuffer's getType() method returns DataBuffer.TYPE_USHORT. This is * a workaround for the fact that java.awt.image.BufferedImage does not support * DataBuffers with type DataBuffer.TYPE_SHORT. */ public class SignedShortDataBuffer extends DataBuffer { private final DataBufferShort helper; // -- Constructors -- public SignedShortDataBuffer( final int size ) { super( DataBuffer.TYPE_USHORT, size ); helper = new DataBufferShort( size ); } public SignedShortDataBuffer( final int size, final int numbanks ) { super( DataBuffer.TYPE_USHORT, size, numbanks ); helper = new DataBufferShort( size, numbanks ); } public SignedShortDataBuffer( final short[] data, final int size ) { super( DataBuffer.TYPE_USHORT, size ); helper = new DataBufferShort( data, size ); } public SignedShortDataBuffer( final short[] data, final int size, final int offset ) { super( DataBuffer.TYPE_USHORT, size, 1, offset ); helper = new DataBufferShort( data, size, offset ); } public SignedShortDataBuffer( final short[][] data, final int size ) { super( DataBuffer.TYPE_USHORT, size, data.length ); helper = new DataBufferShort( data, size ); } public SignedShortDataBuffer( final short[][] data, final int size, final int[] offsets ) { super( DataBuffer.TYPE_USHORT, size, data.length, offsets ); helper = new DataBufferShort( data, size, offsets ); } // -- DataBuffer API methods -- public short[] getData() { return helper.getData(); } public short[] getData( final int bank ) { return helper.getData( bank ); } @Override public int getElem( final int bank, final int i ) { return helper.getElem( bank, i ); } @Override public void setElem( final int bank, final int i, final int val ) { helper.setElem( bank, i, val ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/awt/UnsignedIntDataBuffer.java000066400000000000000000000100501316447754700304330ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.awt; import java.awt.image.DataBuffer; /** * DataBuffer that stores unsigned ints. * * @author Melissa Linkert */ public class UnsignedIntDataBuffer extends DataBuffer { private final int[][] bankData; /** Construct a new buffer of unsigned ints using the given int array. */ public UnsignedIntDataBuffer( final int[] dataArray, final int size ) { super( DataBuffer.TYPE_INT, size ); bankData = new int[ 1 ][]; bankData[ 0 ] = dataArray; } /** Construct a new buffer of unsigned ints using the given 2D int array. */ public UnsignedIntDataBuffer( final int[][] dataArray, final int size ) { super( DataBuffer.TYPE_INT, size ); bankData = dataArray; } public int[] getData() { return bankData[ 0 ]; } public int[] getData( final int bank ) { return bankData[ bank ]; } @Override public int getElem( final int i ) { return getElem( 0, i ); } @Override public int getElem( final int bank, final int i ) { final int value = bankData[ bank ][ i + getOffsets()[ bank ] ]; return ( int ) ( value & 0xffffffffL ); } @Override public float getElemFloat( final int i ) { return getElemFloat( 0, i ); } @Override public float getElemFloat( final int bank, final int i ) { return ( getElem( bank, i ) & 0xffffffffL ); } @Override public double getElemDouble( final int i ) { return getElemDouble( 0, i ); } @Override public double getElemDouble( final int bank, final int i ) { return ( getElem( bank, i ) & 0xffffffffL ); } @Override public void setElem( final int i, final int val ) { setElem( 0, i, val ); } @Override public void setElem( final int bank, final int i, final int val ) { bankData[ bank ][ i + getOffsets()[ bank ] ] = val; } @Override public void setElemFloat( final int i, final float val ) { setElemFloat( 0, i, val ); } @Override public void setElemFloat( final int bank, final int i, final float val ) { bankData[ bank ][ i + getOffsets()[ bank ] ] = ( int ) val; } @Override public void setElemDouble( final int i, final double val ) { setElemDouble( 0, i, val ); } @Override public void setElemDouble( final int bank, final int i, final double val ) { bankData[ bank ][ i + getOffsets()[ bank ] ] = ( int ) val; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/000077500000000000000000000000001316447754700246355ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/AbstractProjector2D.java000066400000000000000000000063351316447754700313300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector; import net.imglib2.Point; import net.imglib2.display.projector.sampler.SamplingProjector2D; import net.imglib2.display.projector.specialized.ArrayImgXYByteProjector; /** * Base class for 2D projectors. Projecting means in this case projecting from a * source format to a target format. 2D hints that the result is something 2 * dimensional. The base class provides methods to select a reference point in a * multi-dimensional data object. Sub classes like * {@link IterableIntervalProjector2D}, {@link SamplingProjector2D} or * {@link ArrayImgXYByteProjector} specify a mapping that uses the reference * point to project data into a 2 dimensional representation.
* A basic example is the extraction of a data plain (containing the reference * point) by sampling two axes * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz */ public abstract class AbstractProjector2D extends Point implements Projector { protected final long[] min; protected final long[] max; /** * initializes a reference point with the specified number of dimensions. * Start position is 0,0,...,0 * * @param numDims */ public AbstractProjector2D( final int numDims ) { // as this is an 2D projector, we need at least two dimensions, // even if the source is one-dimensional super( Math.max( 2, numDims ) ); min = new long[ n ]; max = new long[ n ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/IterableIntervalProjector2D.java000066400000000000000000000143031316447754700330130ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.FlatIterationOrder; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.converter.Converter; import net.imglib2.view.RandomAccessibleIntervalCursor; import net.imglib2.view.Views; /** * A general 2D Projector that uses two dimensions as input to create the 2D * result. The output of the projection is written into a {@link IterableInterval}. * * Depending on input and output an optimal strategy is chosen in the map() method. * * Starting from the reference point two dimensions are sampled such * that a plain gets cut out of a higher dimensional data volume.
* The mapping function can be specified with a {@link Converter}.
* A basic example is cutting out a time frame from a (greyscale) video. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param
* @param */ public class IterableIntervalProjector2D< A, B > extends AbstractProjector2D { final protected Converter< ? super A, B > converter; final protected RandomAccessible< A > source; final protected IterableInterval< B > target; final int numDimensions; private final int dimX; private final int dimY; /** * creates a new 2D projector that samples a plain in the dimensions dimX, * dimY. * * @param dimX * @param dimY * @param source * @param target * @param converter * a converter that is applied to each point in the plain. This * can e.g. be used for normalization, conversions, ... */ public IterableIntervalProjector2D( final int dimX, final int dimY, final RandomAccessible< A > source, final IterableInterval< B > target, final Converter< ? super A, B > converter ) { super( source.numDimensions() ); this.dimX = dimX; this.dimY = dimY; this.target = target; this.source = source; this.converter = converter; this.numDimensions = source.numDimensions(); } /** * projects data from the source to the target and applies the former * specified {@link Converter} e.g. for normalization. */ @Override public void map() { // fix interval for all dimensions for ( int d = 0; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; min[ dimX ] = target.min( 0 ); min[ dimY ] = target.min( 1 ); max[ dimX ] = target.max( 0 ); max[ dimY ] = target.max( 1 ); // TODO: this is ugly, but the only way to make sure, that iteration // order fits in the case of one sized dims. Tobi? final IterableInterval< A > ii = Views.iterable( Views.interval( source, new FinalInterval( min, max ) ) ); final Cursor< A > sourceCursor = ii.cursor(); if ( target.iterationOrder().equals( ii.iterationOrder() ) && !( sourceCursor instanceof RandomAccessibleIntervalCursor ) ) { final Cursor< B > targetCursor = target.cursor(); while ( targetCursor.hasNext() ) { converter.convert( sourceCursor.next(), targetCursor.next() ); } } else if ( target.iterationOrder() instanceof FlatIterationOrder ) { final Cursor< B > targetCursor = target.cursor(); targetCursor.fwd(); final FinalInterval sourceInterval = new FinalInterval( min, max ); // use localizing cursor final RandomAccess< A > sourceRandomAccess = source.randomAccess( sourceInterval ); sourceRandomAccess.setPosition( position ); final long cr = -target.dimension( 0 ); final long width = target.dimension( 0 ); final long height = target.dimension( 1 ); sourceRandomAccess.setPosition( min ); for ( long y = 0; y < height; ++y ) { for ( long x = 0; x < width; ++x ) { converter.convert( sourceRandomAccess.get(), targetCursor.get() ); sourceRandomAccess.fwd( dimX ); targetCursor.fwd(); } sourceRandomAccess.move( cr, dimX ); sourceRandomAccess.fwd( dimY ); } } else { final Cursor< B > targetCursor = target.localizingCursor(); // use localizing cursor final RandomAccess< A > sourceRandomAccess = source.randomAccess(); sourceRandomAccess.setPosition( position ); while ( targetCursor.hasNext() ) { final B b = targetCursor.next(); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), dimX ); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), dimY ); converter.convert( sourceRandomAccess.get(), b ); } } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/Projector.java000066400000000000000000000037031316447754700274520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector; /** * * * @author Stephan Saalfeld */ public interface Projector { public void map(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/RandomAccessibleProjector2D.java000066400000000000000000000125161316447754700327610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector; import net.imglib2.FinalInterval; import net.imglib2.FlatIterationOrder; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.Converter; /** * A general 2D Projector that uses two dimensions as input to create the 2D * result. The output of the projection is written into a * {@link RandomAccessibleInterval}. * * Starting from the reference point two dimensions are sampled such that a * plain gets cut out of a higher dimensional data volume.
* The mapping function can be specified with a {@link Converter}.
* A basic example is cutting out a time frame from a (greyscale) video * * Note: This {@link Projector} should only be used if one can be sure, that the * target {@link RandomAccessibleInterval} is not an {@link IterableInterval} of * {@link FlatIterationOrder}. If, please use * {@link IterableIntervalProjector2D} for performance reasons. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param
* @param */ public class RandomAccessibleProjector2D< A, B > extends AbstractProjector2D { final protected Converter< ? super A, B > converter; final protected RandomAccessibleInterval< B > target; final protected RandomAccessible< A > source; final int numDimensions; private final int dimX; private final int dimY; protected final int X = 0; protected final int Y = 1; /** * creates a new 2D projector that samples a plain in the dimensions dimX, * dimY. * * @param dimX * @param dimY * @param source * @param target * @param converter * a converter that is applied to each point in the plain. This * can e.g. be used for normalization, conversions, ... */ public RandomAccessibleProjector2D( final int dimX, final int dimY, final RandomAccessible< A > source, final RandomAccessibleInterval< B > target, final Converter< ? super A, B > converter ) { super( source.numDimensions() ); this.dimX = dimX; this.dimY = dimY; this.target = target; this.source = source; this.converter = converter; this.numDimensions = source.numDimensions(); } /** * projects data from the source to the target and applies the former * specified {@link Converter} e.g. for normalization. */ @Override public void map() { for ( int d = 2; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; min[ dimX ] = target.min( dimX ); min[ dimY ] = target.min( dimY ); max[ dimX ] = target.max( dimX ); max[ dimY ] = target.max( dimY ); final FinalInterval sourceInterval = new FinalInterval( min, max ); final long cr = -target.dimension( dimX ); final RandomAccess< B > targetRandomAccess = target.randomAccess( target ); final RandomAccess< A > sourceRandomAccess = source.randomAccess( sourceInterval ); final long width = target.dimension( dimX ); final long height = target.dimension( dimY ); sourceRandomAccess.setPosition( min ); targetRandomAccess.setPosition( min[ dimX ], dimX ); targetRandomAccess.setPosition( min[ dimY ], dimY ); for ( long y = 0; y < height; ++y ) { for ( long x = 0; x < width; ++x ) { converter.convert( sourceRandomAccess.get(), targetRandomAccess.get() ); sourceRandomAccess.fwd( dimX ); targetRandomAccess.fwd( dimX ); } sourceRandomAccess.move( cr, dimX ); targetRandomAccess.move( cr, dimX ); sourceRandomAccess.fwd( dimY ); targetRandomAccess.fwd( dimY ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/composite/000077500000000000000000000000001316447754700266375ustar00rootroot00000000000000CompositeXYProjector.java000066400000000000000000000224531316447754700335440ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/composite/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.composite; import java.util.ArrayList; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.Converter; import net.imglib2.display.projector.AbstractProjector2D; import net.imglib2.type.numeric.ARGBType; /** * Creates a composite image from across multiple dimensional positions along an * axis (typically, but not necessarily, channels). Each dimensional position * has its own {@link Converter}. The results of the conversions are summed into * the final value. Positions along the axis can be individually toggled for * inclusion in the computed composite value using the {@link #setComposite} * methods. * * See XYProjector for the code upon which this class was based. * * @author Stephan Saalfeld * @author Curtis Rueden * @author Grant Harris * @author Tobias Pietzsch */ public class CompositeXYProjector< A > extends AbstractProjector2D { private final ArrayList< Converter< A, ARGBType >> converters; private final int dimIndex; private final long positionCount; private final long positionMin; private final boolean[] composite; protected final long[] currentPositions; protected final Converter< A, ARGBType >[] currentConverters; private final IterableInterval< ARGBType > target; private final RandomAccessibleInterval< A > source; @SuppressWarnings( "unchecked" ) public CompositeXYProjector( final RandomAccessibleInterval< A > source, final IterableInterval< ARGBType > target, final ArrayList< Converter< A, ARGBType >> converters, final int dimIndex ) { super( source.numDimensions() ); this.source = source; this.target = target; this.converters = converters; this.dimIndex = dimIndex; // check that there is one converter per dimensional position positionCount = dimIndex < 0 ? 1 : source.dimension( dimIndex ); positionMin = dimIndex < 0 ? 0 : source.min( dimIndex ); final int converterCount = converters.size(); if ( positionCount != converterCount ) { throw new IllegalArgumentException( "Expected " + positionCount + " converters but got " + converterCount ); } composite = new boolean[ converterCount ]; composite[ 0 ] = true; currentPositions = new long[ converterCount ]; currentConverters = new Converter[ converterCount ]; } // -- CompositeXYProjector methods -- /** Toggles the given position index's inclusion in composite values. */ public void setComposite( final int index, final boolean on ) { composite[ index ] = on; } /** Gets whether the given position index is included in composite values. */ public boolean isComposite( final int index ) { return composite[ index ]; } /** * Toggles composite mode globally. If true, all positions along the * dimensional axis are included in the composite; if false, the value will * consist of only the projector's current position (i.e., non-composite * mode). */ public void setComposite( final boolean on ) { for ( int i = 0; i < composite.length; i++ ) composite[ i ] = on; } /** Gets whether composite mode is enabled for all positions. */ public boolean isComposite() { for ( int i = 0; i < composite.length; i++ ) if ( !composite[ i ] ) return false; return true; } // -- Projector methods -- // private static long calls = 0; @Override public void map() { // System.out.println(" CompositeXYProjector::map() : call #"+(++calls)); for ( int d = 2; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; min[ 0 ] = target.min( 0 ); min[ 1 ] = target.min( 1 ); max[ 0 ] = target.max( 0 ); max[ 1 ] = target.max( 1 ); if ( dimIndex < 0 ) { // there is only converter[0] // use it to map the current position final RandomAccess< A > sourceRandomAccess = source.randomAccess( new FinalInterval( min, max ) ); sourceRandomAccess.setPosition( min ); mapSingle( sourceRandomAccess, converters.get( 0 ) ); return; } final int size = updateCurrentArrays(); min[ dimIndex ] = max[ dimIndex ] = currentPositions[ 0 ]; for ( int i = 1; i < size; ++i ) if ( currentPositions[ i ] < min[ dimIndex ] ) min[ dimIndex ] = currentPositions[ i ]; else if ( currentPositions[ i ] > max[ dimIndex ] ) max[ dimIndex ] = currentPositions[ i ]; final RandomAccess< A > sourceRandomAccess = source.randomAccess( new FinalInterval( min, max ) ); sourceRandomAccess.setPosition( min ); if ( size == 1 ) { // there is only one active converter: converter[0] // use it to map the slice at currentPositions[0] mapSingle( sourceRandomAccess, currentConverters[ 0 ] ); return; } final Cursor< ARGBType > targetCursor = target.localizingCursor(); final ARGBType bi = new ARGBType(); while ( targetCursor.hasNext() ) { targetCursor.fwd(); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), 0 ); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), 1 ); int aSum = 0, rSum = 0, gSum = 0, bSum = 0; for ( int i = 0; i < size; i++ ) { sourceRandomAccess.setPosition( currentPositions[ i ], dimIndex ); currentConverters[ i ].convert( sourceRandomAccess.get(), bi ); // accumulate converted result final int value = bi.get(); final int a = ARGBType.alpha( value ); final int r = ARGBType.red( value ); final int g = ARGBType.green( value ); final int b = ARGBType.blue( value ); aSum += a; rSum += r; gSum += g; bSum += b; } if ( aSum > 255 ) aSum = 255; if ( rSum > 255 ) rSum = 255; if ( gSum > 255 ) gSum = 255; if ( bSum > 255 ) bSum = 255; targetCursor.get().set( ARGBType.rgba( rSum, gSum, bSum, aSum ) ); } } // -- Helper methods -- /** * Walk through composite[] and store the currently active converters and * positions (in dimension {@link #dimIndex}) to {@link #currentConverters} * and {@link #currentPositions}. * * A special cases is single-position mode. The projector is in * single-position mode iff all dimensional positions along the composited * axis are excluded. In this case, the current position along that axis is * used instead. The converter corresponding to the current position is * used. * * @return number of positions to convert */ protected int updateCurrentArrays() { int currentSize = 0; for ( int i = 0; i < composite.length; i++ ) if ( composite[ i ] ) ++currentSize; if ( currentSize == 0 ) { // this is the isSingle() case. // map the current position using the converter at that position currentPositions[ 0 ] = position[ dimIndex ]; currentConverters[ 0 ] = converters.get( ( int ) ( position[ dimIndex ] - positionMin ) ); return 1; } // this is the normal case. // fill currentPositions and currentConverters with the active // positions and converters int j = 0; for ( int i = 0; i < composite.length; i++ ) if ( composite[ i ] ) { currentPositions[ j ] = positionMin + i; currentConverters[ j ] = converters.get( i ); ++j; } return currentSize; } protected void mapSingle( final RandomAccess< A > sourceRandomAccess, final Converter< A, ARGBType > conv ) { final Cursor< ARGBType > targetCursor = target.localizingCursor(); while ( targetCursor.hasNext() ) { targetCursor.fwd(); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), 0 ); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), 1 ); conv.convert( sourceRandomAccess.get(), targetCursor.get() ); } } } CompositeXYRandomAccessibleProjector.java000066400000000000000000000236101316447754700366570ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/composite/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.composite; import java.util.ArrayList; import net.imglib2.FinalInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.Converter; import net.imglib2.display.projector.AbstractProjector2D; import net.imglib2.type.numeric.ARGBType; /** * Creates a composite image from across multiple dimensional positions along an * axis (typically, but not necessarily, channels). Each dimensional position * has its own {@link Converter}. The results of the conversions are summed into * the final value. Positions along the axis can be individually toggled for * inclusion in the computed composite value using the {@link #setComposite} * methods. * * See CompositeXYProjector for the code upon which this class was based. * See XYRandomAccessibleProjector for the code upon which this class was * based. * * @author Stephan Saalfeld * @author Curtis Rueden * @author Grant Harris * @author Tobias Pietzsch */ public class CompositeXYRandomAccessibleProjector< A > extends AbstractProjector2D { final protected RandomAccessibleInterval< ARGBType > target; private final ArrayList< Converter< A, ARGBType > > converters; private final int dimIndex; private final long positionCount; private final long positionMin; private final boolean[] composite; protected final long[] currentPositions; protected final Converter< A, ARGBType >[] currentConverters; protected final RandomAccessibleInterval< A > source; @SuppressWarnings( "unchecked" ) public CompositeXYRandomAccessibleProjector( final RandomAccessibleInterval< A > source, final RandomAccessibleInterval< ARGBType > target, final ArrayList< Converter< A, ARGBType >> converters, final int dimIndex ) { super( source.numDimensions() ); this.source = source; this.target = target; this.converters = converters; this.dimIndex = dimIndex; // check that there is one converter per dimensional position positionCount = dimIndex < 0 ? 1 : source.dimension( dimIndex ); positionMin = dimIndex < 0 ? 0 : source.min( dimIndex ); final int converterCount = converters.size(); if ( positionCount != converterCount ) { throw new IllegalArgumentException( "Expected " + positionCount + " converters but got " + converterCount ); } min[ dimIndex ] = source.min( dimIndex ); max[ dimIndex ] = source.max( dimIndex ); composite = new boolean[ converterCount ]; composite[ 0 ] = true; currentPositions = new long[ converterCount ]; currentConverters = new Converter[ converterCount ]; } // -- CompositeXYProjector methods -- /** Toggles the given position index's inclusion in composite values. */ public void setComposite( final int index, final boolean on ) { composite[ index ] = on; } /** Gets whether the given position index is included in composite values. */ public boolean isComposite( final int index ) { return composite[ index ]; } /** * Toggles composite mode globally. If true, all positions along the * dimensional axis are included in the composite; if false, the value will * consist of only the projector's current position (i.e., non-composite * mode). */ public void setComposite( final boolean on ) { for ( int i = 0; i < composite.length; i++ ) composite[ i ] = on; } /** Gets whether composite mode is enabled for all positions. */ public boolean isComposite() { for ( int i = 0; i < composite.length; i++ ) if ( !composite[ i ] ) return false; return true; } // -- Projector methods -- @Override public void map() { for ( int d = 2; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; min[ 0 ] = target.min( 0 ); min[ 1 ] = target.min( 1 ); max[ 0 ] = target.max( 0 ); max[ 1 ] = target.max( 1 ); if ( dimIndex < 0 ) { // there is only converter[0] // use it to map the current position final RandomAccess< A > sourceRandomAccess = source.randomAccess( new FinalInterval( min, max ) ); sourceRandomAccess.setPosition( min ); mapSingle( sourceRandomAccess, converters.get( 0 ) ); return; } final int size = updateCurrentArrays(); min[ dimIndex ] = max[ dimIndex ] = currentPositions[ 0 ]; for ( int i = 1; i < size; ++i ) if ( currentPositions[ i ] < min[ dimIndex ] ) min[ dimIndex ] = currentPositions[ i ]; else if ( currentPositions[ i ] > max[ dimIndex ] ) max[ dimIndex ] = currentPositions[ i ]; final RandomAccess< A > sourceRandomAccess = source.randomAccess( new FinalInterval( min, max ) ); sourceRandomAccess.setPosition( min ); if ( size == 1 ) { // there is only one active converter: converter[0] // use it to map the slice at currentPositions[0] sourceRandomAccess.setPosition( currentPositions[ 0 ], dimIndex ); mapSingle( sourceRandomAccess, currentConverters[ 0 ] ); return; } final ARGBType bi = new ARGBType(); final RandomAccess< ARGBType > targetRandomAccess = target.randomAccess(); targetRandomAccess.setPosition( min[ 1 ], 1 ); while ( targetRandomAccess.getLongPosition( 1 ) <= max[ 1 ] ) { sourceRandomAccess.setPosition( min[ 0 ], 0 ); targetRandomAccess.setPosition( min[ 0 ], 0 ); while ( targetRandomAccess.getLongPosition( 0 ) <= max[ 0 ] ) { int aSum = 0, rSum = 0, gSum = 0, bSum = 0; for ( int i = 0; i < size; i++ ) { sourceRandomAccess.setPosition( currentPositions[ i ], dimIndex ); currentConverters[ i ].convert( sourceRandomAccess.get(), bi ); // accumulate converted result final int value = bi.get(); final int a = ARGBType.alpha( value ); final int r = ARGBType.red( value ); final int g = ARGBType.green( value ); final int b = ARGBType.blue( value ); aSum += a; rSum += r; gSum += g; bSum += b; } if ( aSum > 255 ) aSum = 255; if ( rSum > 255 ) rSum = 255; if ( gSum > 255 ) gSum = 255; if ( bSum > 255 ) bSum = 255; targetRandomAccess.get().set( ARGBType.rgba( rSum, gSum, bSum, aSum ) ); sourceRandomAccess.fwd( 0 ); targetRandomAccess.fwd( 0 ); } sourceRandomAccess.fwd( 1 ); targetRandomAccess.fwd( 1 ); } } // -- Helper methods -- /** * Walk through composite[] and store the currently active converters and * positions (in dimension {@link #dimIndex}) to {@link #currentConverters} * and {@link #currentPositions}. * * A special cases is single-position mode. The projector is in * single-position mode iff all dimensional positions along the composited * axis are excluded. In this case, the current position along that axis is * used instead. The converter corresponding to the current position is * used. * * @return number of positions to convert */ protected int updateCurrentArrays() { int currentSize = 0; for ( int i = 0; i < composite.length; i++ ) if ( composite[ i ] ) ++currentSize; if ( currentSize == 0 ) { // this is the isSingle() case. // map the current position using the converter at that position currentPositions[ 0 ] = position[ dimIndex ]; currentConverters[ 0 ] = converters.get( ( int ) ( position[ dimIndex ] - positionMin ) ); return 1; } // this is the normal case. // fill currentPositions and currentConverters with the active // positions and converters int j = 0; for ( int i = 0; i < composite.length; i++ ) if ( composite[ i ] ) { currentPositions[ j ] = positionMin + i; currentConverters[ j ] = converters.get( i ); ++j; } return currentSize; } protected void mapSingle( final RandomAccess< A > sourceRandomAccess, final Converter< A, ARGBType > conv ) { final RandomAccess< ARGBType > targetRandomAccess = target.randomAccess(); targetRandomAccess.setPosition( min[ 1 ], 1 ); while ( targetRandomAccess.getLongPosition( 1 ) <= max[ 1 ] ) { sourceRandomAccess.setPosition( min[ 0 ], 0 ); targetRandomAccess.setPosition( min[ 0 ], 0 ); while ( targetRandomAccess.getLongPosition( 0 ) <= max[ 0 ] ) { conv.convert( sourceRandomAccess.get(), targetRandomAccess.get() ); sourceRandomAccess.fwd( 0 ); targetRandomAccess.fwd( 0 ); } sourceRandomAccess.fwd( 1 ); targetRandomAccess.fwd( 1 ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/sampler/000077500000000000000000000000001316447754700263005ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/sampler/IntervalSampler.java000066400000000000000000000062611316447754700322600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.sampler; import net.imglib2.RandomAccess; import net.imglib2.Sampler; /** * allows stepwise access to a preselected projected dimension. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param */ public class IntervalSampler< T > implements ProjectedSampler< T > { private final int m_projectionDimension; private final long m_startPosition; private final long m_endPosition; private RandomAccess< T > m_source; public IntervalSampler( final int projectionDimension, final long startPosition, final long endPosition ) { m_projectionDimension = projectionDimension; m_startPosition = startPosition; m_endPosition = endPosition; } @Override public void jumpFwd( final long steps ) { for ( int i = 0; i < steps; i++ ) { fwd(); } } @Override public void fwd() { m_source.fwd( m_projectionDimension ); } @Override public void reset() { m_source.setPosition( m_startPosition, m_projectionDimension ); } @Override public boolean hasNext() { return ( m_source.getLongPosition( m_projectionDimension ) <= m_endPosition ); } @Override public T get() { return m_source.get(); } @Override public Sampler< T > copy() { return m_source.copy(); } @Override public void setRandomAccess( final RandomAccess< T > srcAccess ) { m_source = srcAccess; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/sampler/ProjectedSampler.java000066400000000000000000000051721316447754700324130ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.sampler; import net.imglib2.Iterator; import net.imglib2.RandomAccess; import net.imglib2.Sampler; /** * provides samples from a projected ({@link SamplingProjector2D}) dimension. * E.g. the color values from the color dimension when projecting the values * onto the xy plane. * * Implements {@link Iterator} and {@link Sampler} to allow access to the * (selected) values of the projected dimension * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param */ public interface ProjectedSampler< T > extends Iterator, Sampler< T > { /** * @param srcAccess * sets the random access from which the sampler takes the values * of the projected dimension */ void setRandomAccess( RandomAccess< T > srcAccess ); }; imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/sampler/SamplingProjector2D.java000066400000000000000000000162471316447754700330050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.sampler; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.Converter; import net.imglib2.display.projector.AbstractProjector2D; /** * A general 2D Projector that uses three dimensions as input to create the 2D * result. Starting from the reference point (see {@link AbstractProjector2D}) * two dimensions are sampled such that a plain gets cut out of a higher * dimensional data volume. The third dimension is projected (in a mathematical * sense) onto this plain.
* The mapping function is specified by a {@link Converter}. It is not necessary * to process the complete interval of the third dimension, instead * {@link ProjectedSampler} can be used to control the sampling.
* A basic example is cutting out the x,y plain and projecting the color * dimension onto the plain. Alternatively mapping up to three measures (from a * measurement dimension) to the three color channels would also be possible... * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param
* source type * @param * target type */ public class SamplingProjector2D< A, B > extends AbstractProjector2D { private final static int X = 0; private final static int Y = 1; protected final Converter< ProjectedSampler< A >, B > converter; protected final IterableInterval< B > target; protected final RandomAccessible< A > source; protected final int dimX; protected final int dimY; private final int projectedDimension; private final ProjectedSampler< A > projectionSampler; // min and max of the USED part of the projected dimension private long projectedDimMinPos; private long projectedDimMaxPos; /** * * @param dimX * the x dimension of the created plain * @param dimY * the y dimension of the created plain * @param source * @param target * @param converter * a special converter that uses {@link ProjectedSampler} to * process values from the third dimension (multiple values * selected by the ProjectedDimSampler get converted to a new * value in the resulting 2D dataset e.g. color channel to int * color) * @param projectedDimension * selection of the third dimension * @param projectedPositions */ public SamplingProjector2D( final int dimX, final int dimY, final RandomAccessible< A > source, final IterableInterval< B > target, final Converter< ProjectedSampler< A >, B > converter, final int projectedDimension, final long[] projectedPositions ) { super( source.numDimensions() ); this.dimX = dimX; this.dimY = dimY; this.target = target; this.source = source; this.converter = converter; this.projectedDimension = projectedDimension; // get min and max of the USED part of the projection dim projectedDimMinPos = Long.MAX_VALUE; projectedDimMaxPos = Long.MIN_VALUE; for ( final long pos : projectedPositions ) { if ( pos < projectedDimMinPos ) { projectedDimMinPos = pos; } if ( pos > projectedDimMaxPos ) { projectedDimMaxPos = pos; } } projectionSampler = new SelectiveSampler< A >( projectedDimension, projectedPositions ); } public SamplingProjector2D( final int dimX, final int dimY, final RandomAccessibleInterval< A > source, final IterableInterval< B > target, final Converter< ProjectedSampler< A >, B > converter, final int projectedDimension ) { super( source.numDimensions() ); this.dimX = dimX; this.dimY = dimY; this.target = target; this.source = source; this.converter = converter; this.projectedDimension = projectedDimension; // set min and max of the projection dim projectedDimMinPos = source.min( projectedDimension ); projectedDimMaxPos = source.max( projectedDimension ); projectionSampler = new IntervalSampler< A >( projectedDimension, projectedDimMinPos, projectedDimMaxPos ); } @Override public void map() { // fix interval for all dimensions for ( int d = 0; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; min[ dimX ] = target.min( X ); min[ dimY ] = target.min( Y ); max[ dimX ] = target.max( X ); max[ dimY ] = target.max( Y ); min[ projectedDimension ] = projectedDimMinPos; max[ projectedDimension ] = projectedDimMaxPos; // get tailored random access final FinalInterval sourceInterval = new FinalInterval( min, max ); final Cursor< B > targetCursor = target.localizingCursor(); final RandomAccess< A > sourceRandomAccess = source.randomAccess( sourceInterval ); sourceRandomAccess.setPosition( position ); projectionSampler.setRandomAccess( sourceRandomAccess ); if ( n > 1 ) while ( targetCursor.hasNext() ) { projectionSampler.reset(); final B b = targetCursor.next(); sourceRandomAccess.setPosition( targetCursor.getLongPosition( X ), dimX ); sourceRandomAccess.setPosition( targetCursor.getLongPosition( Y ), dimY ); converter.convert( projectionSampler, b ); } else while ( targetCursor.hasNext() ) { projectionSampler.reset(); final B b = targetCursor.next(); sourceRandomAccess.setPosition( targetCursor.getLongPosition( X ), dimX ); converter.convert( projectionSampler, b ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/sampler/SelectiveSampler.java000066400000000000000000000062641316447754700324220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.sampler; import net.imglib2.RandomAccess; import net.imglib2.Sampler; /** * Provides access to a set of predefined positions of a projected dimension * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param */ public class SelectiveSampler< T > implements ProjectedSampler< T > { private final long[] m_projectedPositions; private final int m_projectionDimension; private RandomAccess< T > m_source; private int m_selectedIndex = 0; public SelectiveSampler( final int projectionDimension, final long[] projectedPositions ) { m_projectedPositions = projectedPositions; m_projectionDimension = projectionDimension; } @Override public void jumpFwd( final long steps ) { m_selectedIndex += steps; } @Override public void fwd() { m_selectedIndex++; } @Override public void reset() { m_selectedIndex = 0; } @Override public boolean hasNext() { return ( m_selectedIndex < m_projectedPositions.length ); } @Override public T get() { m_source.setPosition( m_selectedIndex, m_projectionDimension ); return m_source.get(); } @Override public Sampler< T > copy() { m_source.setPosition( m_selectedIndex, m_projectionDimension ); return m_source.copy(); } @Override public void setRandomAccess( final RandomAccess< T > srcAccess ) { m_source = srcAccess; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/specialized/000077500000000000000000000000001316447754700271315ustar00rootroot00000000000000ArrayImgXYByteProjector.java000066400000000000000000000131361316447754700344310ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/specialized/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.specialized; import net.imglib2.display.projector.AbstractProjector2D; import net.imglib2.display.screenimage.awt.UnsignedByteAWTScreenImage; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.type.numeric.integer.GenericByteType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.util.IntervalIndexer; /** * Fast implementation of a {@link AbstractProjector2D} that selects a 2D data * plain from an ByteType ArrayImg. The map method implements a normalization * function. The resulting image is a ByteType ArrayImg. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param * source */ public class ArrayImgXYByteProjector< A extends GenericByteType< A >> extends AbstractProjector2D { private final byte[] sourceArray; private final byte[] targetArray; private final double min; private final double normalizationFactor; private final boolean isSigned; private final long[] dims; /** * Normalizes an ArrayImg and writes the result into target. This can be * used in conjunction with {@link UnsignedByteAWTScreenImage} for direct * displaying. The normalization is based on a normalization factor and a * minimum value with the following dependency:
*
* normalizationFactor = (typeMax - typeMin) / (newMax - newMin)
* min = newMin
*
* A value is normalized by: normalizedValue = (value - min) * * normalizationFactor.
* Additionally the result gets clamped to the type range of target (that * allows playing with saturation...). * * @param source * Signed/Unsigned input data * @param target * Unsigned output * @param normalizationFactor * @param min */ public ArrayImgXYByteProjector( final ArrayImg< A, ByteArray > source, final ArrayImg< UnsignedByteType, ByteArray > target, final double normalizationFactor, final double min ) { super( source.numDimensions() ); this.isSigned = source.firstElement().getMinValue() < 0; this.targetArray = target.update( null ).getCurrentStorageArray(); this.normalizationFactor = normalizationFactor; this.min = min; this.dims = new long[ n ]; source.dimensions( dims ); sourceArray = source.update( null ).getCurrentStorageArray(); } @Override public void map() { double minCopy = min; int offset = 0; final long[] tmpPos = position.clone(); tmpPos[ 0 ] = 0; tmpPos[ 1 ] = 0; offset = ( int ) IntervalIndexer.positionToIndex( tmpPos, dims ); // copy the selected part of the source array (e.g. a xy plane at time t // in a video) into the target array. System.arraycopy( sourceArray, offset, targetArray, 0, targetArray.length ); if ( isSigned ) { for ( int i = 0; i < targetArray.length; i++ ) { // -128 => 0 && 127 => 255 => unsigned byte // // -128_byte = 11111111_byte => convert => -128_int // (-128_int - 128_int) => calculate => -256_int (11..100000000) // => convert (11..1|00000000) => 0_unsignedByte // // 127_byte => convert => 127_int // (127_int - 128_int) => calculate => -1_int (11..111111111) => // convert (11..1|11111111) => 255_unsignedByte targetArray[ i ] = ( byte ) ( targetArray[ i ] - 0x80 ); } // old min + 128 => unsigned byte minimum minCopy += 0x80; } // // target[] contains now unsigned values // if ( normalizationFactor != 1 ) { for ( int i = 0; i < targetArray.length; i++ ) { // | ensure 0 <= x <= 255 | // | | calculate newValue: x // | | unsigned_byte => int // | | value - min * normalizationFactor targetArray[ i ] = ( byte ) Math.min( 255, Math.max( 0, ( Math.round( ( ( targetArray[ i ] & 0xFF ) - minCopy ) * normalizationFactor ) ) ) ); } } } } ArrayImgXYShortProjector.java000066400000000000000000000124321316447754700346230ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/specialized/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.specialized; import net.imglib2.display.projector.AbstractProjector2D; import net.imglib2.display.screenimage.awt.UnsignedByteAWTScreenImage; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.numeric.integer.GenericShortType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.util.IntervalIndexer; /** * Fast implementation of a {@link AbstractProjector2D} that selects a 2D data * plain from an ShortType ArrayImg. The map method implements a normalization * function. The resulting image is a ShortType ArrayImg. * * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param
*/ public class ArrayImgXYShortProjector< A extends GenericShortType< A >> extends AbstractProjector2D { private final short[] sourceArray; private final short[] targetArray; private final double min; private final double normalizationFactor; private final boolean isSigned; private final long[] dims; /** * Normalizes an ArrayImg and writes the result into target. This can be * used in conjunction with {@link UnsignedByteAWTScreenImage} for direct * displaying. The normalization is based on a normalization factor and a * minimum value with the following dependency:
*
* normalizationFactor = (typeMax - typeMin) / (newMax - newMin)
* min = newMin
*
* A value is normalized by: normalizedValue = (value - min) * * normalizationFactor.
* Additionally the result gets clamped to the type range of target (that * allows playing with saturation...). * * @param source * Signed/Unsigned input data * @param target * Unsigned output * @param normalizationFactor * @param min */ public ArrayImgXYShortProjector( final ArrayImg< A, ShortArray > source, final ArrayImg< UnsignedShortType, ShortArray > target, final double normalizationFactor, final double min ) { super( source.numDimensions() ); this.isSigned = source.firstElement().getMinValue() < 0; this.targetArray = target.update( null ).getCurrentStorageArray(); this.normalizationFactor = normalizationFactor; this.min = min; this.dims = new long[ n ]; source.dimensions( dims ); sourceArray = source.update( null ).getCurrentStorageArray(); } @Override public void map() { // more detailed documentation of the binary arithmetic can be found in // ArrayImgXYByteProjector double minCopy = min; int offset = 0; final long[] tmpPos = position.clone(); tmpPos[ 0 ] = 0; tmpPos[ 1 ] = 0; offset = ( int ) IntervalIndexer.positionToIndex( tmpPos, dims ); // copy the selected part of the source array (e.g. a xy plane at time t // in a video) into the target array. System.arraycopy( sourceArray, offset, targetArray, 0, targetArray.length ); if ( isSigned ) { for ( int i = 0; i < targetArray.length; i++ ) { // Short.MIN => 0 && Short.MAX => 65535 (2^16 - 1) => unsigned // short targetArray[ i ] = ( short ) ( targetArray[ i ] - 0x8000 ); } // old => unsigned short minimum minCopy += 0x8000; } if ( normalizationFactor != 1 ) { for ( int i = 0; i < targetArray.length; i++ ) { // normalizedValue = (oldValue - min) * normalizationFactor // clamped to 0 .. 65535 targetArray[ i ] = ( short ) Math.min( 65535, Math.max( 0, ( Math.round( ( ( targetArray[ i ] & 0xFFFF ) - minCopy ) * normalizationFactor ) ) ) ); } } } } PlanarImgContainerSamplerImpl.java000066400000000000000000000050311316447754700355770ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/specialized/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.specialized; import net.imglib2.img.planar.PlanarImg.PlanarContainerSampler; /** * Helps to sample a planar image by keeping track of the current slice. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz */ public class PlanarImgContainerSamplerImpl implements PlanarContainerSampler { private int m_currentSliceIndex = -1; public PlanarImgContainerSamplerImpl( final int startIndex ) { m_currentSliceIndex = startIndex; } @Override public int getCurrentSliceIndex() { return m_currentSliceIndex; } public int fwd() { return m_currentSliceIndex++; } public void setCurrentSlice( final int slice ) { m_currentSliceIndex = slice; } } PlanarImgXYByteProjector.java000066400000000000000000000133421316447754700345670ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/specialized/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.specialized; import net.imglib2.display.projector.AbstractProjector2D; import net.imglib2.display.screenimage.awt.UnsignedByteAWTScreenImage; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.planar.PlanarImg; import net.imglib2.type.numeric.integer.GenericByteType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.util.IntervalIndexer; /** * Fast implementation of a {@link AbstractProjector2D} that selects a 2D data * plain from a ByteType PlanarImg. The map method implements a normalization * function. The resulting image is a ByteType ArrayImg. * * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param
*/ public class PlanarImgXYByteProjector< A extends GenericByteType< A >> extends AbstractProjector2D { private final PlanarImg< A, ByteArray > source; private final byte[] targetArray; private final double min; private final double normalizationFactor; private final boolean isSigned; private final long[] dims; /** * Normalizes a PlanarImg and writes the result into target. This can be * used in conjunction with {@link UnsignedByteAWTScreenImage} for direct * displaying. The normalization is based on a normalization factor and a * minimum value with the following dependency:
*
* normalizationFactor = (typeMax - typeMin) / (newMax - newMin)
* min = newMin
*
* A value is normalized by: normalizedValue = (value - min) * * normalizationFactor.
* Additionally the result gets clamped to the type range of target (that * allows playing with saturation...). * * @param source * Signed/Unsigned input data * @param target * Unsigned output * @param normalizationFactor * @param min */ public PlanarImgXYByteProjector( final PlanarImg< A, ByteArray > source, final ArrayImg< UnsignedByteType, ByteArray > target, final double normalizationFactor, final double min ) { super( source.numDimensions() ); this.isSigned = source.firstElement().getMinValue() < 0; this.targetArray = target.update( null ).getCurrentStorageArray(); this.normalizationFactor = normalizationFactor; this.min = min; this.dims = new long[ n ]; source.dimensions( dims ); this.source = source; } @Override public void map() { // more detailed documentation of the binary arithmetic can be found in // ArrayImgXYByteProjector double minCopy = min; final int offset = 0; // positioning for every call to map because the plane index is // position dependent int planeIndex; if ( position.length > 2 ) { final long[] tmpPos = new long[ position.length - 2 ]; final long[] tmpDim = new long[ position.length - 2 ]; for ( int i = 0; i < tmpDim.length; i++ ) { tmpPos[ i ] = position[ i + 2 ]; tmpDim[ i ] = source.dimension( i + 2 ); } planeIndex = ( int ) IntervalIndexer.positionToIndex( tmpPos, tmpDim ); } else { planeIndex = 0; } final byte[] sourceArray = source.update( new PlanarImgContainerSamplerImpl( planeIndex ) ).getCurrentStorageArray(); // copy the selected part of the source array (e.g. a xy plane at time t // in a video) into the target array. System.arraycopy( sourceArray, offset, targetArray, 0, targetArray.length ); if ( isSigned ) { for ( int i = 0; i < targetArray.length; i++ ) { // -128 => 0 && 127 => 255 => unsigned byte targetArray[ i ] = ( byte ) ( targetArray[ i ] - 0x80 ); } // old min + 128 => unsigned byte minimum minCopy += 0x80; } if ( normalizationFactor != 1 ) { for ( int i = 0; i < targetArray.length; i++ ) { // normalizedValue = (oldValue - min) * normalizationFactor // clamped to 0 .. 255 targetArray[ i ] = ( byte ) Math.min( 255, Math.max( 0, ( Math.round( ( ( targetArray[ i ] & 0xFF ) - minCopy ) * normalizationFactor ) ) ) ); } } } } PlanarImgXYShortProjector.java000066400000000000000000000134241316447754700347640ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/specialized/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.specialized; import net.imglib2.display.projector.AbstractProjector2D; import net.imglib2.display.screenimage.awt.UnsignedByteAWTScreenImage; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.img.planar.PlanarImg; import net.imglib2.type.numeric.integer.GenericShortType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.util.IntervalIndexer; /** * Fast implementation of a {@link AbstractProjector2D} that selects a 2D data * plain from an ShortType PlanarImg. The map method implements a normalization * function. The resulting image is a ShortType ArrayImg. * * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * * @param
*/ public class PlanarImgXYShortProjector< A extends GenericShortType< A >> extends AbstractProjector2D { private final PlanarImg< A, ShortArray > source; private final short[] targetArray; private final double min; private final double normalizationFactor; private final boolean isSigned; private final long[] dims; /** * Normalizes a PlanarImg and writes the result into target. This can be * used in conjunction with {@link UnsignedByteAWTScreenImage} for direct * displaying. The normalization is based on a normalization factor and a * minimum value with the following dependency:
*
* normalizationFactor = (typeMax - typeMin) / (newMax - newMin)
* min = newMin
*
* A value is normalized by: normalizedValue = (value - min) * * normalizationFactor.
* Additionally the result gets clamped to the type range of target (that * allows playing with saturation...). * * @param source * Signed/Unsigned input data * @param target * Unsigned output * @param normalizationFactor * @param min */ public PlanarImgXYShortProjector( final PlanarImg< A, ShortArray > source, final ArrayImg< UnsignedShortType, ShortArray > target, final double normalizationFactor, final double min ) { super( source.numDimensions() ); this.isSigned = source.firstElement().getMinValue() < 0; this.targetArray = target.update( null ).getCurrentStorageArray(); this.normalizationFactor = normalizationFactor; this.min = min; this.dims = new long[ n ]; source.dimensions( dims ); this.source = source; } @Override public void map() { // more detailed documentation of the binary arithmetic can be found in // ArrayImgXYByteProjector double minCopy = min; final int offset = 0; // positioning for every call to map because the plane index is // position dependent int planeIndex; if ( position.length > 2 ) { final long[] tmpPos = new long[ position.length - 2 ]; final long[] tmpDim = new long[ position.length - 2 ]; for ( int i = 0; i < tmpDim.length; i++ ) { tmpPos[ i ] = position[ i + 2 ]; tmpDim[ i ] = source.dimension( i + 2 ); } planeIndex = ( int ) IntervalIndexer.positionToIndex( tmpPos, tmpDim ); } else { planeIndex = 0; } final short[] sourceArray = source.update( new PlanarImgContainerSamplerImpl( planeIndex ) ).getCurrentStorageArray(); // copy the selected part of the source array (e.g. a xy plane at time t // in a video) into the target array. System.arraycopy( sourceArray, offset, targetArray, 0, targetArray.length ); if ( isSigned ) { for ( int i = 0; i < targetArray.length; i++ ) { // Short.MIN => 0 && Short.MAX => 65535 (2^16 - 1) => unsigned // short targetArray[ i ] = ( short ) ( targetArray[ i ] - 0x8000 ); } // old => unsigned short minimum minCopy += 0x8000; } if ( normalizationFactor != 1 ) { for ( int i = 0; i < targetArray.length; i++ ) { // normalizedValue = (oldValue - min) * normalizationFactor // clamped to 0 .. 65535 targetArray[ i ] = ( short ) Math.min( 65535, Math.max( 0, ( Math.round( ( ( targetArray[ i ] & 0xFFFF ) - minCopy ) * normalizationFactor ) ) ) ); } } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/volatiles/000077500000000000000000000000001316447754700266375ustar00rootroot00000000000000Volatile2DRandomAccessibleProjector.java000066400000000000000000000104271316447754700364030ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/projector/volatiles/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.projector.volatiles; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.Volatile; import net.imglib2.converter.Converter; import net.imglib2.display.projector.IterableIntervalProjector2D; import net.imglib2.view.Views; /** * {@link IterableIntervalProjector2D} for {@link Volatile} input. After each * {@link #map()} call, the projector has a {@link #isValid() state} that * signalizes whether all projected pixels were valid. * * @author Stephan Saalfeld */ public class Volatile2DRandomAccessibleProjector< T, A extends Volatile< T >, B > extends IterableIntervalProjector2D< A, B > { protected boolean valid = false; public Volatile2DRandomAccessibleProjector( final int dimX, final int dimY, final RandomAccessible< A > source, final RandomAccessibleInterval< B > target, final Converter< ? super A, B > converter ) { super( dimX, dimY, source, Views.iterable( target ), converter ); } /** * @return true if all mapped pixels were {@link Volatile#isValid() valid}. */ public boolean isValid() { return valid; } /** * projects data from the source to the target and applies the former * specified {@link Converter} e.g. for normalization. */ @Override public void map() { // fix interval for all dimensions for ( int d = 0; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; min[ 0 ] = target.min( 0 ); min[ 1 ] = target.min( 1 ); max[ 0 ] = target.max( 0 ); max[ 1 ] = target.max( 1 ); final IterableInterval< A > srcIterable = Views.iterable( Views.interval( source, new FinalInterval( min, max ) ) ); final Cursor< B > targetCursor = target.localizingCursor(); if ( target.iterationOrder().equals( srcIterable.iterationOrder() ) ) { // use cursors final Cursor< A > sourceCursor = srcIterable.cursor(); while ( targetCursor.hasNext() ) { converter.convert( sourceCursor.next(), targetCursor.next() ); } } else { // use localizing cursor final RandomAccess< A > sourceRandomAccess = source.randomAccess(); while ( targetCursor.hasNext() ) { final B b = targetCursor.next(); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), 0 ); sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), 1 ); converter.convert( sourceRandomAccess.get(), b ); } } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/000077500000000000000000000000001316447754700251105ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/ScreenImage.java000066400000000000000000000041271316447754700301410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage; /** * Toplevel interface for screen images. * * @param * The type of images this screen image produces. * * @author Curtis Rueden * @author Christian Dietz */ public interface ScreenImage< T > { public T image(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/000077500000000000000000000000001316447754700257035ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/ARGBScreenImage.java000066400000000000000000000101021316447754700313560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.DataBufferInt; import java.awt.image.DirectColorModel; import java.awt.image.Raster; import java.awt.image.SampleModel; import java.awt.image.WritableRaster; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.numeric.ARGBType; import net.imglib2.util.Fraction; /** * * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class ARGBScreenImage extends ArrayImg< ARGBType, IntArray > implements AWTScreenImage { final protected int[] data; final protected BufferedImage image; static final public ColorModel ARGB_COLOR_MODEL = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 ); public ARGBScreenImage( final int width, final int height ) { this( width, height, new int[ width * height ] ); } /** * Create an {@link Image} with {@code data}. Writing to the {@code data} * array will update the {@link Image}. */ public ARGBScreenImage( final int width, final int height, final IntArray data ) { this( width, height, data.getCurrentStorageArray() ); } /** * Create an {@link Image} with {@code data}. Writing to the {@code data} * array will update the {@link Image}. */ public ARGBScreenImage( final int width, final int height, final int[] data ) { super( new IntArray( data ), new long[]{ width, height }, new Fraction() ); setLinkedType( new ARGBType( this ) ); this.data = data; final SampleModel sampleModel = ARGB_COLOR_MODEL.createCompatibleWritableRaster( 1, 1 ).getSampleModel() .createCompatibleSampleModel( width, height ); final DataBuffer dataBuffer = new DataBufferInt( data, width * height, 0 ); final WritableRaster rgbRaster = Raster.createWritableRaster( sampleModel, dataBuffer, null ); image = new BufferedImage( ARGB_COLOR_MODEL, rgbRaster, false, null ); } @Override public BufferedImage image() { return image; } /** * The underlying array holding the data. Writing to this array will change * the content of the {@link Image} returned by * {@link ARGBScreenImage#image()} */ public int[] getData() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/AWTScreenImage.java000066400000000000000000000042061316447754700313060ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.Image; import net.imglib2.display.screenimage.ScreenImage; /** * A {@link ScreenImage} that produces AWT {@link Image} objects. * * @author Stephan Saalfeld */ public interface AWTScreenImage extends ScreenImage< Image > { @Override public Image image(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/AWTScreenImageUtil.java000066400000000000000000000156051316447754700321510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.ShortType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.integer.UnsignedIntType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; /** * Utility class to create {@link AWTScreenImage}s. * * TODO: Add convenience methods to render {@link RandomAccessibleInterval}s. * * @author Christian Dietz * */ public class AWTScreenImageUtil { /** * Get an appropriate {@link AWTScreenImage} given a type and the * dimensionality of the incoming image. * *

* Only the first two dimensions of the long[] dims are considered. *

* * TODO: review if this is really the only solution to get it running with * jenkins javac. * * @param type * type used to create empty {@link AWTScreenImage} * @param dims * dimensions of the resulting {@link ArrayImgAWTScreenImage} * @return * * // HACK: raw-cast of container to ArrayImgAWTScreenImage needed * for Sun Java 6 compiler * */ @SuppressWarnings( { "unchecked", "rawtypes" } ) public static < T extends NativeType< T >> ArrayImgAWTScreenImage< T, ? > emptyScreenImage( final T type, final long[] dims ) { if ( ByteType.class.isAssignableFrom( type.getClass() ) ) { final ByteArray array = new ByteArray( numElements( dims ) ); final ArrayImgAWTScreenImage< ByteType, ByteArray > container = new ByteAWTScreenImage( new ByteType( array ), array, dims ); container.setLinkedType( new ByteType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( UnsignedByteType.class.isAssignableFrom( type.getClass() ) ) { final ByteArray array = new ByteArray( numElements( dims ) ); final ArrayImgAWTScreenImage< UnsignedByteType, ByteArray > container = new UnsignedByteAWTScreenImage( new UnsignedByteType( array ), array, dims ); container.setLinkedType( new UnsignedByteType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( ShortType.class.isAssignableFrom( type.getClass() ) ) { final ShortArray array = new ShortArray( numElements( dims ) ); final ArrayImgAWTScreenImage< ShortType, ShortArray > container = new ShortAWTScreenImage( new ShortType( array ), array, dims ); container.setLinkedType( new ShortType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( UnsignedShortType.class.isAssignableFrom( type.getClass() ) ) { final ShortArray array = new ShortArray( numElements( dims ) ); final ArrayImgAWTScreenImage< UnsignedShortType, ShortArray > container = new UnsignedShortAWTScreenImage( new UnsignedShortType( array ), array, dims ); container.setLinkedType( new UnsignedShortType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( IntType.class.isAssignableFrom( type.getClass() ) ) { final IntArray array = new IntArray( numElements( dims ) ); final ArrayImgAWTScreenImage< IntType, IntArray > container = new IntAWTScreenImage( new IntType( array ), array, dims ); container.setLinkedType( new IntType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( UnsignedIntType.class.isAssignableFrom( type.getClass() ) ) { final IntArray array = new IntArray( numElements( dims ) ); final ArrayImgAWTScreenImage< UnsignedIntType, IntArray > container = new UnsignedIntAWTScreenImage( new UnsignedIntType( array ), array, dims ); container.setLinkedType( new UnsignedIntType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( FloatType.class.isAssignableFrom( type.getClass() ) ) { final FloatArray array = new FloatArray( numElements( dims ) ); final ArrayImgAWTScreenImage< FloatType, FloatArray > container = new FloatAWTScreenImage( new FloatType( array ), array, dims ); container.setLinkedType( new FloatType( container ) ); return ( ArrayImgAWTScreenImage ) container; } if ( DoubleType.class.isAssignableFrom( type.getClass() ) ) { final DoubleArray array = new DoubleArray( numElements( dims ) ); final ArrayImgAWTScreenImage< DoubleType, DoubleArray > container = new DoubleAWTScreenImage( new DoubleType( array ), array, dims ); container.setLinkedType( new DoubleType( container ) ); return ( ArrayImgAWTScreenImage ) container; } throw new IllegalArgumentException( "Can't find AWTScreenImage for type " + type.toString() + "!" ); } // only the first two dimensions are considered private static int numElements( final long[] dims ) { return ( int ) ( dims[ 0 ] * dims[ 1 ] ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/ArrayImgAWTScreenImage.java000066400000000000000000000104511316447754700327410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.Transparency; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.ComponentColorModel; import java.awt.image.DataBuffer; import java.awt.image.PixelInterleavedSampleModel; import java.awt.image.Raster; import java.awt.image.SampleModel; import java.awt.image.WritableRaster; import net.imglib2.Dimensions; import net.imglib2.img.array.ArrayImg; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; /** * An {@link AWTScreenImage} that is an {@link ArrayImg}. * * @author Curtis Rueden */ public abstract class ArrayImgAWTScreenImage< T extends NativeType< T >, A > extends ArrayImg< T, A > implements AWTScreenImage { private final BufferedImage bufferedImage; public ArrayImgAWTScreenImage( final ArrayImg< T, A > img ) { this( img.firstElement(), img.update( null ), dimensions( img ) ); } public ArrayImgAWTScreenImage( final T type, final A data, final long[] dim ) { super( data, dim, type.getEntitiesPerPixel() ); bufferedImage = createBufferedImage( type, data, ( int ) dim[ 0 ], ( int ) dim[ 1 ] ); } @Override public BufferedImage image() { return bufferedImage; } protected int getBitsPerPixel( final T type ) { if ( type instanceof RealType ) { return ( ( RealType< ? > ) type ).getBitsPerPixel(); } throw new IllegalStateException( "Unknown bits per pixel: " + type ); } protected abstract DataBuffer createDataBuffer( A data ); private BufferedImage createBufferedImage( final T type, final A data, final int width, final int height ) { final DataBuffer buffer = createDataBuffer( data ); final SampleModel model = new PixelInterleavedSampleModel( buffer.getDataType(), width, height, 1, width, new int[] { 0 } ); final ColorModel colorModel = createColorModel( type, buffer ); final WritableRaster raster = Raster.createWritableRaster( model, buffer, null ); return new BufferedImage( colorModel, raster, false, null ); } private ColorModel createColorModel( final T type, final DataBuffer buffer ) { final ColorSpace cs = ColorSpace.getInstance( ColorSpace.CS_GRAY ); final int[] bits = { getBitsPerPixel( type ) }; return new ComponentColorModel( cs, bits, false, false, Transparency.OPAQUE, buffer.getDataType() ); } private static long[] dimensions( final Dimensions img ) { final long[] dimensions = new long[ img.numDimensions() ]; img.dimensions( dimensions ); return dimensions; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/ByteAWTScreenImage.java000066400000000000000000000054061316447754700321350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import net.imglib2.display.awt.SignedByteDataBuffer; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.type.numeric.integer.ByteType; /** * A {@link AWTScreenImage} that is an {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class ByteAWTScreenImage extends ArrayImgAWTScreenImage< ByteType, ByteArray > { public ByteAWTScreenImage( final ArrayImg< ByteType, ByteArray > img ) { super( img ); } public ByteAWTScreenImage( final ByteType type, final ByteArray data, final long[] dim ) { super( type, data, dim ); } @Override protected SignedByteDataBuffer createDataBuffer( final ByteArray data ) { final byte[] sourceArray = data.getCurrentStorageArray(); return new SignedByteDataBuffer( sourceArray, sourceArray.length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/DoubleAWTScreenImage.java000066400000000000000000000054211316447754700324410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.image.DataBufferDouble; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.type.numeric.real.DoubleType; /** * A {@link AWTScreenImage} that is an {@code ArrayImg} * . * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class DoubleAWTScreenImage extends ArrayImgAWTScreenImage< DoubleType, DoubleArray > { public DoubleAWTScreenImage( final ArrayImg< DoubleType, DoubleArray > img ) { super( img ); } public DoubleAWTScreenImage( final DoubleType type, final DoubleArray data, final long[] dim ) { super( type, data, dim ); } @Override protected DataBufferDouble createDataBuffer( final DoubleArray data ) { final double[] sourceArray = data.getCurrentStorageArray(); return new DataBufferDouble( sourceArray, sourceArray.length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/FloatAWTScreenImage.java000066400000000000000000000053731316447754700323020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.image.DataBufferFloat; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.type.numeric.real.FloatType; /** * A {@link AWTScreenImage} that is an {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class FloatAWTScreenImage extends ArrayImgAWTScreenImage< FloatType, FloatArray > { public FloatAWTScreenImage( final ArrayImg< FloatType, FloatArray > img ) { super( img ); } public FloatAWTScreenImage( final FloatType type, final FloatArray data, final long[] dim ) { super( type, data, dim ); } @Override protected DataBufferFloat createDataBuffer( final FloatArray data ) { final float[] sourceArray = data.getCurrentStorageArray(); return new DataBufferFloat( sourceArray, sourceArray.length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/IntAWTScreenImage.java000066400000000000000000000053361316447754700317660ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.image.DataBufferInt; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.numeric.integer.IntType; /** * A {@link AWTScreenImage} that is an {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class IntAWTScreenImage extends ArrayImgAWTScreenImage< IntType, IntArray > { public IntAWTScreenImage( final ArrayImg< IntType, IntArray > img ) { super( img ); } public IntAWTScreenImage( final IntType type, final IntArray data, final long[] dim ) { super( type, data, dim ); } @Override protected DataBufferInt createDataBuffer( final IntArray data ) { final int[] sourceArray = data.getCurrentStorageArray(); return new DataBufferInt( sourceArray, sourceArray.length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/ShortAWTScreenImage.java000066400000000000000000000054301316447754700323260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import net.imglib2.display.awt.SignedShortDataBuffer; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.numeric.integer.ShortType; /** * A {@link AWTScreenImage} that is an {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class ShortAWTScreenImage extends ArrayImgAWTScreenImage< ShortType, ShortArray > { public ShortAWTScreenImage( final ArrayImg< ShortType, ShortArray > img ) { super( img ); } public ShortAWTScreenImage( final ShortType type, final ShortArray data, final long[] dim ) { super( type, data, dim ); } @Override protected SignedShortDataBuffer createDataBuffer( final ShortArray data ) { final short[] sourceArray = data.getCurrentStorageArray(); return new SignedShortDataBuffer( sourceArray, sourceArray.length ); } } UnsignedByteAWTScreenImage.java000066400000000000000000000054571316447754700335610ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.image.DataBufferByte; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.type.numeric.integer.UnsignedByteType; /** * A {@link AWTScreenImage} that is an * {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class UnsignedByteAWTScreenImage extends ArrayImgAWTScreenImage< UnsignedByteType, ByteArray > { public UnsignedByteAWTScreenImage( final ArrayImg< UnsignedByteType, ByteArray > img ) { super( img ); } public UnsignedByteAWTScreenImage( final UnsignedByteType type, final ByteArray data, final long[] dim ) { super( type, data, dim ); } @Override protected DataBufferByte createDataBuffer( final ByteArray data ) { final byte[] sourceArray = data.getCurrentStorageArray(); return new DataBufferByte( sourceArray, sourceArray.length ); } } UnsignedIntAWTScreenImage.java000066400000000000000000000054661316447754700334100ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import net.imglib2.display.awt.UnsignedIntDataBuffer; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.numeric.integer.UnsignedIntType; /** * A {@link AWTScreenImage} that is an {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class UnsignedIntAWTScreenImage extends ArrayImgAWTScreenImage< UnsignedIntType, IntArray > { public UnsignedIntAWTScreenImage( final ArrayImg< UnsignedIntType, IntArray > img ) { super( img ); } public UnsignedIntAWTScreenImage( final UnsignedIntType type, final IntArray data, final long[] dim ) { super( type, data, dim ); } @Override protected UnsignedIntDataBuffer createDataBuffer( final IntArray data ) { final int[] sourceArray = data.getCurrentStorageArray(); return new UnsignedIntDataBuffer( sourceArray, sourceArray.length ); } } UnsignedShortAWTScreenImage.java000066400000000000000000000055041316447754700337460ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/display/screenimage/awt/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display.screenimage.awt; import java.awt.image.DataBufferUShort; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.numeric.integer.UnsignedShortType; /** * A {@link AWTScreenImage} that is an * {@code ArrayImg}. * * @author Michael Zinsmaier * @author Martin Horn * @author Christian Dietz * @author Curtis Rueden */ public class UnsignedShortAWTScreenImage extends ArrayImgAWTScreenImage< UnsignedShortType, ShortArray > { public UnsignedShortAWTScreenImage( final ArrayImg< UnsignedShortType, ShortArray > img ) { super( img ); } public UnsignedShortAWTScreenImage( final UnsignedShortType type, final ShortArray data, final long[] dim ) { super( type, data, dim ); } @Override protected DataBufferUShort createDataBuffer( final ShortArray data ) { final short[] sourceArray = data.getCurrentStorageArray(); return new DataBufferUShort( sourceArray, sourceArray.length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/exception/000077500000000000000000000000001316447754700231575ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/exception/ImgLibException.java000066400000000000000000000044151316447754700270500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.exception; /** * @author Curtis Rueden * @author Stephan Preibisch */ public class ImgLibException extends Exception { public ImgLibException( final String message ) { super( message ); } public ImgLibException( final Object obj, final String message ) { super( obj.getClass().getCanonicalName() + ": " + message ); } public ImgLibException() { super(); } public ImgLibException( final Throwable t ) { super( t ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/exception/IncompatibleTypeException.java000066400000000000000000000043401316447754700311520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.exception; import net.imglib2.type.Type; /** * Is thrown if a {@link Type} is not supported. * * @author Curtis Rueden * @author Stephan Preibisch * @author Johannes Schindelin */ public class IncompatibleTypeException extends ImgLibException { public IncompatibleTypeException( final Object obj, final String message ) { super( obj.getClass().getCanonicalName() + ": " + message ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/000077500000000000000000000000001316447754700231565ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/BinMapper1d.java000066400000000000000000000074031316447754700261270ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; /** * An interface for defining a bin mapping algorithm. Arbitrary values of type T * are mapped to long indices. There are also bounds testing methods. * * @author Barry DeZonia */ public interface BinMapper1d< T > { /** * Returns true if this bin mapping has bins on the ends of the distribution * that count out of bounds values. */ boolean hasTails(); /** * Returns the number of bins within this bin mapping distribution. */ long getBinCount(); /** * Converts a data value to a long index within the bin distribution. */ long map( T value ); /** * Gets the data value associated with the center of a bin. * * @param binPos * @param value * Output to contain center data value */ void getCenterValue( long binPos, T value ); /** * Gets the data value associated with the left edge of a bin. * * @param binPos * Bin number of interest * @param value * Output to contain left edge data value */ void getLowerBound( long binPos, T value ); /** * Gets the data value associated with the right edge of a bin. * * @param binPos * Bin number of interest * @param value * Output to contain right edge data value */ void getUpperBound( long binPos, T value ); /** * Returns true if values matching the right edge data value for a given bin * are counted in the distribution. Basically is this bin interval closed on * the right or not. * * @param binPos * Bin number of interest */ boolean includesUpperBound( long binPos ); /** * Returns true if values matching the left edge data value for a given bin * are counted in the distribution. Basically is this bin interval closed on * the left or not. * * @param binPos * Bin number of interest */ boolean includesLowerBound( long binPos ); /** * Returns a copy of this {@code BinMapper1d}. */ BinMapper1d< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/DiscreteFrequencyDistribution.java000066400000000000000000000201461316447754700320500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.RealPositionable; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.LongType; /** * This class represents an n-dimensional set of counters. Histogram * implementations use these for tracking value counts. * * @author Barry DeZonia */ public class DiscreteFrequencyDistribution implements Img< LongType > { // -- instance variables -- private final Img< LongType > counts; private final RandomAccess< LongType > accessor; private long totalValues; // -- public api -- /** * Construct an n-dimensional counter with the given number of bins */ public DiscreteFrequencyDistribution( final long[] binCounts ) { // check inputs for issues for ( int i = 0; i < binCounts.length; i++ ) { if ( binCounts[ i ] <= 0 ) { throw new IllegalArgumentException( "invalid bin count (<= 0)" ); } } // then build object counts = new ArrayImgFactory< LongType >().create( binCounts, new LongType() ); accessor = counts.randomAccess(); totalValues = 0; } /** * Construct an n-dimensional counter using a provided {@code Img} to * store counts. */ public DiscreteFrequencyDistribution( final Img< LongType > img ) { counts = img; accessor = counts.randomAccess(); resetCounters(); } /** * Resets all frequency counts to zero. */ public void resetCounters() { final Cursor< LongType > cursor = counts.cursor(); while ( cursor.hasNext() ) { cursor.next().setZero(); } totalValues = 0; } /** * Returns the frequency count associated with a given bin. */ public long frequency( final long[] binPos ) { for ( int i = 0; i < accessor.numDimensions(); i++ ) { if ( binPos[ i ] < 0 || binPos[ i ] >= dimension( i ) ) return 0; } accessor.setPosition( binPos ); return accessor.get().get(); } /** * Sets the frequency count associated with a given bin. */ public void setFrequency( final long[] binPos, final long value ) { if ( value < 0 ) { throw new IllegalArgumentException( "frequency count must be >= 0" ); } accessor.setPosition( binPos ); final long currentValue = accessor.get().get(); totalValues += ( value - currentValue ); accessor.get().set( value ); } /** * Returns the relative frequency {@code (0 <= f <= 1)} associated with a given bin. */ public double relativeFrequency( final long[] binPos ) { if ( totalValues == 0 ) return 0; return 1.0 * frequency( binPos ) / totalValues; } /** * Increments the frequency count of a specified bin. */ public void increment( final long[] binPos ) { accessor.setPosition( binPos ); accessor.get().inc(); totalValues++; } /** * Decrements the frequency count of a specified bin. */ public void decrement( final long[] binPos ) { accessor.setPosition( binPos ); accessor.get().dec(); totalValues--; } /** * Returns the total number of values counted by this distribution. */ public long totalValues() { return totalValues; } /** * Returns the highest frequency count found within the bins. */ public long modeCount() { final List< long[] > modes = modePositions(); return frequency( modes.get( 0 ) ); } /** * Returns a list of bin positions of the highest frequency bins. */ public List< long[] > modePositions() { long commonValue = 0; final List< long[] > modePositions = new ArrayList< long[] >(); final Cursor< LongType > cursor = localizingCursor(); while ( cursor.hasNext() ) { final long val = cursor.next().get(); if ( val > commonValue ) { commonValue = val; modePositions.clear(); final long[] pos = new long[ numDimensions() ]; cursor.localize( pos ); modePositions.add( pos ); } else if ( val == commonValue ) { final long[] pos = new long[ numDimensions() ]; cursor.localize( pos ); modePositions.add( pos ); } } return modePositions; } // -- Img methods -- @Override public RandomAccess< LongType > randomAccess() { return counts.randomAccess(); } @Override public RandomAccess< LongType > randomAccess( final Interval interval ) { return counts.randomAccess( interval ); } @Override public int numDimensions() { return counts.numDimensions(); } @Override public long min( final int d ) { return counts.min( d ); } @Override public void min( final long[] min ) { counts.min( min ); } @Override public void min( final Positionable min ) { counts.min( min ); } @Override public long max( final int d ) { return counts.max( d ); } @Override public void max( final long[] max ) { counts.max( max ); } @Override public void max( final Positionable max ) { counts.max( max ); } @Override public double realMin( final int d ) { return counts.realMin( d ); } @Override public void realMin( final double[] min ) { counts.realMin( min ); } @Override public void realMin( final RealPositionable min ) { counts.realMin( min ); } @Override public double realMax( final int d ) { return counts.realMax( d ); } @Override public void realMax( final double[] max ) { counts.realMax( max ); } @Override public void realMax( final RealPositionable max ) { counts.realMax( max ); } @Override public void dimensions( final long[] dimensions ) { counts.dimensions( dimensions ); } @Override public long dimension( final int d ) { return counts.dimension( d ); } @Override public Cursor< LongType > cursor() { return counts.cursor(); } @Override public Cursor< LongType > localizingCursor() { return counts.localizingCursor(); } @Override public long size() { return counts.size(); } @Override public LongType firstElement() { return counts.firstElement(); } @Override public Object iterationOrder() { return counts.iterationOrder(); } @Override public Iterator< LongType > iterator() { return counts.iterator(); } @Override public ImgFactory< LongType > factory() { return counts.factory(); } @Override public DiscreteFrequencyDistribution copy() { return new DiscreteFrequencyDistribution( counts.copy() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/Histogram1d.java000066400000000000000000000420531316447754700262070ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import java.util.Iterator; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.RealPositionable; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.type.numeric.integer.LongType; /** * A Histogram1d is a histogram that tracks up to four kinds of values: 1) * values in the center of the distribution 2) values to the left of the center * of the distribution (lower tail) 3) values to the right of the center of the * distribution (upper tail) 4) values outside the other areas *

* Note: the last three classifications may not be present depending upon the * makeup of the input data. * * @author Barry DeZonia */ public class Histogram1d< T > implements Img< LongType > { // -- instance variables -- private T firstValue; private BinMapper1d< T > mapper; private DiscreteFrequencyDistribution distrib; private long[] pos; private long ignoredCount; // -- constructor -- /** * Construct a histogram from a bin mapping algorithm. Use countData() to * populate it. * * @param mapper * The algorithm used to map values to bins */ public Histogram1d( final BinMapper1d< T > mapper ) { this.mapper = mapper; this.distrib = new DiscreteFrequencyDistribution( new long[] { mapper.getBinCount() } ); this.pos = new long[ 1 ]; this.ignoredCount = 0; } /** * Construct a histogram whose bin mappings match another histogram. After * this construction the histogram bins are unpopulated. * * @param other * The histogram to copy. */ public Histogram1d( final Histogram1d< T > other ) { mapper = other.mapper.copy(); distrib = other.distrib.copy(); pos = other.pos.clone(); // TODO - is reset what we really want? or copy the exact counts too? reset(); } /** * Construct a histogram from an iterable set of data and a bin mapping * algorithm. * * @param data * The iterable set of values to calculate upon * @param mapper * The algorithm used to map values to bins */ public Histogram1d( final Iterable< T > data, final BinMapper1d< T > mapper ) { this( mapper ); init( data ); } // -- public api -- /** * Returns the first data value of the input iteration. */ public T firstDataValue() { return firstValue; } /** * Returns true if the histogram has tail bins at both ends which count * extreme values. */ public boolean hasTails() { return mapper.hasTails(); } /** * Returns the frequency count of values in the lower tail bin (if any). */ public long lowerTailCount() { if ( !hasTails() ) return 0; pos[ 0 ] = 0; return distrib.frequency( pos ); } /** * Returns the frequency count of values in the upper tail bin (if any). */ public long upperTailCount() { if ( !hasTails() ) return 0; pos[ 0 ] = mapper.getBinCount() - 1; return distrib.frequency( pos ); } /** * Returns the frequency count of all values in the middle of the * distribution. */ public long valueCount() { return distributionCount() - lowerTailCount() - upperTailCount(); } /** * Returns the frequency count of all values in the distribution: lower tail * + middle + upper tail. Does not include ignored values. */ public long distributionCount() { return distrib.totalValues(); } /** * Returns the frequency count of values that were ignored because they * could not be mapped to any bin. */ public long ignoredCount() { return ignoredCount; } /** * Returns the total count of all values observed; both within and without * the entire distribution. Thus it includes ignored values. One should * decide carefully between using distributionCount() and totalCount(). */ public long totalCount() { return distributionCount() + ignoredCount(); } /** * Returns the frequency count of values within a bin using a representative * value. Note that multiple values can be mapped to one bin so this is NOT * the frequency count of this exact value in the distribution. * * @param value * A representative value of interest */ public long frequency( final T value ) { final long bin = mapper.map( value ); return frequency( bin ); } /** * Returns the frequency count of the values within a bin. */ public long frequency( final long binPos ) { if ( binPos < 0 || binPos >= mapper.getBinCount() ) return 0; pos[ 0 ] = binPos; return distrib.frequency( pos ); } /** * Returns the relative frequency of values within a bin using a * representative value. Note that multiple values can be mapped to one bin * so this is NOT the relative frequency of this exact value in the * distribution. *

* This calculation is of the number of values in the bin divided by either * the number of values in the distribution or the number of values in the * center of the distribution (tails ignored). *

* One can devise other ways to count relative frequencies that consider * ignored values also. If needed one can use the various count methods and * frequency methods to calculate any relative frequency desired. * * @param value * A representative value of interest * @param includeTails * Flag for determining whether to include tails in calculation. */ public double relativeFrequency( final T value, final boolean includeTails ) { final long bin = mapper.map( value ); return relativeFrequency( bin, includeTails ); } /** * Returns the relative frequency of values within a bin. *

* This calculation is of the number of values in the bin divided by either * the number of values in the distribution or the number of values in the * center of the distribution (tails ignored). *

* One can devise other ways to count relative frequencies that consider * ignored values also. If needed one can use the various count methods and * frequency methods to calculate any relative frequency desired. * * @param binPos * The position of the bin of interest * @param includeTails * Flag for determining whether to include tails in calculation. */ public double relativeFrequency( final long binPos, final boolean includeTails ) { final double numer = frequency( binPos ); final long denom = includeTails ? distributionCount() : valueCount(); return numer / denom; } /** * Returns the number of bins contained in the histogram. */ public long getBinCount() { return mapper.getBinCount(); } /** * Returns a bin position by mapping from a representative value. */ public long map( final T value ) { return mapper.map( value ); } /** * Gets the value associated with the center of a bin. * * @param binPos * The bin number of interest * @param value * The output to fill with the center value */ public void getCenterValue( final long binPos, final T value ) { mapper.getCenterValue( binPos, value ); } /** * Gets the value associated with the left edge of a bin. * * @param binPos * The bin number of interest * @param value * The output to fill with the left edge value */ public void getLowerBound( final long binPos, final T value ) { mapper.getLowerBound( binPos, value ); } /** * Gets the value associated with the right edge of the bin. * * @param binPos * The bin number of interest * @param value * The output to fill with the right edge value */ public void getUpperBound( final long binPos, final T value ) { mapper.getUpperBound( binPos, value ); } /** * Returns true if the given bin interval is closed on the right * * @param binPos * The bin number of the interval of interest */ public boolean includesUpperBound( final long binPos ) { return mapper.includesUpperBound( binPos ); } /** * Returns true if the given bin interval is closed on the left * * @param binPos * The bin number of the interval of interest */ public boolean includesLowerBound( final long binPos ) { return mapper.includesLowerBound( binPos ); } /** * Returns true if a given value is mapped to the lower tail of the * distribution. * * @param value * The value to determine the location of */ public boolean isInLowerTail( final T value ) { if ( !hasTails() ) return false; final long bin = mapper.map( value ); return bin == 0; } /** * Returns true if a given value is mapped to the upper tail of the * distribution. * * @param value * The value to determine the location of */ public boolean isInUpperTail( final T value ) { if ( !hasTails() ) return false; final long bin = mapper.map( value ); return bin == getBinCount() - 1; } /** * Returns true if a given value is mapped to the middle of the * distribution. * * @param value * The value to determine the location of */ public boolean isInMiddle( final T value ) { if ( !hasTails() ) return true; final long bin = mapper.map( value ); return ( bin > 0 ) && ( bin < getBinCount() - 1 ); } /** * Returns true if a given value is outside the distribution. * * @param value * The value to determine the location of */ public boolean isOutside( final T value ) { final long bin = mapper.map( value ); return ( bin == Long.MIN_VALUE ) || ( bin == Long.MAX_VALUE ); } /** * Get the discrete frequency distribution associated with this histogram. */ public DiscreteFrequencyDistribution dfd() { return distrib; } /** * Counts the data contained in the given data source using the underlying * bin distribution. * * @param data * The total data to count */ public void countData( final Iterable< T > data ) { init( data ); } /** * Counts additional data contained in a given iterable collection. One can * use this to update an existing histogram with a subset of values. * * @param data * The new data to count */ public void addData( final Iterable< T > data ) { add( data ); } /** * Uncounts some original data contained in a given iterable collection. One * can use this to update an existing histogram with a subset of values. * * @param data * The old data to uncount */ public void subtractData( final Iterable< T > data ) { subtract( data ); } /** * Directly increment a bin by position. * * @param binPos * The 1-d index of the bin */ public void increment( final long binPos ) { pos[ 0 ] = binPos; distrib.increment( pos ); } /** * Directly decrement a bin by position. * * @param binPos * The 1-d index of the bin */ public void decrement( final long binPos ) { pos[ 0 ] = binPos; distrib.decrement( pos ); } /** * Directly increment a bin by value. * * @param value * The value to map to a bin position */ public void increment( final T value ) { final long bin = mapper.map( value ); if ( bin == Long.MIN_VALUE || bin == Long.MAX_VALUE ) { ignoredCount++; } else { pos[ 0 ] = bin; distrib.increment( pos ); } } /** * Directly decrement a bin by value, * * @param value * The value to map to a bin position */ public void decrement( final T value ) { final long bin = mapper.map( value ); if ( bin == Long.MIN_VALUE || bin == Long.MAX_VALUE ) { ignoredCount--; } else { pos[ 0 ] = bin; distrib.decrement( pos ); } } /** * Resets all data counts to 0. */ public void resetCounters() { reset(); } /** * Returns a bare long[] histogram with the same bin counts as this * histogram. */ public long[] toLongArray() { final long[] result = new long[ ( int ) getBinCount() ]; final Cursor< LongType > cursor = cursor(); int i = 0; while ( cursor.hasNext() ) { result[ i++ ] = cursor.next().get(); } return result; } // -- delegated Img methods -- /** * Return the number of dimensions of the frequency distribution of this * histogram. */ @Override public int numDimensions() { return distrib.numDimensions(); } /** * Return the size of the given dimension of the frequency distribution of * this histogram. */ @Override public long dimension( final int d ) { return distrib.dimension( d ); } /** * Fill the provided long[] with the sizes of all dimensions of the * frequency distribution of this histogram. */ @Override public void dimensions( final long[] dims ) { distrib.dimensions( dims ); } @Override public RandomAccess< LongType > randomAccess() { return distrib.randomAccess(); } @Override public RandomAccess< LongType > randomAccess( final Interval interval ) { return distrib.randomAccess( interval ); } public long min() { return min( 0 ); } @Override public long min( final int d ) { return distrib.min( d ); } @Override public void min( final long[] min ) { distrib.min( min ); } @Override public void min( final Positionable min ) { distrib.min( min ); } public long max() { return max( 0 ); } @Override public long max( final int d ) { return distrib.max( d ); } @Override public void max( final long[] max ) { distrib.max( max ); } @Override public void max( final Positionable max ) { distrib.max( max ); } public double realMin() { return realMin( 0 ); } @Override public double realMin( final int d ) { return distrib.realMin( d ); } @Override public void realMin( final double[] min ) { distrib.realMin( min ); } @Override public void realMin( final RealPositionable min ) { distrib.realMin( min ); } public double realMax() { return realMax( 0 ); } @Override public double realMax( final int d ) { return distrib.realMax( d ); } @Override public void realMax( final double[] max ) { distrib.realMax( max ); } @Override public void realMax( final RealPositionable max ) { distrib.realMax( max ); } @Override public Cursor< LongType > cursor() { return distrib.cursor(); } @Override public Cursor< LongType > localizingCursor() { return distrib.localizingCursor(); } @Override public long size() { return distrib.size(); } @Override public LongType firstElement() { return distrib.firstElement(); } @Override public Object iterationOrder() { return distrib.iterationOrder(); } @Override public Iterator< LongType > iterator() { return distrib.iterator(); } @Override public ImgFactory< LongType > factory() { return distrib.factory(); } @Override public Histogram1d< T > copy() { return new Histogram1d< T >( this ); } // -- helpers -- private void reset() { distrib.resetCounters(); ignoredCount = 0; firstValue = null; } private void init( final Iterable< T > data ) { reset(); // record the first element final Iterator iter = data.iterator(); if ( iter.hasNext() ) { firstValue = iter.next(); increment( firstValue ); } // record the rest of the elements while ( iter.hasNext() ) { increment ( iter.next() ); } } private void add( final Iterable< T > data ) { for ( final T value : data ) { increment( value ); } } private void subtract( final Iterable< T > data ) { for ( final T value : data ) { decrement( value ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/HistogramNd.java000066400000000000000000000665211316447754700262520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.RealPositionable; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.type.numeric.integer.LongType; // TODO - calculate lazily but should be able to count upper/lower/middle in // one pass rather than the multiple passes that are now in place. /** * A HistogramNd is an n-dimensional histogram that tracks up to four kinds of * values: 1) values in the center of the distribution 2) values to the left of * the center of the distribution (lower tail) 3) values to the right of the * center of the distribution (upper tail) 4) values outside the other areas *

* Note: the last three classifications may not be present depending upon the * makeup of the input data. * * @author Barry DeZonia */ public class HistogramNd< T > implements Img< LongType > { // -- instance variables -- private List< BinMapper1d< T >> mappers; private DiscreteFrequencyDistribution distrib; private long[] pos; private long ignoredCount; @SuppressWarnings( "synthetic-access" ) private final Incrementer incrementer = new Incrementer(); @SuppressWarnings( "synthetic-access" ) private final Decrementer decrementer = new Decrementer(); // -- constructors -- /** * Construct a histogram from a list of bin mapping algorithms. Use * countData() to populate it. * * @param mappers * The algorithms used to map values to bins */ public HistogramNd( final List< BinMapper1d< T >> mappers ) { this.mappers = mappers; final long[] dims = new long[ mappers.size() ]; for ( int i = 0; i < mappers.size(); i++ ) { dims[ i ] = mappers.get( i ).getBinCount(); } distrib = new DiscreteFrequencyDistribution( dims ); pos = new long[ mappers.size() ]; ignoredCount = 0; } /** * Construct a histogram whose bin mappings match another histogram. After * this construction the histogram bins are unpopulated. * * @param other * The histogram to copy. */ public HistogramNd( final HistogramNd< T > other ) { final List< BinMapper1d< T >> mappersCopy = new ArrayList< BinMapper1d< T >>(); for ( final BinMapper1d< T > m : mappers ) { mappersCopy.add( m.copy() ); } mappers = mappersCopy; distrib = other.distrib.copy(); pos = other.pos.clone(); ignoredCount = 0; } /** * Construct a histogram from an iterable set of data and a list of bin * mapping algorithms. Must be given one iterable data source that returns * multiple data values at each point. * * @param data * The iterable set of values to calculate upon * @param mappers * The algorithms used to map values to bins */ public HistogramNd( final Iterable< List< T >> data, final List< BinMapper1d< T >> mappers ) { this( mappers ); init( data ); } /** * Construct a histogram from an iterable set of data and a list of bin * mapping algorithms. Must be given multiple iterable data sources that * each return a single data value at each point. * * @param data * The iterable set of values to calculate upon * @param mappers * The algorithms used to map values to bins */ public HistogramNd( final List< Iterable< T >> data, final List< BinMapper1d< T >> mappers ) { this( mappers ); init( data ); } // -- public api -- /** * Returns true if the histogram has tail bins which count extreme values * for the given dimension. */ public boolean hasTails( final int dim ) { return mappers.get( dim ).hasTails(); } /** * Returns true if the histogram has tail bins which count extreme values * for one or more dimensions */ public boolean hasTails() { for ( int i = 0; i < mappers.size(); i++ ) { if ( hasTails( i ) ) return true; } return false; } /** * Returns the frequency count of values in the lower tail bin (if any) for * the given dimension. */ public long lowerTailCount( final int dim ) { if ( !hasTails( dim ) ) return 0; long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); if ( binPos[ dim ] == 0 ) sum += distrib.frequency( binPos ); } return sum; } /** * Returns the frequency count of values in all lower tail bins (if any). */ public long lowerTailCount() { if ( !hasTails() ) return 0; long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); for ( int i = 0; i < mappers.size(); i++ ) { if ( binPos[ i ] == 0 ) { sum += distrib.frequency( binPos ); break; } } } return sum; } /** * Returns the frequency count of values in the upper tail bin (if any) for * the given dimension. */ public long upperTailCount( final int dim ) { if ( !hasTails( dim ) ) return 0; final long dimSize = mappers.get( dim ).getBinCount(); long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); if ( binPos[ dim ] == dimSize - 1 ) sum += distrib.frequency( binPos ); } return sum; } /** * Returns the frequency count of values in all upper tail bins (if any). */ public long upperTailCount() { if ( !hasTails() ) return 0; long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); for ( int i = 0; i < mappers.size(); i++ ) { if ( binPos[ i ] == mappers.get( i ).getBinCount() - 1 ) { sum += distrib.frequency( binPos ); break; } } } return sum; } /** * Returns the frequency count of all values in the middle of the * distribution for a given dimension. */ public long valueCount( final int dim ) { final boolean hasTails = hasTails( dim ); final long dimSize = mappers.get( dim ).getBinCount(); long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); boolean inTail = false; if ( hasTails && ( binPos[ dim ] == 0 ) || ( binPos[ dim ] == dimSize - 1 ) ) { inTail = true; } if ( !inTail ) sum += distrib.frequency( binPos ); } return sum; } /** * Returns the frequency count of all values in the middle of the * distribution. */ public long valueCount() { // NB : would like to do this: // return distributionCount() - lowerTailCount() - upperTailCount(); // But this double counts some tail bins. if ( !hasTails() ) return distributionCount(); long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); boolean inTail = false; for ( int i = 0; i < binPos.length; i++ ) { if ( ( binPos[ i ] == 0 ) || ( binPos[ i ] == mappers.get( i ).getBinCount() - 1 ) ) { inTail = true; break; } } if ( !inTail ) sum += distrib.frequency( binPos ); } return sum; } /** * Returns the frequency count of all values in the specified dimension of * the distribution: lower tail + middle + upper tail. Does not include * ignored values. */ public long distributionCount( final int dim, final long dimVal ) { long sum = 0; final Cursor< ? > cursor = distrib.localizingCursor(); final long[] binPos = new long[ distrib.numDimensions() ]; while ( cursor.hasNext() ) { cursor.next(); cursor.localize( binPos ); if ( binPos[ dim ] != dimVal ) continue; sum += distrib.frequency( binPos ); } return sum; } /** * Returns the frequency count of all values in the distribution: lower tail * + middle + upper tail. Does not include ignored values. */ public long distributionCount() { return distrib.totalValues(); } /** * Returns the frequency count of values that were ignored because they * could not be mapped to any bin. */ public long ignoredCount() { return ignoredCount; } /** * Returns the total count of all values observed; both within and without * the entire distribution. Thus it includes ignored values. One should * decide carefully between using distributionCount() and totalCount(). */ public long totalCount() { return distributionCount() + ignoredCount(); } /** * Returns the frequency count of values within a bin using a set of * representative values. Note that multiple values can be mapped to one bin * so this is NOT the frequency count of this exact set of values in the * distribution. * * @param values * A set of representative values of interest */ public long frequency( final List< T > values ) { map( values, pos ); return frequency( pos ); } /** * Returns the frequency count of the values within a bin. */ public long frequency( final long[] binPos ) { return distrib.frequency( binPos ); } /** * Returns the relative frequency of values within a bin using a set of * representative values. Note that multiple values can be mapped to one bin * so this is NOT the relative frequency of this exact set of values in the * distribution. *

* This calculation is of the number of values in the bin divided by either * the number of values in the distribution or the number of values in the * center of the distribution (tails ignored). *

* One can devise other ways to count relative frequencies that consider * ignored values also. If needed one can use the various count methods and * frequency methods to calculate any relative frequency desired. * * @param values * A representative set of values of interest * @param includeTails * Flag for determining whether to include tails in calculation. */ public double relativeFrequency( final List< T > values, final boolean includeTails ) { map( values, pos ); return relativeFrequency( pos, includeTails ); } /** * Returns the relative frequency of values within a bin. *

* This calculation is of the number of values in the bin divided by either * the number of values in the distribution or the number of values in the * center of the distribution (tails ignored). *

* One can devise other ways to count relative frequencies that consider * ignored values also. If needed one can use the various count methods and * frequency methods to calculate any relative frequency desired. * * @param binPos * The position of the bin of interest * @param includeTails * Flag for determining whether to include tails in calculation. */ public double relativeFrequency( final long[] binPos, final boolean includeTails ) { final double numer = frequency( binPos ); final long denom = includeTails ? totalCount() : valueCount(); return numer / denom; } /** * Returns the number of bins contained in the histogram. */ public long getBinCount() { if ( mappers.size() == 0 ) return 0; long count = 1; for ( int i = 0; i < mappers.size(); i++ ) { count *= mappers.get( i ).getBinCount(); } return count; } /** * Fills a bin position by mapping from a set of representative values. */ public void map( final List< T > values, final long[] binPos ) { for ( int i = 0; i < mappers.size(); i++ ) { binPos[ i ] = mappers.get( i ).map( values.get( i ) ); } } /** * Gets the values associated with the center of a bin. * * @param binPos * The bin index of interest * @param values * The outputs to fill with the center values */ public void getCenterValues( final long[] binPos, final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { final T value = values.get( i ); mappers.get( i ).getCenterValue( binPos[ i ], value ); } } /** * Gets the values associated with the left edge of a bin. * * @param binPos * The bin index of interest * @param values * The outputs to fill with the left edge values */ public void getLowerBounds( final long[] binPos, final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { final T value = values.get( i ); mappers.get( i ).getLowerBound( binPos[ i ], value ); } } /** * Gets the values associated with the right edge of a bin. * * @param binPos * The bin index of interest * @param values * The outputs to fill with the right edge values */ public void getUpperBounds( final long[] binPos, final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { final T value = values.get( i ); mappers.get( i ).getUpperBound( binPos[ i ], value ); } } /** * Returns true if the given bin interval is closed on the right * * @param binPos * The bin number of the interval of interest */ public boolean includesUpperBounds( final long[] binPos ) { for ( int i = 0; i < mappers.size(); i++ ) { if ( !mappers.get( i ).includesUpperBound( binPos[ i ] ) ) return false; } return true; } /** * Returns true if the given bin interval is closed on the left * * @param binPos * The bin number of the interval of interest */ public boolean includesLowerBounds( final long[] binPos ) { for ( int i = 0; i < mappers.size(); i++ ) { if ( !mappers.get( i ).includesLowerBound( binPos[ i ] ) ) return false; } return true; } /** * Returns true if the given bin interval is closed on the right for the * given dimension. * * @param dim * The dimension of interest * @param binPos * The bin number of the interval of interest */ public boolean includesUpperBound( final int dim, final long binPos ) { return mappers.get( dim ).includesUpperBound( binPos ); } /** * Returns true if the given bin interval is closed on the left for the * given dimension. * * @param dim * The dimension of interest * @param binPos * The bin number of the interval of interest */ public boolean includesLowerBound( final int dim, final long binPos ) { return mappers.get( dim ).includesLowerBound( binPos ); } /** * Returns true if a given set of values are mapped to the lower tail of the * distribution. * * @param values * The set of values to determine the location of */ public boolean isInLowerTail( final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { if ( isInLowerTail( i, values.get( i ) ) ) { return true; } } return false; } /** * Returns true if a given value for a given dimension is mapped to the * lower tail of the distribution. * * @param dim * The dimension number of the axis of interest * @param value * The value to determine the location of */ public boolean isInLowerTail( final int dim, final T value ) { if ( hasTails( dim ) ) { final long binPos = mappers.get( dim ).map( value ); if ( binPos == 0 ) { return true; } } return false; } /** * Returns true if a given set of values are mapped to the upper tail of the * distribution. * * @param values * The set of values to determine the location of */ public boolean isInUpperTail( final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { if ( isInUpperTail( i, values.get( i ) ) ) { return true; } } return false; } /** * Returns true if a given value for a given dimension is mapped to the * upper tail of the distribution. * * @param dim * The dimension number of the axis of interest * @param value * The value to determine the location of */ public boolean isInUpperTail( final int dim, final T value ) { if ( hasTails( dim ) ) { final long binPos = mappers.get( dim ).map( value ); if ( binPos == mappers.get( dim ).getBinCount() - 1 ) { return true; } } return false; } /** * Returns true if a given set of values are mapped to the middle of the * distribution. * * @param values * The set of values to determine the location of */ public boolean isInMiddle( final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { if ( !isInMiddle( i, values.get( i ) ) ) { return false; } } return true; } /** * Returns true if a given value for a given dimension is mapped to the * middle of the distribution. * * @param dim * The dimension number of the axis of interest * @param value * The value to determine the location of */ public boolean isInMiddle( final int dim, final T value ) { if ( hasTails( dim ) ) { final long binPos = mappers.get( dim ).map( value ); if ( ( binPos == 0 ) || ( binPos == mappers.get( dim ).getBinCount() - 1 ) ) { return false; } } return true; } /** * Returns true if a given set of values are outside the distribution. * * @param values * The set of values to determine the location of */ public boolean isOutside( final List< T > values ) { for ( int i = 0; i < mappers.size(); i++ ) { if ( isOutside( i, values.get( i ) ) ) { return true; } } return false; } /** * Returns true if a given value for a given dimension is outside the * distribution. * * @param value * The value to determine the location of */ public boolean isOutside( final int dim, final T value ) { final long binPos = mappers.get( dim ).map( value ); if ( ( binPos == Long.MIN_VALUE ) || ( binPos == Long.MAX_VALUE ) ) { return true; } return false; } /** * Get the discrete frequency distribution associated with this histogram. */ public DiscreteFrequencyDistribution dfd() { return distrib; } /** * Counts the data contained in the given data source using the underlying * bin distribution. * * @param data * The total data to count */ public void countData( final Iterable< List< T >> data ) { init( data ); } /** * Counts the data contained in the given data source using the underlying * bin distribution. * * @param data * The total data to count */ public void countData( final List< Iterable< T >> data ) { init( data ); } /** * Counts additional data contained in a given iterable collection. One can * use this to update an existing histogram with a subset of values. * * @param data * The new data to count */ public void addData( final Iterable< List< T >> data ) { add( data ); } /** * Counts additional data contained in a given iterable collection. One can * use this to update an existing histogram with a subset of values. * * @param data * The new data to count */ public void addData( final List< Iterable< T >> data ) { add( data ); } /** * Uncounts some original data contained in a given iterable collection. One * can use this to update an existing histogram with a subset of values. * * @param data * The old data to uncount */ public void subtractData( final Iterable< List< T >> data ) { subtract( data ); } /** * Uncounts some original data contained in a given iterable collection. One * can use this to update an existing histogram with a subset of values. * * @param data * The old data to uncount */ public void subtractData( final List< Iterable< T >> data ) { subtract( data ); } /** * Directly increment a bin by position. * * @param binPos * The 1-d index of the bin */ public void increment( final long[] binPos ) { distrib.increment( binPos ); } /** * Directly decrement a bin by position. * * @param binPos * The 1-d index of the bin */ public void decrement( final long[] binPos ) { distrib.decrement( binPos ); } /** * Directly increment a bin by value. * * @param values * The values to map to a bin position */ public void increment( final List< T > values ) { count( values, incrementer ); } /** * Directly decrement a bin by value, * * @param values * The values to map to a bin position */ public void decrement( final List< T > values ) { count( values, decrementer ); } /** * Resets all data counts to 0. */ public void resetCounters() { reset(); } // -- delegated Img methods -- /** * Return the number of dimensions of the frequency distribution of this * histogram. */ @Override public int numDimensions() { return distrib.numDimensions(); } /** * Return the size of the given dimension of the frequency distribution of * this histogram. */ @Override public long dimension( final int d ) { return distrib.dimension( d ); } /** * Fill the provided long[] with the sizes of all dimensions of the * frequency distribution of this histogram. */ @Override public void dimensions( final long[] dims ) { distrib.dimensions( dims ); } @Override public RandomAccess< LongType > randomAccess() { return distrib.randomAccess(); } @Override public RandomAccess< LongType > randomAccess( final Interval interval ) { return distrib.randomAccess( interval ); } @Override public long min( final int d ) { return distrib.min( d ); } @Override public void min( final long[] min ) { distrib.min( min ); } @Override public void min( final Positionable min ) { distrib.min( min ); } @Override public long max( final int d ) { return distrib.max( d ); } @Override public void max( final long[] max ) { distrib.max( max ); } @Override public void max( final Positionable max ) { distrib.max( max ); } @Override public double realMin( final int d ) { return distrib.realMin( d ); } @Override public void realMin( final double[] min ) { distrib.realMin( min ); } @Override public void realMin( final RealPositionable min ) { distrib.realMin( min ); } @Override public double realMax( final int d ) { return distrib.realMax( d ); } @Override public void realMax( final double[] max ) { distrib.realMax( max ); } @Override public void realMax( final RealPositionable max ) { distrib.realMax( max ); } @Override public Cursor< LongType > cursor() { return distrib.cursor(); } @Override public Cursor< LongType > localizingCursor() { return distrib.localizingCursor(); } @Override public long size() { return distrib.size(); } @Override public LongType firstElement() { return distrib.firstElement(); } @Override public Object iterationOrder() { return distrib.iterationOrder(); } @Override public Iterator< LongType > iterator() { return distrib.iterator(); } @Override public ImgFactory< LongType > factory() { return distrib.factory(); } @Override public HistogramNd< T > copy() { return new HistogramNd< T >( this ); } // -- helpers -- private void reset() { distrib.resetCounters(); ignoredCount = 0; } private void init( final Iterable< List< T >> data ) { reset(); add( data ); } private void init( final List< Iterable< T >> data ) { reset(); add( data ); } private void add( final Iterable< List< T >> data ) { modifyCounts( data, incrementer ); } private void add( final List< Iterable< T >> data ) { modifyCounts( data, incrementer ); } private void subtract( final Iterable< List< T >> data ) { modifyCounts( data, decrementer ); } private void subtract( final List< Iterable< T >> data ) { modifyCounts( data, decrementer ); } private void modifyCounts( final Iterable< List< T >> data, final Counter counter ) { final Iterator< List< T >> iter = data.iterator(); while ( iter.hasNext() ) { count( iter.next(), counter ); } } private void modifyCounts( final List< Iterable< T >> data, final Counter counter ) { final List< T > vals = new ArrayList< T >( mappers.size() ); final List< Iterator< T >> iters = new ArrayList< Iterator< T >>(); for ( int i = 0; i < data.size(); i++ ) { iters.add( data.get( i ).iterator() ); vals.add( null ); } boolean hasNext = true; do { for ( int i = 0; i < iters.size(); i++ ) { if ( !iters.get( i ).hasNext() ) hasNext = false; } if ( hasNext ) { for ( int i = 0; i < iters.size(); i++ ) { vals.set( i, iters.get( i ).next() ); } count( vals, counter ); } } while ( hasNext ); } private void count( final List< T > values, final Counter counter ) { map( values, pos ); boolean ignored = false; for ( int i = 0; i < pos.length; i++ ) { if ( pos[ i ] == Long.MIN_VALUE || pos[ i ] == Long.MAX_VALUE ) { ignored = true; break; } } counter.count( pos, ignored ); } private interface Counter { void count( long[] pos, boolean ignored ); } private class Decrementer implements Counter { @SuppressWarnings( "synthetic-access" ) @Override public void count( final long[] position, final boolean ignored ) { if ( ignored ) ignoredCount--; else distrib.decrement( position ); } } private class Incrementer implements Counter { @SuppressWarnings( "synthetic-access" ) @Override public void count( final long[] position, final boolean ignored ) { if ( ignored ) ignoredCount++; else distrib.increment( position ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/Integer1dBinMapper.java000066400000000000000000000144331316447754700274460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import java.util.ArrayList; import java.util.List; import net.imglib2.type.numeric.IntegerType; /** * Maps integer values into a 1-d set of bins. * * @author Barry DeZonia */ public class Integer1dBinMapper< T extends IntegerType< T >> implements BinMapper1d< T > { // -- instance variables -- private final long bins; private final long minVal, maxVal; private final boolean tailBins; // -- constructor -- /** * Specify a mapping of integral data from a user defined range into a * specified number of bins. If tailBins is true then there will be two bins * that count values outside the user specified ranges. If false then values * outside the range fail to map to any bin. * * @param minVal * The first data value of interest. * @param numBins * The total number of bins to create. * @param tailBins * A boolean specifying whether to have a bin in each tail to * count values outside the user defined range. */ public Integer1dBinMapper( final long minVal, final long numBins, final boolean tailBins ) { this.bins = numBins; this.tailBins = tailBins; this.minVal = minVal; if ( tailBins ) { this.maxVal = minVal + numBins - 1 - 2; } else { this.maxVal = minVal + numBins - 1; } if ( ( bins <= 0 ) || ( tailBins && bins <= 2 ) ) { throw new IllegalArgumentException( "invalid Integer1dBinMapper: no data bins specified" ); } } // -- BinMapper methods -- @Override public long getBinCount() { return bins; } @Override public long map( final T value ) { final long val = value.getIntegerLong(); long pos; if ( val >= minVal && val <= maxVal ) { pos = val - minVal; if ( tailBins ) pos++; } else if ( tailBins ) { if ( val < minVal ) pos = 0; else pos = bins - 1; } else { // no tail bins and we are outside if ( val < minVal ) pos = Long.MIN_VALUE; else pos = Long.MAX_VALUE; } return pos; } @Override public void getCenterValue( final long binPos, final T value ) { long val; if ( tailBins ) { if ( binPos == 0 ) val = minVal - 1; // TODO HACK - what is best to return? else if ( binPos == bins - 1 ) val = maxVal + 1; // TODO same HACK else val = minVal + binPos - 1; } else { // no tail bins val = minVal + binPos; } value.setInteger( val ); } @Override public void getLowerBound( final long binPos, final T value ) { if ( tailBins && ( binPos == 0 || binPos == bins - 1 ) ) { if ( binPos == 0 ) value.setInteger( Long.MIN_VALUE + 1 ); else value.setInteger( maxVal + 1 ); } else { getCenterValue( binPos, value ); } } @Override public void getUpperBound( final long binPos, final T value ) { if ( tailBins && ( binPos == 0 || binPos == bins - 1 ) ) { if ( binPos == 0 ) value.setInteger( minVal - 1 ); else value.setInteger( Long.MAX_VALUE - 1 ); } else { getCenterValue( binPos, value ); } } @Override public boolean includesLowerBound( final long binPos ) { return true; } @Override public boolean includesUpperBound( final long binPos ) { return true; } @Override public boolean hasTails() { return tailBins; } @Override public Integer1dBinMapper< T > copy() { return new Integer1dBinMapper< T >( minVal, bins, tailBins ); } /** * This is a convenience method for creating a {@link HistogramNd} from * inputs that describe a set of integer 1-d based bin mappers. The inputs * should all have n entries for an n-d set of mappers. * * @param minVals * The minimum bin values for each dimension * @param numBins * The total bin count for each dimension * @param tailBins * Flags per dimension for whether to include tail bins * @return An unpopulated HistogramNd */ public static < K extends IntegerType< K >> HistogramNd< K > histogramNd( final long[] minVals, final long[] numBins, final boolean[] tailBins ) { if ( ( minVals.length != numBins.length ) || ( minVals.length != tailBins.length ) ) { throw new IllegalArgumentException( "multiDimMapper: differing input array sizes" ); } final List< BinMapper1d< K >> binMappers = new ArrayList< BinMapper1d< K >>(); for ( int i = 0; i < minVals.length; i++ ) { final Integer1dBinMapper< K > mapper = new Integer1dBinMapper< K >( minVals[ i ], numBins[ i ], tailBins[ i ] ); binMappers.add( mapper ); } return new HistogramNd< K >( binMappers ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/histogram/Real1dBinMapper.java000066400000000000000000000171621316447754700267360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import java.util.ArrayList; import java.util.List; import net.imglib2.type.numeric.RealType; /** * Maps real values into a 1-d set of bins. Though this class will work with * integral data types it is really more appropriate to do so using a * {@link Integer1dBinMapper}. * * @author Barry DeZonia */ public class Real1dBinMapper< T extends RealType< T >> implements BinMapper1d< T > { // -- instance variables -- private final long bins; private final double minVal, maxVal; private final boolean tailBins; private final double binWidth; private final long interiorBins; // -- constructor -- /** * Specify a mapping of real data from a user defined range into a specified * number of bins. If tailBins is true then there will be two bins that * count values outside the user specified ranges. If false then values * outside the range fail to map to any bin. * * @param minVal * The first data value of interest. * @param maxVal * The last data value of interest. * @param numBins * The total number of bins to create. * @param tailBins * A boolean specifying whether to have a bin in each tail to * count values outside the user defined range. */ public Real1dBinMapper( final double minVal, final double maxVal, final long numBins, final boolean tailBins ) { this.bins = numBins; this.minVal = minVal; this.maxVal = maxVal; this.tailBins = tailBins; if ( numBins <= 0 || ( tailBins && numBins <= 2 ) ) { throw new IllegalArgumentException( "invalid Real1dBinMapper: no data bins specified" ); } if ( minVal > maxVal ) { throw new IllegalArgumentException( "invalid Real1dBinMapper: invalid data range specified (min > max)" ); } if ( tailBins ) { this.interiorBins = bins - 2; } else { this.interiorBins = bins; } if ( minVal == maxVal ) this.binWidth = 1.0 / interiorBins; else this.binWidth = ( maxVal - minVal ) / ( interiorBins ); } // -- BinMapper methods -- @Override public long getBinCount() { return bins; } @Override public long map( final T value ) { final double val = value.getRealDouble(); long pos; if ( val >= minVal && val <= maxVal ) { final double bin = ( val - minVal ) / binWidth; pos = ( long ) Math.floor( bin ); // catch out of bounds which can happen for edge values and roundoff // errs if ( pos >= interiorBins ) pos = interiorBins - 1; if ( tailBins ) pos++; } else if ( tailBins ) { if ( val < minVal ) pos = 0; else pos = bins - 1; } else { // no tail bins and we are outside if ( val < minVal ) pos = Long.MIN_VALUE; else pos = Long.MAX_VALUE; } return pos; } @Override public void getCenterValue( final long binPos, final T value ) { value.setReal( center( binPos ) ); } @Override public void getLowerBound( final long binPos, final T value ) { value.setReal( min( binPos ) ); } @Override public void getUpperBound( final long binPos, final T value ) { value.setReal( max( binPos ) ); } @Override public boolean includesLowerBound( final long binPos ) { if ( tailBins && binPos == bins - 1 ) return false; return true; } @Override public boolean includesUpperBound( final long binPos ) { if ( tailBins ) { if ( binPos >= bins - 2 ) return true; } else { // no tail bins if ( binPos == bins - 1 ) return true; } return false; } @Override public boolean hasTails() { return tailBins; } @Override public Real1dBinMapper< T > copy() { return new Real1dBinMapper< T >( minVal, maxVal, bins, tailBins ); } /** * This is a convenience method for creating a {@link HistogramNd} from * inputs that describe a set of real 1-d based bin mappers. The inputs * should all have n entries for an n-d set of mappers. * * @param minVals * The minimum bin values for each dimension * @param maxVals * The maximum bin values for each dimension * @param numBins * The total bin count for each dimension * @param tailBins * Flags per dimension for whether to include tail bins * @return An unpopulated HistogramNd */ public static < K extends RealType< K >> HistogramNd< K > histogramNd( final double[] minVals, final double[] maxVals, final long[] numBins, final boolean[] tailBins ) { if ( ( minVals.length != numBins.length ) || ( minVals.length != tailBins.length ) ) { throw new IllegalArgumentException( "multiDimMappers: differing input array sizes" ); } final List< BinMapper1d< K >> binMappers = new ArrayList< BinMapper1d< K >>(); for ( int i = 0; i < minVals.length; i++ ) { final Real1dBinMapper< K > mapper = new Real1dBinMapper< K >( minVals[ i ], maxVals[ i ], numBins[ i ], tailBins[ i ] ); binMappers.add( mapper ); } return new HistogramNd< K >( binMappers ); } // -- helpers -- private double min( final long pos ) { if ( pos < 0 || pos > bins - 1 ) { throw new IllegalArgumentException( "invalid bin position specified" ); } if ( tailBins ) { if ( pos == 0 ) return Double.NEGATIVE_INFINITY; if ( pos == bins - 1 ) return maxVal; return minVal + ( 1.0 * ( pos - 1 ) / ( bins - 2 ) ) * ( maxVal - minVal ); } return minVal + ( 1.0 * pos / ( bins ) ) * ( maxVal - minVal ); } private double max( final long pos ) { if ( pos < 0 || pos > bins - 1 ) { throw new IllegalArgumentException( "invalid bin position specified" ); } if ( tailBins ) { if ( pos == 0 ) return minVal; if ( pos == bins - 1 ) return Double.POSITIVE_INFINITY; return minVal + ( 1.0 * pos / ( bins - 2 ) ) * ( maxVal - minVal ); } return minVal + ( 1.0 * ( pos + 1 ) / ( bins ) ) * ( maxVal - minVal ); } private double center( final long pos ) { return ( min( pos ) + max( pos ) ) / 2; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/000077500000000000000000000000001316447754700217355ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/AbstractImg.java000066400000000000000000000117331316447754700250050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import java.util.Iterator; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.RealPositionable; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class AbstractImg< T > implements Img< T > { final protected int n; protected long numPixels; protected final long[] dimension; protected final long[] max; public AbstractImg( final long[] size ) { this.n = size.length; this.numPixels = numElements( size ); this.dimension = size.clone(); max = new long[ size.length ]; for ( int i = 0; i < size.length; ++i ) max[ i ] = size[ i ] - 1; } @Override public Iterator< T > iterator() { return cursor(); } @Override public T firstElement() { return cursor().next(); } public static long numElements( final long[] dim ) { long numPixels = 1; for ( int i = 0; i < dim.length; ++i ) numPixels *= dim[ i ]; return numPixels; } @Override public int numDimensions() { return n; } @Override public void dimensions( final long[] s ) { for ( int i = 0; i < n; ++i ) s[ i ] = dimension[ i ]; } @Override public long dimension( final int d ) { try { return this.dimension[ d ]; } catch ( final ArrayIndexOutOfBoundsException e ) { return 1; } } @Override public long size() { return numPixels; } @Override public String toString() { String className = this.getClass().getCanonicalName(); className = className.substring( className.lastIndexOf( "." ) + 1, className.length() ); String description = className + " [" + dimension[ 0 ]; for ( int i = 1; i < n; ++i ) description += "x" + dimension[ i ]; description += "]"; return description; } @Override public double realMax( final int d ) { return max[ d ]; } @Override public void realMax( final double[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = max[ d ]; } @Override public void realMax( final RealPositionable m ) { m.setPosition( max ); } @Override public double realMin( final int d ) { return 0; } @Override public void realMin( final double[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = 0; } @Override public void realMin( final RealPositionable m ) { for ( int d = 0; d < n; ++d ) m.setPosition( 0, d ); } @Override public long max( final int d ) { return max[ d ]; } @Override public void max( final long[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = max[ d ]; } @Override public void max( final Positionable m ) { m.setPosition( max ); } @Override public void min( final long[] m ) { for ( int d = 0; d < n; ++d ) m[ d ] = 0; } @Override public long min( final int d ) { return 0; } @Override public void min( final Positionable m ) { for ( int d = 0; d < n; ++d ) m.setPosition( 0, d ); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return randomAccess(); } // @Override // public OrthoSliceIterator< T > createOrthoSliceIterator( final Image< T > image, final int x, final int y, final int[] position ) // { // return new OrthoSliceIterator< T >( image, x, y, position ); // } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/AbstractNativeImg.java000066400000000000000000000052531316447754700261540ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class AbstractNativeImg< T extends NativeType< T >, A > extends AbstractImg< T > implements NativeImg< T, A > { final protected Fraction entitiesPerPixel; protected long numEntities; protected T linkedType; public AbstractNativeImg( final long[] dim, final Fraction entitiesPerPixel ) { super( dim ); this.entitiesPerPixel = entitiesPerPixel; this.numEntities = entitiesPerPixel.mulCeil( numPixels ); } @Override public void setLinkedType( final T type ) { this.linkedType = type; } @Override public T createLinkedType() { try { return linkedType.duplicateTypeOnSameNativeImg(); } catch ( final NullPointerException e ) { return null; } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/Img.java000066400000000000000000000055131316447754700233200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessibleInterval; /** * An {@link Img} is a {@link RandomAccessibleInterval} that has its min at * 0n and its max positive. {@link Img}s store pixels and * thus are the basis for conventional image processing. * * @author Stephan Saalfeld * @author Stephan Preibisch */ public interface Img< T > extends RandomAccessibleInterval< T >, IterableInterval< T > { /** * Get a {@link ImgFactory} that creates {@link Img}s of the same kind as * this one. * * This is useful to create Imgs for temporary storage in generic methods * where the specific Img type is unknown. Note, that the factory can be * used even if all references to this Img have been invalidated. * * @return a factory for Imgs of the same kind as this one. */ public ImgFactory< T > factory(); /** * @return - A copy of the current {@link Img} instance, all pixels are * duplicated */ public Img< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/ImgFactory.java000066400000000000000000000133101316447754700246420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import java.util.function.Supplier; import net.imglib2.Dimensions; import net.imglib2.exception.IncompatibleTypeException; import net.imglib2.type.NativeType; import net.imglib2.type.Type; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class ImgFactory< T > { /** * The {@link ImgFactory} can decide how to create the {@link Img}. A * {@link NativeImgFactory} will ask the {@link Type} to create a suitable * {@link NativeImg}. * * @return {@link Img} */ public abstract Img< T > create( final long[] dim, final T type ); /** * The {@link ImgFactory} can decide how to create the {@link Img}. A * {@link NativeImgFactory} will ask the {@link Type} to create a suitable * {@link NativeImg}. * * @return {@link Img} */ public Img< T > create( final Dimensions dim, final T type ) { final long[] size = new long[ dim.numDimensions() ]; dim.dimensions( size ); return create( size, type ); } /** * The {@link ImgFactory} can decide how to create the {@link Img}. A * {@link NativeImgFactory} will ask the {@link Type} to create a suitable * {@link NativeImg}. * * @return {@link Img} */ public Img< T > create( final int[] dim, final T type ) { return create( Util.int2long( dim ), type ); } /** * Creates the same {@link ImgFactory} for a different generic parameter if * possible. * * If the type "S" does not suit the needs of the {@link ImgFactory} (for * example implement {@link NativeType} in all {@link NativeImgFactory}, * this method will throw an {@link IncompatibleTypeException}. * * @param * the new type * @param type * an instance of S * @return {@link ImgFactory} of type S * @throws IncompatibleTypeException * if type S is not compatible */ public abstract < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException; /** * The {@link ImgFactory} can decide how to create the {@link Img}. A * {@link NativeImgFactory} will ask the supplied {@link Type} to create a * suitable {@link NativeImg}. * * @return {@link Img} */ public Img< T > create( final Supplier< T > typeSupplier, final long... dim ) { return create( dim, typeSupplier.get() ); } /** * The {@link ImgFactory} can decide how to create the {@link Img}. A * {@link NativeImgFactory} will ask the supplied {@link Type} to create a * suitable {@link NativeImg}. * * @return {@link Img} */ public Img< T > create( final Supplier< T > typeSupplier, final Dimensions dim ) { return create( dim, typeSupplier.get() ); } /** * The {@link ImgFactory} can decide how to create the {@link Img}. A * {@link NativeImgFactory} will ask the supplied {@link Type} to create a * suitable {@link NativeImg}. * *

* Note: This is not a vararg function because the underlying int[] * based methods alreay copies the int[] dimensions into a disposable * long[] anyways. This would be an unnecessary copy for int... varargs. *

* * @return {@link Img} */ public Img< T > create( final Supplier< T > typeSupplier, final int[] dim ) { return create( dim, typeSupplier.get() ); } /** * Creates the same {@link ImgFactory} for a different generic parameter if * possible. * * If the supplied type "S" does not suit the needs of the * {@link ImgFactory} (for example implement {@link NativeType} in all * {@link NativeImgFactory}, this method will throw an * {@link IncompatibleTypeException}. * * @param * the new type * @param typeSupplier * a supplier of S * @return {@link ImgFactory} of type S * @throws IncompatibleTypeException * if type S is not compatible */ public < S > ImgFactory< S > imgFactory( final Supplier< S > typeSupplier ) throws IncompatibleTypeException { return imgFactory( typeSupplier.get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/ImgView.java000066400000000000000000000131171316447754700241520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import net.imglib2.Cursor; import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.type.Type; import net.imglib2.view.IterableRandomAccessibleInterval; import net.imglib2.view.Views; import net.imglib2.view.iteration.SubIntervalIterable; /** * Allows a {@link RandomAccessibleInterval} to be treated as an {@link Img}. * * @author Tobias Pietzsch * @author Christian Dietz */ public class ImgView< T extends Type< T > > extends IterableRandomAccessibleInterval< T > implements Img< T >, SubIntervalIterable< T > { // factory private final ImgFactory< T > factory; // ImgView ii private final IterableInterval< T > ii; /** * View on {@link Img} which is defined by a given Interval, but still is an * {@link Img}. * * Deprecation: Use {@link ImgView#wrap(RandomAccessibleInterval, ImgFactory)} * to represent a RandomAccessibleInterval as an Img * * @param in * Source interval for the view * @param fac * T Factory to create img */ @Deprecated public ImgView( final RandomAccessibleInterval< T > in, final ImgFactory< T > fac ) { super( in ); factory = fac; ii = Views.flatIterable( in ); } @Override public ImgFactory< T > factory() { return factory; } @Override public Img< T > copy() { final Img< T > copy = factory.create( this, randomAccess().get() .createVariable() ); final Cursor< T > srcCursor = localizingCursor(); final RandomAccess< T > resAccess = copy.randomAccess(); while ( srcCursor.hasNext() ) { srcCursor.fwd(); resAccess.setPosition( srcCursor ); resAccess.get().set( srcCursor.get() ); } return copy; } @Override public Cursor< T > cursor() { return ii.cursor(); } @Override public Cursor< T > localizingCursor() { return ii.localizingCursor(); } @SuppressWarnings( "unchecked" ) @Override public boolean supportsOptimizedCursor( final Interval interval ) { if ( this.sourceInterval instanceof SubIntervalIterable ) return ( ( SubIntervalIterable< T > ) this.sourceInterval ).supportsOptimizedCursor( interval ); else return false; } @SuppressWarnings( "unchecked" ) @Override public Object subIntervalIterationOrder( final Interval interval ) { if ( this.sourceInterval instanceof SubIntervalIterable ) return ( ( SubIntervalIterable< T > ) this.sourceInterval ).subIntervalIterationOrder( interval ); else return new FlatIterationOrder( interval ); } @SuppressWarnings( "unchecked" ) @Override public Cursor< T > cursor( final Interval interval ) { if ( this.sourceInterval instanceof SubIntervalIterable ) return ( ( SubIntervalIterable< T > ) this.sourceInterval ).cursor( interval ); else return Views.interval( this.sourceInterval, interval ).cursor(); } @SuppressWarnings( "unchecked" ) @Override public Cursor< T > localizingCursor( final Interval interval ) { if ( this.sourceInterval instanceof SubIntervalIterable ) return ( ( SubIntervalIterable< T > ) this.sourceInterval ).localizingCursor( interval ); else return Views.interval( this.sourceInterval, interval ) .localizingCursor(); } /** * Represent an arbitrary RandomAccessibleInterval as an Img * * @param accessible * RandomAccessibleInterval which will be wrapped with an ImgView * @param factory * ImgFactory returned by {@link ImgView#factory()} * @return * RandomAccessibleInterval represented as an Img */ public static < T extends Type< T >> Img< T > wrap(final RandomAccessibleInterval< T > accessible, final ImgFactory< T > factory){ if(accessible instanceof Img){ return (Img) accessible; }else{ return new ImgView< T >(accessible, factory); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/NativeImg.java000066400000000000000000000044271316447754700244720ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import net.imglib2.type.Type; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface NativeImg< T extends Type< T >, A > extends Img< T > { /** * called by type with cursor. * * @param updater * cursor * @return native array which is referred to by the updater */ public A update( final Object updater ); public void setLinkedType( final T type ); public T createLinkedType(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/NativeImgFactory.java000066400000000000000000000073211316447754700260160ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import net.imglib2.img.basictypeaccess.ByteAccess; import net.imglib2.img.basictypeaccess.CharAccess; import net.imglib2.img.basictypeaccess.DoubleAccess; import net.imglib2.img.basictypeaccess.FloatAccess; import net.imglib2.img.basictypeaccess.IntAccess; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.ShortAccess; import net.imglib2.type.NativeType; import net.imglib2.type.Type; import net.imglib2.util.Fraction; /** * TODO * */ public abstract class NativeImgFactory< T extends NativeType< T > > extends ImgFactory< T > { /** * This class will ask the {@link Type} to create a suitable {@link Img} for * the {@link Type} and the dimensionality. * * {@link Type} will then call one of the abstract methods defined below to * create the {@link NativeImg} * * @return {@link Img} - the instantiated Container */ @Override public NativeImg< T, ? > create( final long[] dim, final T type ) { return type.createSuitableNativeImg( this, dim ); } /* basic type containers */ public abstract NativeImg< T, ? extends ByteAccess > createByteInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeImg< T, ? extends CharAccess > createCharInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeImg< T, ? extends ShortAccess > createShortInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeImg< T, ? extends IntAccess > createIntInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeImg< T, ? extends LongAccess > createLongInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeImg< T, ? extends FloatAccess > createFloatInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeImg< T, ? extends DoubleAccess > createDoubleInstance( long[] dimensions, Fraction entitiesPerPixel ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/WrappedImg.java000066400000000000000000000037461316447754700246510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; /** * An object that wraps an {@link Img} somehow. * * @author Christian Dietz */ public interface WrappedImg< T > { Img< T > getImg(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/000077500000000000000000000000001316447754700230535ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/AbstractArrayCursor.java000066400000000000000000000100501316447754700276520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.AbstractCursorInt; import net.imglib2.Cursor; import net.imglib2.type.NativeType; import net.imglib2.util.IntervalIndexer; /** * {@link Cursor} on an {@link ArrayImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Christian Dietz * @author Tobias Pietzsch */ //TODO Review Javadoc public abstract class AbstractArrayCursor< T extends NativeType< T > > extends AbstractCursorInt< T > { /** * Offset of this cursor */ protected final int offset; /** * Size of this cursor */ protected final int size; /** * An instance of T */ protected final T type; /** * Source image */ protected final ArrayImg< T, ? > img; /** * Last index */ protected final int lastIndex; /** * TODO Javadoc * * @param cursor */ protected AbstractArrayCursor( final AbstractArrayCursor< T > cursor ) { super( cursor.numDimensions() ); this.img = cursor.img; this.type = img.createLinkedType(); this.offset = cursor.offset; this.size = cursor.size; this.lastIndex = cursor.lastIndex; type.updateIndex( cursor.type.getIndex() ); type.updateContainer( this ); } /** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.img = img; this.lastIndex = offset + size - 1; this.offset = offset; this.size = size; reset(); } @Override public T get() { return type; } @Override public boolean hasNext() { return type.getIndex() < lastIndex; } @Override public void jumpFwd( final long steps ) { type.incIndex( ( int ) steps ); } @Override public void fwd() { type.incIndex(); } @Override public void reset() { type.updateIndex( offset - 1 ); type.updateContainer( this ); } @Override public String toString() { return type.toString(); } @Override public int getIntPosition( final int dim ) { return IntervalIndexer.indexToPosition( type.getIndex(), img.dim, dim ); } @Override public void localize( final int[] position ) { IntervalIndexer.indexToPosition( type.getIndex(), img.dim, position ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/AbstractArrayLocalizingCursor.java000066400000000000000000000122541316447754700316760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.AbstractLocalizingCursorInt; import net.imglib2.Cursor; import net.imglib2.type.NativeType; import net.imglib2.util.IntervalIndexer; /** * Localizing {@link Cursor} on an {@link ArrayImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Christian Dietz * @author Tobias Pietzsch * */ //TODO Review Javadoc public abstract class AbstractArrayLocalizingCursor< T extends NativeType< T > > extends AbstractLocalizingCursorInt< T > { /** * Size of this cursor. */ protected final int size; /** * Offset of this cursor. */ protected final int offset; /** * An instance of T. */ protected final T type; /** * The underlying source {@link ArrayImg}. */ protected final ArrayImg< T, ? > img; /** * Last index. */ protected final int lastIndex; /** * Maximum of the {@link ArrayImg} in every dimension. This is used to check * isOutOfBounds(). */ protected final int[] max; /** * TODO Javadoc * * @param cursor */ protected AbstractArrayLocalizingCursor( final AbstractArrayLocalizingCursor< T > cursor ) { super( cursor.numDimensions() ); this.img = cursor.img; this.type = img.createLinkedType(); this.offset = cursor.offset; this.size = cursor.size; this.lastIndex = offset + size - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) { position[ d ] = cursor.position[ d ]; max[ d ] = cursor.max[ d ]; } type.updateIndex( cursor.type.getIndex() ); type.updateContainer( this ); } /** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayLocalizingCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.img = img; this.offset = offset; this.size = size; this.type = img.createLinkedType(); this.lastIndex = offset + size - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) img.max( d ); reset(); } /** * {@inheritDoc} */ @Override public T get() { return type; } /** * {@inheritDoc} */ @Override public boolean hasNext() { return type.getIndex() < lastIndex; } /** * {@inheritDoc} */ @Override public void fwd() { type.incIndex(); // for ( int d = 0; d < n; ++d ) // { // if ( ++position[ d ] > max[ d ] ) position[ d ] = 0; // else break; // } /* * Benchmarks @ 2014-04-01 demonstrate that the less readable code below * is reliably 5-10% faster than the almost equivalent commented code * above. The reason is NOT simply that d=0 is executed outside the * loop. We have tested that and it does not provide improved speed when * done in the above version of the code. Below, it plays a role. */ if ( ++position[ 0 ] <= max[ 0 ] ) { return; } else { position[ 0 ] = 0; for ( int d = 1; d < n; ++d ) { if ( ++position[ d ] <= max[ d ] ) break; else position[ d ] = 0; } return; } } /** * {@inheritDoc} */ @Override public void jumpFwd( final long steps ) { type.incIndex( ( int ) steps ); IntervalIndexer.indexToPosition( type.getIndex(), img.dim, position ); } /** * {@inheritDoc} */ @Override public void reset() { type.updateIndex( offset - 1 ); IntervalIndexer.indexToPosition( offset, img.dim, position ); position[ 0 ]--; type.updateContainer( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayCursor.java000066400000000000000000000047221316447754700261770ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.Cursor; import net.imglib2.type.NativeType; /** * {@link Cursor} on an {@link ArrayImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public final class ArrayCursor< T extends NativeType< T > > extends AbstractArrayCursor< T > { protected ArrayCursor( final ArrayCursor< T > cursor ) { super( cursor ); } public ArrayCursor( final ArrayImg< T, ? > img ) { super( img, 0, ( int ) img.size() ); } @Override public ArrayCursor< T > copy() { return new ArrayCursor< T >( this ); } @Override public ArrayCursor< T > copyCursor() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayImg.java000066400000000000000000000147631316447754700254440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.Cursor; import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; import net.imglib2.img.AbstractNativeImg; import net.imglib2.img.Img; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Intervals; import net.imglib2.view.iteration.SubIntervalIterable; /** * This {@link Img} stores an image in a single linear array of basic types. By * that, it provides the fastest possible access to data while limiting the * number of basic types stored to {@link Integer#MAX_VALUE}. Keep in mind that * this does not necessarily reflect the number of pixels, because a pixel can * be stored in less than or more than a basic type entry. * * @param * @param
* * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ArrayImg< T extends NativeType< T >, A > extends AbstractNativeImg< T, A > implements SubIntervalIterable< T > { final int[] steps, dim; // the DataAccess created by the ArrayContainerFactory final private A data; // TODO check for the size of numPixels being < Integer.MAX_VALUE? // TODO Type is suddenly not necessary anymore public ArrayImg( final A data, final long[] dim, final Fraction entitiesPerPixel ) { super( dim, entitiesPerPixel ); this.dim = new int[ n ]; for ( int d = 0; d < n; ++d ) this.dim[ d ] = ( int ) dim[ d ]; this.steps = new int[ n ]; IntervalIndexer.createAllocationSteps( this.dim, this.steps ); this.data = data; } @Override public A update( final Object o ) { return data; } @Override public ArrayCursor< T > cursor() { return new ArrayCursor< T >( this ); } @Override public ArrayLocalizingCursor< T > localizingCursor() { return new ArrayLocalizingCursor< T >( this ); } @Override public ArrayRandomAccess< T > randomAccess() { return new ArrayRandomAccess< T >( this ); } @Override public ArrayRandomAccess< T > randomAccess( final Interval interval ) { return randomAccess(); } @Override public FlatIterationOrder iterationOrder() { return new FlatIterationOrder( this ); } @Override public ArrayImgFactory< T > factory() { return new ArrayImgFactory< T >(); } @Override public ArrayImg< T, ? > copy() { final ArrayImg< T, ? > copy = factory().create( dimension, firstElement().createVariable() ); final ArrayCursor< T > source = this.cursor(); final ArrayCursor< T > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); return copy; } /** * {@inheritDoc} */ @Override public Cursor< T > cursor( final Interval interval ) { final int dimLength = fastCursorAvailable( interval ); assert dimLength > 0; return new ArraySubIntervalCursor< T >( this, ( int ) offset( interval ), ( int ) size( interval, dimLength ) ); } private long size( final Interval interval, final int length ) { long size = interval.dimension( 0 ); for ( int d = 1; d < length; ++d ) { size *= interval.dimension( d ); } return size; } private long offset( final Interval interval ) { final int maxDim = numDimensions() - 1; long i = interval.min( maxDim ); for ( int d = maxDim - 1; d >= 0; --d ) { i = i * dimension( d ) + interval.min( d ); } return i; } /** * If method returns -1 no fast cursor is available, else the amount of dims * (starting from zero) which can be iterated fast are returned. */ private int fastCursorAvailable( final Interval interval ) { // first check whether the interval is completely contained. if ( !Intervals.contains( this, interval ) ) return -1; // find the first dimension in which image and interval differ int dimIdx = 0; for ( ; dimIdx < n; ++dimIdx ) if ( interval.dimension( dimIdx ) != dimension( dimIdx ) ) break; if ( dimIdx == n ) return dimIdx; // in the dimension after that, image and interval may differ ++dimIdx; // but image extents of all higher dimensions must equal 1 for ( int d = dimIdx; d < n; ++d ) if ( interval.dimension( d ) != 1 ) return -1; return dimIdx; } /** * {@inheritDoc} */ @Override public Cursor< T > localizingCursor( final Interval interval ) { final int dimLength = fastCursorAvailable( interval ); assert dimLength > 0; return new ArrayLocalizingSubIntervalCursor< T >( this, ( int ) offset( interval ), ( int ) size( interval, dimLength ) ); } /** * {@inheritDoc} */ @Override public boolean supportsOptimizedCursor( final Interval interval ) { return fastCursorAvailable( interval ) > 0; } /** * {@inheritDoc} */ @Override public Object subIntervalIterationOrder( final Interval interval ) { return new FlatIterationOrder( interval ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayImgFactory.java000066400000000000000000000133121316447754700267610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.exception.IncompatibleTypeException; import net.imglib2.img.AbstractImg; import net.imglib2.img.ImgFactory; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.CharArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * * * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ArrayImgFactory< T extends NativeType< T > > extends NativeImgFactory< T > { @Override public ArrayImg< T, ? > create( final long[] dim, final T type ) { return ( ArrayImg< T, ? > ) type.createSuitableNativeImg( this, dim ); } public static int numEntitiesRangeCheck( final long[] dimensions, final Fraction entitiesPerPixel ) { final long numEntities = entitiesPerPixel.mulCeil( AbstractImg.numElements( dimensions ) ); if ( numEntities > Integer.MAX_VALUE ) throw new RuntimeException( "Number of elements in Container too big, use for example CellContainer instead: " + numEntities + " > " + Integer.MAX_VALUE ); return ( int ) numEntities; } @Override public ArrayImg< T, ByteArray > createByteInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, ByteArray >( new ByteArray( numEntities ), dimensions, entitiesPerPixel ); } @Override public ArrayImg< T, CharArray> createCharInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, CharArray >( new CharArray( numEntities ), dimensions, entitiesPerPixel ); } @Override public ArrayImg< T, DoubleArray > createDoubleInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, DoubleArray >( new DoubleArray( numEntities ), dimensions, entitiesPerPixel ); } @Override public ArrayImg< T, FloatArray > createFloatInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, FloatArray >( new FloatArray( numEntities ), dimensions, entitiesPerPixel ); } @Override public ArrayImg< T, IntArray > createIntInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, IntArray >( new IntArray( numEntities ), dimensions, entitiesPerPixel ); } @Override public ArrayImg< T, LongArray > createLongInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, LongArray >( new LongArray( numEntities ), dimensions, entitiesPerPixel ); } @Override public ArrayImg< T, ShortArray > createShortInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { final int numEntities = numEntitiesRangeCheck( dimensions, entitiesPerPixel ); return new ArrayImg< T, ShortArray >( new ShortArray( numEntities ), dimensions, entitiesPerPixel ); } @SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { if ( NativeType.class.isInstance( type ) ) return new ArrayImgFactory(); throw new IncompatibleTypeException( this, type.getClass().getCanonicalName() + " does not implement NativeType." ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayImgs.java000066400000000000000000000450641316447754700256250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.img.basictypeaccess.ByteAccess; import net.imglib2.img.basictypeaccess.DoubleAccess; import net.imglib2.img.basictypeaccess.FloatAccess; import net.imglib2.img.basictypeaccess.IntAccess; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.ShortAccess; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.Type; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.complex.ComplexDoubleType; import net.imglib2.type.numeric.complex.ComplexFloatType; import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.LongType; import net.imglib2.type.numeric.integer.ShortType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.integer.UnsignedIntType; import net.imglib2.type.numeric.integer.UnsignedLongType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.Fraction; /** *

* Convenience factory methods for creation of {@link ArrayImg} instances with * the most common pixel {@link Type} variants. The collection includes * factories to re-use existing primitive type arrays as data. This can be used * for in-place access to data from other libraries such as AWT or ImageJ. Keep * in mind that this cannot be a complete collection since the number of * existing pixel {@link Type}s may be extended. *

* *

* For pixel {@link Type}s T not present in this collection, use the generic * {@link ArrayImgFactory#create(long[], net.imglib2.type.NativeType)}, e.g. *

* *
 * img = new ArrayImgFactory< MyType >.create( new long[] { 100, 200 }, new MyType() );
 * 
* * @author Stephan Saalfeld * @author Philipp Hanslovsky */ final public class ArrayImgs { private ArrayImgs() {} /** * Create an {@link ArrayImg}<{@link UnsignedByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< UnsignedByteType, ByteArray > unsignedBytes( final long... dim ) { return ( ArrayImg< UnsignedByteType, ByteArray > ) new ArrayImgFactory< UnsignedByteType >().create( dim, new UnsignedByteType() ); } /** * Creates an {@link ArrayImg}<{@link UnsignedByteType}, {@link ByteArray}> * reusing a passed byte[] array. */ final public static ArrayImg< UnsignedByteType, ByteArray > unsignedBytes( final byte[] array, final long... dim ) { return unsignedBytes( new ByteArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link UnsignedByteType}, * {@link ByteAccess}> using a {@link ByteAccess} passed as argument. */ final public static < A extends ByteAccess > ArrayImg< UnsignedByteType, A > unsignedBytes( final A access, final long... dim ) { final ArrayImg< UnsignedByteType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final UnsignedByteType t = new UnsignedByteType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link ByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< ByteType, ByteArray > bytes( final long... dim ) { return ( ArrayImg< ByteType, ByteArray > ) new ArrayImgFactory< ByteType >().create( dim, new ByteType() ); } /** * Creates an {@link ArrayImg}<{@link ByteType}, {@link ByteArray}> reusing * a passed byte[] array. */ final public static ArrayImg< ByteType, ByteArray > bytes( final byte[] array, final long... dim ) { return bytes( new ByteArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link ByteType}, {@link ByteAccess}> * using a {@link ByteAccess} passed as argument. */ final public static < A extends ByteAccess > ArrayImg< ByteType, A > bytes( final A access, final long... dim ) { final ArrayImg< ByteType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final ByteType t = new ByteType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link UnsignedShortType}, * {@link ShortArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< UnsignedShortType, ShortArray > unsignedShorts( final long... dim ) { return ( ArrayImg< UnsignedShortType, ShortArray > ) new ArrayImgFactory< UnsignedShortType >().create( dim, new UnsignedShortType() ); } /** * Creates an {@link ArrayImg}<{@link UnsignedShortType}, * {@link ShortArray}> reusing a passed short[] array. */ final public static ArrayImg< UnsignedShortType, ShortArray > unsignedShorts( final short[] array, final long... dim ) { return unsignedShorts( new ShortArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link UnsignedShortType}, * {@link ShortAccess}> using a {@link ShortAccess} passed as argument. */ final public static < A extends ShortAccess > ArrayImg< UnsignedShortType, A > unsignedShorts( final A access, final long... dim ) { final ArrayImg< UnsignedShortType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final UnsignedShortType t = new UnsignedShortType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link ShortType}, {@link ShortArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< ShortType, ShortArray > shorts( final long... dim ) { return ( ArrayImg< ShortType, ShortArray > ) new ArrayImgFactory< ShortType >().create( dim, new ShortType() ); } /** * Creates an {@link ArrayImg}<{@link ShortType}, {@link ShortArray}> * reusing a passed short[] array. */ final public static ArrayImg< ShortType, ShortArray > shorts( final short[] array, final long... dim ) { return shorts( new ShortArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link ShortType}, {@link ShortAccess}> * using a {@link ShortAccess} passed as argument. */ final public static < A extends ShortAccess > ArrayImg< ShortType, A > shorts( final A access, final long... dim ) { final ArrayImg< ShortType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final ShortType t = new ShortType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link UnsignedIntType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< UnsignedIntType, IntArray > unsignedInts( final long... dim ) { return ( ArrayImg< UnsignedIntType, IntArray > ) new ArrayImgFactory< UnsignedIntType >().create( dim, new UnsignedIntType() ); } /** * Creates an {@link ArrayImg}<{@link UnsignedIntType}, {@link IntArray}> * reusing a passed int[] array. */ final public static ArrayImg< UnsignedIntType, IntArray > unsignedInts( final int[] array, final long... dim ) { return unsignedInts( new IntArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link UnsignedIntType}, * {@link IntAccess}> using a {@link IntAccess} passed as argument. */ final public static < A extends IntAccess > ArrayImg< UnsignedIntType, A > unsignedInts( final A access, final long... dim ) { final ArrayImg< UnsignedIntType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final UnsignedIntType t = new UnsignedIntType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link IntType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< IntType, IntArray > ints( final long... dim ) { return ( ArrayImg< IntType, IntArray > ) new ArrayImgFactory< IntType >().create( dim, new IntType() ); } /** * Creates an {@link ArrayImg}<{@link IntType}, {@link IntArray}> reusing a * passed int[] array. */ final public static ArrayImg< IntType, IntArray > ints( final int[] array, final long... dim ) { return ints( new IntArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link IntType}, {@link IntAccess}> * using a {@link IntAccess} passed as argument. */ final public static < A extends IntAccess > ArrayImg< IntType, A > ints( final A access, final long... dim ) { final ArrayImg< IntType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final IntType t = new IntType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link UnsignedLongType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< UnsignedLongType, LongArray > unsignedLongs( final long... dim ) { return ( ArrayImg< UnsignedLongType, LongArray > ) new ArrayImgFactory< UnsignedLongType >().create( dim, new UnsignedLongType() ); } /** * Creates an {@link ArrayImg}<{@link UnsignedLongType}, {@link LongArray}> * reusing a passed long[] array. */ final public static ArrayImg< UnsignedLongType, LongArray > unsignedLongss( final long[] array, final long... dim ) { return unsignedLongs( new LongArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link UnsignedLongType}, * {@link LongAccess}> using a {@link LongAccess} passed as argument. */ final public static < A extends LongAccess > ArrayImg< UnsignedLongType, A > unsignedLongs( final A access, final long... dim ) { final ArrayImg< UnsignedLongType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final UnsignedLongType t = new UnsignedLongType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link LongType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< LongType, LongArray > longs( final long... dim ) { return ( ArrayImg< LongType, LongArray > ) new ArrayImgFactory< LongType >().create( dim, new LongType() ); } /** * Creates an {@link ArrayImg}<{@link LongType}, {@link LongArray}> reusing * a passed long[] array. */ final public static ArrayImg< LongType, LongArray > longs( final long[] array, final long... dim ) { return longs( new LongArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link LongType}, {@link LongAccess}> * using a {@link LongAccess} passed as argument. */ final public static < A extends LongAccess > ArrayImg< LongType, A > longs( final A access, final long... dim ) { final ArrayImg< LongType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final LongType t = new LongType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link BitType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< BitType, LongArray > bits( final long... dim ) { return ( ArrayImg< BitType, LongArray > ) new ArrayImgFactory< BitType >().create( dim, new BitType() ); } /** * Creates an {@link ArrayImg}<{@link BitType}, {@link LongAccess}> * using a {@link LongAccess} passed as argument. */ final static public < A extends LongAccess > ArrayImg< BitType, A > bits( final A access, final long... dim ) { final ArrayImg< BitType, A > img = new ArrayImg<>( access, dim, new Fraction( 1, 64 ) ); final BitType t = new BitType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link FloatType}, {@link FloatArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< FloatType, FloatArray > floats( final long... dim ) { return ( ArrayImg< FloatType, FloatArray > ) new ArrayImgFactory< FloatType >().create( dim, new FloatType() ); } /** * Creates an {@link ArrayImg}<{@link FloatType}, {@link FloatArray}> * reusing a passed float[] array. */ final public static ArrayImg< FloatType, FloatArray > floats( final float[] array, final long... dim ) { return floats( new FloatArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link FloatType}, {@link FloatAccess}> * using a {@link FloatAccess} passed as argument. */ final static public < A extends FloatAccess > ArrayImg< FloatType, A > floats( final A access, final long... dim ) { final ArrayImg< FloatType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final FloatType t = new FloatType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link DoubleType}, {@link DoubleArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< DoubleType, DoubleArray > doubles( final long... dim ) { return ( ArrayImg< DoubleType, DoubleArray > ) new ArrayImgFactory< DoubleType >().create( dim, new DoubleType() ); } /** * Creates an {@link ArrayImg}<{@link DoubleType}, {@link DoubleArray}> * reusing a passed double[] array. */ final public static ArrayImg< DoubleType, DoubleArray > doubles( final double[] array, final long... dim ) { return doubles( new DoubleArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link DoubleType}, * {@link DoubleAccess}> using a {@link DoubleAccess} passed as argument. */ final static public < A extends DoubleAccess > ArrayImg< DoubleType, A > doubles( final A access, final long... dim ) { final ArrayImg< DoubleType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final DoubleType t = new DoubleType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link ARGBType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< ARGBType, IntArray > argbs( final long... dim ) { return ( ArrayImg< ARGBType, IntArray > ) new ArrayImgFactory< ARGBType >().create( dim, new ARGBType() ); } /** * Creates an {@link ArrayImg}<{@link ARGBType}, {@link IntArray}> reusing a * passed int[] array. */ final public static ArrayImg< ARGBType, IntArray > argbs( final int[] array, final long... dim ) { return argbs( new IntArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link ARGBType}, {@link IntAccess}> * using a {@link IntAccess} passed as argument. */ final static public < A extends IntAccess > ArrayImg< ARGBType, A > argbs( final A access, final long... dim ) { final ArrayImg< ARGBType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final ARGBType t = new ARGBType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link ComplexFloatType}, {@link FloatArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< ComplexFloatType, FloatArray > complexFloats( final long... dim ) { return ( ArrayImg< ComplexFloatType, FloatArray > ) new ArrayImgFactory< ComplexFloatType >().create( dim, new ComplexFloatType() ); } /** * Creates an {@link ArrayImg}<{@link FloatType}, {@link FloatArray}> * reusing a passed float[] array. */ final public static ArrayImg< ComplexFloatType, FloatArray > complexFloats( final float[] array, final long... dim ) { return complexFloats( new FloatArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link ComplexFloatType}, * {@link FloatAccess}> using a {@link FloatAccess} passed as argument. */ final public static < A extends FloatAccess > ArrayImg< ComplexFloatType, A > complexFloats( final A access, final long... dim ) { final ArrayImg< ComplexFloatType, A > img = new ArrayImg<>( access, dim, new Fraction( 2, 1 ) ); final ComplexFloatType t = new ComplexFloatType( img ); img.setLinkedType( t ); return img; } /** * Create an {@link ArrayImg}<{@link ComplexDoubleType}, * {@link DoubleArray}>. */ @SuppressWarnings( "unchecked" ) final static public ArrayImg< ComplexDoubleType, DoubleArray > complexDoubles( final long... dim ) { return ( ArrayImg< ComplexDoubleType, DoubleArray > ) new ArrayImgFactory< ComplexDoubleType >().create( dim, new ComplexDoubleType() ); } /** * Creates an {@link ArrayImg}<{@link DoubleType}, {@link DoubleArray}> * reusing a passed double[] array. */ final public static ArrayImg< ComplexDoubleType, DoubleArray > complexDoubles( final double[] array, final long... dim ) { return complexDoubles( new DoubleArray( array ), dim ); } /** * Creates an {@link ArrayImg}<{@link ComplexDoubleType}, * {@link DoubleAccess}> using a {@link DoubleAccess} passed as argument. */ final public static < A extends DoubleAccess > ArrayImg< ComplexDoubleType, A > complexDoubles( final A access, final long... dim ) { final ArrayImg< ComplexDoubleType, A > img = new ArrayImg<>( access, dim, new Fraction( 2, 1 ) ); final ComplexDoubleType t = new ComplexDoubleType( img ); img.setLinkedType( t ); return img; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayLocalizingCursor.java000066400000000000000000000052521316447754700302120ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.Cursor; import net.imglib2.type.NativeType; /** * Localizing {@link Cursor} on an {@link ArrayImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public final class ArrayLocalizingCursor< T extends NativeType< T > > extends AbstractArrayLocalizingCursor< T > { /** * TODO Javadoc * * @param cursor */ protected ArrayLocalizingCursor( final ArrayLocalizingCursor< T > cursor ) { super( cursor ); } /** * TODO Javadoc * * @param img */ public ArrayLocalizingCursor( final ArrayImg< T, ? > img ) { super( img, 0, ( int ) img.size() ); } /** * {@inheritDoc} */ @Override public ArrayLocalizingCursor< T > copy() { return new ArrayLocalizingCursor< T >( this ); } @Override public ArrayLocalizingCursor< T > copyCursor() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayLocalizingSubIntervalCursor.java000066400000000000000000000054571316447754700324000ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.type.NativeType; /** * Localizing {@link AbstractArrayLocalizingCursor} on an {@link ArrayImg}. * * @param * * @author Christian Dietz * @author Tobias Pietzsch */ public final class ArrayLocalizingSubIntervalCursor< T extends NativeType< T > > extends AbstractArrayLocalizingCursor< T > { /** * TODO Javadoc * * @param img * @param offset * @param size */ protected ArrayLocalizingSubIntervalCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img, offset, size ); } /** * TODO Javadoc * * @param cursor */ protected ArrayLocalizingSubIntervalCursor( final ArrayLocalizingSubIntervalCursor< T > cursor ) { super( cursor ); } /** * {@inheritDoc} */ @Override public ArrayLocalizingSubIntervalCursor< T > copy() { return new ArrayLocalizingSubIntervalCursor< T >( this ); } @Override public ArrayLocalizingSubIntervalCursor< T > copyCursor() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArrayRandomAccess.java000066400000000000000000000157151316447754700272700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.AbstractLocalizableInt; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.type.NativeType; /** * {@link RandomAccess} on an {@link ArrayImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class ArrayRandomAccess< T extends NativeType< T > > extends AbstractLocalizableInt implements RandomAccess< T > { protected final T type; final ArrayImg< T, ? > img; protected ArrayRandomAccess( final ArrayRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); this.img = randomAccess.img; this.type = img.createLinkedType(); int index = 0; for ( int d = 0; d < n; d++ ) { position[ d ] = randomAccess.position[ d ]; index += position[ d ] * img.steps[ d ]; } type.updateContainer( this ); type.updateIndex( index ); } public ArrayRandomAccess( final ArrayImg< T, ? > container ) { super( container.numDimensions() ); this.img = container; this.type = container.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = 0; type.updateContainer( this ); type.updateIndex( 0 ); } @Override public T get() { return type; } @Override public void fwd( final int d ) { type.incIndex( img.steps[ d ] ); ++position[ d ]; } @Override public void bck( final int d ) { type.decIndex( img.steps[ d ] ); --position[ d ]; } @Override public void move( final int distance, final int d ) { type.incIndex( img.steps[ d ] * distance ); position[ d ] += distance; } @Override public void move( final long distance, final int d ) { type.incIndex( img.steps[ d ] * ( int ) distance ); position[ d ] += distance; } @Override public void move( final Localizable localizable ) { int index = 0; for ( int d = 0; d < n; ++d ) { final int distance = localizable.getIntPosition( d ); position[ d ] += distance; index += distance * img.steps[ d ]; } type.incIndex( index ); } @Override public void move( final int[] distance ) { int index = 0; for ( int d = 0; d < n; ++d ) { position[ d ] += distance[ d ]; index += distance[ d ] * img.steps[ d ]; } type.incIndex( index ); } @Override public void move( final long[] distance ) { int index = 0; for ( int d = 0; d < n; ++d ) { position[ d ] += distance[ d ]; index += distance[ d ] * img.steps[ d ]; } type.incIndex( index ); } @Override public void setPosition( final Localizable localizable ) { localizable.localize( position ); int index = 0; for ( int d = 0; d < n; ++d ) index += position[ d ] * img.steps[ d ]; type.updateIndex( index ); } @Override public void setPosition( final int[] pos ) { int index = 0; for ( int d = 0; d < n; ++d ) { position[ d ] = pos[ d ]; index += pos[ d ] * img.steps[ d ]; } type.updateIndex( index ); } @Override public void setPosition( final long[] pos ) { int index = 0; for ( int d = 0; d < n; ++d ) { final int p = ( int ) pos[ d ]; position[ d ] = p; index += p * img.steps[ d ]; } type.updateIndex( index ); } @Override public void setPosition( final int pos, final int d ) { type.incIndex( ( pos - position[ d ] ) * img.steps[ d ] ); position[ d ] = pos; } @Override public void setPosition( final long pos, final int d ) { type.incIndex( ( ( int ) pos - position[ d ] ) * img.steps[ d ] ); position[ d ] = ( int ) pos; } @Override public ArrayRandomAccess< T > copy() { return new ArrayRandomAccess< T >( this ); } @Override public ArrayRandomAccess< T > copyRandomAccess() { return copy(); } /* Special methods for access in one-dimensional arrays only */ /** * Moves one step forward in dimension 0 */ public void fwdDim0() { type.incIndex(); ++position[ 0 ]; } /** * Moves one step backward in dimension 0 */ public void bckDim0() { type.decIndex(); --position[ 0 ]; } /** * Moves n steps in dimension 0 * * @param distance * - how many steps (positive or negative) */ public void moveDim0( final int distance ) { type.incIndex( distance ); position[ 0 ] += distance; } /** * Moves n steps in dimension 0 * * @param distance * - how many steps (positive or negative) */ public void move( final long distance ) { type.incIndex( ( int ) distance ); position[ 0 ] += distance; } /** * Sets the {@link ArrayRandomAccess} to a certain position in dimension 0 * * Careful: it assumes that it is only a one-dimensional image, all other * dimensions would be set to zero (this saves one subtraction) * * @param pos * - the new position */ public void setPositionDim0( final int pos ) { type.updateIndex( pos ); position[ 0 ] = pos; } /** * Sets the {@link ArrayRandomAccess} to a certain position in dimension 0 * * Careful: it assumes that it is only a one-dimensional image, all other * dimensions would be set to zero (this saves one subtraction) * * @param pos * - the new position */ public void setPositionDim0( final long pos ) { type.updateIndex( ( int ) pos ); position[ 0 ] = ( int ) pos; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/array/ArraySubIntervalCursor.java000066400000000000000000000053271316447754700303600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import net.imglib2.Cursor; import net.imglib2.type.NativeType; /** * {@link Cursor} on an {@link ArrayImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public final class ArraySubIntervalCursor< T extends NativeType< T > > extends AbstractArrayCursor< T > { /** * TODO Javadoc * * @param cursor */ protected ArraySubIntervalCursor( final ArraySubIntervalCursor< T > cursor ) { super( cursor ); } /** * TODO Javadoc * * @param img * @param offset * @param size */ public ArraySubIntervalCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img, offset, size ); } /** * {@inheritDoc} */ @Override public ArraySubIntervalCursor< T > copy() { return new ArraySubIntervalCursor< T >( this ); } @Override public ArraySubIntervalCursor< T > copyCursor() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/000077500000000000000000000000001316447754700251025ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/ByteAccess.java000066400000000000000000000040721316447754700277750ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface ByteAccess { public byte getValue( final int index ); public void setValue( final int index, final byte value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/CharAccess.java000066400000000000000000000040721316447754700277470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface CharAccess { public char getValue( final int index ); public void setValue( final int index, final char value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/DoubleAccess.java000066400000000000000000000041001316447754700302740ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface DoubleAccess { public double getValue( final int index ); public void setValue( final int index, final double value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/FloatAccess.java000066400000000000000000000040751316447754700301420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface FloatAccess { public float getValue( final int index ); public void setValue( final int index, final float value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/IntAccess.java000066400000000000000000000040671316447754700276300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface IntAccess { public int getValue( final int index ); public void setValue( final int index, final int value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/LongAccess.java000066400000000000000000000040721316447754700277710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface LongAccess { public long getValue( final int index ); public void setValue( final int index, final long value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/PlanarAccess.java000066400000000000000000000041361316447754700303100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * Interface allowing access to data on a plane-by-plane basis. * * @param
* primitive array type * @author Curtis Rueden */ public interface PlanarAccess< A > { A getPlane( int no ); void setPlane( int no, A plane ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/ShortAccess.java000066400000000000000000000040751316447754700301740ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface ShortAccess { public short getValue( final int index ); public void setValue( final int index, final short value ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/000077500000000000000000000000001316447754700262205ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractByteArray.java000066400000000000000000000050431316447754700324530ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.ByteAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractByteArray< A extends AbstractByteArray< A > > implements ByteAccess, ArrayDataAccess< A > { protected byte data[]; public AbstractByteArray( final int numEntities ) { this.data = new byte[ numEntities ]; } public AbstractByteArray( final byte[] data ) { this.data = data; } @Override public byte getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final byte value ) { data[ index ] = value; } @Override public byte[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractCharArray.java000066400000000000000000000050431316447754700324250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.CharAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractCharArray< A extends AbstractCharArray< A > > implements CharAccess, ArrayDataAccess< A > { protected char data[]; public AbstractCharArray( final int numEntities ) { this.data = new char[ numEntities ]; } public AbstractCharArray( final char[] data ) { this.data = data; } @Override public char getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final char value ) { data[ index ] = value; } @Override public char[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractDoubleArray.java000066400000000000000000000050731316447754700327650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.DoubleAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractDoubleArray< A extends AbstractDoubleArray< A > > implements DoubleAccess, ArrayDataAccess< A > { protected double data[]; public AbstractDoubleArray( final int numEntities ) { this.data = new double[ numEntities ]; } public AbstractDoubleArray( final double[] data ) { this.data = data; } @Override public double getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final double value ) { data[ index ] = value; } @Override public double[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractFloatArray.java000066400000000000000000000050571316447754700326220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.FloatAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractFloatArray< A extends AbstractFloatArray< A > > implements FloatAccess, ArrayDataAccess< A > { protected float data[]; public AbstractFloatArray( final int numEntities ) { this.data = new float[ numEntities ]; } public AbstractFloatArray( final float[] data ) { this.data = data; } @Override public float getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final float value ) { data[ index ] = value; } @Override public float[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractIntArray.java000066400000000000000000000050271316447754700323040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.IntAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractIntArray< A extends AbstractIntArray< A > > implements IntAccess, ArrayDataAccess< A > { protected int data[]; public AbstractIntArray( final int numEntities ) { this.data = new int[ numEntities ]; } public AbstractIntArray( final int[] data ) { this.data = data; } @Override public int getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final int value ) { data[ index ] = value; } @Override public int[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractLongArray.java000066400000000000000000000050431316447754700324470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.LongAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractLongArray< A extends AbstractLongArray< A > > implements LongAccess, ArrayDataAccess< A > { protected long data[]; public AbstractLongArray( final int numEntities ) { this.data = new long[ numEntities ]; } public AbstractLongArray( final long[] data ) { this.data = data; } @Override public long getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final long value ) { data[ index ] = value; } @Override public long[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/AbstractShortArray.java000066400000000000000000000050571316447754700326540ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.img.basictypeaccess.ShortAccess; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ abstract public class AbstractShortArray< A extends AbstractShortArray< A > > implements ShortAccess, ArrayDataAccess< A > { protected short data[]; public AbstractShortArray( final int numEntities ) { this.data = new short[ numEntities ]; } public AbstractShortArray( final short[] data ) { this.data = data; } @Override public short getValue( final int index ) { return data[ index ]; } @Override public void setValue( final int index, final short value ) { data[ index ] = value; } @Override public short[] getCurrentStorageArray() { return data; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/ArrayDataAccess.java000066400000000000000000000043361316447754700320630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import java.io.Serializable; /** * Trivial interface for primitive array based data access implementations * that can replicate themselves and return the underlying array. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface ArrayDataAccess< A > extends Serializable { A createArray( int numEntities ); Object getCurrentStorageArray(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/ByteArray.java000066400000000000000000000043501316447754700307670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ByteArray extends AbstractByteArray< ByteArray > { public ByteArray( final int numEntities ) { super( numEntities ); } public ByteArray( final byte[] data ) { super( data ); } @Override public ByteArray createArray( final int numEntities ) { return new ByteArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/CharArray.java000066400000000000000000000043501316447754700307410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class CharArray extends AbstractCharArray< CharArray > { public CharArray( final int numEntities ) { super( numEntities ); } public CharArray( final char[] data ) { super( data ); } @Override public CharArray createArray( final int numEntities ) { return new CharArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyByteArray.java000066400000000000000000000050441316447754700320040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyByteArray extends AbstractByteArray< DirtyByteArray > implements Dirty { protected boolean dirty = false; public DirtyByteArray( final int numEntities ) { super( numEntities ); } public DirtyByteArray( final byte[] data ) { super( data ); } @Override public void setValue( final int index, final byte value ) { dirty = true; data[ index ] = value; } @Override public DirtyByteArray createArray( final int numEntities ) { return new DirtyByteArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyCharArray.java000066400000000000000000000050441316447754700317560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyCharArray extends AbstractCharArray< DirtyCharArray > implements Dirty { protected boolean dirty = false; public DirtyCharArray( final int numEntities ) { super( numEntities ); } public DirtyCharArray( final char[] data ) { super( data ); } @Override public void setValue( final int index, final char value ) { dirty = true; data[ index ] = value; } @Override public DirtyCharArray createArray( final int numEntities ) { return new DirtyCharArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyDoubleArray.java000066400000000000000000000050661316447754700323170ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyDoubleArray extends AbstractDoubleArray< DirtyDoubleArray > implements Dirty { protected boolean dirty = false; public DirtyDoubleArray( final int numEntities ) { super( numEntities ); } public DirtyDoubleArray( final double[] data ) { super( data ); } @Override public void setValue( final int index, final double value ) { dirty = true; data[ index ] = value; } @Override public DirtyDoubleArray createArray( final int numEntities ) { return new DirtyDoubleArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyFloatArray.java000066400000000000000000000050551316447754700321500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyFloatArray extends AbstractFloatArray< DirtyFloatArray > implements Dirty { protected boolean dirty = false; public DirtyFloatArray( final int numEntities ) { super( numEntities ); } public DirtyFloatArray( final float[] data ) { super( data ); } @Override public void setValue( final int index, final float value ) { dirty = true; data[ index ] = value; } @Override public DirtyFloatArray createArray( final int numEntities ) { return new DirtyFloatArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyIntArray.java000066400000000000000000000050331316447754700316310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyIntArray extends AbstractIntArray< DirtyIntArray > implements Dirty { protected boolean dirty = false; public DirtyIntArray( final int numEntities ) { super( numEntities ); } public DirtyIntArray( final int[] data ) { super( data ); } @Override public void setValue( final int index, final int value ) { dirty = true; data[ index ] = value; } @Override public DirtyIntArray createArray( final int numEntities ) { return new DirtyIntArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyLongArray.java000066400000000000000000000050441316447754700320000ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyLongArray extends AbstractLongArray< DirtyLongArray > implements Dirty { protected boolean dirty = false; public DirtyLongArray( final int numEntities ) { super( numEntities ); } public DirtyLongArray( final long[] data ) { super( data ); } @Override public void setValue( final int index, final long value ) { dirty = true; data[ index ] = value; } @Override public DirtyLongArray createArray( final int numEntities ) { return new DirtyLongArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DirtyShortArray.java000066400000000000000000000050551316447754700322020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; import net.imglib2.Dirty; /** * * @author Stephan Saalfeld */ public class DirtyShortArray extends AbstractShortArray< DirtyShortArray > implements Dirty { protected boolean dirty = false; public DirtyShortArray( final int numEntities ) { super( numEntities ); } public DirtyShortArray( final short[] data ) { super( data ); } @Override public void setValue( final int index, final short value ) { dirty = true; data[ index ] = value; } @Override public DirtyShortArray createArray( final int numEntities ) { return new DirtyShortArray( numEntities ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/DoubleArray.java000066400000000000000000000044001316447754700312720ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class DoubleArray extends AbstractDoubleArray< DoubleArray > { public DoubleArray( final int numEntities ) { super( numEntities ); } public DoubleArray( final double[] data ) { super( data ); } @Override public DoubleArray createArray( final int numEntities ) { return new DoubleArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/FloatArray.java000066400000000000000000000043701316447754700311330ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class FloatArray extends AbstractFloatArray< FloatArray > { public FloatArray( final int numEntities ) { super( numEntities ); } public FloatArray( final float[] data ) { super( data ); } @Override public FloatArray createArray( final int numEntities ) { return new FloatArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/IntArray.java000066400000000000000000000043701316447754700306200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class IntArray extends AbstractIntArray< IntArray > { protected int data[]; public IntArray( final int numEntities ) { super( numEntities ); } public IntArray( final int[] data ) { super( data ); } @Override public IntArray createArray( final int numEntities ) { return new IntArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/LongArray.java000066400000000000000000000043501316447754700307630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class LongArray extends AbstractLongArray< LongArray > { public LongArray( final int numEntities ) { super( numEntities ); } public LongArray( final long[] data ) { super( data ); } @Override public LongArray createArray( final int numEntities ) { return new LongArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/array/ShortArray.java000066400000000000000000000044121316447754700311620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.array; /** * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ShortArray extends AbstractShortArray< ShortArray > { protected short data[]; public ShortArray( final int numEntities ) { super( numEntities ); } public ShortArray( final short[] data ) { super( data ); } @Override public ShortArray createArray( final int numEntities ) { return new ShortArray( numEntities ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/000077500000000000000000000000001316447754700271045ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/VolatileAccess.java000066400000000000000000000034151316447754700326530ustar00rootroot00000000000000/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; /** * A basic type access that can contain valid or invalid data. * * @author Tobias Pietzsch <tobias.pietzsch@gmail.com> */ public interface VolatileAccess { boolean isValid(); } VolatileArrayDataAccess.java000066400000000000000000000036121316447754700343640ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.array.ArrayDataAccess; /** * An {@link ArrayDataAccess} that can contain valid or invalid data. * * @author Tobias Pietzsch */ public interface VolatileArrayDataAccess< A > extends ArrayDataAccess< A >, VolatileAccess { A createArray( int numEntities, boolean isValid ); } VolatileByteAccess.java000066400000000000000000000034121316447754700334150ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.ByteAccess; /** * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface VolatileByteAccess extends ByteAccess, VolatileAccess {} VolatileCharAccess.java000066400000000000000000000034121316447754700333670ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.CharAccess; /** * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface VolatileCharAccess extends CharAccess, VolatileAccess {} VolatileDoubleAccess.java000066400000000000000000000034201316447754700337230ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.DoubleAccess; /** * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface VolatileDoubleAccess extends DoubleAccess, VolatileAccess {} VolatileFloatAccess.java000066400000000000000000000033601316447754700335610ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.FloatAccess; /** * @author Tobias Pietzsch */ public interface VolatileFloatAccess extends FloatAccess, VolatileAccess {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/VolatileIntAccess.java000066400000000000000000000034061316447754700333260ustar00rootroot00000000000000/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.IntAccess; /** * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface VolatileIntAccess extends IntAccess, VolatileAccess {} VolatileLongAccess.java000066400000000000000000000034111316447754700334100ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.LongAccess; /** * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface VolatileLongAccess extends LongAccess, VolatileAccess {} VolatileShortAccess.java000066400000000000000000000033601316447754700336130ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles; import net.imglib2.img.basictypeaccess.ShortAccess; /** * @author Tobias Pietzsch */ public interface VolatileShortAccess extends ShortAccess, VolatileAccess {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/000077500000000000000000000000001316447754700302225ustar00rootroot00000000000000AbstractVolatileByteArray.java000066400000000000000000000015521316447754700360770ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractByteArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileByteArray< A extends AbstractVolatileByteArray< A > > extends AbstractByteArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileByteArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileByteArray( final byte[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } AbstractVolatileCharArray.java000066400000000000000000000015521316447754700360510ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractCharArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileCharArray< A extends AbstractVolatileCharArray< A > > extends AbstractCharArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileCharArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileCharArray( final char[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } AbstractVolatileDoubleArray.java000066400000000000000000000015701316447754700364060ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractDoubleArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileDoubleArray< A extends AbstractVolatileDoubleArray< A > > extends AbstractDoubleArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileDoubleArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileDoubleArray( final double[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } AbstractVolatileFloatArray.java000066400000000000000000000015611316447754700362410ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractFloatArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileFloatArray< A extends AbstractVolatileFloatArray< A > > extends AbstractFloatArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileFloatArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileFloatArray( final float[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } AbstractVolatileIntArray.java000066400000000000000000000015431316447754700357260ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractIntArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileIntArray< A extends AbstractVolatileIntArray< A > > extends AbstractIntArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileIntArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileIntArray( final int[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } AbstractVolatileLongArray.java000066400000000000000000000015521316447754700360730ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractLongArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileLongArray< A extends AbstractVolatileLongArray< A > > extends AbstractLongArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileLongArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileLongArray( final long[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } AbstractVolatileShortArray.java000066400000000000000000000015611316447754700362730ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/arraypackage net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.AbstractShortArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileArrayDataAccess; /** * @author Tobias Pietzsch */ public abstract class AbstractVolatileShortArray< A extends AbstractVolatileShortArray< A > > extends AbstractShortArray< A > implements VolatileArrayDataAccess< A > { final protected boolean isValid; public AbstractVolatileShortArray( final int numEntities, final boolean isValid ) { super( numEntities ); this.isValid = isValid; } public AbstractVolatileShortArray( final short[] data, final boolean isValid ) { super( data ); this.isValid = isValid; } @Override public boolean isValid() { return isValid; } @Override public A createArray( final int numEntities ) { return createArray( numEntities, true ); } } DirtyVolatileByteArray.java000066400000000000000000000052451316447754700354320ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileByteAccess; /** * A {@link ByteArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileByteArray extends AbstractVolatileByteArray< DirtyVolatileByteArray > implements VolatileByteAccess, Dirty { protected boolean dirty = false; public DirtyVolatileByteArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileByteArray( final byte[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final byte value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileByteArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileByteArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } DirtyVolatileCharArray.java000066400000000000000000000052451316447754700354040ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.CharArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileCharAccess; /** * A {@link CharArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileCharArray extends AbstractVolatileCharArray< DirtyVolatileCharArray > implements VolatileCharAccess, Dirty { protected boolean dirty = false; public DirtyVolatileCharArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileCharArray( final char[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final char value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileCharArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileCharArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } DirtyVolatileDoubleArray.java000066400000000000000000000052771316447754700357460ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileDoubleAccess; /** * A {@link DoubleArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileDoubleArray extends AbstractVolatileDoubleArray< DirtyVolatileDoubleArray > implements VolatileDoubleAccess, Dirty { protected boolean dirty = false; public DirtyVolatileDoubleArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileDoubleArray( final double[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final double value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileDoubleArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileDoubleArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } DirtyVolatileFloatArray.java000066400000000000000000000052621316447754700355730ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileFloatAccess; /** * A {@link FloatArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileFloatArray extends AbstractVolatileFloatArray< DirtyVolatileFloatArray > implements VolatileFloatAccess, Dirty { protected boolean dirty = false; public DirtyVolatileFloatArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileFloatArray( final float[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final float value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileFloatArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileFloatArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } DirtyVolatileIntArray.java000066400000000000000000000052301316447754700352530ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileIntAccess; /** * A {@link IntArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileIntArray extends AbstractVolatileIntArray< DirtyVolatileIntArray > implements VolatileIntAccess, Dirty { protected boolean dirty = false; public DirtyVolatileIntArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileIntArray( final int[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final int value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileIntArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileIntArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } DirtyVolatileLongArray.java000066400000000000000000000052451316447754700354260ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileLongAccess; /** * A {@link LongArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileLongArray extends AbstractVolatileLongArray< DirtyVolatileLongArray > implements VolatileLongAccess, Dirty { protected boolean dirty = false; public DirtyVolatileLongArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileLongArray( final long[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final long value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileLongArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileLongArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } DirtyVolatileShortArray.java000066400000000000000000000052621316447754700356250ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.Dirty; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileShortAccess; /** * A {@link ShortArray} with an {@link #isDirty()} and an {@link #isValid()} * flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class DirtyVolatileShortArray extends AbstractVolatileShortArray< DirtyVolatileShortArray > implements VolatileShortAccess, Dirty { protected boolean dirty = false; public DirtyVolatileShortArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public DirtyVolatileShortArray( final short[] data, final boolean isValid ) { super( data, isValid ); } @Override public void setValue( final int index, final short value ) { dirty = true; data[ index ] = value; } @Override public DirtyVolatileShortArray createArray( final int numEntities, final boolean isValid ) { return new DirtyVolatileShortArray( numEntities, isValid ); } @Override public boolean isDirty() { return dirty; } @Override public void setDirty() { dirty = true; } } VolatileByteArray.java000066400000000000000000000044721316447754700344170ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileByteAccess; /** * A {@link ByteArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileByteArray extends AbstractVolatileByteArray< VolatileByteArray > implements VolatileByteAccess { public VolatileByteArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileByteArray( final byte[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileByteArray createArray( final int numEntities, final boolean isValid ) { return new VolatileByteArray( numEntities, isValid ); } } VolatileCharArray.java000066400000000000000000000044721316447754700343710ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.CharArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileCharAccess; /** * A {@link CharArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileCharArray extends AbstractVolatileCharArray< VolatileCharArray > implements VolatileCharAccess { public VolatileCharArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileCharArray( final char[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileCharArray createArray( final int numEntities, final boolean isValid ) { return new VolatileCharArray( numEntities, isValid ); } } VolatileDoubleArray.java000066400000000000000000000045221316447754700347220ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileDoubleAccess; /** * A {@link DoubleArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileDoubleArray extends AbstractVolatileDoubleArray< VolatileDoubleArray > implements VolatileDoubleAccess { public VolatileDoubleArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileDoubleArray( final double[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileDoubleArray createArray( final int numEntities, final boolean isValid ) { return new VolatileDoubleArray( numEntities, isValid ); } } VolatileFloatArray.java000066400000000000000000000045061316447754700345570ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileFloatAccess; /** * A {@link FloatArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileFloatArray extends AbstractVolatileFloatArray< VolatileFloatArray > implements VolatileFloatAccess { public VolatileFloatArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileFloatArray( final float[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileFloatArray createArray( final int numEntities, final boolean isValid ) { return new VolatileFloatArray( numEntities, isValid ); } } VolatileIntArray.java000066400000000000000000000044561316447754700342500ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileIntAccess; /** * A {@link IntArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileIntArray extends AbstractVolatileIntArray< VolatileIntArray > implements VolatileIntAccess { public VolatileIntArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileIntArray( final int[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileIntArray createArray( final int numEntities, final boolean isValid ) { return new VolatileIntArray( numEntities, isValid ); } } VolatileLongArray.java000066400000000000000000000044721316447754700344130ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileLongAccess; /** * A {@link LongArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileLongArray extends AbstractVolatileLongArray< VolatileLongArray > implements VolatileLongAccess { public VolatileLongArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileLongArray( final long[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileLongArray createArray( final int numEntities, final boolean isValid ) { return new VolatileLongArray( numEntities, isValid ); } } VolatileShortArray.java000066400000000000000000000045061316447754700346110ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/basictypeaccess/volatiles/array/* * #%L * BigDataViewer core classes with minimal dependencies * %% * Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch, * Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.basictypeaccess.volatiles.array; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.img.basictypeaccess.volatiles.VolatileShortAccess; /** * A {@link ShortArray} with an {@link #isValid()} flag. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class VolatileShortArray extends AbstractVolatileShortArray< VolatileShortArray > implements VolatileShortAccess { public VolatileShortArray( final int numEntities, final boolean isValid ) { super( numEntities, isValid ); } public VolatileShortArray( final short[] data, final boolean isValid ) { super( data, isValid ); } @Override public VolatileShortArray createArray( final int numEntities, final boolean isValid ) { return new VolatileShortArray( numEntities, isValid ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/000077500000000000000000000000001316447754700226545ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/AbstractCellImg.java000066400000000000000000000104601316447754700265200ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessible; import net.imglib2.img.AbstractNativeImg; import net.imglib2.img.Img; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * Abstract superclass for {@link Img} types that divide their underlying data * into cells. * * @author Mark Hiner * @author Tobias Pietzsch */ public abstract class AbstractCellImg< T extends NativeType< T >, A, C extends Cell< A >, I extends RandomAccessible< C > & IterableInterval< C > > extends AbstractNativeImg< T, A > { protected final CellGrid grid; protected final I cells; public AbstractCellImg( final CellGrid grid, final I imgOfCells, final Fraction entitiesPerPixel ) { super( grid.getImgDimensions(), entitiesPerPixel ); this.grid = grid; this.cells = imgOfCells; } /** * This interface is implemented by all samplers on the {@link AbstractCellImg}. It * allows to ask for the cell the sampler is currently in. */ public interface CellImgSampler< C > { /** * @return the cell the sampler is currently in. */ public C getCell(); } @Override @SuppressWarnings( "unchecked" ) public A update( final Object cursor ) { // directly get data? return ( ( CellImgSampler< C > ) cursor ).getCell().getData(); } @Override public CellCursor< T, C > cursor() { return new CellCursor<>( this ); } @Override public CellLocalizingCursor< T, C > localizingCursor() { return new CellLocalizingCursor<>( this ); } @Override public CellRandomAccess< T, C > randomAccess() { return new CellRandomAccess<>( this ); } @Override public CellIterationOrder iterationOrder() { return new CellIterationOrder( this ); } /** * Get the underlying image of cells which gives access to the individual * {@link Cell}s through Cursors and RandomAccesses. * * @return the image of cells. */ public I getCells() { return cells; } /** * Get the {@link CellGrid} which describes the layout of the * {@link AbstractCellImg}. The grid provides the dimensions of the image, the * number of cells in each dimension, and the dimensions of individual * cells. * * @return the cell grid layout. */ public CellGrid getCellGrid() { return grid; } protected void copyDataTo( final AbstractCellImg< T, ?, ?, ? > copy ) { final CellCursor< T, C > source = this.cursor(); final CellCursor< T, ? > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/Cell.java000066400000000000000000000105701316447754700244010ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import java.io.Serializable; import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Intervals; /** * A cell of an {@link AbstractCellImg}. * * @author Tobias Pietzsch */ public class Cell< A > implements Serializable { private static final long serialVersionUID = 1L; protected final int n; protected final int[] dimensions; protected final int[] steps; protected final long[] min; protected final long[] max; private final int numPixels; private final A data; public Cell( final int[] dimensions, final long[] min, final A data ) { this.n = dimensions.length; this.dimensions = dimensions.clone(); this.steps = new int[ n ]; IntervalIndexer.createAllocationSteps( dimensions, steps ); this.min = min.clone(); max = new long[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = min[ d ] + dimensions[ d ] - 1; numPixels = ( int ) Intervals.numElements( dimensions ); this.data = data; } /** * Get the basic type array that stores this cells pixels. * * @return underlying basic type array. */ public A getData() { return data; } public long size() { return numPixels; } public long indexToGlobalPosition( final int index, final int d ) { return IntervalIndexer.indexToPosition( index, dimensions, steps, d ) + min[ d ]; } public void indexToGlobalPosition( final int index, final long[] position ) { IntervalIndexer.indexToPosition( index, dimensions, position ); for ( int d = 0; d < position.length; ++d ) position[ d ] += min[ d ]; } /** * Compute the index in the underlying flat array of this cell which * corresponds to the specified global {@code position}. * * @param position * a global position * @return corresponding index */ public int globalPositionToIndex( final long[] position ) { return IntervalIndexer.positionWithOffsetToIndex( position, dimensions, min ); } /** * * @param d * dimension * @return minimum */ public long min( final int d ) { return min[ d ]; } /** * Write the minimum of each dimension into long[]. * * @param minimum */ public void min( final long[] minimum ) { for ( int d = 0; d < n; ++d ) minimum[ d ] = min[ d ]; } /** * Get the number of pixels in a given dimension d. * * @param d */ public int dimension( final int d ) { return dimensions[ d ]; } /** * Write the number of pixels in each dimension into long[]. * * @param dim */ public void dimensions( final int[] dim ) { for ( int d = 0; d < n; ++d ) dim[ d ] = dimensions[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellCursor.java000066400000000000000000000112671316447754700256030ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import net.imglib2.AbstractCursor; import net.imglib2.Cursor; import net.imglib2.type.NativeType; /** * {@link Cursor} on a {@link AbstractCellImg}. * * @author Tobias Pietzsch */ public class CellCursor< T extends NativeType< T >, C extends Cell< ? > > extends AbstractCursor< T > implements AbstractCellImg.CellImgSampler< C > { protected final T type; protected final Cursor< C > cursorOnCells; protected int lastIndexInCell; /** * The current index of the type. It is faster to duplicate this here than * to access it through type.getIndex(). */ protected int index; /** * Caches cursorOnCells.hasNext(). */ protected boolean isNotLastCell; protected CellCursor( final CellCursor< T, C > cursor ) { super( cursor.numDimensions() ); this.type = cursor.type.duplicateTypeOnSameNativeImg(); this.cursorOnCells = cursor.cursorOnCells.copyCursor(); isNotLastCell = cursor.isNotLastCell; lastIndexInCell = cursor.lastIndexInCell; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); } public CellCursor( final AbstractCellImg< T, ?, C, ? > img ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.cursorOnCells = img.getCells().cursor(); reset(); } @Override public C getCell() { return cursorOnCells.get(); } @Override public T get() { return type; } @Override public CellCursor< T, C > copy() { return new CellCursor<>( this ); } @Override public CellCursor< T, C > copyCursor() { return copy(); } @Override public boolean hasNext() { return ( index < lastIndexInCell ) || isNotLastCell; } @Override public void jumpFwd( final long steps ) { long newIndex = index + steps; while ( newIndex > lastIndexInCell ) { newIndex -= lastIndexInCell + 1; cursorOnCells.fwd(); isNotLastCell = cursorOnCells.hasNext(); lastIndexInCell = ( int ) ( getCell().size() - 1 ); } index = ( int ) newIndex; type.updateIndex( index ); type.updateContainer( this ); } @Override public void fwd() { if ( ++index > lastIndexInCell ) { moveToNextCell(); index = 0; } type.updateIndex( index ); } @Override public void reset() { cursorOnCells.reset(); moveToNextCell(); type.updateIndex( index ); } @Override public String toString() { return type.toString(); } @Override public long getLongPosition( final int dim ) { return getCell().indexToGlobalPosition( index, dim ); } @Override public void localize( final long[] position ) { getCell().indexToGlobalPosition( index, position ); } /** * Move cursor right before the first element of the next cell. Update type * and index variables. */ private void moveToNextCell() { cursorOnCells.fwd(); isNotLastCell = cursorOnCells.hasNext(); lastIndexInCell = ( int ) ( getCell().size() - 1 ); index = -1; type.updateContainer( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellGrid.java000066400000000000000000000155731316447754700252170ustar00rootroot00000000000000package net.imglib2.img.cell; import java.util.Arrays; import net.imglib2.Positionable; import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Util; /** * Defines {@link AbstractCellImg} geometry and translates between image, cell, * and grid coordinates. * * @author Tobias Pietzsch */ public class CellGrid { private final int n; private final long[] dimensions; private final int[] cellDimensions; private final long[] numCells; private final int[] borderSize; private final int hashcode; public CellGrid( final long[] dimensions, final int[] cellDimensions ) { this.n = dimensions.length; this.dimensions = dimensions.clone(); this.cellDimensions = cellDimensions.clone(); numCells = new long[ n ]; borderSize = new int[ n ]; for ( int d = 0; d < n; ++d ) { numCells[ d ] = ( dimensions[ d ] - 1 ) / cellDimensions[ d ] + 1; borderSize[ d ] = ( int ) ( dimensions[ d ] - ( numCells[ d ] - 1 ) * cellDimensions[ d ] ); } hashcode = 31 * Arrays.hashCode( dimensions ) + Arrays.hashCode( cellDimensions ); } public CellGrid( final CellGrid grid ) { n = grid.n; dimensions = grid.dimensions.clone(); cellDimensions = grid.cellDimensions.clone(); numCells = grid.numCells.clone(); borderSize = grid.borderSize.clone(); hashcode = grid.hashcode; } public int numDimensions() { return n; } public long[] getGridDimensions() { return numCells.clone(); } public void gridDimensions( final long[] s ) { for ( int i = 0; i < n; ++i ) s[ i ] = numCells[ i ]; } public long gridDimension( final int d ) { return numCells[ d ]; } /** * Get the number of pixels in each dimension as a new long[]. Note, that this * is the number of pixels in all cells combined, not the number of cells! */ public long[] getImgDimensions() { return dimensions.clone(); } /** * Write the number of pixels in each dimension into long[]. Note, that this * is the number of pixels in all cells combined, not the number of cells! * * @param dimensions */ public void imgDimensions( final long[] dimensions ) { for ( int i = 0; i < n; ++i ) dimensions[ i ] = this.dimensions[ i ]; } /** * Get the number of pixels in a given dimension d. Note, that this * is the number of pixels in all cells combined, not the number of cells! * * @param d */ public long imgDimension( final int d ) { return dimensions[ d ]; } /** * Write the number of pixels in a standard cell in each dimension into * long[]. Cells on the max border of the image may be cut off and have * different dimensions. * * @param dimensions */ public void cellDimensions( final int[] dimensions ) { for ( int i = 0; i < n; ++i ) dimensions[ i ] = cellDimensions[ i ]; } /** * Get the number of pixels in a standard cell in a given dimension * d. Cells on the max border of the image may be cut off and have * different dimensions. * * @param d */ public int cellDimension( final int d ) { return cellDimensions[ d ]; } /** * From the index of a cell in the grid, compute the image position of the * first pixel of the cell (the offset of the cell in image coordinates) and * the dimensions of the cell. The dimensions will be the standard * {@link #cellDimensions} unless the cell is at the border of the image in * which case it might be truncated. *

* Note, that this method assumes that the cell grid has flat iteration * order. It this is not the case, use * {@link #getCellDimensions(long[], long[], int[])}. *

* * @param index * flattened grid coordinates of the cell. * @param cellMin * offset of the cell in image coordinates are written here. * @param cellDims * dimensions of the cell are written here. */ public void getCellDimensions( long index, final long[] cellMin, final int[] cellDims ) { for ( int d = 0; d < n; ++d ) { final long j = index / numCells[ d ]; final long gridPos = index - j * numCells[ d ]; index = j; cellDims[ d ] = ( ( gridPos == numCells[ d ] - 1 ) ? borderSize[ d ] : cellDimensions[ d ] ); cellMin[ d ] = gridPos * cellDimensions[ d ]; } } /** * From the position of a cell in the grid, compute the image position of * the first pixel of the cell (the offset of the cell in image coordinates) * and the dimensions of the cell. The dimensions will be the standard * {@link #cellDimensions} unless the cell is at the border of the image in * which case it might be truncated. * * @param cellGridPosition * grid coordinates of the cell. * @param cellMin * offset of the cell in image coordinates are written here. * @param cellDims * dimensions of the cell are written here. */ public void getCellDimensions( final long[] cellGridPosition, final long[] cellMin, final int[] cellDims ) { for ( int d = 0; d < n; ++d ) { cellDims[ d ] = ( ( cellGridPosition[ d ] + 1 == numCells[ d ] ) ? borderSize[ d ] : cellDimensions[ d ] ); cellMin[ d ] = cellGridPosition[ d ] * cellDimensions[ d ]; } } /** * From the flattened index of a cell in the grid, compute the position of a * cell in the grid. * * @param index * flattened grid coordinates of the cell. * @param cellGridPosition * grid coordinates of the cell are written here. */ public void getCellGridPositionFlat( final long index, final long[] cellGridPosition ) { IntervalIndexer.indexToPosition( index, numCells, cellGridPosition ); } /** * Get the grid position of the cell containing the element at {@code position}. * * @param position * position of an element in the image. * @param cellPos * is set to the grid position of the cell containing the element. */ public void getCellPosition( final long[] position, final long[] cellPos ) { for ( int d = 0; d < n; ++d ) cellPos[ d ] = position[ d ] / cellDimensions[ d ]; } /** * Get the grid position of the cell containing the element at {@code position}. * * @param position * position of an element in the image. * @param cellPos * is set to the grid position of the cell containing the element. */ public void getCellPosition( final long[] position, final Positionable cellPos ) { for ( int d = 0; d < n; ++d ) cellPos.setPosition( position[ d ] / cellDimensions[ d ], d ); } @Override public int hashCode() { return hashcode; } @Override public boolean equals( final Object obj ) { if ( obj instanceof CellGrid ) { final CellGrid other = ( CellGrid ) obj; return Arrays.equals( dimensions, other.dimensions ) && Arrays.equals( cellDimensions, other.cellDimensions ); } return false; } @Override public String toString() { return getClass().getSimpleName() + "( dims = " + Util.printCoordinates( dimensions ) + ", cellDims = " + Util.printCoordinates( cellDimensions ) + " )"; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellImg.java000066400000000000000000000015501316447754700250340ustar00rootroot00000000000000package net.imglib2.img.cell; import net.imglib2.img.ImgFactory; import net.imglib2.img.list.ListImg; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; public class CellImg< T extends NativeType< T >, A > extends AbstractCellImg< T, A, Cell< A >, ListImg< Cell< A > > > { private final CellImgFactory< T > factory; public CellImg( final CellImgFactory< T > factory, final CellGrid grid, final ListImg< Cell< A > > imgOfCells, final Fraction entitiesPerPixel ) { super( grid, imgOfCells, entitiesPerPixel ); this.factory = factory; } @Override public ImgFactory< T > factory() { return factory; } @Override public CellImg< T, A > copy() { @SuppressWarnings( "unchecked" ) final CellImg< T, A > copy = ( CellImg< T, A > ) factory().create( dimension, firstElement().createVariable() ); copyDataTo( copy ); return copy; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellImgFactory.java000066400000000000000000000212551316447754700263700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import net.imglib2.exception.IncompatibleTypeException; import net.imglib2.img.ImgFactory; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.array.ArrayDataAccess; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.CharArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.img.list.ListImg; import net.imglib2.img.list.ListLocalizingCursor; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.Intervals; /** * Factory for creating {@link AbstractCellImg CellImgs}. The cell dimensions * for a standard cell can be supplied in the constructor of the factory. If no * cell dimensions are given, the factory creates cells of size 10 x 10 x * ... x 10. * * @author Tobias Pietzsch */ public class CellImgFactory< T extends NativeType< T > > extends NativeImgFactory< T > { private final int[] defaultCellDimensions; public CellImgFactory() { this( 10 ); } public CellImgFactory( final int... cellDimensions ) { defaultCellDimensions = cellDimensions.clone(); verifyDimensions( defaultCellDimensions ); } /** * Verify that {@code dimensions} is not null or empty, and that no * dimension is less than 1. Throw {@link IllegalArgumentException} * otherwise. * * @param dimensions * @throws IllegalArgumentException */ public static void verifyDimensions( final int[] dimensions ) throws IllegalArgumentException { if ( dimensions == null ) throw new IllegalArgumentException( "dimensions == null" ); if ( dimensions.length == 0 ) throw new IllegalArgumentException( "dimensions.length == 0" ); for ( int d = 0; d < dimensions.length; d++ ) if ( dimensions[ d ] <= 0 ) throw new IllegalArgumentException( "dimensions[ " + d + " ] <= 0" ); } /** * Verify that {@code dimensions} is not null or empty, and that no * dimension is less than 1. Throw {@link IllegalArgumentException} * otherwise. * * @param dimensions * @throws IllegalArgumentException */ public static void verifyDimensions( final long dimensions[] ) throws IllegalArgumentException { if ( dimensions == null ) throw new IllegalArgumentException( "dimensions == null" ); if ( dimensions.length == 0 ) throw new IllegalArgumentException( "dimensions.length == 0" ); for ( int d = 0; d < dimensions.length; d++ ) if ( dimensions[ d ] <= 0 ) throw new IllegalArgumentException( "dimensions[ " + d + " ] <= 0" ); } /** * Computes cell size array by truncating or expanding * {@code defaultCellDimensions} to length {@code n}. Then verifies that a * cell does not contain more than {@code Integer.MAX_VALUE} entities. * * @param defaultCellDimensions * @param n * @param entitiesPerPixel * @return * @throws IllegalArgumentException */ public static int[] getCellDimensions( final int[] defaultCellDimensions, final int n, final Fraction entitiesPerPixel ) throws IllegalArgumentException { final int[] cellDimensions = new int[ n ]; final int max = defaultCellDimensions.length - 1; for ( int i = 0; i < n; i++ ) cellDimensions[ i ] = defaultCellDimensions[ ( i < max ) ? i : max ]; final long numEntities = entitiesPerPixel.mulCeil( Intervals.numElements( cellDimensions ) ); if ( numEntities > Integer.MAX_VALUE ) throw new IllegalArgumentException( "Number of entities in cell too large. Use smaller cell size." ); return cellDimensions; } @Override public CellImg< T, ? > create( final long[] dim, final T type ) { return ( CellImg< T, ? > ) type.createSuitableNativeImg( this, dim ); } @Override public CellImg< T, ByteArray > createByteInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new ByteArray( 1 ), dimensions, entitiesPerPixel ); } @Override public CellImg< T, CharArray > createCharInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new CharArray( 1 ), dimensions, entitiesPerPixel ); } @Override public CellImg< T, ShortArray > createShortInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new ShortArray( 1 ), dimensions, entitiesPerPixel ); } @Override public CellImg< T, IntArray > createIntInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new IntArray( 1 ), dimensions, entitiesPerPixel ); } @Override public CellImg< T, LongArray > createLongInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new LongArray( 1 ), dimensions, entitiesPerPixel ); } @Override public CellImg< T, FloatArray > createFloatInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new FloatArray( 1 ), dimensions, entitiesPerPixel ); } @Override public CellImg< T, DoubleArray > createDoubleInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return createInstance( new DoubleArray( 1 ), dimensions, entitiesPerPixel ); } @SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { if ( NativeType.class.isInstance( type ) ) return new CellImgFactory( defaultCellDimensions ); throw new IncompatibleTypeException( this, type.getClass().getCanonicalName() + " does not implement NativeType." ); } private < A extends ArrayDataAccess< A > > CellImg< T, A > createInstance( final A creator, final long[] dimensions, final Fraction entitiesPerPixel ) { verifyDimensions( dimensions ); final int n = dimensions.length; final int[] cellDimensions = getCellDimensions( defaultCellDimensions, n, entitiesPerPixel ); final CellGrid grid = new CellGrid( dimensions, cellDimensions ); final long[] gridDimensions = new long[ grid.numDimensions() ]; grid.gridDimensions( gridDimensions ); final Cell< A > type = new Cell<>( new int[] { 1 }, new long[] { 1 }, null ); final ListImg< Cell< A > > cells = new ListImg<>( gridDimensions, type ); final long[] cellGridPosition = new long[ n ]; final long[] cellMin = new long[ n ]; final int[] cellDims = new int[ n ]; final ListLocalizingCursor< Cell< A > > cellCursor = cells.localizingCursor(); while ( cellCursor.hasNext() ) { cellCursor.fwd(); cellCursor.localize( cellGridPosition ); grid.getCellDimensions( cellGridPosition, cellMin, cellDims ); final A data = creator.createArray( ( int ) entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) ) ); cellCursor.set( new Cell<>( cellDims, cellMin, data ) ); } return new CellImg<>( this, grid, cells, entitiesPerPixel ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellIterationOrder.java000066400000000000000000000053711316447754700272570ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; /** * Iteration order for a {@link CellImg}. A {@link CellImg} is iterated cell by * cell, where each cell is iterated in flat iteration order. * * @author Tobias Pietzsch */ public class CellIterationOrder { private final AbstractCellImg< ?, ?, ?, ? > img; public CellIterationOrder( final AbstractCellImg< ?, ?, ?, ? > img ) { this.img = img; } /** * To be equal an object has to be a {@link CellIterationOrder} on a * {@link CellImg} of the same dimensions and cell-dimensions. * * @return true, if obj is a compatible {@link CellIterationOrder}. */ @Override public boolean equals( final Object obj ) { if ( !( obj instanceof CellIterationOrder ) ) return false; final AbstractCellImg< ?, ?, ?, ? > other = ( ( CellIterationOrder ) obj ).img; return other.getCellGrid().equals( img.getCellGrid() ) && other.getCells().iterationOrder().equals( img.getCells().iterationOrder() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellLocalizingCursor.java000066400000000000000000000124001316447754700276050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import net.imglib2.AbstractLocalizingCursor; import net.imglib2.Cursor; import net.imglib2.type.NativeType; /** * Localizing {@link Cursor} on a {@link AbstractCellImg}. * * @author Tobias Pietzsch */ public class CellLocalizingCursor< T extends NativeType< T >, C extends Cell< ? > > extends AbstractLocalizingCursor< T > implements AbstractCellImg.CellImgSampler< C > { protected final T type; protected final Cursor< C > cursorOnCells; protected int lastIndexInCell; protected long[] currentCellMin; protected long[] currentCellMax; /** * The current index of the type. It is faster to duplicate this here than * to access it through type.getIndex(). */ protected int index; /** * Caches cursorOnCells.hasNext(). */ protected boolean isNotLastCell; protected CellLocalizingCursor( final CellLocalizingCursor< T, C > cursor ) { super( cursor.numDimensions() ); this.type = cursor.type.duplicateTypeOnSameNativeImg(); this.cursorOnCells = cursor.cursorOnCells.copyCursor(); this.currentCellMin = cursor.currentCellMin; this.currentCellMax = cursor.currentCellMax; isNotLastCell = cursor.isNotLastCell; lastIndexInCell = cursor.lastIndexInCell; for ( int d = 0; d < n; ++d ) position[ d ] = cursor.position[ d ]; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); } public CellLocalizingCursor( final AbstractCellImg< T, ?, C, ? > img ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.cursorOnCells = img.getCells().cursor(); this.currentCellMin = null; this.currentCellMax = null; reset(); } @Override public C getCell() { return cursorOnCells.get(); } @Override public T get() { return type; } @Override public CellLocalizingCursor< T, C > copy() { return new CellLocalizingCursor<>( this ); } @Override public CellLocalizingCursor< T, C > copyCursor() { return copy(); } @Override public boolean hasNext() { return isNotLastCell || ( index < lastIndexInCell ); } @Override public void jumpFwd( final long steps ) { long newIndex = index + steps; while ( newIndex > lastIndexInCell ) { newIndex -= lastIndexInCell + 1; cursorOnCells.fwd(); isNotLastCell = cursorOnCells.hasNext(); lastIndexInCell = ( int ) ( getCell().size() - 1 ); } final C cell = getCell(); currentCellMin = cell.min; currentCellMax = cell.max; index = ( int ) newIndex; cell.indexToGlobalPosition( index, position ); type.updateIndex( index ); type.updateContainer( this ); } @Override public void fwd() { if ( ++index > lastIndexInCell ) { moveToNextCell(); index = 0; } type.updateIndex( index ); for ( int d = 0; d < n; ++d ) { if ( ++position[ d ] > currentCellMax[ d ] ) position[ d ] = currentCellMin[ d ]; else break; } } @Override public void reset() { cursorOnCells.reset(); moveToNextCell(); index = -1; type.updateIndex( index ); } /** * Move cursor right before the first element of the next cell. Update type, * position, and index variables. */ private void moveToNextCell() { cursorOnCells.fwd(); isNotLastCell = cursorOnCells.hasNext(); final C cell = getCell(); lastIndexInCell = ( int ) ( cell.size() - 1 ); currentCellMin = cell.min; currentCellMax = cell.max; position[ 0 ] = currentCellMin[ 0 ] - 1; for ( int d = 1; d < n; ++d ) position[ d ] = currentCellMin[ d ]; type.updateContainer( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/CellRandomAccess.java000066400000000000000000000331701316447754700266650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import net.imglib2.AbstractLocalizable; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.type.NativeType; /** * {@link RandomAccess} on a {@link AbstractCellImg}. * * The boundaries of the current cell are cached, so that position changes * within the same cell have minimal overhead. * * @author Tobias Pietzsch */ public class CellRandomAccess< T extends NativeType< T >, C extends Cell< ? > > extends AbstractLocalizable implements RandomAccess< T >, AbstractCellImg.CellImgSampler< C > { protected final T type; protected final CellGrid grid; protected final RandomAccess< C > randomAccessOnCells; protected final int[] cellDims; protected final long[] dimensions; protected int[] currentCellSteps; protected long[] currentCellMin; protected long[] currentCellMax; protected boolean isOutOfBounds; protected final long[] oobCellMin; protected final long[] oobCellMax; /** * The current index of the type. It is faster to duplicate this here than * to access it through type.getIndex(). */ protected int index; protected CellRandomAccess( final CellRandomAccess< T, C > randomAccess ) { super( randomAccess.numDimensions() ); type = randomAccess.type.duplicateTypeOnSameNativeImg(); grid = randomAccess.grid; randomAccessOnCells = randomAccess.randomAccessOnCells.copyRandomAccess(); randomAccess.localize( position ); cellDims = randomAccess.cellDims; dimensions = randomAccess.dimensions; currentCellSteps = randomAccess.currentCellSteps; currentCellMin = randomAccess.currentCellMin; currentCellMax = randomAccess.currentCellMax; isOutOfBounds = randomAccess.isOutOfBounds; oobCellMin = randomAccess.oobCellMin; oobCellMax = randomAccess.oobCellMax; index = randomAccess.index; type.updateContainer( this ); type.updateIndex( index ); } public CellRandomAccess( final AbstractCellImg< T, ?, C, ? > img ) { super( img.numDimensions() ); type = img.createLinkedType(); grid = img.getCellGrid(); randomAccessOnCells = img.getCells().randomAccess(); cellDims = new int[ n ]; dimensions = new long[ n ]; img.getCellGrid().cellDimensions( cellDims ); img.getCellGrid().imgDimensions( dimensions ); isOutOfBounds = false; oobCellMin = new long[ n ]; oobCellMax = new long[ n ]; for ( int d = 0; d < n; ++d ) { oobCellMin[ d ] = Long.MAX_VALUE; oobCellMax[ d ] = Long.MIN_VALUE; } img.getCellGrid().getCellPosition( position, randomAccessOnCells ); updatePosition( false ); } @Override public C getCell() { return randomAccessOnCells.get(); } @Override public T get() { return type; } @Override public CellRandomAccess< T, C > copy() { return new CellRandomAccess<>( this ); } @Override public CellRandomAccess< T, C > copyRandomAccess() { return copy(); } @Override public void fwd( final int d ) { index += currentCellSteps[ d ]; if ( ++position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.fwd( d ); updatePosition( position[ d ] >= dimensions[ d ] ); } type.updateIndex( index ); } @Override public void bck( final int d ) { index -= currentCellSteps[ d ]; if ( --position[ d ] < currentCellMin[ d ] ) { randomAccessOnCells.bck( d ); updatePosition( position[ d ] < 0 ); } type.updateIndex( index ); } @Override public void move( final int distance, final int d ) { index += distance * currentCellSteps[ d ]; position[ d ] += distance; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); updatePosition( position[ d ] < 0 || position[ d ] >= dimensions[ d ] ); } type.updateIndex( index ); } @Override public void move( final long distance, final int d ) { index += ( int ) distance * currentCellSteps[ d ]; position[ d ] += distance; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); updatePosition( position[ d ] < 0 || position[ d ] >= dimensions[ d ] ); } type.updateIndex( index ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) { final long pos = localizable.getLongPosition( d ); if ( pos != 0 ) { index += ( int ) pos * currentCellSteps[ d ]; position[ d ] += pos; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); boolean movedOutOfBounds = position[ d ] < 0 || position[ d ] >= dimensions[ d ]; for ( ++d; d < n; ++d ) { final long pos2 = localizable.getLongPosition( d ); if ( pos2 != 0 ) { position[ d ] += pos2; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); movedOutOfBounds |= position[ d ] < 0 || position[ d ] >= dimensions[ d ]; } } } updatePosition( movedOutOfBounds ); } } } type.updateIndex( index ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) { if ( distance[ d ] != 0 ) { index += distance[ d ] * currentCellSteps[ d ]; position[ d ] += distance[ d ]; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); boolean movedOutOfBounds = position[ d ] < 0 || position[ d ] >= dimensions[ d ]; for ( ++d; d < n; ++d ) { if ( distance[ d ] != 0 ) { position[ d ] += distance[ d ]; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); movedOutOfBounds |= position[ d ] < 0 || position[ d ] >= dimensions[ d ]; } } } updatePosition( movedOutOfBounds ); } } } type.updateIndex( index ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) { if ( distance[ d ] != 0 ) { index += ( int ) distance[ d ] * currentCellSteps[ d ]; position[ d ] += distance[ d ]; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); boolean movedOutOfBounds = position[ d ] < 0 || position[ d ] >= dimensions[ d ]; for ( ++d; d < n; ++d ) { if ( distance[ d ] != 0 ) { position[ d ] += distance[ d ]; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); movedOutOfBounds |= position[ d ] < 0 || position[ d ] >= dimensions[ d ]; } } } updatePosition( movedOutOfBounds ); } } } type.updateIndex( index ); } @Override public void setPosition( final int pos, final int d ) { index += ( int ) ( pos - position[ d ] ) * currentCellSteps[ d ]; position[ d ] = pos; if ( pos < currentCellMin[ d ] || pos > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( pos / cellDims[ d ], d ); updatePosition( position[ d ] < 0 || position[ d ] >= dimensions[ d ] ); } type.updateIndex( index ); } @Override public void setPosition( final long pos, final int d ) { index += ( int ) ( pos - position[ d ] ) * currentCellSteps[ d ]; position[ d ] = pos; if ( pos < currentCellMin[ d ] || pos > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( pos / cellDims[ d ], d ); updatePosition( position[ d ] < 0 || position[ d ] >= dimensions[ d ] ); } type.updateIndex( index ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) { final long pos = localizable.getLongPosition( d ); if ( pos != position[ d ] ) { index += ( int ) ( pos - position[ d ] ) * currentCellSteps[ d ]; position[ d ] = pos; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); boolean movedOutOfBounds = position[ d ] < 0 || position[ d ] >= dimensions[ d ]; for ( ++d; d < n; ++d ) { final long posInner = localizable.getLongPosition( d ); if ( posInner != position[ d ] ) { position[ d ] = posInner; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); movedOutOfBounds |= position[ d ] < 0 || position[ d ] >= dimensions[ d ]; } } } updatePosition( movedOutOfBounds ); } } } type.updateIndex( index ); } @Override public void setPosition( final int[] pos ) { for ( int d = 0; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { index += ( int ) ( pos[ d ] - position[ d ] ) * currentCellSteps[ d ]; if ( pos[ d ] < currentCellMin[ d ] || pos[ d ] > currentCellMax[ d ] ) { setPos2( pos, d ); break; } position[ d ] = pos[ d ]; } } type.updateIndex( index ); } private void setPos2( final int[] pos, final int d0 ) { boolean movedOutOfBounds = false; for ( int d = d0; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { position[ d ] = pos[ d ]; if ( pos[ d ] < currentCellMin[ d ] || pos[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( pos[ d ] / cellDims[ d ], d ); movedOutOfBounds |= pos[ d ] < 0 || pos[ d ] >= dimensions[ d ]; } } } updatePosition( movedOutOfBounds ); } @Override public void setPosition( final long[] pos ) { for ( int d = 0; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { index += ( int ) ( pos[ d ] - position[ d ] ) * currentCellSteps[ d ]; position[ d ] = pos[ d ]; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); boolean movedOutOfBounds = position[ d ] < 0 || position[ d ] >= dimensions[ d ]; for ( ++d; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { position[ d ] = pos[ d ]; if ( position[ d ] < currentCellMin[ d ] || position[ d ] > currentCellMax[ d ] ) { randomAccessOnCells.setPosition( position[ d ] / cellDims[ d ], d ); movedOutOfBounds |= position[ d ] < 0 || position[ d ] >= dimensions[ d ]; } } } updatePosition( movedOutOfBounds ); } } } type.updateIndex( index ); } /** * Update type to currentCellSteps, currentCellMin, and type after switching * cells. This is called after randomAccessOnCells and position fields have * been set. * * @param updateD * the (first) dimension that triggered the call by moving out of * current cell range. */ private void updatePosition( final boolean movedOutOfBounds ) { // are we out of the image? if ( movedOutOfBounds ) { isOutOfBounds = true; currentCellMin = oobCellMin; currentCellMax = oobCellMax; } else { if ( isOutOfBounds ) { // did we come back into the image? for ( int d = 0; d < n; ++d ) if ( position[ d ] < 0 || position[ d ] >= dimensions[ d ] ) return; // yes. we came back into the image. // re-initialize randomAccessOnCells to the correct // position. isOutOfBounds = false; grid.getCellPosition( position, randomAccessOnCells ); } final C cell = getCell(); currentCellSteps = cell.steps; currentCellMin = cell.min; currentCellMax = cell.max; index = cell.globalPositionToIndex( position ); type.updateContainer( this ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/cell/LazyCellImg.java000066400000000000000000000066611316447754700257040ustar00rootroot00000000000000package net.imglib2.img.cell; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.img.NativeImg; import net.imglib2.img.cell.LazyCellImg.LazyCells; import net.imglib2.img.list.AbstractLongListImg; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * A {@link AbstractCellImg} that obtains its Cells lazily when they are * accessed. Cells are obtained by a {@link Get} method that is provided by the * user. Typically this is some kind of cache. * * @param * the pixel type * @param
* the underlying native access type * * @author Tobias Pietzsch */ public class LazyCellImg< T extends NativeType< T >, A > extends AbstractCellImg< T, A, Cell< A >, LazyCells< Cell< A > > > { @FunctionalInterface public interface Get< T > { T get( long index ); } public LazyCellImg( final CellGrid grid, final T type, final Get< Cell< A > > get ) { super( grid, new LazyCells<>( grid.getGridDimensions(), get ), type.getEntitiesPerPixel() ); try { linkType( type, this ); } catch ( NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) { throw new RuntimeException( e ); } } public LazyCellImg( final CellGrid grid, final Fraction entitiesPerPixel, final Get< Cell< A > > get ) { super( grid, new LazyCells<>( grid.getGridDimensions(), get ), entitiesPerPixel ); } @Override public ImgFactory< T > factory() { throw new UnsupportedOperationException( "not implemented yet" ); } @Override public Img< T > copy() { throw new UnsupportedOperationException( "not implemented yet" ); } public static final class LazyCells< T > extends AbstractLongListImg< T > { private final Get< T > get; public LazyCells( final long[] dimensions, final Get< T > get ) { super( dimensions ); this.get = get; } @Override protected T get( final long index ) { return get.get( index ); } @Override protected void set( final long index, final T value ) { throw new UnsupportedOperationException(); } @Override public ImgFactory< T > factory() { throw new UnsupportedOperationException(); } @Override public Img< T > copy() { throw new UnsupportedOperationException(); } } /** * Reflection hack because there is no {@code T NativeType * .create(NativeImg)} method in ImgLib2 Note that for this method * to be introduced, NativeType would need an additional generic parameter A * that specifies the accepted family of access objects that can be used in * the NativeImg... big change * * @throws SecurityException * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InstantiationException */ @SuppressWarnings( { "rawtypes", "unchecked" } ) public static void linkType( final NativeType t, final NativeImg img ) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { final Constructor constructor = t.getClass().getDeclaredConstructor( NativeImg.class ); if ( constructor != null ) { final NativeType linkedType = ( NativeType )constructor.newInstance( img ); img.setLinkedType( linkedType ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/000077500000000000000000000000001316447754700227105ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/AbstractListImg.java000066400000000000000000000100061316447754700266040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import java.util.ArrayList; import net.imglib2.FlatIterationOrder; import net.imglib2.img.AbstractImg; import net.imglib2.img.Img; import net.imglib2.type.Type; import net.imglib2.util.IntervalIndexer; /** * Abstract base class for {@link Img} that store pixels in a single linear * array (an {@link ArrayList} or similar).In principle, the number of entities * stored is limited to {@link Integer#MAX_VALUE}. * * Derived classes need to implement the {@link #get(int)} and * {@link #set(int, Object)} methods that are used by accessors to access * pixels. These could be implemented to fetch pixels from an {@link ArrayList}, * create them on the fly, cache to disk, etc. * * @param * The value type of the pixels. You can us {@link Type}s or * arbitrary {@link Object}s. If you use non-{@link Type} pixels, * note, that you cannot use {@link Type#set(Type)} to change the * value stored in every reference. Instead, you can use the * {@link ListCursor#set(Object)} and * {@link ListRandomAccess#set(Object)} methods to alter pixels. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractListImg< T > extends AbstractImg< T > { final protected int[] step; final protected int[] dim; protected AbstractListImg( final long[] dim ) { super( dim ); this.dim = new int[ n ]; for ( int d = 0; d < n; ++d ) this.dim[ d ] = ( int ) dim[ d ]; step = new int[ n ]; IntervalIndexer.createAllocationSteps( this.dim, step ); } protected abstract T get( final int index ); protected abstract void set( final int index, final T value ); @Override public ListCursor< T > cursor() { return new ListCursor< T >( this ); } @Override public ListLocalizingCursor< T > localizingCursor() { return new ListLocalizingCursor< T >( this ); } @Override public ListRandomAccess< T > randomAccess() { return new ListRandomAccess< T >( this ); } @Override public ListImgFactory< T > factory() { return new ListImgFactory< T >(); } @Override public FlatIterationOrder iterationOrder() { return new FlatIterationOrder( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/AbstractLongListImg.java000066400000000000000000000223051316447754700274310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import net.imglib2.AbstractCursor; import net.imglib2.AbstractLocalizable; import net.imglib2.AbstractLocalizingCursor; import net.imglib2.FlatIterationOrder; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.img.AbstractImg; import net.imglib2.img.Img; import net.imglib2.type.Type; import net.imglib2.util.IntervalIndexer; /** * Abstract base class for {@link Img} that store pixels in a single linear * list addressed by a long. The number of entities that can be addressed is * limited to {@link Long#MAX_VALUE}. * * Derived classes need to implement the {@link #get(long)} and * {@link #set(long, Object)} methods that are used by accessors to access * pixels. * * @param * The value type of the pixels. You can us {@link Type}s or * arbitrary {@link Object}s. If you use non-{@link Type} pixels you * cannot use {@link Type#set(Type)} to change the value stored in * every reference. Instead, you can use the * {@link LongListCursor#set(Object)} and * {@link LongListRandomAccess#set(Object)} methods to alter pixels. * * @author Stephan Saalfeld * @author Stephan Preibisch * @author Tobias Pietzsch */ public abstract class AbstractLongListImg< T > extends AbstractImg< T > { public class LongListCursor extends AbstractCursor< T > { private long i; final private long maxNumPixels; protected LongListCursor( final LongListCursor cursor ) { super( cursor.numDimensions() ); this.maxNumPixels = cursor.maxNumPixels; i = cursor.i; } public LongListCursor() { super( AbstractLongListImg.this.numDimensions() ); this.maxNumPixels = size() - 1; reset(); } @Override public T get() { return AbstractLongListImg.this.get( i ); } public void set( final T t ) { AbstractLongListImg.this.set( i, t ); } @Override public LongListCursor copy() { return new LongListCursor( this ); } @Override public LongListCursor copyCursor() { return copy(); } @Override public boolean hasNext() { return i < maxNumPixels; } @Override public void jumpFwd( final long steps ) { i += steps; } @Override public void fwd() { ++i; } @Override public void reset() { i = -1; } @Override public void localize( final long[] position ) { IntervalIndexer.indexToPosition( i, dimension, position ); } @Override public long getLongPosition( final int d ) { return IntervalIndexer.indexToPosition( i, dimension, step, d ); } } public class LongListLocalizingCursor extends AbstractLocalizingCursor< T > { private long i; final private long maxNumPixels; final private long[] max; public LongListLocalizingCursor( final LongListLocalizingCursor cursor ) { super( cursor.numDimensions() ); maxNumPixels = cursor.maxNumPixels; max = new long[ n ]; for ( int d = 0; d < n; ++d ) { max[ d ] = cursor.max[ d ]; position[ d ] = cursor.position[ d ]; } i = cursor.i; } public LongListLocalizingCursor() { super( AbstractLongListImg.this.numDimensions() ); maxNumPixels = size() - 1; max = new long[ n ]; max( max ); reset(); } @Override public void fwd() { ++i; for ( int d = 0; d < n; d++ ) if ( ++position[ d ] > max[ d ] ) position[ d ] = 0; else break; } @Override public void jumpFwd( final long steps ) { i += steps; IntervalIndexer.indexToPosition( i, dimension, position ); } @Override public boolean hasNext() { return i < maxNumPixels; } @Override public void reset() { i = -1; position[ 0 ] = -1; for ( int d = 1; d < n; d++ ) position[ d ] = 0; } @Override public T get() { return AbstractLongListImg.this.get( i ); } public void set( final T t ) { AbstractLongListImg.this.set( i, t ); } @Override public LongListLocalizingCursor copy() { return new LongListLocalizingCursor( this ); } @Override public LongListLocalizingCursor copyCursor() { return copy(); } } public class LongListRandomAccess extends AbstractLocalizable implements RandomAccess< T > { private long i; public LongListRandomAccess( final LongListRandomAccess randomAccess ) { super( randomAccess.numDimensions() ); for ( int d = 0; d < n; ++d ) position[ d ] = randomAccess.position[ d ]; i = randomAccess.i; } public LongListRandomAccess() { super( AbstractLongListImg.this.numDimensions() ); i = 0; } @Override public T get() { return AbstractLongListImg.this.get( i ); } public void set( final T t ) { AbstractLongListImg.this.set( i, t ); } @Override public void fwd( final int d ) { i += step[ d ]; ++position[ d ]; } @Override public void bck( final int d ) { i -= step[ d ]; --position[ d ]; } @Override public void move( final int distance, final int d ) { i += step[ d ] * distance; position[ d ] += distance; } @Override public void move( final long distance, final int d ) { move( distance, d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) move( localizable.getLongPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void setPosition( final Localizable localizable ) { localizable.localize( position ); i = position[ 0 ]; for ( int d = 1; d < n; ++d ) i += position[ d ] * step[ d ]; } @Override public void setPosition( final int[] position ) { i = position[ 0 ]; this.position[ 0 ] = i; for ( int d = 1; d < n; ++d ) { final long p = position[ d ]; i += p * step[ d ]; this.position[ d ] = p; } } @Override public void setPosition( final long[] position ) { i = position[ 0 ]; this.position[ 0 ] = i; for ( int d = 1; d < n; ++d ) { final long p = position[ d ]; i += p * step[ d ]; this.position[ d ] = p; } } @Override public void setPosition( final int position, final int d ) { i += step[ d ] * ( position - this.position[ d ] ); this.position[ d ] = position; } @Override public void setPosition( final long position, final int d ) { i += step[ d ] * ( position - this.position[ d ] ); this.position[ d ] = position; } @Override public LongListRandomAccess copy() { return new LongListRandomAccess( this ); } @Override public LongListRandomAccess copyRandomAccess() { return copy(); } } final protected long[] step; protected AbstractLongListImg( final long[] dimensions ) { super( dimensions ); step = new long[ n ]; IntervalIndexer.createAllocationSteps( dimension, step ); } protected abstract T get( final long index ); protected abstract void set( final long index, final T value ); @Override public LongListCursor cursor() { return new LongListCursor(); } @Override public LongListLocalizingCursor localizingCursor() { return new LongListLocalizingCursor(); } @Override public LongListRandomAccess randomAccess() { return new LongListRandomAccess(); } @Override public FlatIterationOrder iterationOrder() { return new FlatIterationOrder( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/ListCursor.java000066400000000000000000000065561316447754700257000ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import net.imglib2.AbstractCursorInt; import net.imglib2.Cursor; import net.imglib2.util.IntervalIndexer; /** * {@link Cursor} on a {@link ListImg}. * * @param * the pixel type * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ final public class ListCursor< T > extends AbstractCursorInt< T > { private int i; final private int maxNumPixels; final private AbstractListImg< T > img; protected ListCursor( final ListCursor< T > cursor ) { super( cursor.numDimensions() ); img = cursor.img; this.maxNumPixels = cursor.maxNumPixels; i = cursor.i; } public ListCursor( final AbstractListImg< T > img ) { super( img.numDimensions() ); this.img = img; this.maxNumPixels = ( int ) img.size() - 1; reset(); } @Override public T get() { return img.get( i ); } public void set( final T t ) { img.set( i, t ); } @Override public ListCursor< T > copy() { return new ListCursor< T >( this ); } @Override public ListCursor< T > copyCursor() { return copy(); } @Override public boolean hasNext() { return i < maxNumPixels; } @Override public void jumpFwd( final long steps ) { i += steps; } @Override public void fwd() { ++i; } @Override public void reset() { i = -1; } @Override public void localize( final int[] position ) { IntervalIndexer.indexToPosition( i, img.dim, position ); } @Override public int getIntPosition( final int d ) { return IntervalIndexer.indexToPosition( i, img.dim, img.step, d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/ListImg.java000066400000000000000000000110101316447754700251140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import java.util.ArrayList; import java.util.Collection; import net.imglib2.img.Img; import net.imglib2.type.Type; /** * This {@link Img} stores an image in a single linear {@link ArrayList}. Each * pixel is stored as an individual object, so {@link ListImg} should only be * used for images with relatively few pixels. In principle, the number of * entities stored is limited to {@link Integer#MAX_VALUE}. * * @param * The value type of the pixels. You can us {@link Type}s or * arbitrary {@link Object}s. If you use non-{@link Type} pixels, * note, that you cannot use {@link Type#set(Type)} to change the * value stored in every reference. Instead, you can use the * {@link ListCursor#set(Object)} and * {@link ListRandomAccess#set(Object)} methods to alter the * underlying {@link ArrayList}. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class ListImg< T > extends AbstractListImg< T > { final private ArrayList< T > pixels; public ListImg( final long[] dim, final T type ) { super( dim ); pixels = new ArrayList< T >( ( int ) numPixels ); if ( type instanceof Type< ? > ) { final Type< ? > t = ( Type< ? > ) type; @SuppressWarnings( "unchecked" ) final ArrayList< Type< ? > > tpixels = ( ArrayList< Type< ? > > ) pixels; for ( int i = 0; i < numPixels; ++i ) tpixels.add( t.createVariable() ); } else { for ( int i = 0; i < numPixels; ++i ) pixels.add( null ); } } public ListImg( final Collection< T > collection, final long... dim ) { super( dim ); assert numPixels == collection.size() : "Dimensions do not match number of pixels."; pixels = new ArrayList< T >( ( int ) numPixels ); pixels.addAll( collection ); } @Override protected T get( final int index ) { return pixels.get( index ); } @Override protected void set( final int index, final T value ) { pixels.set( index, value ); } private static < A extends Type< A > > ListImg< A > copyWithType( final ListImg< A > img ) { final ListImg< A > copy = new ListImg< A >( img.dimension, img.firstElement().createVariable() ); final ListCursor< A > source = img.cursor(); final ListCursor< A > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); return copy; } @SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public ListImg< T > copy() { final T type = firstElement(); if ( type instanceof Type< ? > ) { final ListImg< ? > copy = copyWithType( ( ListImg< Type > ) this ); return ( ListImg< T > ) copy; } return new ListImg< T >( this.pixels, dimension ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/ListImgFactory.java000066400000000000000000000056601316447754700264620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import java.util.ArrayList; import net.imglib2.exception.IncompatibleTypeException; import net.imglib2.img.ImgFactory; import net.imglib2.type.Type; /** * {@link ImgFactory} for {@link ListImg} of any type T. You can us {@link Type} * s or arbitrary {@link Object}s. If you use non-{@link Type} pixels, note, * that you cannot use {@link Type#set(Type)} to change the value stored in * every reference in the {@link ListImg}. Instead, you can use the * {@link ListCursor#set(Object)} and {@link ListRandomAccess#set(Object)} * methods to alter the underlying {@link ArrayList}. * * @param * The value type of the pixels. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class ListImgFactory< T > extends ImgFactory< T > { @Override public ListImg< T > create( final long[] dim, final T type ) { return new ListImg< T >( dim, type ); } @SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { return new ListImgFactory(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/ListLocalizingCursor.java000066400000000000000000000072201316447754700277010ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import net.imglib2.AbstractLocalizingCursorInt; import net.imglib2.Cursor; import net.imglib2.util.IntervalIndexer; /** * Localizing {@link Cursor} on a {@link ListImg}. * * @param * the pixel type * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ final public class ListLocalizingCursor< T > extends AbstractLocalizingCursorInt< T > { private int i; final private int maxNumPixels; final private long[] max; final private AbstractListImg< T > img; public ListLocalizingCursor( final ListLocalizingCursor< T > cursor ) { super( cursor.numDimensions() ); img = cursor.img; maxNumPixels = cursor.maxNumPixels; max = new long[ n ]; for ( int d = 0; d < n; ++d ) { max[ d ] = cursor.max[ d ]; position[ d ] = cursor.position[ d ]; } i = cursor.i; } public ListLocalizingCursor( final AbstractListImg< T > img ) { super( img.numDimensions() ); this.img = img; maxNumPixels = ( int ) img.size() - 1; max = new long[ n ]; img.max( max ); reset(); } @Override public void fwd() { ++i; for ( int d = 0; d < n; d++ ) if ( ++position[ d ] > max[ d ] ) position[ d ] = 0; else break; } @Override public void jumpFwd( final long steps ) { i += steps; IntervalIndexer.indexToPosition( i, img.dim, position ); } @Override public boolean hasNext() { return i < maxNumPixels; } @Override public void reset() { i = -1; position[ 0 ] = -1; for ( int d = 1; d < n; d++ ) position[ d ] = 0; } @Override public T get() { return img.get( i ); } public void set( final T t ) { img.set( i, t ); } @Override public ListLocalizingCursor< T > copy() { return new ListLocalizingCursor< T >( this ); } @Override public ListLocalizingCursor< T > copyCursor() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/list/ListRandomAccess.java000066400000000000000000000114111316447754700267470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import net.imglib2.AbstractLocalizableInt; import net.imglib2.Localizable; import net.imglib2.RandomAccess; /** * {@link RandomAccess} on a {@link ListImg}. * * @param * the pixel type * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class ListRandomAccess< T > extends AbstractLocalizableInt implements RandomAccess< T > { private int i; private final AbstractListImg< T > img; public ListRandomAccess( final ListRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); img = randomAccess.img; for ( int d = 0; d < n; ++d ) position[ d ] = randomAccess.position[ d ]; i = randomAccess.i; } public ListRandomAccess( final AbstractListImg< T > img ) { super( img.numDimensions() ); this.img = img; i = 0; } @Override public T get() { return img.get( i ); } public void set( final T t ) { img.set( i, t ); } @Override public void fwd( final int d ) { i += img.step[ d ]; ++position[ d ]; } @Override public void bck( final int d ) { i -= img.step[ d ]; --position[ d ]; } @Override public void move( final int distance, final int d ) { i += img.step[ d ] * distance; position[ d ] += distance; } @Override public void move( final long distance, final int d ) { move( ( int ) distance, d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) move( localizable.getIntPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) move( ( int ) distance[ d ], d ); } @Override public void setPosition( final Localizable localizable ) { localizable.localize( position ); i = position[ 0 ]; for ( int d = 1; d < n; ++d ) i += position[ d ] * img.step[ d ]; } @Override public void setPosition( final int[] position ) { i = position[ 0 ]; this.position[ 0 ] = i; for ( int d = 1; d < n; ++d ) { final int p = position[ d ]; i += p * img.step[ d ]; this.position[ d ] = p; } } @Override public void setPosition( final long[] position ) { i = ( int ) position[ 0 ]; this.position[ 0 ] = i; for ( int d = 1; d < n; ++d ) { final int p = ( int ) position[ d ]; i += p * img.step[ d ]; this.position[ d ] = p; } } @Override public void setPosition( final int position, final int d ) { i += img.step[ d ] * ( position - this.position[ d ] ); this.position[ d ] = position; } @Override public void setPosition( final long position, final int d ) { i += img.step[ d ] * ( position - this.position[ d ] ); this.position[ d ] = ( int ) position; } @Override public ListRandomAccess< T > copy() { return new ListRandomAccess< T >( this ); } @Override public ListRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/000077500000000000000000000000001316447754700232125ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarCursor.java000066400000000000000000000112251316447754700264710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.AbstractCursorInt; import net.imglib2.type.NativeType; /** * Basic Iterator for {@link PlanarImg PlanarContainers} * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class PlanarCursor< T extends NativeType< T > > extends AbstractCursorInt< T > implements PlanarImg.PlanarContainerSampler { protected final T type; protected final PlanarImg< T, ? > container; protected final int lastIndex, lastSliceIndex; protected int sliceIndex; /** * The current index of the type. It is faster to duplicate this here than * to access it through type.getIndex(). */ protected int index; protected PlanarCursor( final PlanarCursor< T > cursor ) { super( cursor.numDimensions() ); container = cursor.container; this.type = container.createLinkedType(); lastIndex = cursor.lastIndex; lastSliceIndex = cursor.lastSliceIndex; sliceIndex = cursor.sliceIndex; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); } public PlanarCursor( final PlanarImg< T, ? > container ) { super( container.numDimensions() ); this.type = container.createLinkedType(); this.container = container; lastIndex = ( ( n > 1 ) ? container.dimensions[ 1 ] : 1 ) * container.dimensions[ 0 ] - 1; lastSliceIndex = container.numSlices() - 1; reset(); } @Override public int getCurrentSliceIndex() { return sliceIndex; } @Override public T get() { return type; } @Override public PlanarCursor< T > copy() { return new PlanarCursor< T >( this ); } @Override public PlanarCursor< T > copyCursor() { return copy(); } /** * Note: This test is fragile in a sense that it returns true for elements * after the last element as well. * * @return false for the last element */ @Override public boolean hasNext() { return ( sliceIndex < lastSliceIndex ) || ( index < lastIndex ); } @Override public void fwd() { if ( ++index > lastIndex ) { index = 0; ++sliceIndex; type.updateContainer( this ); } type.updateIndex( index ); } @Override public void jumpFwd( final long steps ) { long newIndex = index + steps; if ( newIndex > lastIndex ) { final long s = newIndex / ( lastIndex + 1 ); newIndex -= s * ( lastIndex + 1 ); sliceIndex += s; type.updateContainer( this ); } index = ( int ) newIndex; type.updateIndex( index ); } @Override public void reset() { sliceIndex = 0; index = -1; type.updateIndex( -1 ); type.updateContainer( this ); } @Override public String toString() { return type.toString(); } @Override public void localize( final int[] position ) { container.indexToGlobalPosition( sliceIndex, index, position ); } @Override public int getIntPosition( final int dim ) { return container.indexToGlobalPosition( sliceIndex, index, dim ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarCursor1D.java000066400000000000000000000047011316447754700266570ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.type.NativeType; /** * Basic Iterator for 1d {@link PlanarImg PlanarContainers} * * @author Stephan Saalfeld */ public class PlanarCursor1D< T extends NativeType< T > > extends PlanarCursor< T > { public PlanarCursor1D( final PlanarImg< T, ? > container ) { super( container ); } @Override public boolean hasNext() { return type.getIndex() < lastIndex; } @Override public void localize( final int[] position ) { position[ 0 ] = type.getIndex(); } @Override public int getIntPosition( final int dim ) { if ( dim == 0 ) return type.getIndex(); return 0; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarCursor2D.java000066400000000000000000000055341316447754700266650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.type.NativeType; /** * Basic Iterator for 2d {@link PlanarImg PlanarContainers} * * @param * * @author Stephan Saalfeld */ public class PlanarCursor2D< T extends NativeType< T > > extends PlanarCursor< T > { public PlanarCursor2D( final PlanarImg< T, ? > container ) { super( container ); } @Override public boolean hasNext() { return type.getIndex() < lastIndex; } @Override public void fwd() { type.incIndex(); } @Override public void localize( final int[] position ) { final int indexInSlice = type.getIndex(); final int dim0 = container.dimensions[ 0 ]; position[ 1 ] = indexInSlice / dim0; position[ 0 ] = indexInSlice - position[ 1 ] * dim0; } @Override public int getIntPosition( final int dim ) { final int indexInSlice = type.getIndex(); final int dim0 = container.dimensions[ 0 ]; final int pos1 = indexInSlice / dim0; if ( dim == 0 ) return indexInSlice - pos1 * dim0; else if ( dim == 1 ) return pos1; else return 0; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarImg.java000066400000000000000000000226461316447754700257410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import java.util.ArrayList; import net.imglib2.Cursor; import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; import net.imglib2.img.AbstractNativeImg; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.PlanarAccess; import net.imglib2.img.basictypeaccess.array.ArrayDataAccess; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.Intervals; import net.imglib2.view.iteration.SubIntervalIterable; /** * A {@link NativeImg} that stores data in an list of primitive arrays, one per * image plane. *

* The {@link PlanarImg} provides access to the underlying data arrays via the * {@link #getPlane(int)} method. *

* * @author Jan Funke * @author Stephan Preibisch * @author Stephan Saalfeld * @author Johannes Schindelin * @author Tobias Pietzsch */ public class PlanarImg< T extends NativeType< T >, A extends ArrayDataAccess< A > > extends AbstractNativeImg< T, A > implements PlanarAccess< A >, SubIntervalIterable< T > { final protected int numSlices; /* * duplicate of long[] dimension as an int array. */ final protected int[] dimensions; final protected int[] sliceSteps; final protected ArrayList< A > mirror; public PlanarImg( final long[] dim, final Fraction entitiesPerPixel ) { this( null, dim, entitiesPerPixel ); } PlanarImg( final A creator, final long[] dim, final Fraction entitiesPerPixel ) { super( dim, entitiesPerPixel ); dimensions = new int[ n ]; for ( int d = 0; d < n; ++d ) dimensions[ d ] = ( int ) dim[ d ]; if ( n > 2 ) { sliceSteps = new int[ n ]; sliceSteps[ 2 ] = 1; for ( int i = 3; i < n; ++i ) { final int j = i - 1; sliceSteps[ i ] = dimensions[ j ] * sliceSteps[ j ]; } } else { sliceSteps = null; } // compute number of slices int s = 1; for ( int d = 2; d < n; ++d ) s *= dimensions[ d ]; numSlices = s; mirror = new ArrayList< A >( numSlices ); if ( creator == null ) { for ( int i = 0; i < numSlices; ++i ) mirror.add( null ); } else { final int numEntitiesPerSlice = ( int ) entitiesPerPixel.mulCeil( ( ( n > 1 ) ? dimensions[ 1 ] : 1 ) * dimensions[ 0 ] ); for ( int i = 0; i < numSlices; ++i ) mirror.add( creator.createArray( numEntitiesPerSlice ) ); } } /** * This interface is implemented by all samplers on the {@link PlanarImg}. * It allows the container to ask for the slice the sampler is currently in. */ public interface PlanarContainerSampler { /** * @return the index of the slice the sampler is currently accessing. */ public int getCurrentSliceIndex(); } @Override public A update( final Object c ) { final int i = ( ( PlanarContainerSampler ) c ).getCurrentSliceIndex(); return mirror.get( i < 0 ? 0 : ( i >= numSlices ? numSlices - 1 : i ) ); } /** * @return total number of image planes */ public int numSlices() { return numSlices; } /** * For a given ≥2d location, estimate the pixel index in the stack slice. * * @param l * @return * * TODO: remove this method? (it doesn't seem to be used anywhere) */ public final int getIndex( final int[] l ) { if ( n > 1 ) return l[ 1 ] * dimensions[ 0 ] + l[ 0 ]; return l[ 0 ]; } /** * Compute a global position from the index of a slice and an index within * that slice. * * @param sliceIndex * index of slice * @param indexInSlice * index of element within slice * @param position * receives global position of element * * TODO: move this method to AbstractPlanarCursor? (that seems to * be the only place where it is needed) */ public void indexToGlobalPosition( int sliceIndex, final int indexInSlice, final int[] position ) { if ( n > 1 ) { position[ 1 ] = indexInSlice / dimensions[ 0 ]; position[ 0 ] = indexInSlice - position[ 1 ] * dimensions[ 0 ]; if ( n > 2 ) { final int maxDim = n - 1; for ( int d = 2; d < maxDim; ++d ) { final int j = sliceIndex / dimensions[ d ]; position[ d ] = sliceIndex - j * dimensions[ d ]; sliceIndex = j; } position[ maxDim ] = sliceIndex; } } else { position[ 0 ] = indexInSlice; } } /** * Compute a global position from the index of a slice and an index within * that slice. * * @param sliceIndex * index of slice * @param indexInSlice * index of element within slice * @param dim * which dimension of the position we are interested in * @return dimension dim of global position * * TODO: move this method to AbstractPlanarCursor? (that seems to be * the only place where it is needed) */ public int indexToGlobalPosition( final int sliceIndex, final int indexInSlice, final int dim ) { if ( dim == 0 ) return indexInSlice % dimensions[ 0 ]; else if ( dim == 1 ) return indexInSlice / dimensions[ 0 ]; else if ( dim < n ) return ( sliceIndex / sliceSteps[ dim ] ) % dimensions[ dim ]; else return 0; } @Override public PlanarCursor< T > cursor() { if ( n == 1 ) return new PlanarCursor1D< T >( this ); else if ( n == 2 ) return new PlanarCursor2D< T >( this ); else return new PlanarCursor< T >( this ); } @Override public PlanarLocalizingCursor< T > localizingCursor() { if ( n == 1 ) return new PlanarLocalizingCursor1D< T >( this ); else if ( n == 2 ) return new PlanarLocalizingCursor2D< T >( this ); else return new PlanarLocalizingCursor< T >( this ); } @Override public PlanarRandomAccess< T > randomAccess() { if ( n == 1 ) return new PlanarRandomAccess1D< T >( this ); return new PlanarRandomAccess< T >( this ); } @Override public FlatIterationOrder iterationOrder() { return new FlatIterationOrder( this ); } @Override public A getPlane( final int no ) { return mirror.get( no ); } @Override public void setPlane( final int no, final A plane ) { mirror.set( no, plane ); } @Override public PlanarImgFactory< T > factory() { return new PlanarImgFactory< T >(); } @Override public PlanarImg< T, ? > copy() { final PlanarImg< T, ? > copy = factory().create( dimension, firstElement().createVariable() ); final PlanarCursor< T > cursor1 = this.cursor(); final PlanarCursor< T > cursor2 = copy.cursor(); while ( cursor1.hasNext() ) cursor2.next().set( cursor1.next() ); return copy; } /** * {@inheritDoc} */ @Override public boolean supportsOptimizedCursor( final Interval interval ) { // we want to optimize exactly one plane return Intervals.contains( this, interval ) && correspondsToPlane( interval ); } /** * {@inheritDoc} */ @Override public Object subIntervalIterationOrder( final Interval interval ) { return new FlatIterationOrder( interval ); } /** * {@inheritDoc} */ @Override public Cursor< T > cursor( final Interval interval ) { assert ( supportsOptimizedCursor( interval ) ); return new PlanarPlaneSubsetCursor< T >( this, interval ); } private boolean correspondsToPlane( final Interval interval ) { // check if interval describes one plane if ( interval.dimension( 0 ) != dimension[ 0 ] ) return false; if ( dimension.length == 1 ) return true; if ( interval.dimension( 1 ) != dimension[ 1 ] ) return false; for ( int d = 2; d < interval.numDimensions(); ++d ) { if ( interval.dimension( d ) != 1 ) return false; } return true; } /** * {@inheritDoc} */ @Override public Cursor< T > localizingCursor( final Interval interval ) { assert ( supportsOptimizedCursor( interval ) ); return new PlanarPlaneSubsetLocalizingCursor< T >( this, interval ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarImgFactory.java000066400000000000000000000114141316447754700272600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.exception.IncompatibleTypeException; import net.imglib2.img.ImgFactory; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.CharArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * Factory that creates an appropriate {@link PlanarImg}. * * @author Jan Funke * @author Stephan Preibisch * @author Stephan Saalfeld * @author Johannes Schindelin */ public class PlanarImgFactory< T extends NativeType< T > > extends NativeImgFactory< T > { @Override public PlanarImg< T, ? > create( final long[] dim, final T type ) { return ( PlanarImg< T, ? > ) type.createSuitableNativeImg( this, dim ); } @Override public NativeImg< T, ByteArray > createByteInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, ByteArray >( new ByteArray( 1 ), dimensions, entitiesPerPixel ); } @Override public NativeImg< T, CharArray > createCharInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, CharArray >( new CharArray( 1 ), dimensions, entitiesPerPixel ); } @Override public NativeImg< T, DoubleArray > createDoubleInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, DoubleArray >( new DoubleArray( 1 ), dimensions, entitiesPerPixel ); } @Override public NativeImg< T, FloatArray > createFloatInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, FloatArray >( new FloatArray( 1 ), dimensions, entitiesPerPixel ); } @Override public NativeImg< T, IntArray > createIntInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, IntArray >( new IntArray( 1 ), dimensions, entitiesPerPixel ); } @Override public NativeImg< T, LongArray > createLongInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, LongArray >( new LongArray( 1 ), dimensions, entitiesPerPixel ); } @Override public NativeImg< T, ShortArray > createShortInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { return new PlanarImg< T, ShortArray >( new ShortArray( 1 ), dimensions, entitiesPerPixel ); } @SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { if ( NativeType.class.isInstance( type ) ) return new PlanarImgFactory(); throw new IncompatibleTypeException( this, type.getClass().getCanonicalName() + " does not implement NativeType." ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarImgs.java000066400000000000000000000174761316447754700261310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.Type; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.complex.ComplexDoubleType; import net.imglib2.type.numeric.complex.ComplexFloatType; import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.LongType; import net.imglib2.type.numeric.integer.ShortType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.integer.UnsignedIntType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; /** * Convenience factory methods for creation of {@link PlanarImg} instances with * the most common pixel {@link Type} variants. Keep in mind that this cannot be * a complete collection since the number of existing pixel {@link Type}s may be * extended. * * For pixel {@link Type}s T not present in this collection, use the generic * {@link PlanarImgFactory#create(long[], net.imglib2.type.NativeType)}, e.g. * *
 * img = new PlanarImgFactory< MyType >.create( new long[] { 100, 200 }, new MyType() );
 * 
* * @author Stephan Saalfeld */ final public class PlanarImgs { private PlanarImgs() {} /** * Create an {@link PlanarImg}<{@link UnsignedByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedByteType, ByteArray > unsignedBytes( final long... dim ) { return ( PlanarImg< UnsignedByteType, ByteArray > ) new PlanarImgFactory< UnsignedByteType >().create( dim, new UnsignedByteType() ); } /** * Create an {@link PlanarImg}<{@link ByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ByteType, ByteArray > bytes( final long... dim ) { return ( PlanarImg< ByteType, ByteArray > ) new PlanarImgFactory< ByteType >().create( dim, new ByteType() ); } /** * Create an {@link PlanarImg}<{@link UnsignedShortType}, {@link ShortArray} * >. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedShortType, ShortArray > unsignedShorts( final long... dim ) { return ( PlanarImg< UnsignedShortType, ShortArray > ) new PlanarImgFactory< UnsignedShortType >().create( dim, new UnsignedShortType() ); } /** * Create an {@link PlanarImg}<{@link ShortType}, {@link ShortArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ShortType, ShortArray > shorts( final long... dim ) { return ( PlanarImg< ShortType, ShortArray > ) new PlanarImgFactory< ShortType >().create( dim, new ShortType() ); } /** * Create an {@link PlanarImg}<{@link UnsignedIntType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedIntType, IntArray > unsignedInts( final long... dim ) { return ( PlanarImg< UnsignedIntType, IntArray > ) new PlanarImgFactory< UnsignedIntType >().create( dim, new UnsignedIntType() ); } /** * Create an {@link PlanarImg}<{@link IntType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< IntType, IntArray > ints( final long... dim ) { return ( PlanarImg< IntType, IntArray > ) new PlanarImgFactory< IntType >().create( dim, new IntType() ); } /** * Create an {@link PlanarImg}<{@link LongType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< LongType, LongArray > longs( final long... dim ) { return ( PlanarImg< LongType, LongArray > ) new PlanarImgFactory< LongType >().create( dim, new LongType() ); } /** * Create an {@link PlanarImg}<{@link BitType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< BitType, LongArray > bits( final long... dim ) { return ( PlanarImg< BitType, LongArray > ) new PlanarImgFactory< BitType >().create( dim, new BitType() ); } /** * Create an {@link PlanarImg}<{@link FloatType}, {@link FloatArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< FloatType, FloatArray > floats( final long... dim ) { return ( PlanarImg< FloatType, FloatArray > ) new PlanarImgFactory< FloatType >().create( dim, new FloatType() ); } /** * Create an {@link PlanarImg}<{@link DoubleType}, {@link DoubleArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< DoubleType, DoubleArray > doubles( final long... dim ) { return ( PlanarImg< DoubleType, DoubleArray > ) new PlanarImgFactory< DoubleType >().create( dim, new DoubleType() ); } /** * Create an {@link PlanarImg}<{@link ARGBType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ARGBType, IntArray > argbs( final long... dim ) { return ( PlanarImg< ARGBType, IntArray > ) new PlanarImgFactory< ARGBType >().create( dim, new ARGBType() ); } /** * Create an {@link PlanarImg}<{@link ComplexFloatType}, {@link FloatArray} * >. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ComplexFloatType, FloatArray > complexFloats( final long... dim ) { return ( PlanarImg< ComplexFloatType, FloatArray > ) new PlanarImgFactory< ComplexFloatType >().create( dim, new ComplexFloatType() ); } /** * Create an {@link PlanarImg}<{@link ComplexDoubleType}, * {@link DoubleArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ComplexDoubleType, DoubleArray > complexDoubles( final long... dim ) { return ( PlanarImg< ComplexDoubleType, DoubleArray > ) new PlanarImgFactory< ComplexDoubleType >().create( dim, new ComplexDoubleType() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarLocalizingCursor.java000066400000000000000000000120471316447754700305100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.AbstractLocalizingCursorInt; import net.imglib2.type.NativeType; /** * Localizing Iterator for a {@link PlanarImg PlanarContainers} * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class PlanarLocalizingCursor< T extends NativeType< T > > extends AbstractLocalizingCursorInt< T > implements PlanarImg.PlanarContainerSampler { protected final T type; protected final PlanarImg< T, ? > container; protected final int lastIndex, lastSliceIndex; protected int sliceIndex; /** * The current index of the type. It is faster to duplicate this here than * to access it through type.getIndex(). */ protected int index; /** * Maximum of the {@link PlanarImg} in every dimension. This is used to * check isOutOfBounds(). */ protected final int[] max; protected PlanarLocalizingCursor( final PlanarLocalizingCursor< T > cursor ) { super( cursor.numDimensions() ); container = cursor.container; this.type = container.createLinkedType(); lastIndex = cursor.lastIndex; lastSliceIndex = cursor.lastSliceIndex; max = new int[ n ]; for ( int d = 0; d < n; ++d ) { max[ d ] = cursor.max[ d ]; position[ d ] = cursor.position[ d ]; } sliceIndex = cursor.sliceIndex; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); } public PlanarLocalizingCursor( final PlanarImg< T, ? > container ) { super( container.numDimensions() ); this.type = container.createLinkedType(); this.container = container; lastIndex = ( ( n > 1 ) ? container.dimensions[ 1 ] : 1 ) * container.dimensions[ 0 ] - 1; lastSliceIndex = container.numSlices() - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) container.max( d ); reset(); } @Override public int getCurrentSliceIndex() { return sliceIndex; } @Override public T get() { return type; } @Override public PlanarLocalizingCursor< T > copy() { return new PlanarLocalizingCursor< T >( this ); } @Override public PlanarLocalizingCursor< T > copyCursor() { return copy(); } /** * Note: This test is fragile in a sense that it returns true for elements * after the last element as well. * * @return false for the last element */ @Override public boolean hasNext() { return ( sliceIndex < lastSliceIndex ) || ( index < lastIndex ); } @Override public void fwd() { if ( ++index > lastIndex ) { index = 0; ++sliceIndex; type.updateContainer( this ); } type.updateIndex( index ); for ( int d = 0; d < n; ++d ) { if ( ++position[ d ] > max[ d ] ) position[ d ] = 0; else break; } } @Override public void jumpFwd( final long steps ) { long newIndex = index + steps; if ( newIndex > lastIndex ) { final long s = newIndex / ( lastIndex + 1 ); newIndex -= s * ( lastIndex + 1 ); sliceIndex += s; type.updateContainer( this ); } index = ( int ) newIndex; type.updateIndex( index ); container.indexToGlobalPosition( sliceIndex, index, position ); } @Override public void reset() { position[ 0 ] = -1; for ( int d = 1; d < n; d++ ) position[ d ] = 0; sliceIndex = 0; index = -1; type.updateIndex( -1 ); type.updateContainer( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarLocalizingCursor1D.java000066400000000000000000000047371316447754700307040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.type.NativeType; /** * TODO * */ public class PlanarLocalizingCursor1D< T extends NativeType< T > > extends PlanarLocalizingCursor< T > { protected PlanarLocalizingCursor1D( final PlanarLocalizingCursor1D< T > cursor ) { super( cursor ); } public PlanarLocalizingCursor1D( final PlanarImg< T, ? > container ) { super( container ); } @Override public PlanarLocalizingCursor1D< T > copy() { return new PlanarLocalizingCursor1D< T >( this ); } @Override public boolean hasNext() { return type.getIndex() < lastIndex; } @Override public void fwd() { type.incIndex(); ++position[ 0 ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarLocalizingCursor2D.java000066400000000000000000000050431316447754700306740ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.type.NativeType; /** * TODO * */ public class PlanarLocalizingCursor2D< T extends NativeType< T > > extends PlanarLocalizingCursor< T > { protected PlanarLocalizingCursor2D( final PlanarLocalizingCursor2D< T > cursor ) { super( cursor ); } public PlanarLocalizingCursor2D( final PlanarImg< T, ? > container ) { super( container ); } @Override public PlanarLocalizingCursor2D< T > copy() { return new PlanarLocalizingCursor2D< T >( this ); } @Override public boolean hasNext() { return type.getIndex() < lastIndex; } @Override public void fwd() { type.incIndex(); if ( ++position[ 0 ] > max[ 0 ] ) { position[ 0 ] = 0; ++position[ 1 ]; } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarPlaneSubsetCursor.java000066400000000000000000000122441316447754700306410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.AbstractCursorInt; import net.imglib2.Interval; import net.imglib2.type.NativeType; /** * Basic Iterator for {@link PlanarImg PlanarContainers} * * @param * * @author Christian Dietz * @author Jonathan Hale */ public class PlanarPlaneSubsetCursor< T extends NativeType< T >> extends AbstractCursorInt< T > implements PlanarImg.PlanarContainerSampler { /** * Access to the type */ private final T type; /** * Container */ private final PlanarImg< T, ? > container; /** * Current slice index */ private final int sliceIndex; /** * Size of one plane */ private final int planeSize; /** * Last index on plane */ private final int lastPlaneIndex; /** * Copy Constructor * * @param cursor - the cursor to copy from. */ protected PlanarPlaneSubsetCursor( final PlanarPlaneSubsetCursor< T > cursor ) { super( cursor.numDimensions() ); container = cursor.container; this.type = container.createLinkedType(); sliceIndex = cursor.sliceIndex; planeSize = cursor.planeSize; lastPlaneIndex = cursor.lastPlaneIndex; type.updateContainer( this ); type.updateIndex( cursor.type.getIndex() ); } /** * Constructor * * @param container - the container this cursor shall work on. * @param interval - the interval to iterate over. */ public PlanarPlaneSubsetCursor( final PlanarImg< T, ? > container, final Interval interval ) { super( container.numDimensions() ); this.type = container.createLinkedType(); this.container = container; this.planeSize = ( ( n > 1 ) ? ( int ) interval.dimension( 1 ) : 1 ) * ( int ) interval.dimension( 0 ); this.lastPlaneIndex = planeSize - 1; this.sliceIndex = ( int ) ( offset( interval ) / planeSize ); reset(); } /** * {@inheritDoc} */ @Override public final int getCurrentSliceIndex() { return sliceIndex; } /** * {@inheritDoc} */ @Override public final T get() { return type; } /** * {@inheritDoc} */ @Override public PlanarPlaneSubsetCursor< T > copy() { return new PlanarPlaneSubsetCursor< T >( this ); } /** * {@inheritDoc} */ @Override public PlanarPlaneSubsetCursor< T > copyCursor() { return copy(); } /** * {@inheritDoc} */ @Override public final boolean hasNext() { return type.getIndex() < lastPlaneIndex; } /** * {@inheritDoc} */ @Override public final void fwd() { type.incIndex(); } /** * {@inheritDoc} */ @Override public final void jumpFwd( final long steps ) { type.incIndex( ( int ) steps ); } /** * {@inheritDoc} */ @Override public final void reset() { // Set index inside the slice type.updateIndex( -1 ); type.updateContainer( this ); } /** * {@inheritDoc} */ @Override public String toString() { return type.toString(); } /** * {@inheritDoc} */ @Override public final void localize( final int[] position ) { container.indexToGlobalPosition( sliceIndex, type.getIndex(), position ); } /** * {@inheritDoc} */ @Override public final int getIntPosition( final int dim ) { return container.indexToGlobalPosition( sliceIndex, type.getIndex(), dim ); } private long offset(final Interval interval) { final int maxDim = numDimensions() - 1; long i = interval.min(maxDim); for (int d = maxDim - 1; d >= 0; --d) i = i * container.dimension(d) + interval.min(d); return i; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarPlaneSubsetLocalizingCursor.java000066400000000000000000000133011316447754700326500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.AbstractLocalizingCursorInt; import net.imglib2.Interval; import net.imglib2.type.NativeType; /** * * Cursor optimized for one plane in an PlanarImg. * * @author Jonathan Hale * @author Tobias Pietzsch * * @param */ public class PlanarPlaneSubsetLocalizingCursor< T extends NativeType< T > > extends AbstractLocalizingCursorInt< T > implements PlanarImg.PlanarContainerSampler { /** * Access to the type */ private final T type; /** * Container */ private final PlanarImg< T, ? > container; /** * Current slice index */ private final int sliceIndex; /** * Last index on the plane */ private final int lastIndexPlane; private final int maxX; private final int dimX; /** * Copy Constructor * * @param cursor * PlanarPlaneSubsetLocalizingCursor to copy from */ protected PlanarPlaneSubsetLocalizingCursor( final PlanarPlaneSubsetLocalizingCursor< T > cursor ) { super( cursor.numDimensions() ); container = cursor.container; this.type = container.createLinkedType(); sliceIndex = cursor.sliceIndex; lastIndexPlane = cursor.lastIndexPlane; maxX = cursor.maxX; dimX = cursor.dimX; for ( int d = 0; d < n; ++d ) position[ d ] = cursor.position[ d ]; type.updateContainer( this ); type.updateIndex( cursor.type.getIndex() ); } /** * Constructor * * @param container * PlanarImg this cursor shall work on. * @param interval * Interval over which shall be iterated. */ public PlanarPlaneSubsetLocalizingCursor( final PlanarImg< T, ? > container, final Interval interval ) { super( container.numDimensions() ); this.type = container.createLinkedType(); this.container = container; final int planeSize = ( ( n > 1 ) ? ( int ) interval.dimension( 1 ) : 1 ) * ( int ) interval.dimension( 0 ); this.lastIndexPlane = planeSize - 1; // Set current slice index sliceIndex = ( int ) ( offset( interval ) / planeSize ); maxX = ( int ) interval.max( 0 ); dimX = ( int ) container.dimension( 0 ); type.updateContainer( this ); // we're working on one container only. for ( int d = 2; d < n; ++d ) position[ d ] = ( int ) interval.min( d ); reset(); } /** * {@inheritDoc} */ @Override public final int getCurrentSliceIndex() { return sliceIndex; } /** * {@inheritDoc} */ @Override public final T get() { return type; } /** * {@inheritDoc} */ @Override public PlanarPlaneSubsetLocalizingCursor< T > copy() { return new PlanarPlaneSubsetLocalizingCursor< T >( this ); } /** * {@inheritDoc} */ @Override public PlanarPlaneSubsetLocalizingCursor< T > copyCursor() { return copy(); } /** * {@inheritDoc} */ @Override public final boolean hasNext() { return type.getIndex() < lastIndexPlane; } /** * {@inheritDoc} */ @Override public final void fwd() { type.incIndex(); if ( ++position[ 0 ] > maxX && n > 1 ) { position[ 0 ] = 0; ++position[ 1 ]; } } /** * {@inheritDoc} */ @Override public final void jumpFwd( final long steps ) { type.incIndex( ( int ) steps ); updatePositionFromIndex( type.getIndex() ); } private void updatePositionFromIndex( final int index ) { if ( n == 1 ) position[ 0 ] = index; else { final int j = index / dimX; position[ 0 ] = index - j * dimX; position[ 1 ] = j; } } /** * {@inheritDoc} */ @Override public final void reset() { type.updateIndex( -1 ); updatePositionFromIndex( type.getIndex() ); } /** * {@inheritDoc} */ @Override public String toString() { return type.toString(); } /* * Computes global offset of the interval in the Img */ private long offset( final Interval interval ) { final int maxDim = numDimensions() - 1; long i = interval.min( maxDim ); for ( int d = maxDim - 1; d >= 0; --d ) i = i * container.dimension( d ) + interval.min( d ); return i; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarRandomAccess.java000066400000000000000000000206201316447754700275550ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.AbstractLocalizableInt; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.type.NativeType; /** * {@link RandomAccess} on a {@link PlanarImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class PlanarRandomAccess< T extends NativeType< T > > extends AbstractLocalizableInt implements RandomAccess< T >, PlanarImg.PlanarContainerSampler { final protected int[] sliceSteps; final protected int width; final protected T type; protected int sliceIndex; protected PlanarRandomAccess( final PlanarRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); sliceSteps = randomAccess.sliceSteps; width = randomAccess.width; sliceIndex = randomAccess.sliceIndex; for ( int d = 0; d < n; ++d ) position[ d ] = randomAccess.position[ d ]; type = randomAccess.type.duplicateTypeOnSameNativeImg(); type.updateContainer( this ); type.updateIndex( randomAccess.type.getIndex() ); } public PlanarRandomAccess( final PlanarImg< T, ? > container ) { super( container.numDimensions() ); sliceSteps = container.sliceSteps; width = ( int ) container.dimension( 0 ); type = container.createLinkedType(); type.updateIndex( 0 ); type.updateContainer( this ); } @Override public int getCurrentSliceIndex() { return sliceIndex; } @Override public T get() { return type; } @Override public PlanarRandomAccess< T > copy() { return new PlanarRandomAccess< T >( this ); } @Override public PlanarRandomAccess< T > copyRandomAccess() { return copy(); } @Override public void fwd( final int d ) { ++position[ d ]; if ( d == 0 ) type.incIndex(); else if ( d == 1 ) type.incIndex( width ); else { sliceIndex += sliceSteps[ d ]; type.updateContainer( this ); } } @Override public void bck( final int d ) { --position[ d ]; if ( d == 0 ) type.decIndex(); else if ( d == 1 ) type.decIndex( width ); else { sliceIndex -= sliceSteps[ d ]; type.updateContainer( this ); } } @Override public void move( final int distance, final int d ) { position[ d ] += distance; if ( d == 0 ) { type.incIndex( distance ); } else if ( d == 1 ) { type.incIndex( distance * width ); } else { sliceIndex += sliceSteps[ d ] * distance; type.updateContainer( this ); } } @Override public void move( final long distance, final int d ) { move( ( int ) distance, d ); } @Override public void move( final Localizable localizable ) { final int d0 = localizable.getIntPosition( 0 ); final int d1 = localizable.getIntPosition( 1 ); type.incIndex( d0 + d1 * width ); position[ 0 ] += d0; position[ 1 ] += d1; for ( int d = 2; d < n; ++d ) { final int dist = localizable.getIntPosition( d ); if ( dist != 0 ) { sliceIndex += dist * sliceSteps[ d ]; position[ d ] += dist; for ( ++d; d < n; ++d ) { if ( dist != 0 ) { sliceIndex += dist * sliceSteps[ d ]; position[ d ] += dist; } } type.updateContainer( this ); } } } @Override public void move( final int[] distance ) { type.incIndex( distance[ 0 ] + distance[ 1 ] * width ); position[ 0 ] += distance[ 0 ]; position[ 1 ] += distance[ 1 ]; for ( int d = 2; d < n; ++d ) { final int dist = distance[ d ]; if ( dist != 0 ) { sliceIndex += dist * sliceSteps[ d ]; position[ d ] += dist; for ( ++d; d < n; ++d ) { if ( dist != 0 ) { sliceIndex += dist * sliceSteps[ d ]; position[ d ] += dist; } } type.updateContainer( this ); } } } @Override public void move( final long[] distance ) { type.incIndex( ( int ) distance[ 0 ] + ( int ) distance[ 1 ] * width ); position[ 0 ] += ( int ) distance[ 0 ]; position[ 1 ] += ( int ) distance[ 1 ]; for ( int d = 2; d < n; ++d ) { final int dist = ( int ) distance[ d ]; if ( dist != 0 ) { sliceIndex += dist * sliceSteps[ d ]; position[ d ] += dist; for ( ++d; d < n; ++d ) { if ( dist != 0 ) { sliceIndex += dist * sliceSteps[ d ]; position[ d ] += dist; } } type.updateContainer( this ); } } } @Override public void setPosition( final int pos, final int d ) { if ( d == 0 ) { type.incIndex( pos - position[ 0 ] ); } else if ( d == 1 ) { type.incIndex( ( pos - position[ 1 ] ) * width ); } else { sliceIndex += ( pos - position[ d ] ) * sliceSteps[ d ]; type.updateContainer( this ); } position[ d ] = pos; } @Override public void setPosition( final long pos, final int d ) { setPosition( ( int ) pos, d ); } @Override public void setPosition( final Localizable localizable ) { final int p0 = localizable.getIntPosition( 0 ); final int p1 = localizable.getIntPosition( 1 ); type.updateIndex( p0 + p1 * width ); position[ 0 ] = p0; position[ 1 ] = p1; for ( int d = 2; d < n; ++d ) { final int pos = localizable.getIntPosition( d ); if ( pos != position[ d ] ) { sliceIndex += ( pos - position[ d ] ) * sliceSteps[ d ]; position[ d ] = pos; for ( ++d; d < n; ++d ) { final int pos2 = localizable.getIntPosition( d ); if ( pos2 != position[ d ] ) { sliceIndex += ( pos2 - position[ d ] ) * sliceSteps[ d ]; position[ d ] = pos2; } } type.updateContainer( this ); } } } @Override public void setPosition( final int[] pos ) { type.updateIndex( pos[ 0 ] + pos[ 1 ] * width ); position[ 0 ] = pos[ 0 ]; position[ 1 ] = pos[ 1 ]; for ( int d = 2; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { sliceIndex += ( pos[ d ] - position[ d ] ) * sliceSteps[ d ]; position[ d ] = pos[ d ]; for ( ++d; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { sliceIndex += ( pos[ d ] - position[ d ] ) * sliceSteps[ d ]; position[ d ] = pos[ d ]; } } type.updateContainer( this ); } } } @Override public void setPosition( final long[] pos ) { type.updateIndex( ( int ) pos[ 0 ] + ( int ) pos[ 1 ] * width ); position[ 0 ] = ( int ) pos[ 0 ]; position[ 1 ] = ( int ) pos[ 1 ]; for ( int d = 2; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { sliceIndex += ( pos[ d ] - position[ d ] ) * sliceSteps[ d ]; position[ d ] = ( int ) pos[ d ]; for ( ++d; d < n; ++d ) { if ( pos[ d ] != position[ d ] ) { sliceIndex += ( pos[ d ] - position[ d ] ) * sliceSteps[ d ]; position[ d ] = ( int ) pos[ d ]; } } type.updateContainer( this ); } } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/planar/PlanarRandomAccess1D.java000066400000000000000000000071631316447754700277510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.type.NativeType; /** * {@link RandomAccess} for a 1-dimensional {@link PlanarImg}. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class PlanarRandomAccess1D< T extends NativeType< T > > extends PlanarRandomAccess< T > { public PlanarRandomAccess1D( final PlanarImg< T, ? > container ) { super( container ); } @Override public void fwd( final int dim ) { ++position[ 0 ]; type.incIndex(); } @Override public void bck( final int dim ) { --position[ 0 ]; type.decIndex(); } @Override public void move( final int distance, final int d ) { position[ 0 ] += distance; type.incIndex( distance ); } @Override public void move( final Localizable localizable ) { final int distance = localizable.getIntPosition( 0 ); position[ 0 ] += distance; type.incIndex( distance ); } @Override public void move( final int[] distance ) { position[ 0 ] += distance[ 0 ]; type.incIndex( distance[ 0 ] ); } @Override public void move( final long[] distance ) { position[ 0 ] += ( int ) distance[ 0 ]; type.incIndex( ( int ) distance[ 0 ] ); } @Override public void setPosition( final int pos, final int dim ) { type.updateIndex( pos ); position[ 0 ] = pos; } @Override public void setPosition( final Localizable localizable ) { final int pos = localizable.getIntPosition( 0 ); type.updateIndex( pos ); this.position[ 0 ] = pos; } @Override public void setPosition( final int[] position ) { type.updateIndex( position[ 0 ] ); this.position[ 0 ] = position[ 0 ]; } @Override public void setPosition( final long[] position ) { type.updateIndex( ( int ) position[ 0 ] ); this.position[ 0 ] = ( int ) position[ 0 ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/000077500000000000000000000000001316447754700232325ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/BooleanNtree.java000066400000000000000000000056721316447754700264640ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; /** * BitAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class BooleanNtree implements NtreeAccess< Boolean, BooleanNtree > { private final long[] position; private final Ntree< Boolean > data; public BooleanNtree( final long[] dimenions, final long[] position, final boolean value ) { this.data = new Ntree< Boolean >( dimenions, value ); this.position = position; } /* Copy constructor */ private BooleanNtree( final Ntree< Boolean > data, final long[] position ) { this.data = data; this.position = position; } public boolean getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } public void setValue( final int index, final boolean value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Boolean > getCurrentStorageNtree() { return data; } @Override public BooleanNtree createInstance( final long[] pos ) { return new BooleanNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/ByteNtree.java000066400000000000000000000057441316447754700260100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.ByteAccess; /** * ByteAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class ByteNtree implements ByteAccess, NtreeAccess< Byte, ByteNtree > { private final long[] position; private final Ntree< Byte > data; public ByteNtree( final long[] dimenions, final long[] position, final Byte value ) { this.data = new Ntree< Byte >( dimenions, value ); this.position = position; } /* Copy constructor */ private ByteNtree( final Ntree< Byte > data, final long[] position ) { this.data = data; this.position = position; } @Override public byte getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final byte value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Byte > getCurrentStorageNtree() { return data; } @Override public ByteNtree createInstance( final long[] pos ) { return new ByteNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/CharNtree.java000066400000000000000000000060021316447754700257460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.CharAccess; /** * CharAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class CharNtree implements CharAccess, NtreeAccess< Character, CharNtree > { private final long[] position; private final Ntree< Character > data; public CharNtree( final long[] dimenions, final long[] position, final Character value ) { this.data = new Ntree< Character >( dimenions, value ); this.position = position; } /* Copy constructor */ private CharNtree( final Ntree< Character > data, final long[] position ) { this.data = data; this.position = position; } @Override public char getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final char value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Character > getCurrentStorageNtree() { return data; } @Override public CharNtree createInstance( final long[] pos ) { return new CharNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/DoubleNtree.java000066400000000000000000000057761316447754700263240ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.DoubleAccess; /** * DoubleAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class DoubleNtree implements DoubleAccess, NtreeAccess< Double, DoubleNtree > { private final long[] position; private final Ntree< Double > data; public DoubleNtree( final long[] dimenions, final long[] position, final Double value ) { this.data = new Ntree< Double >( dimenions, value ); this.position = position; } /* Copy constructor */ private DoubleNtree( final Ntree< Double > data, final long[] pos ) { this.data = data; this.position = pos; } @Override public double getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final double value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Double > getCurrentStorageNtree() { return data; } @Override public DoubleNtree createInstance( final long[] pos ) { return new DoubleNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/FloatNtree.java000066400000000000000000000057671316447754700261570ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.FloatAccess; /** * FloatAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class FloatNtree implements FloatAccess, NtreeAccess< Float, FloatNtree > { private final long[] position; private final Ntree< Float > data; public FloatNtree( final long[] dimenions, final long[] position, final Float value ) { this.data = new Ntree< Float >( dimenions, value ); this.position = position; } /* Copy constructor */ private FloatNtree( final Ntree< Float > data, final long[] position ) { this.data = data; this.position = position; } @Override public float getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final float value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Float > getCurrentStorageNtree() { return data; } @Override public FloatNtree createInstance( final long[] pos ) { return new FloatNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/IntNtree.java000066400000000000000000000062631316447754700256340ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.IntAccess; /** * IntAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class IntNtree implements IntAccess, NtreeAccess< Integer, IntNtree > { private final long[] position; private final Ntree< Integer > data; /** * Standard constructor called by factory * * @param dimensions * The dimensions of the tree * @param value * Uniform value of created nodes of the tree */ public IntNtree( final long[] dimensions, final long[] position, final int value ) { this.data = new Ntree< Integer >( dimensions, value ); this.position = position; } /* Copy constructor */ private IntNtree( final Ntree< Integer > data, final long[] position ) { this.data = data; this.position = position; } @Override public int getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final int value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Integer > getCurrentStorageNtree() { return data; } @Override public IntNtree createInstance( final long[] pos ) { return new IntNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/LongNtree.java000066400000000000000000000062271316447754700260010ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.LongAccess; /** * LongAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class LongNtree implements LongAccess, NtreeAccess< Long, LongNtree > { private final long[] position; private final Ntree< Long > data; /** * Standard constructor called by factory * * @param dimensions * The dimensions of the tree * @param value * Uniform value of created nodes of the tree */ public LongNtree( final long[] dimensions, final long[] position, final long value ) { this.data = new Ntree< Long >( dimensions, value ); this.position = position; } public LongNtree( final Ntree< Long > data, final long[] position ) { this.data = data; this.position = position; } @Override public long getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final long value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Long > getCurrentStorageNtree() { return data; } @Override public LongNtree createInstance( final long[] pos ) { return new LongNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/Ntree.java000066400000000000000000000210101316447754700251440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; /** * N-dimensional equivalent of a quad/oct-tree. * * @author Tobias Pietzsch */ public final class Ntree< T extends Comparable< T >> { public static final class NtreeNode< T > { private T value; private final NtreeNode< T > parent; private NtreeNode< T >[] children; public NtreeNode( final NtreeNode< T > parent, final T value ) { this.parent = parent; this.value = value; } boolean hasChildren() { return children != null; } public T getValue() { return value; } public void setValue( final T value ) { this.value = value; } public NtreeNode< T >[] getChildren() { return children; } public void setChildren( final NtreeNode< T >[] children ) { this.children = children; } } /** * number of dimensions. */ final int n; /** * maximum depth of the tree. */ final int numTreeLevels; /** * how many children (if any) each node has. */ final int numChildren; /** * Root of the tree */ NtreeNode< T > root; /** * dimensions of tree */ final long[] dimensions; // /** // * KNIME requirements, empty constructor for fast serialization // */ // public Ntree() { // } /** * Create a ntree structure capable of representing an array of the given * dimensions. Initially, the tree contains only a root node and represents * an array of uniform values. * * @param dimensions * of the array * @param value * uniform value of all pixels in the array */ public Ntree( final long[] dimensions, final T value ) { this.n = dimensions.length; this.dimensions = dimensions.clone(); // set the maximum number of levels in the ntree. // This is how many times to split the maximum dimension // in half to arrive at a single pixel long maxdim = 0; for ( int d = 0; d < n; ++d ) maxdim = Math.max( maxdim, dimensions[ d ] ); this.numTreeLevels = ( int ) Math.ceil( Math.log( maxdim ) / Math.log( 2 ) ) + 1; this.numChildren = 1 << n; this.root = new NtreeNode< T >( null, value ); } /** * helper method for the copy constructor {@link #Ntree(Ntree)} to create a * deep copy of the tree. */ @SuppressWarnings( "unchecked" ) private NtreeNode< T > copyRecursively( final NtreeNode< T > node, final NtreeNode< T > newParent ) { final NtreeNode< T > copy = new NtreeNode< T >( newParent, node.getValue() ); if ( node.hasChildren() ) { copy.children = new NtreeNode[ numChildren ]; for ( int i = 0; i < numChildren; ++i ) { copy.children[ i ] = copyRecursively( node.children[ i ], copy ); } } return copy; } /** * Copy constructor. Create a deep copy of ntree. */ Ntree( final Ntree< T > ntree ) { dimensions = ntree.dimensions; n = ntree.n; numTreeLevels = ntree.numTreeLevels; numChildren = ntree.numChildren; root = copyRecursively( ntree.root, null ); } /** * Get the lowest-level node containing position. Note that position is not * necessarily the only pixel inside the node. So use this for read-access * to pixel values only. * * @param position * a position inside the image. * @return the lowest-level node containing position. */ synchronized NtreeNode< T > getNode( final long[] position ) { NtreeNode< T > current = root; for ( int l = numTreeLevels - 2; l >= 0; --l ) { if ( !current.hasChildren() ) break; final long bitmask = 1 << l; int childindex = 0; for ( int d = 0; d < n; ++d ) if ( ( position[ d ] & bitmask ) != 0 ) childindex |= 1 << d; current = current.children[ childindex ]; } return current; } /** * Create a node containing only position (if it does not exist already). * This may insert nodes at several levels in the tree. * * @param position * a position inside the image. * @return node containing exactly position. */ @SuppressWarnings( "unchecked" ) synchronized NtreeNode< T > createNode( final long[] position ) { NtreeNode< T > current = root; for ( int l = numTreeLevels - 2; l >= 0; --l ) { if ( !current.hasChildren() ) { current.children = new NtreeNode[ numChildren ]; for ( int i = 0; i < numChildren; ++i ) current.children[ i ] = new NtreeNode< T >( current, current.getValue() ); } final long bitmask = 1 << l; int childindex = 0; for ( int d = 0; d < n; ++d ) if ( ( position[ d ] & bitmask ) != 0 ) childindex |= 1 << d; current = current.children[ childindex ]; } return current; } /** * Set the value at position and get the lowest-level node containing * position. Note that position is not necessarily the only pixel inside the * node, if the value matches neighboring values. If necessary, new nodes * will be created. If possible, nodes will be merged. * * @param position * a position inside the image. * @param value * value to store at position. * @return node containing position. */ @SuppressWarnings( "unchecked" ) synchronized NtreeNode< T > createNodeWithValue( final long[] position, final T value ) { NtreeNode< T > current = root; for ( int l = numTreeLevels - 2; l >= 0; --l ) { if ( !current.hasChildren() ) { if ( current.getValue().compareTo( value ) == 0 ) return current; current.children = new NtreeNode[ numChildren ]; for ( int i = 0; i < numChildren; ++i ) current.children[ i ] = new NtreeNode< T >( current, current.getValue() ); } final long bitmask = 1 << l; int childindex = 0; for ( int d = 0; d < n; ++d ) if ( ( position[ d ] & bitmask ) != 0 ) childindex |= 1 << d; current = current.children[ childindex ]; } if ( current.getValue().compareTo( value ) == 0 ) return current; current.setValue( value ); return mergeUpwards( current ); } /** * If all the children of our parent have the same value remove them all. * Call recursively for parent. * * @param node * the starting node (whose parents should be tested * recursively). * @return node that the starting node was ultimately merged into. */ NtreeNode< T > mergeUpwards( final NtreeNode< T > node ) { final NtreeNode< T > parent = node.parent; if ( parent == null ) return node; final NtreeNode< T > child0 = parent.children[ 0 ]; if ( child0.hasChildren() ) return node; for ( int i = 1; i < numChildren; ++i ) { final NtreeNode< T > child = parent.children[ i ]; if ( child.hasChildren() || child0.getValue().compareTo( child.getValue() ) != 0 ) return node; } parent.setValue( child0.getValue() ); parent.children = null; return mergeUpwards( parent ); } /** * Returns the root node of the ntree * * @return root node */ public NtreeNode< T > getRootNode() { return root; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/NtreeAccess.java000066400000000000000000000040031316447754700262710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; public interface NtreeAccess< L extends Comparable< L >, A extends NtreeAccess< L, A > > { Ntree< L > getCurrentStorageNtree(); A createInstance( long[] pos ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/NtreeCursor.java000066400000000000000000000061361316447754700263560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.Cursor; import net.imglib2.img.sparse.NtreeImg.PositionProvider; import net.imglib2.iterator.LocalizingIntervalIterator; import net.imglib2.type.NativeType; /** * @author Tobias Pietzsch * */ public final class NtreeCursor< T extends NativeType< T >> extends LocalizingIntervalIterator implements Cursor< T >, PositionProvider { private final NtreeImg< T, ? > img; private final T type; public NtreeCursor( final NtreeImg< T, ? > img ) { super( img ); this.img = img; this.type = img.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = 0; position[ 0 ]--; type.updateContainer( this ); } private NtreeCursor( final NtreeCursor< T > cursor ) { super( cursor ); this.img = cursor.img; this.type = img.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = cursor.position[ d ]; type.updateContainer( this ); } @Override public T get() { return type; } @Override public T next() { fwd(); return get(); } @Override public void remove() {} @Override public NtreeCursor< T > copy() { return new NtreeCursor< T >( this ); } @Override public NtreeCursor< T > copyCursor() { return copy(); } @Override public long[] getPosition() { return position; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/NtreeImg.java000066400000000000000000000100261316447754700256060ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import java.io.Serializable; import net.imglib2.FlatIterationOrder; import net.imglib2.img.AbstractNativeImg; import net.imglib2.img.ImgFactory; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * @author Tobias Pietzsch * */ public final class NtreeImg< T extends NativeType< T >, A extends NtreeAccess< ?, A >> extends AbstractNativeImg< T, A > implements Serializable { /** * TODO: remove with proper serialization */ private static final long serialVersionUID = 1L; // final Ntree ntree; final A data; public NtreeImg( final A data, final long[] dim, final Fraction entitiesPerPixel ) { super( dim, entitiesPerPixel ); // this.ntree = new Ntree(dimensions, 0); this.data = data; } private NtreeImg( final NtreeImg< T, A > img ) { super( img.dimension, new Fraction() ); // this.ntree = new Ntree(img.dimension, 0); this.data = img.data; } public static interface PositionProvider { long[] getPosition(); } // updater is the RandomAccess / Cursor etc // each call creates a new IntAccess wrapper @Override public A update( final Object updater ) { return data.createInstance( ( ( PositionProvider ) updater ).getPosition() ); } /* * (non-Javadoc) * * @see net.imglib2.RandomAccessible#randomAccess() */ @Override public NtreeRandomAccess< T > randomAccess() { return new NtreeRandomAccess< T >( this ); } @Override public NtreeCursor< T > cursor() { return new NtreeCursor< T >( this ); } @Override public NtreeCursor< T > localizingCursor() { return cursor(); } @Override public ImgFactory< T > factory() { return new NtreeImgFactory< T >(); } @Override public NtreeImg< T, A > copy() { // TODO: More efficient way to create a copy of the img @SuppressWarnings( "unchecked" ) final NtreeImg< T, A > copy = ( NtreeImg< T, A > ) factory().create( dimension, firstElement().createVariable() ); final NtreeCursor< T > source = this.cursor(); final NtreeCursor< T > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); return copy; } @Override public FlatIterationOrder iterationOrder() { return new FlatIterationOrder( this ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/NtreeImgFactory.java000066400000000000000000000126441316447754700271460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.exception.IncompatibleTypeException; import net.imglib2.img.ImgFactory; import net.imglib2.img.NativeImgFactory; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * @author Tobias Pietzsch * */ public class NtreeImgFactory< T extends NativeType< T >> extends NativeImgFactory< T > { @Override public NtreeImg< T, ? > create( final long[] dim, final T type ) { return ( NtreeImg< T, ? > ) type.createSuitableNativeImg( this, dim ); } @Override public NtreeImg< T, ByteNtree > createByteInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, ByteNtree >( new ByteNtree( dimensions, new long[ dimensions.length ], ( byte ) 0 ), dimensions, entitiesPerPixel ); } @Override public NtreeImg< T, CharNtree > createCharInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, CharNtree >( new CharNtree( dimensions, new long[ dimensions.length ], ( char ) 0 ), dimensions, entitiesPerPixel ); } @Override public NtreeImg< T, ShortNtree > createShortInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, ShortNtree >( new ShortNtree( dimensions, new long[ dimensions.length ], ( short ) 0 ), dimensions, entitiesPerPixel ); } @Override public NtreeImg< T, IntNtree > createIntInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, IntNtree >( new IntNtree( dimensions, new long[ dimensions.length ], 0 ), dimensions, entitiesPerPixel ); } @Override public NtreeImg< T, LongNtree > createLongInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, LongNtree >( new LongNtree( dimensions, new long[ dimensions.length ], 0 ), dimensions, entitiesPerPixel ); } @Override public NtreeImg< T, FloatNtree > createFloatInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, FloatNtree >( new FloatNtree( dimensions, new long[ dimensions.length ], 0.0f ), dimensions, entitiesPerPixel ); } @Override public NtreeImg< T, DoubleNtree > createDoubleInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { if ( entitiesPerPixel.getNumerator() != entitiesPerPixel.getDenominator() ) throw new RuntimeException( "not implemented" ); return new NtreeImg< T, DoubleNtree >( new DoubleNtree( dimensions, new long[ dimensions.length ], 0.0d ), dimensions, entitiesPerPixel ); } @SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { if ( NativeType.class.isInstance( type ) ) return new NtreeImgFactory(); throw new IncompatibleTypeException( this, type.getClass().getCanonicalName() + " does not implement NativeType." ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/NtreeIntAccess.java000066400000000000000000000052131316447754700267500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.IntAccess; // TODO: REMOVE? This seems redundant with IntNTree? /** * IntAccess based on a {@link Ntree}{@code}. * * @author Tobias Pietzsch */ public final class NtreeIntAccess implements IntAccess { private final Ntree< Integer > ntree; private final long[] position; public NtreeIntAccess( final Ntree< Integer > ntree, final long[] position ) { this.ntree = ntree; this.position = position; } @Override public int getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return ntree.getNode( position ).getValue(); } @Override public void setValue( final int index, final int value ) { // ignore index, get tree position from RandomAccess/Cursor ntree.createNodeWithValue( position, value ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/NtreeRandomAccess.java000066400000000000000000000134051316447754700274400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.img.sparse.NtreeImg.PositionProvider; import net.imglib2.type.NativeType; import net.imglib2.util.Util; /** * @author Tobias Pietzsch * */ public final class NtreeRandomAccess< T extends NativeType< T >> implements PositionProvider, RandomAccess< T > { private final NtreeImg< T, ? > img; private final T type; private final int n; private final long[] position; public NtreeRandomAccess( final NtreeImg< T, ? > img ) { this.n = img.numDimensions(); this.position = new long[ img.numDimensions() ]; this.img = img; this.type = img.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = 0; type.updateContainer( this ); } private NtreeRandomAccess( final NtreeRandomAccess< T > randomAccess ) { this.n = randomAccess.numDimensions(); this.position = new long[ randomAccess.numDimensions() ]; this.img = randomAccess.img; this.type = img.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = randomAccess.position[ d ]; type.updateContainer( this ); } @Override public void fwd( final int d ) { ++position[ d ]; } @Override public void bck( final int d ) { --position[ d ]; } @Override public void move( final long distance, final int d ) { position[ d ] += distance; } @Override public void setPosition( final int[] pos ) { for ( int d = 0; d < n; ++d ) position[ d ] = pos[ d ]; } @Override public void setPosition( final long[] pos ) { for ( int d = 0; d < n; ++d ) position[ d ] = pos[ d ]; } @Override public void setPosition( final long pos, final int d ) { position[ d ] = pos; } @Override public T get() { return type; } @Override public NtreeRandomAccess< T > copy() { return new NtreeRandomAccess< T >( this ); } @Override public NtreeRandomAccess< T > copyRandomAccess() { return copy(); } @Override public long[] getPosition() { return position; } @Override public void move( final int distance, final int dim ) { move( ( long ) distance, dim ); } @Override public void setPosition( final int position, final int dim ) { setPosition( ( long ) position, dim ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) { final long dist = distance[ d ]; if ( dist != 0 ) move( dist, d ); } } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) { final long dist = distance[ d ]; if ( dist != 0 ) move( dist, d ); } } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) { final long dist = localizable.getLongPosition( d ); if ( dist != 0 ) move( dist, d ); } } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) { setPosition( localizable.getLongPosition( d ), d ); } } @Override public void localize( final float[] pos ) { for ( int d = 0; d < n; d++ ) pos[ d ] = this.position[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < n; d++ ) pos[ d ] = this.position[ d ]; } @Override public void localize( final int[] pos ) { for ( int d = 0; d < n; d++ ) pos[ d ] = ( int ) this.position[ d ]; } @Override public void localize( final long[] pos ) { for ( int d = 0; d < n; d++ ) pos[ d ] = this.position[ d ]; } @Override public float getFloatPosition( final int dim ) { return position[ dim ]; } @Override public double getDoublePosition( final int dim ) { return position[ dim ]; } @Override public int getIntPosition( final int dim ) { return ( int ) position[ dim ]; } @Override public long getLongPosition( final int dim ) { return position[ dim ]; } @Override public String toString() { return Util.printCoordinates( position ) + " = " + get(); } @Override public int numDimensions() { return n; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/img/sparse/ShortNtree.java000066400000000000000000000056521316447754700262020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import net.imglib2.img.basictypeaccess.ShortAccess; /** * * @author Tobias Pietzsch */ public final class ShortNtree implements ShortAccess, NtreeAccess< Short, ShortNtree > { private final long[] position; private final Ntree< Short > data; public ShortNtree( final long[] dimenions, final long[] position, final short value ) { this.data = new Ntree< Short >( dimenions, value ); this.position = position; } public ShortNtree( final Ntree< Short > data, final long[] position ) { this.data = data; this.position = position; } @Override public short getValue( final int index ) { // ignore index, get tree position from RandomAccess/Cursor return data.getNode( position ).getValue(); } @Override public void setValue( final int index, final short value ) { // ignore index, get tree position from RandomAccess/Cursor data.createNodeWithValue( position, value ); } @Override public Ntree< Short > getCurrentStorageNtree() { return data; } @Override public ShortNtree createInstance( final long[] pos ) { return new ShortNtree( data, pos ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/000077500000000000000000000000001316447754700240505ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/Interpolant.java000066400000000000000000000057521316447754700272230ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation; import net.imglib2.EuclideanSpace; import net.imglib2.RealInterval; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; import net.imglib2.View; /** * A {@link RealRandomAccessible} that is generated through interpolation. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ final public class Interpolant< T, F extends EuclideanSpace > implements RealRandomAccessible< T >, View { final protected F source; final InterpolatorFactory< T, F > factory; public Interpolant( final F source, final InterpolatorFactory< T, F > factory ) { this.source = source; this.factory = factory; } @Override public int numDimensions() { return source.numDimensions(); } @Override public RealRandomAccess< T > realRandomAccess() { return factory.create( source ); } @Override public RealRandomAccess< T > realRandomAccess( final RealInterval interval ) { return factory.create( source, interval ); } public F getSource() { return source; } /** * @return {@link InterpolatorFactory} used for interpolation */ public InterpolatorFactory< T, F > getInterpolatorFactory() { return factory; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/InterpolatorFactory.java000066400000000000000000000045231316447754700307310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation; import net.imglib2.RealInterval; import net.imglib2.RealRandomAccess; /** * @param * Type of values provided by the interpolator. * @param * Type of function, which the interpolator operates on. * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface InterpolatorFactory< T, F > { public RealRandomAccess< T > create( final F f ); public RealRandomAccess< T > create( final F f, final RealInterval interval ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/neighborsearch/000077500000000000000000000000001316447754700270335ustar00rootroot00000000000000InverseDistanceWeightingInterpolator.java000066400000000000000000000106501316447754700371600ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/neighborsearch/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.neighborsearch; import net.imglib2.RealPoint; import net.imglib2.RealRandomAccess; import net.imglib2.Sampler; import net.imglib2.neighborsearch.KNearestNeighborSearch; import net.imglib2.type.numeric.RealType; /** * {@link RealRandomAccess} to a {@link KNearestNeighborSearch} whose sample * value is generated by weighting the k nearest neighbors of a query * real coordinate by their inverse distance to an arbitrary power p. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class InverseDistanceWeightingInterpolator< T extends RealType< T > > extends RealPoint implements RealRandomAccess< T > { final static protected double minThreshold = Double.MIN_VALUE * 1000; final protected KNearestNeighborSearch< T > search; final T value; final int numNeighbors; final double p; final double p2; /** * Creates a new {@link InverseDistanceWeightingInterpolator} based on a * {@link KNearestNeighborSearch}. * * @param search * - the {@link KNearestNeighborSearch} * @param p * power applied to the distance, higher values result in * 'sharper' results, 0 results in a non-weighted mean of the * k nearest neighbors. */ public InverseDistanceWeightingInterpolator( final KNearestNeighborSearch< T > search, final double p ) { super( search.numDimensions() ); this.search = search; this.p = p; p2 = p / 2.0; search.search( this ); this.value = search.getSampler( 0 ).get().copy(); this.numNeighbors = search.getK(); } @Override public T get() { search.search( this ); if ( numNeighbors == 1 || search.getSquareDistance( 0 ) / search.getSquareDistance( 1 ) < minThreshold ) value.set( search.getSampler( 0 ).get() ); else { double sumIntensity = 0; double sumWeights = 0; for ( int i = 0; i < numNeighbors; ++i ) { final Sampler< T > sampler = search.getSampler( i ); if ( sampler == null ) break; final T t = sampler.get(); final double weight = computeWeight( search.getSquareDistance( i ) ); sumWeights += weight; sumIntensity += t.getRealDouble() * weight; } value.setReal( sumIntensity / sumWeights ); } return value; } protected double computeWeight( final double squareDistance ) { return 1.0 / Math.pow( squareDistance, p2 ); } @Override public InverseDistanceWeightingInterpolator< T > copy() { return new InverseDistanceWeightingInterpolator< T >( search.copy(), p ); } @Override public InverseDistanceWeightingInterpolator< T > copyRealRandomAccess() { return copy(); } } InverseDistanceWeightingInterpolatorFactory.java000066400000000000000000000065221316447754700405130ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/neighborsearch/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.neighborsearch; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; import net.imglib2.neighborsearch.KNearestNeighborSearch; import net.imglib2.type.numeric.RealType; /** * Factory for {@link InverseDistanceWeightingInterpolator} instances that work * on a {@link KNearestNeighborSearch}. * * @param * * @author Tobias Pietzsch * @author Stephan Preibisch */ public class InverseDistanceWeightingInterpolatorFactory< T extends RealType< T > > implements InterpolatorFactory< T, KNearestNeighborSearch< T > > { final double p; public InverseDistanceWeightingInterpolatorFactory() { this.p = 3; } public InverseDistanceWeightingInterpolatorFactory( final double p ) { this.p = p; } /** * Creates a new {@link InverseDistanceWeightingInterpolator} using a copy * of the passed {@link KNearestNeighborSearch}. */ @Override public InverseDistanceWeightingInterpolator< T > create( final KNearestNeighborSearch< T > search ) { return new InverseDistanceWeightingInterpolator< T >( search.copy(), p ); } /** *

* Creates a new {@link InverseDistanceWeightingInterpolator} using a copy * of the passed {@link KNearestNeighborSearch}. *

* *

* For now, ignore the {@link RealInterval} and return * {@link #create(KNearestNeighborSearch)}. *

*/ @Override public InverseDistanceWeightingInterpolator< T > create( final KNearestNeighborSearch< T > search, final RealInterval interval ) { return create( search ); } } NearestNeighborSearchInterpolator.java000066400000000000000000000054501316447754700364330ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/neighborsearch/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.neighborsearch; import net.imglib2.RealPoint; import net.imglib2.RealRandomAccess; import net.imglib2.neighborsearch.NearestNeighborSearch; /** * Nearest-neighbor interpolation implemented by {@link NearestNeighborSearch}. * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public class NearestNeighborSearchInterpolator< T > extends RealPoint implements RealRandomAccess< T > { final protected NearestNeighborSearch< T > search; public NearestNeighborSearchInterpolator( final NearestNeighborSearch< T > search ) { super( search.numDimensions() ); this.search = search; } @Override public T get() { search.search( this ); return search.getSampler().get(); } @Override public NearestNeighborSearchInterpolator< T > copy() { return new NearestNeighborSearchInterpolator< T >( search.copy() ); } @Override public NearestNeighborSearchInterpolator< T > copyRealRandomAccess() { return copy(); } } NearestNeighborSearchInterpolatorFactory.java000066400000000000000000000061331316447754700377620ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/neighborsearch/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.neighborsearch; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; import net.imglib2.neighborsearch.NearestNeighborSearch; /** * Factory for {@link NearestNeighborSearchInterpolator} instances that work on * a {@link NearestNeighborSearch}. * * @param * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public class NearestNeighborSearchInterpolatorFactory< T > implements InterpolatorFactory< T, NearestNeighborSearch< T > > { /** * Creates a new {@link NearestNeighborSearchInterpolator} using a copy of * the passed {@link NearestNeighborSearch}. */ @Override public NearestNeighborSearchInterpolator< T > create( final NearestNeighborSearch< T > search ) { return new NearestNeighborSearchInterpolator< T >( search.copy() ); } /** *

* Creates a new {@link NearestNeighborSearchInterpolator} using a copy of * the passed {@link NearestNeighborSearch}. *

* *

* For now, ignore the {@link RealInterval} and return * {@link #create(NearestNeighborSearch)}. *

*/ @Override public NearestNeighborSearchInterpolator< T > create( final NearestNeighborSearch< T > search, final RealInterval interval ) { return create( search ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/000077500000000000000000000000001316447754700265125ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/FloorInterpolator.java000066400000000000000000000074141316447754700330470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RealRandomAccess; import net.imglib2.position.transform.Floor; /** * {@link RealRandomAccess} to a {@link RandomAccess} by nearest floor * interpolation (i.e., the value is sampled at floor(x)). * *

In ImgLib2, the coordinate of a sample corresponds to the 'center' point * of the sample, i.e. the location at which the sample was acquired. This * scheme is intuitive in both rasters and irregularly samples data but can * trigger confusion when displaying images on a screen with a pixel raster * which, in this scheme, spans the range [-0.5,width-0.5]. In the * screen-friendly alternative scheme, where sample coordinates reference the * top left corner of the pixel rectangle representing a sample the range * covered by an image is [0,width], however, coordinate transfer * functions other than translation and homogeneous scaling generate different * results than in the center-scheme. Rendering an image using * {@link FloorInterpolator} means using the top-left-scheme, rendering it * using {@link NearestNeighborInterpolator}, {@link NLinearInterpolator}, or * {@link LanczosInterpolator} means using the center-scheme.

* * @param * * @author Stephan Saalfeld */ public class FloorInterpolator< T > extends Floor< RandomAccess< T > > implements RealRandomAccess< T > { protected FloorInterpolator( final FloorInterpolator< T > floorInterpolator ) { super( floorInterpolator.target.copyRandomAccess() ); } protected FloorInterpolator( final RandomAccessible< T > randomAccessible ) { super( randomAccessible.randomAccess() ); } @Override public T get() { return target.get(); } @Override public FloorInterpolator< T > copy() { return new FloorInterpolator< T >( this ); } @Override public FloorInterpolator< T > copyRealRandomAccess() { return copy(); } } FloorInterpolatorFactory.java000066400000000000000000000051011316447754700343070ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; /** * * @param * * @author Stephan Saalfeld */ public class FloorInterpolatorFactory< T > implements InterpolatorFactory< T, RandomAccessible< T > > { @Override public FloorInterpolator< T > create( final RandomAccessible< T > randomAccessible ) { return new FloorInterpolator< T >( randomAccessible ); } /** * For now, ignore the {@link RealInterval} and return * {@link #create(RandomAccessible)}. */ @Override public FloorInterpolator< T > create( final RandomAccessible< T > randomAccessible, final RealInterval interval ) { return create( randomAccessible ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/LanczosInterpolator.java000066400000000000000000000153601316447754700333760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RealRandomAccess; import net.imglib2.Sampler; import net.imglib2.position.transform.FloorOffset; import net.imglib2.type.numeric.RealType; /** * n-dimensional double-based Lanczos Interpolation * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class LanczosInterpolator< T extends RealType< T > > extends FloorOffset< RandomAccess< T > > implements RealRandomAccess< T > { final static protected double piSquare = Math.PI * Math.PI; final static protected int lutScale = 10; final protected int alpha; final protected T interpolatedValue; final protected long[] size, max; final protected double minValue, maxValue; final protected boolean clip; final protected double[] lut, products; final static private long[] createOffset( final int a, final int n ) { final long[] offset = new long[ n ]; for ( int d = 0; d < n; ++d ) offset[ d ] = -a + 1; return offset; } /** * Creates a new Lanczos-interpolation * * @param randomAccessible * - the {@link RandomAccessible} to work on * @param alpha * - the radius of values to incorporate (typically 2 or 3) * @param clip * - clips the value to range of the {@link RealType}, i.e. tests * if the interpolated value is out of range * @param min * - range for clipping (ignored if min==max) * @param max * - range for clipping (ignored if min==max) */ public LanczosInterpolator( final RandomAccessible< T > randomAccessible, final int alpha, final boolean clip, final double min, final double max ) { super( randomAccessible.randomAccess(), createOffset( alpha, randomAccessible.numDimensions() ) ); this.alpha = alpha; lut = createLanczosLUT( alpha, lutScale ); products = new double[ n + 1 ]; products[ n ] = 1.0; this.size = new long[ n ]; this.max = new long[ n ]; for ( int d = 0; d < n; ++d ) size[ d ] = alpha * 2; this.clip = clip; this.interpolatedValue = target.get().createVariable(); if ( min == max ) { this.minValue = interpolatedValue.getMinValue(); this.maxValue = interpolatedValue.getMaxValue(); } else { this.minValue = min; this.maxValue = max; } } public LanczosInterpolator( final LanczosInterpolator< T > interpolator ) { super( interpolator.target.copyRandomAccess(), interpolator.offset ); this.alpha = interpolator.alpha; lut = interpolator.lut.clone(); products = interpolator.products.clone(); this.size = interpolator.size.clone(); this.max = interpolator.max.clone(); this.clip = interpolator.clip; this.interpolatedValue = interpolator.interpolatedValue.copy(); this.minValue = interpolator.minValue; this.maxValue = interpolator.maxValue; } final static private double[] createLanczosLUT( final int max, final int scale ) { final double[] lut = new double[ max * scale + 2 ]; for ( int i = 0; i < lut.length; ++i ) { final double x = ( double ) i / ( double ) lutScale; lut[ i ] = lanczos( x, max ); } return lut; } final protected void resetKernel() { for ( int d = n - 1; d >= 0; --d ) { final long p = target.getLongPosition( d ); max[ d ] = p + size[ d ]; products[ d ] = lookUpLanczos( position[ d ] - p ) * products[ d + 1 ]; } } final protected void accumulate( final int d ) { for ( int e = d; e >= 0; --e ) products[ e ] = lookUpLanczos( position[ e ] - target.getLongPosition( e ) ) * products[ e + 1 ]; } @Override public T get() { double convolved = 0; resetKernel(); boolean proceed = true; A: while ( proceed ) { convolved += target.get().getRealDouble() * products[ 0 ]; for ( int d = 0; d < n; ++d ) { target.fwd( d ); final long p = target.getLongPosition( d ); if ( p < max[ d ] ) { products[ d ] = lookUpLanczos( position[ d ] - p ) * products[ ++d ]; continue A; } target.move( -size[ d ], d ); accumulate( d ); } proceed = false; } // do clipping if desired (it should be, except maybe for float or // double input) if ( clip ) { if ( convolved < minValue ) convolved = minValue; else if ( convolved > maxValue ) convolved = maxValue; } interpolatedValue.setReal( convolved ); return interpolatedValue; } private static final double lanczos( final double x, final double a ) { if ( x == 0 ) return 1; return ( ( a * Math.sin( Math.PI * x ) * Math.sin( Math.PI * x / a ) ) / ( piSquare * x * x ) ); } final private double lookUpLanczos( final double x ) { final double y = x < 0 ? -lutScale * x : lutScale * x; final int yi = ( int ) y; final double d = y - yi; return ( lut[ yi + 1 ] - lut[ yi ] ) * d + lut[ yi ]; } @Override public Sampler< T > copy() { return copy(); } @Override public RealRandomAccess< T > copyRealRandomAccess() { return new LanczosInterpolator< T >( this ); } } LanczosInterpolatorFactory.java000066400000000000000000000135451316447754700346520ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; import net.imglib2.type.Type; import net.imglib2.type.numeric.RealType; /** * TODO * */ public class LanczosInterpolatorFactory< T extends RealType< T > > implements InterpolatorFactory< T, RandomAccessible< T > > { int alpha; boolean clipping; double min, max; /** * Creates a new {@link LanczosInterpolatorFactory} using the Lanczos (sinc) * interpolation in a certain window * * @param alpha * the rectangular radius of the window for perfoming the lanczos * interpolation * @param clipping * the lanczos-interpolation can create values that are bigger or * smaller than the original values, so they can be clipped to * the range of the {@link Type} if wanted */ public LanczosInterpolatorFactory( final int alpha, final boolean clipping ) { this.alpha = alpha; this.clipping = clipping; this.min = this.max = 0; } /** * Creates a new {@link LanczosInterpolatorFactory} using the Lanczos (sinc) * interpolation in a certain window * * @param alpha * the rectangular radius of the window for perfoming the lanczos * interpolation * @param min * the lanczos-interpolation can create values that are bigger or * smaller than the original values, so they can be clipped to * the range of the if wanted * @param max * the lanczos-interpolation can create values that are bigger or * smaller than the original values, so they can be clipped to * the range of the if wanted */ public LanczosInterpolatorFactory( final int alpha, final double min, final double max ) { this.alpha = alpha; this.clipping = true; this.min = min; this.max = max; } /** * Creates a new {@link LanczosInterpolatorFactory} using the Lanczos (sinc) * interpolation in a certain window * * @param min * the lanczos-interpolation can create values that are bigger or * smaller than the original values, so they can be clipped to * the range of the if wanted * @param max * the lanczos-interpolation can create values that are bigger or * smaller than the original values, so they can be clipped to * the range of the if wanted */ public LanczosInterpolatorFactory( final double min, final double max ) { this.alpha = 3; this.clipping = true; this.min = min; this.max = max; } /** * Creates a new {@link LanczosInterpolatorFactory} with standard parameters * (do clipping, alpha=3) */ public LanczosInterpolatorFactory() { this( 3, true ); } @Override public LanczosInterpolator< T > create( final RandomAccessible< T > randomAccessible ) { return new LanczosInterpolator< T >( randomAccessible, alpha, clipping, min, max ); } /** * For now, ignore the {@link RealInterval} and return * {@link #create(RandomAccessible)}. */ @Override public LanczosInterpolator< T > create( final RandomAccessible< T > randomAccessible, final RealInterval interval ) { return create( randomAccessible ); } /** * Set the rectangular radius of the window for perfoming the lanczos * interpolation * * @param alpha * radius */ public void setAlpha( final int alpha ) { this.alpha = alpha; } /** * The lanczos-interpolation can create values that are bigger or smaller * than the original values, so they can be clipped to the range of the * {@link RealType} if wanted * * @param clipping * perform clipping (true) */ public void setClipping( final boolean clipping ) { this.clipping = clipping; } /** * @return rectangular radius of the window for perfoming the lanczos * interpolation */ public int getAlpha() { return alpha; } /** * @return if clipping to the {@link RealType} range will be performed */ public boolean getClipping() { return clipping; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/NLinearInterpolator.java000066400000000000000000000213341316447754700333130ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RealRandomAccess; import net.imglib2.position.transform.Floor; import net.imglib2.type.numeric.NumericType; import net.imglib2.util.IntervalIndexer; /** * Performs multi-linear interpolation. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class NLinearInterpolator< T extends NumericType< T > > extends Floor< RandomAccess< T > > implements RealRandomAccess< T > { /** * Index into {@link weights} array. * *

* To visit the pixels that contribute to an interpolated value, we move in * a (binary-reflected) Gray code pattern, such that only one dimension of * the target position is modified per move. *

*

* This index is the corresponding gray code bit pattern which will select * the correct corresponding weight. *

*

* See * http://en.wikipedia.org/ * wiki/Gray_code *

*/ protected int code; /** * Weights for each pixel of the 2x2x...x2 hypercube of pixels * participating in the interpolation. * *

* Indices into this array are arranged in the standard iteration order (as * provided by {@link IntervalIndexer#positionToIndex}). Element 0 refers to * position (0,0,...,0), element 1 refers to position * (1,0,...,0), element 2 refers to position (0,1,...,0), * etc. *

*/ final protected double[] weights; final protected T accumulator; final protected T tmp; protected NLinearInterpolator( final NLinearInterpolator< T > interpolator ) { super( interpolator.target.copyRandomAccess() ); weights = interpolator.weights.clone(); code = interpolator.code; accumulator = interpolator.accumulator.createVariable(); tmp = interpolator.tmp.createVariable(); for ( int d = 0; d < n; ++d ) { position[ d ] = interpolator.position[ d ]; discrete[ d ] = interpolator.discrete[ d ]; } } protected NLinearInterpolator( final RandomAccessible< T > randomAccessible, final T type ) { super( randomAccessible.randomAccess() ); weights = new double[ 1 << n ]; code = 0; accumulator = type.createVariable(); tmp = type.createVariable(); } protected NLinearInterpolator( final RandomAccessible< T > randomAccessible ) { this( randomAccessible, randomAccessible.randomAccess().get() ); } /** * Fill the {@link weights} array. * *

* Let w_d denote the fraction of a pixel at which the sample * position p_d lies from the floored position pf_d in * dimension d. That is, the value at pf_d contributes * with (1 - w_d) to the sampled value; the value at * ( pf_d + 1 ) contributes with w_d. *

*

* At every pixel, the total weight results from multiplying the weights of * all dimensions for that pixel. That is, the "top-left" contributing pixel * (position floored in all dimensions) gets assigned weight * (1-w_0)(1-w_1)...(1-w_n). *

*

* We work through the weights array starting from the highest dimension. * For the highest dimension, the first half of the weights contain the * factor (1 - w_n) because this first half corresponds to floored * pixel positions in the highest dimension. The second half contain the * factor w_n. In this first step, the first weight of the first * half gets assigned (1 - w_n). The first element of the second * half gets assigned w_n *

*

* From their, we work recursively down to dimension 0. That is, each half * of weights is again split recursively into two partitions. The first * element of the second partitions is the first element of the half * multiplied with (w_d). The first element of the first partitions * is multiplied with (1 - w_d). *

*

* When we have reached dimension 0, all weights will have a value assigned. *

*/ protected void fillWeights() { weights[ 0 ] = 1.0d; for ( int d = n - 1; d >= 0; --d ) { final double w = position[ d ] - target.getLongPosition( d ); final double wInv = 1.0d - w; final int wInvIndexIncrement = 1 << d; final int loopCount = 1 << ( n - 1 - d ); final int baseIndexIncrement = wInvIndexIncrement * 2; int baseIndex = 0; for ( int i = 0; i < loopCount; ++i ) { weights[ baseIndex + wInvIndexIncrement ] = weights[ baseIndex ] * w; weights[ baseIndex ] *= wInv; baseIndex += baseIndexIncrement; } } // printWeights(); // System.out.println(); } /** * Get the interpolated value at the current position. * *

* To visit the pixels that contribute to an interpolated value, we move in * a (binary-reflected) Gray code pattern, such that only one dimension of * the target position is modified per move. *

*

* See * http://en.wikipedia.org/ * wiki/Gray_code *

*/ @Override public T get() { fillWeights(); accumulator.set( target.get() ); accumulator.mul( weights[ 0 ] ); code = 0; graycodeFwdRecursive( n - 1 ); target.bck( n - 1 ); return accumulator; } @Override public NLinearInterpolator< T > copy() { return new NLinearInterpolator< T >( this ); } @Override public NLinearInterpolator< T > copyRealRandomAccess() { return copy(); } final private void graycodeFwdRecursive( final int dimension ) { if ( dimension == 0 ) { target.fwd( 0 ); code += 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.fwd( dimension ); code += 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } } final private void graycodeBckRecursive( final int dimension ) { if ( dimension == 0 ) { target.bck( 0 ); code -= 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.bck( dimension ); code -= 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } } /** * multiply current target value with current weight and add to accumulator. */ final private void accumulate() { tmp.set( target.get() ); tmp.mul( weights[ code ] ); accumulator.add( tmp ); // System.out.print( "accumulating value at " + target ); // System.out.print( "with weights [" ); // printCode(); // System.out.printf( "] = %f" + "\n", weights[ code ] ); } @SuppressWarnings( "unused" ) final private void printWeights() { for ( int i = 0; i < weights.length; ++i ) System.out.printf( "weights [ %2d ] = %f\n", i, weights[ i ] ); } @SuppressWarnings( "unused" ) final private void printCode() { final int maxbits = 4; final String binary = Integer.toBinaryString( code ); for ( int i = binary.length(); i < maxbits; ++i ) System.out.print( "0" ); System.out.print( binary ); } } NLinearInterpolator1D.java000066400000000000000000000062241316447754700334220ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.NumericType; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class NLinearInterpolator1D< T extends NumericType< T > > extends NLinearInterpolator< T > { protected NLinearInterpolator1D( final NLinearInterpolator1D< T > interpolator ) { super( interpolator ); } protected NLinearInterpolator1D( final RandomAccessible< T > randomAccessible, final T type ) { super( randomAccessible, type ); } protected NLinearInterpolator1D( final RandomAccessible< T > randomAccessible ) { super( randomAccessible ); } @Override final public int numDimensions() { return 1; } @Override protected void fillWeights() { final double w0 = position[ 0 ] - target.getLongPosition( 0 ); weights[ 0 ] = 1.0d - w0; weights[ 1 ] = w0; } @Override public T get() { // fillWeights(); final double w0 = position[ 0 ] - target.getLongPosition( 0 ); accumulator.set( target.get() ); accumulator.mul( 1.0d - w0 ); target.fwd( 0 ); tmp.set( target.get() ); tmp.mul( w0 ); accumulator.add( tmp ); target.bck( 0 ); return accumulator; } @Override public NLinearInterpolator1D< T > copy() { return new NLinearInterpolator1D< T >( this ); } } NLinearInterpolator2D.java000066400000000000000000000067541316447754700334330ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.NumericType; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class NLinearInterpolator2D< T extends NumericType< T > > extends NLinearInterpolator< T > { protected NLinearInterpolator2D( final NLinearInterpolator2D< T > interpolator ) { super( interpolator ); } protected NLinearInterpolator2D( final RandomAccessible< T > randomAccessible, final T type ) { super( randomAccessible, type ); } protected NLinearInterpolator2D( final RandomAccessible< T > randomAccessible ) { super( randomAccessible ); } @Override final public int numDimensions() { return 2; } @Override protected void fillWeights() { final double w0 = position[ 0 ] - target.getLongPosition( 0 ); final double w0Inv = 1.0d - w0; final double w1 = position[ 1 ] - target.getLongPosition( 1 ); final double w1Inv = 1.0d - w1; weights[ 0 ] = w0Inv * w1Inv; weights[ 1 ] = w0 * w1Inv; weights[ 2 ] = w0Inv * w1; weights[ 3 ] = w0 * w1; } @Override public T get() { fillWeights(); accumulator.set( target.get() ); accumulator.mul( weights[ 0 ] ); target.fwd( 0 ); tmp.set( target.get() ); tmp.mul( weights[ 1 ] ); accumulator.add( tmp ); target.fwd( 1 ); tmp.set( target.get() ); tmp.mul( weights[ 3 ] ); accumulator.add( tmp ); target.bck( 0 ); tmp.set( target.get() ); tmp.mul( weights[ 2 ] ); accumulator.add( tmp ); target.bck( 1 ); return accumulator; } @Override public NLinearInterpolator2D< T > copy() { return new NLinearInterpolator2D< T >( this ); } } NLinearInterpolator3D.java000066400000000000000000000102031316447754700334140ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.NumericType; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class NLinearInterpolator3D< T extends NumericType< T > > extends NLinearInterpolator< T > { protected NLinearInterpolator3D( final NLinearInterpolator3D< T > interpolator ) { super( interpolator ); } protected NLinearInterpolator3D( final RandomAccessible< T > randomAccessible, final T type ) { super( randomAccessible, type ); } protected NLinearInterpolator3D( final RandomAccessible< T > randomAccessible ) { super( randomAccessible ); } @Override final public int numDimensions() { return 3; } @Override protected void fillWeights() { final double w0 = position[ 0 ] - target.getLongPosition( 0 ); final double w0Inv = 1.0d - w0; final double w1 = position[ 1 ] - target.getLongPosition( 1 ); final double w1Inv = 1.0d - w1; final double w2 = position[ 2 ] - target.getLongPosition( 2 ); final double w2Inv = 1.0d - w2; weights[ 0 ] = w0Inv * w1Inv * w2Inv; weights[ 1 ] = w0 * w1Inv * w2Inv; weights[ 2 ] = w0Inv * w1 * w2Inv; weights[ 3 ] = w0 * w1 * w2Inv; weights[ 4 ] = w0Inv * w1Inv * w2; weights[ 5 ] = w0 * w1Inv * w2; weights[ 6 ] = w0Inv * w1 * w2; weights[ 7 ] = w0 * w1 * w2; } @Override public T get() { fillWeights(); accumulator.set( target.get() ); accumulator.mul( weights[ 0 ] ); target.fwd( 0 ); tmp.set( target.get() ); tmp.mul( weights[ 1 ] ); accumulator.add( tmp ); target.fwd( 1 ); tmp.set( target.get() ); tmp.mul( weights[ 3 ] ); accumulator.add( tmp ); target.bck( 0 ); tmp.set( target.get() ); tmp.mul( weights[ 2 ] ); accumulator.add( tmp ); target.fwd( 2 ); tmp.set( target.get() ); tmp.mul( weights[ 6 ] ); accumulator.add( tmp ); target.fwd( 0 ); tmp.set( target.get() ); tmp.mul( weights[ 7 ] ); accumulator.add( tmp ); target.bck( 1 ); tmp.set( target.get() ); tmp.mul( weights[ 5 ] ); accumulator.add( tmp ); target.bck( 0 ); tmp.set( target.get() ); tmp.mul( weights[ 4 ] ); accumulator.add( tmp ); target.bck( 2 ); return accumulator; } @Override public NLinearInterpolator3D< T > copy() { return new NLinearInterpolator3D< T >( this ); } } NLinearInterpolatorARGB.java000066400000000000000000000127511316447754700336730ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.ARGBType; import net.imglib2.util.Util; /** * N-linear interpolator for ARGB values with overflow check. * * @author Stephan Saalfeld */ public class NLinearInterpolatorARGB extends NLinearInterpolator< ARGBType > { protected double accA, accR, accG, accB; protected NLinearInterpolatorARGB( final NLinearInterpolatorARGB interpolator ) { super( interpolator ); } protected NLinearInterpolatorARGB( final RandomAccessible< ARGBType > randomAccessible, final ARGBType type ) { super( randomAccessible, type ); } protected NLinearInterpolatorARGB( final RandomAccessible< ARGBType > randomAccessible ) { this( randomAccessible, randomAccessible.randomAccess().get() ); } /** * Get the interpolated value at the current position. * *

* To visit the pixels that contribute to an interpolated value, we move in * a (binary-reflected) Gray code pattern, such that only one dimension of * the target position is modified per move. *

*

* See http://en.wikipedia.org/wiki/Gray_code *

*/ @Override public ARGBType get() { fillWeights(); final int argb = target.get().get(); accA = ( ( argb >> 24 ) & 0xff ) * weights[ 0 ]; accR = ( ( argb >> 16 ) & 0xff ) * weights[ 0 ]; accG = ( ( argb >> 8 ) & 0xff ) * weights[ 0 ]; accB = ( argb & 0xff ) * weights[ 0 ]; code = 0; graycodeFwdRecursive( n - 1 ); target.bck( n - 1 ); final int a = Math.min( 255, ( int ) Util.round( accA ) ); final int r = Math.min( 255, ( int ) Util.round( accR ) ); final int g = Math.min( 255, ( int ) Util.round( accG ) ); final int b = Math.min( 255, ( int ) Util.round( accB ) ); accumulator.set( ( ( ( ( ( a << 8 ) | r ) << 8 ) | g ) << 8 ) | b ); return accumulator; } @Override public NLinearInterpolatorARGB copy() { return new NLinearInterpolatorARGB( this ); } @Override public NLinearInterpolatorARGB copyRealRandomAccess() { return copy(); } final private void graycodeFwdRecursive( final int dimension ) { if ( dimension == 0 ) { target.fwd( 0 ); code += 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.fwd( dimension ); code += 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } } final private void graycodeBckRecursive( final int dimension ) { if ( dimension == 0 ) { target.bck( 0 ); code -= 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.bck( dimension ); code -= 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } } /** * multiply current target value with current weight and add to accumulator. */ final private void accumulate() { final int argb = target.get().get(); accA += ( ( argb >> 24 ) & 0xff ) * weights[ code ]; accR += ( ( argb >> 16 ) & 0xff ) * weights[ code ]; accG += ( ( argb >> 8 ) & 0xff ) * weights[ code ]; accB += ( argb & 0xff ) * weights[ code ]; // System.out.print( "accumulating value at " + target ); // System.out.print( "with weights [" ); // printCode(); // System.out.printf( "] = %f" + "\n", weights[ code ] ); } @SuppressWarnings( "unused" ) final private void printWeights() { for ( int i = 0; i < weights.length; ++i ) System.out.printf( "weights [ %2d ] = %f\n", i, weights[ i ] ); } @SuppressWarnings( "unused" ) final private void printCode() { final int maxbits = 4; final String binary = Integer.toBinaryString( code ); for ( int i = binary.length(); i < maxbits; ++i ) System.out.print( "0" ); System.out.print( binary ); } } NLinearInterpolatorARGBFactory.java000066400000000000000000000052561316447754700352250ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; import net.imglib2.type.numeric.ARGBType; /** * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public class NLinearInterpolatorARGBFactory implements InterpolatorFactory< ARGBType, RandomAccessible< ARGBType > > { @Override public NLinearInterpolatorARGB create( final RandomAccessible< ARGBType > randomAccessible ) { return new NLinearInterpolatorARGB( randomAccessible ); } /** * For now, ignore the {@link RealInterval} and return * {@link #create(RandomAccessible)}. */ @Override public NLinearInterpolatorARGB create( final RandomAccessible< ARGBType > randomAccessible, final RealInterval interval ) { return create( randomAccessible ); } } NLinearInterpolatorFactory.java000066400000000000000000000057441316447754700345730ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; import net.imglib2.type.numeric.NumericType; /** * * @param * * @author Stephan Saalfeld * @author Tobias Pietzsch * @author Stephan Preibisch */ public class NLinearInterpolatorFactory< T extends NumericType< T > > implements InterpolatorFactory< T, RandomAccessible< T > > { @Override public NLinearInterpolator< T > create( final RandomAccessible< T > randomAccessible ) { switch ( randomAccessible.numDimensions() ) { case 1: return new NLinearInterpolator1D< T >( randomAccessible ); case 2: return new NLinearInterpolator2D< T >( randomAccessible ); // case 3: // return new NLinearInterpolator3D< T >( randomAccessible ); default: return new NLinearInterpolator< T >( randomAccessible ); } } /** * For now, ignore the {@link RealInterval} and return * {@link #create(RandomAccessible)}. */ @Override public NLinearInterpolator< T > create( final RandomAccessible< T > randomAccessible, final RealInterval interval ) { return create( randomAccessible ); } } NearestNeighborInterpolator.java000066400000000000000000000075571316447754700347760ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RealRandomAccess; import net.imglib2.position.transform.Round; /** * {@link RealRandomAccess} to a {@link RandomAccess} by nearest neighbor * interpolation. * *

In ImgLib2, the coordinate of a sample corresponds to the 'center' point * of the sample, i.e. the location at which the sample was acquired. This * scheme is intuitive in both rasters and irregularly samples data but can * trigger confusion when displaying images on a screen with a pixel raster * which, in this scheme, spans the range [-0.5,width-0.5]. In the * screen-friendly alternative scheme, where sample coordinates reference the * top left corner of the pixel rectangle representing a sample the range * covered by an image is [0,width], however, coordinate transfer * functions other than translation and homogeneous scaling generate different * results than in the center-scheme. Rendering an image using * {@link FloorInterpolator} means using the top-left-scheme, rendering it * using {@link NearestNeighborInterpolator}, {@link NLinearInterpolator}, or * {@link LanczosInterpolator} means using the center-scheme.

* * @param * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public class NearestNeighborInterpolator< T > extends Round< RandomAccess< T > > implements RealRandomAccess< T > { protected NearestNeighborInterpolator( final NearestNeighborInterpolator< T > nearestNeighborInterpolator ) { super( nearestNeighborInterpolator.target.copyRandomAccess() ); } protected NearestNeighborInterpolator( final RandomAccessible< T > randomAccessible ) { super( randomAccessible.randomAccess() ); } @Override public T get() { return target.get(); } @Override public NearestNeighborInterpolator< T > copy() { return new NearestNeighborInterpolator< T >( this ); } @Override public NearestNeighborInterpolator< T > copyRealRandomAccess() { return copy(); } } NearestNeighborInterpolatorFactory.java000066400000000000000000000052411316447754700363120ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/interpolation/randomaccess/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.interpolation.randomaccess; import net.imglib2.RandomAccessible; import net.imglib2.RealInterval; import net.imglib2.interpolation.InterpolatorFactory; /** * * @param * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public class NearestNeighborInterpolatorFactory< T > implements InterpolatorFactory< T, RandomAccessible< T > > { @Override public NearestNeighborInterpolator< T > create( final RandomAccessible< T > randomAccessible ) { return new NearestNeighborInterpolator< T >( randomAccessible ); } /** * For now, ignore the {@link RealInterval} and return * {@link #create(RandomAccessible)}. */ @Override public NearestNeighborInterpolator< T > create( final RandomAccessible< T > randomAccessible, final RealInterval interval ) { return create( randomAccessible ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/000077500000000000000000000000001316447754700230125ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/IntervalIterator.java000066400000000000000000000170361316447754700271620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterator; import net.imglib2.AbstractInterval; import net.imglib2.Interval; import net.imglib2.Iterator; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.Sampler; import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Util; /** * Use this class to iterate a virtual {@link Interval} in flat order, that is: * row by row, plane by plane, cube by cube, ... This is useful for iterating an * arbitrary interval in a defined order. For that, connect an * {@link IntervalIterator} to a {@link Positionable}. * *
{@code
 * ...
 * IntervalIterator i = new IntervalIterator(image);
 * RandomAccess s = image.randomAccess();
 * while (i.hasNext()) {
 *   i.fwd();
 *   s.setPosition(i);
 *   s.get().performOperation(...);
 *   ...
 * }
 * ...
 * }
* * Note that {@link IntervalIterator} is the right choice in situations where * not for each pixel you want to localize and/or set the * {@link Positionable} [{@link Sampler}], that is in a sparse sampling * situation. For localizing at each iteration step (as in the simplified * example above), use {@link LocalizingIntervalIterator} instead. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class IntervalIterator extends AbstractInterval implements Iterator, Localizable { final protected long[] dimensions; final protected long[] steps; final protected long lastIndex; protected long index = -1; /** * Iterates an {@link Interval} of the given dimensions with min= * 0n * * @param dimensions */ public IntervalIterator( final long[] dimensions ) { super( dimensions ); this.dimensions = new long[ n ]; steps = new long[ n ]; final int m = n - 1; long k = steps[ 0 ] = 1; for ( int d = 0; d < m; ) { final long dimd = dimensions[ d ]; this.dimensions[ d ] = dimd; k *= dimd; steps[ ++d ] = k; } final long dimm = dimensions[ m ]; this.dimensions[ m ] = dimm; lastIndex = k * dimm - 1; } /** * Iterates an {@link Interval} of the given dimensions with min= * 0n * * @param dimensions */ public IntervalIterator( final int[] dimensions ) { this( Util.int2long( dimensions ) ); } /** * Iterates an {@link Interval} with given min and max. * * @param min * @param max */ public IntervalIterator( final long[] min, final long[] max ) { super( min, max ); dimensions = new long[ n ]; steps = new long[ n ]; final int m = n - 1; long k = steps[ 0 ] = 1; for ( int d = 0; d < m; ) { final long s = max[ d ] - min[ d ] + 1; dimensions[ d ] = s; k *= s; steps[ ++d ] = k; } final long sizem = max[ m ] - min[ m ] + 1; dimensions[ m ] = sizem; lastIndex = k * sizem - 1; } /** * Iterates an {@link Interval} with given min and max. * * @param min * @param max */ public IntervalIterator( final int[] min, final int[] max ) { this( Util.int2long( min ), Util.int2long( max ) ); } /** * Iterates a given {@link Interval}. * * @param interval */ public IntervalIterator( final Interval interval ) { super( interval ); dimensions = new long[ n ]; steps = new long[ n ]; final int m = n - 1; long k = steps[ 0 ] = 1; for ( int d = 0; d < m; ) { final long dimd = interval.dimension( d ); dimensions[ d ] = dimd; k *= dimd; steps[ ++d ] = k; } final long dimm = interval.dimension( m ); dimensions[ m ] = dimm; lastIndex = k * dimm - 1; } static public IntervalIterator create( final Interval interval ) { final int n = interval.numDimensions(); for ( int d = 0; d < n; ++d ) if ( interval.min( d ) != 0 ) return new IntervalIterator( interval ); return new ZeroMinIntervalIterator( interval ); } /* Iterator */ @Override public void jumpFwd( final long i ) { index += i; } @Override public void fwd() { ++index; } @Override public void reset() { index = -1; } @Override public boolean hasNext() { return index < lastIndex; } /** * @return - the current iteration index */ public long getIndex() { return index; } /* Localizable */ @Override public long getLongPosition( final int dim ) { return IntervalIndexer.indexToPositionWithOffset( index, dimensions, steps, min, dim ); } @Override public void localize( final long[] position ) { IntervalIndexer.indexToPositionWithOffset( index, dimensions, min, position ); } @Override public int getIntPosition( final int dim ) { return ( int ) IntervalIndexer.indexToPositionWithOffset( index, dimensions, steps, min, dim ); } @Override public void localize( final int[] position ) { IntervalIndexer.indexToPositionWithOffset( index, dimensions, min, position ); } @Override public double getDoublePosition( final int dim ) { return IntervalIndexer.indexToPositionWithOffset( index, dimensions, steps, min, dim ); } /* RealLocalizable */ @Override public float getFloatPosition( final int dim ) { return IntervalIndexer.indexToPositionWithOffset( index, dimensions, steps, min, dim ); } @Override public void localize( final float[] position ) { IntervalIndexer.indexToPositionWithOffset( index, dimensions, min, position ); } @Override public void localize( final double[] position ) { IntervalIndexer.indexToPositionWithOffset( index, dimensions, min, position ); } /* Object */ @Override public String toString() { final int[] l = new int[ dimensions.length ]; localize( l ); return Util.printCoordinates( l ); } /* Interval */ @Override public long dimension( final int d ) { return dimensions[ d ]; } @Override public void dimensions( final long[] dim ) { for ( int d = 0; d < n; ++d ) dim[ d ] = this.dimensions[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/LocalizingIntervalIterator.java000066400000000000000000000120101316447754700311610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterator; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Util; /** * Use this class to iterate a virtual {@link Interval} in flat order, that is: * row by row, plane by plane, cube by cube, ... This is useful for iterating an * arbitrary interval in a defined order. For that, connect a * {@link LocalizingIntervalIterator} to a {@link Positionable}. * *
 * {@code
 * ...
 * LocalizingIntervalIterator i = new LocalizingIntervalIterator(image);
 * RandomAccess s = image.randomAccess();
 * while (i.hasNext()) {
 *   i.fwd();
 *   s.setPosition(i);
 *   s.type().performOperation(...);
 *   ...
 * }
 * ...
 * }
* * Note that {@link LocalizingIntervalIterator} is the right choice in * situations where, for each pixel, you want to localize and/or set * the {@link RandomAccess}, that is, in a dense sampling situation. For * localizing sparsely (e.g. under an external condition), use * {@link IntervalIterator} instead. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class LocalizingIntervalIterator extends IntervalIterator { final protected long[] position; public LocalizingIntervalIterator( final long[] dimensions ) { super( dimensions ); position = new long[ n ]; reset(); } public LocalizingIntervalIterator( final int[] dimensions ) { this( Util.int2long( dimensions ) ); } public LocalizingIntervalIterator( final long[] min, final long[] max ) { super( min, max ); position = new long[ n ]; reset(); } public LocalizingIntervalIterator( final int[] min, final int[] max ) { this( Util.int2long( min ), Util.int2long( max ) ); } public LocalizingIntervalIterator( final Interval interval ) { super( interval ); position = new long[ n ]; reset(); } /* Iterator */ @Override public void fwd() { ++index; for ( int d = 0; d < n; ++d ) { if ( ++position[ d ] > max[ d ] ) position[ d ] = min[ d ]; else break; } } @Override public void jumpFwd( final long i ) { index += i; IntervalIndexer.indexToPositionWithOffset( index, dimensions, min, position ); } @Override public void reset() { index = -1; position[ 0 ] = min[ 0 ] - 1; for ( int d = 1; d < n; ++d ) position[ d ] = min[ d ]; } /* Localizable */ @Override public void localize( final float[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = this.position[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = this.position[ d ]; } @Override public void localize( final int[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = ( int ) this.position[ d ]; } @Override public void localize( final long[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = this.position[ d ]; } @Override public float getFloatPosition( final int d ) { return position[ d ]; } @Override public double getDoublePosition( final int d ) { return position[ d ]; } @Override public int getIntPosition( final int d ) { return ( int ) position[ d ]; } @Override public long getLongPosition( final int d ) { return position[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/LocalizingZeroMinIntervalIterator.java000066400000000000000000000075361316447754700325060ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterator; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.Sampler; import net.imglib2.util.IntervalIndexer; /** * Use this class to iterate a virtual rectangular {@link Interval} whose * min coordinates are at 0n in flat order, that * is: row by row, plane by plane, cube by cube, ... This is useful for * iterating an arbitrary interval in a defined order. For that, connect a * {@link LocalizingZeroMinIntervalIterator} to a {@link Positionable}. * *
 * {@code
 * ...
 * LocalizingZeroMinIntervalIterator i = new LocalizingZeroMinIntervalIterator(image);
 * RandomAccess s = image.randomAccess();
 * while (i.hasNext()) {
 *   i.fwd();
 *   s.setPosition(i);
 *   s.type().performOperation(...);
 *   ...
 * }
 * ...
 * }
 * 
* * Note that {@link LocalizingZeroMinIntervalIterator} is the right choice in * situations where, for each pixel, you want to localize and/or set * the {@link Positionable} [{@link Sampler}], that is in a dense sampling * situation. For localizing sparsely (e.g. under an external condition), use * {@link ZeroMinIntervalIterator} instead. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class LocalizingZeroMinIntervalIterator extends LocalizingIntervalIterator { public LocalizingZeroMinIntervalIterator( final long[] dimensions ) { super( dimensions ); } public LocalizingZeroMinIntervalIterator( final int[] dimensions ) { super( dimensions ); } public LocalizingZeroMinIntervalIterator( final Interval interval ) { super( interval ); } /* Iterator */ @Override public void fwd() { ++index; for ( int d = 0; d < n; ++d ) { if ( ++position[ d ] > max[ d ] ) position[ d ] = 0; else break; } } @Override public void jumpFwd( final long i ) { index += i; IntervalIndexer.indexToPosition( index, dimensions, position ); } @Override public void reset() { index = -1; position[ 0 ] = -1; for ( int d = 1; d < n; ++d ) position[ d ] = 0; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/OffsetableIntervalIterator.java000066400000000000000000000060741316447754700311550ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterator; import net.imglib2.Interval; /** * A {@link IntervalIterator} that has an adjustable offset * * * @author Stephan Preibisch */ public class OffsetableIntervalIterator extends IntervalIterator { public OffsetableIntervalIterator( final long[] dimensions ) { super( dimensions ); } public OffsetableIntervalIterator( final int[] dimensions ) { super( dimensions ); } public OffsetableIntervalIterator( final long[] min, final long[] max ) { super( min, max ); } public OffsetableIntervalIterator( final int[] min, final int[] max ) { super( min, max ); } public OffsetableIntervalIterator( final Interval interval ) { super( interval ); } /** * Adjust the offset and reset the iterator * * @param min * - new offset */ public void setMin( final int[] min ) { for ( int d = 0; d < n; ++d ) { this.min[ d ] = min[ d ]; this.max[ d ] = this.dimensions[ d ] + min[ d ] - 1; } reset(); } /** * Adjust the offset and reset the iterator * * @param min * - new offset */ public void setMin( final long[] min ) { for ( int d = 0; d < n; ++d ) { this.min[ d ] = min[ d ]; this.max[ d ] = this.dimensions[ d ] + min[ d ] - 1; } reset(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/OffsetableLocalizingIntervalIterator.java000066400000000000000000000062141316447754700331650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterator; import net.imglib2.Interval; /** * A {@link LocalizingIntervalIterator} that has an adjustable offset * * * @author Stephan Preibisch */ public class OffsetableLocalizingIntervalIterator extends LocalizingIntervalIterator { public OffsetableLocalizingIntervalIterator( final long[] dimensions ) { super( dimensions ); } public OffsetableLocalizingIntervalIterator( final int[] dimensions ) { super( dimensions ); } public OffsetableLocalizingIntervalIterator( final long[] min, final long[] max ) { super( min, max ); } public OffsetableLocalizingIntervalIterator( final int[] min, final int[] max ) { super( min, max ); } public OffsetableLocalizingIntervalIterator( final Interval interval ) { super( interval ); } /** * Adjust the offset and reset the iterator * * @param min * - new offset */ public void setMin( final int[] min ) { for ( int d = 0; d < n; ++d ) { this.min[ d ] = min[ d ]; this.max[ d ] = this.dimensions[ d ] + min[ d ] - 1; } reset(); } /** * Adjust the offset and reset the iterator * * @param min * - new offset */ public void setMin( final long[] min ) { for ( int d = 0; d < n; ++d ) { this.min[ d ] = min[ d ]; this.max[ d ] = this.dimensions[ d ] + min[ d ] - 1; } reset(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/iterator/ZeroMinIntervalIterator.java000066400000000000000000000106301316447754700304570ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterator; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.Sampler; import net.imglib2.util.IntervalIndexer; /** * Use this class to iterate a virtual rectangular {@link Interval} whose * min coordinates are at 0n in flat order, that * is: row by row, plane by plane, cube by cube, ... This is useful for * iterating an arbitrary interval in a defined order. For that, connect a * {@link ZeroMinIntervalIterator} to a {@link Positionable}. * *
 * {@code
 * ...
 * ZeroMinIntervalIterator i = new ZeroMinIntervalIterator(image);
 * RandomAccess s = image.randomAccess();
 * while (i.hasNext()) {
 *   i.fwd();
 *   s.setPosition(i);
 *   s.type().performOperation(...);
 *   ...
 * }
 * ...
 * }
 * 
* * Note that {@link ZeroMinIntervalIterator} is the right choice in situations * where not for each pixel you want to localize and/or set the * {@link Positionable} [{@link Sampler}], that is in a sparse sampling * situation. For localizing at each iteration step (as in the simplified * example above), use {@link LocalizingZeroMinIntervalIterator} instead. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ZeroMinIntervalIterator extends IntervalIterator { public ZeroMinIntervalIterator( final long[] dimensions ) { super( dimensions ); } public ZeroMinIntervalIterator( final Interval interval ) { super( interval ); } /* Localizable */ @Override final public long getLongPosition( final int d ) { return IntervalIndexer.indexToPosition( index, dimensions, steps, d ); } @Override final public void localize( final long[] position ) { IntervalIndexer.indexToPosition( index, dimensions, position ); } @Override final public int getIntPosition( final int d ) { return ( int ) IntervalIndexer.indexToPosition( index, dimensions, steps, d ); } @Override final public void localize( final int[] position ) { IntervalIndexer.indexToPosition( index, dimensions, position ); } /* RealLocalizable */ @Override final public double getDoublePosition( final int d ) { return IntervalIndexer.indexToPosition( index, dimensions, steps, d ); } @Override final public void localize( final double[] position ) { IntervalIndexer.indexToPosition( index, dimensions, position ); } @Override final public float getFloatPosition( final int d ) { return IntervalIndexer.indexToPosition( index, dimensions, steps, d ); } @Override final public void localize( final float[] position ) { IntervalIndexer.indexToPosition( index, dimensions, position ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/000077500000000000000000000000001316447754700241445ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/KNearestNeighborSearch.java000066400000000000000000000074241316447754700313360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * k-nearest-neighbor search in an Euclidean space. The interface * describes implementations that perform the search for a specified location * and provide access to the data, location and distance of the found nearest * neighbors until the next search is performed. In a multi-threaded * application, each thread will thus need its own * {@link KNearestNeighborSearch}. * * @author Stephan Saalfeld */ public interface KNearestNeighborSearch< T > extends NearestNeighborSearch< T > { /** * Perform k-nearest-neighbor search for a reference coordinate. * * @param reference */ @Override public void search( final RealLocalizable reference ); /** * Get the of k nearest neighbor points used in this search * * @return the number of nearest neighbor points k used for this search */ public int getK(); /** * Access the data of the ith nearest neighbor, ordered * by square Euclidean distance. Data is accessed through a {@link Sampler} * that guarantees write access if the underlying data set is writable. */ public Sampler< T > getSampler( final int i ); /** * Access the position of the ith nearest neighbor, * ordered by square Euclidean distance. */ public RealLocalizable getPosition( final int i ); /** * Access the square Euclidean distance between the reference location as * used for the last search and the ith nearest * neighbor, ordered by square Euclidean distance. */ public double getSquareDistance( final int i ); /** * Access the Euclidean distance between the reference location as used for * the last search and the ith nearest neighbor, ordered * by square Euclidean distance. */ public double getDistance( final int i ); /** * Create a copy. */ @Override public KNearestNeighborSearch< T > copy(); } KNearestNeighborSearchOnIterableRealInterval.java000066400000000000000000000123251316447754700355310ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.IterableRealInterval; import net.imglib2.RealCursor; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * k-nearest-neighbor search on {@link IterableRealInterval} * implemented as linear search. * * @author Stephan Saalfeld */ public class KNearestNeighborSearchOnIterableRealInterval< T > implements KNearestNeighborSearch< T > { final protected IterableRealInterval< T > iterable; final protected int k, n; final protected RealCursor< T >[] elements; final protected double[] squareDistances; final protected double[] referenceLocation; /** * Calculate the square Euclidean distance of a query location to the * location stored in referenceLocation. */ final protected double squareDistance( final RealLocalizable query ) { double squareSum = 0; for ( int d = 0; d < n; ++d ) { final double distance = query.getDoublePosition( d ) - referenceLocation[ d ]; squareSum += distance * distance; } return squareSum; } @SuppressWarnings( "unchecked" ) public KNearestNeighborSearchOnIterableRealInterval( final IterableRealInterval< T > iterable, final int k ) { this.iterable = iterable; this.k = k; n = iterable.numDimensions(); elements = ( new RealCursor[ k ] ); squareDistances = new double[ k ]; referenceLocation = new double[ n ]; } @Override public int numDimensions() { return n; } @Override public int getK() { return k; } @Override public void search( final RealLocalizable reference ) { for ( int i = 0; i < k; ++i ) squareDistances[ i ] = Double.MAX_VALUE; reference.localize( referenceLocation ); final RealCursor< T > cursor = iterable.localizingCursor(); while ( cursor.hasNext() ) { cursor.fwd(); final double squareDistance = squareDistance( cursor ); int i = k - 1; if ( squareDistances[ i ] > squareDistance ) { final RealCursor< T > candidate = cursor.copyCursor(); for ( int j = i - 1; i > 0 && squareDistances[ j ] > squareDistance; --i, --j ) { squareDistances[ i ] = squareDistances[ j ]; elements[ i ] = elements[ j ]; } squareDistances[ i ] = squareDistance; elements[ i ] = candidate; } } } /* KNearestNeighborSearch */ @Override public RealLocalizable getPosition( final int i ) { return elements[ i ]; } @Override public RealCursor< T > getSampler( final int i ) { return elements[ i ]; } @Override public double getSquareDistance( final int i ) { return squareDistances[ i ]; } @Override public double getDistance( final int i ) { return Math.sqrt( squareDistances[ i ] ); } /* NearestNeighborSearch */ @Override public RealLocalizable getPosition() { return getPosition( 0 ); } @Override public Sampler< T > getSampler() { return getSampler( 0 ); } @Override public double getSquareDistance() { return getSquareDistance( 0 ); } @Override public double getDistance() { return getDistance( 0 ); } @Override public KNearestNeighborSearchOnIterableRealInterval< T > copy() { final KNearestNeighborSearchOnIterableRealInterval< T > copy = new KNearestNeighborSearchOnIterableRealInterval< T >( iterable, k ); System.arraycopy( referenceLocation, 0, copy.referenceLocation, 0, referenceLocation.length ); for ( int i = 0; i < k; ++i ) { copy.elements[ i ] = elements[ i ]; copy.squareDistances[ i ] = squareDistances[ i ]; } return copy; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/KNearestNeighborSearchOnKDTree.java000066400000000000000000000122711316447754700326660ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.KDTree; import net.imglib2.KDTreeNode; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * Implementation of {@link KNearestNeighborSearch} search for kd-trees. * * @author Tobias Pietzsch */ public class KNearestNeighborSearchOnKDTree< T > implements KNearestNeighborSearch< T > { protected KDTree< T > tree; protected final int n; protected final double[] pos; protected final int k; protected KDTreeNode< T >[] bestPoints; protected double[] bestSquDistances; @SuppressWarnings( "unchecked" ) public KNearestNeighborSearchOnKDTree( final KDTree< T > tree, final int k ) { this.tree = tree; this.n = tree.numDimensions(); this.pos = new double[ n ]; this.k = k; this.bestPoints = new KDTreeNode[ k ]; this.bestSquDistances = new double[ k ]; for ( int i = 0; i < k; ++i ) bestSquDistances[ i ] = Double.MAX_VALUE; } @Override public int numDimensions() { return n; } @Override public int getK() { return k; } @Override public void search( final RealLocalizable reference ) { reference.localize( pos ); for ( int i = 0; i < k; ++i ) bestSquDistances[ i ] = Double.MAX_VALUE; searchNode( tree.getRoot() ); } protected void searchNode( final KDTreeNode< T > current ) { // consider the current node final double squDistance = current.squDistanceTo( pos ); if ( squDistance < bestSquDistances[ k - 1 ] ) { int i = k - 1; for ( int j = i - 1; i > 0 && squDistance < bestSquDistances[ j ]; --i, --j ) { bestSquDistances[ i ] = bestSquDistances[ j ]; bestPoints[ i ] = bestPoints[ j ]; } bestSquDistances[ i ] = squDistance; bestPoints[ i ] = current; } final double axisDiff = pos[ current.getSplitDimension() ] - current.getSplitCoordinate(); final double axisSquDistance = axisDiff * axisDiff; final boolean leftIsNearBranch = axisDiff < 0; // search the near branch final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left : current.right; final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right : current.left; if ( nearChild != null ) searchNode( nearChild ); // search the away branch - maybe if ( ( axisSquDistance <= bestSquDistances[ k - 1 ] ) && ( awayChild != null ) ) searchNode( awayChild ); } @Override public Sampler< T > getSampler( final int i ) { return bestPoints[ i ]; } @Override public RealLocalizable getPosition( final int i ) { return bestPoints[ i ]; } @Override public double getSquareDistance( final int i ) { return bestSquDistances[ i ]; } @Override public double getDistance( final int i ) { return Math.sqrt( bestSquDistances[ i ] ); } /* NearestNeighborSearch */ @Override public RealLocalizable getPosition() { return getPosition( 0 ); } @Override public Sampler< T > getSampler() { return getSampler( 0 ); } @Override public double getSquareDistance() { return getSquareDistance( 0 ); } @Override public double getDistance() { return getDistance( 0 ); } @Override public KNearestNeighborSearchOnKDTree< T > copy() { final KNearestNeighborSearchOnKDTree< T > copy = new KNearestNeighborSearchOnKDTree< T >( tree, k ); System.arraycopy( pos, 0, copy.pos, 0, pos.length ); for ( int i = 0; i < k; ++i ) { copy.bestPoints[ i ] = bestPoints[ i ]; copy.bestSquDistances[ i ] = bestSquDistances[ i ]; } return copy; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/NearestNeighborSearch.java000066400000000000000000000066241316447754700312240ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.EuclideanSpace; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * Nearest-neighbor search in an Euclidean space. The interface describes * implementations that perform the search for a specified location and provide * access to the data, location and distance of the found nearest neighbor until * the next search is performed. In a multi-threaded application, each thread * will thus need its own {@link NearestNeighborSearch}. * * @author Stephan Saalfeld */ public interface NearestNeighborSearch< T > extends EuclideanSpace { /** * Perform nearest-neighbor search for a reference coordinate. * * @param reference */ public void search( final RealLocalizable reference ); /** * Access the data of the nearest neighbor. Data is accessed through a * {@link Sampler} that guarantees write access if the underlying data set * is writable. */ public Sampler< T > getSampler(); /** * Access the position of the nearest neighbor, ordered by square Euclidean * distance. */ public RealLocalizable getPosition(); /** * Access the square Euclidean distance between the reference location as * used for the last search and the nearest neighbor, ordered by square * Euclidean distance. */ public double getSquareDistance(); /** * Access the Euclidean distance between the reference location as used for * the last search and the nearest neighbor, ordered by square Euclidean * distance. */ public double getDistance(); /** * Create a copy. */ public NearestNeighborSearch< T > copy(); } NearestNeighborSearchOnIterableRealInterval.java000066400000000000000000000104061316447754700354140ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.IterableRealInterval; import net.imglib2.RealCursor; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * k-nearest-neighbor search on {@link IterableRealInterval} * implemented as linear search. * * @author Stephan Saalfeld */ public class NearestNeighborSearchOnIterableRealInterval< T > implements NearestNeighborSearch< T > { final protected IterableRealInterval< T > iterable; final protected int n; protected RealCursor< T > element = null; protected double squareDistance = Double.MAX_VALUE; final protected double[] referenceLocation; /** * Calculate the square Euclidean distance of a query location to the * location stored in referenceLocation. */ final protected double squareDistance( final RealLocalizable query ) { double squareSum = 0; for ( int d = 0; d < n; ++d ) { final double distance = query.getDoublePosition( d ) - referenceLocation[ d ]; squareSum += distance * distance; } return squareSum; } public NearestNeighborSearchOnIterableRealInterval( final IterableRealInterval< T > iterable ) { this.iterable = iterable; n = iterable.numDimensions(); referenceLocation = new double[ n ]; } @Override public int numDimensions() { return n; } @Override public void search( final RealLocalizable reference ) { squareDistance = Double.MAX_VALUE; reference.localize( referenceLocation ); final RealCursor< T > cursor = iterable.localizingCursor(); while ( cursor.hasNext() ) { cursor.fwd(); final double cursorSquareDistance = squareDistance( cursor ); if ( squareDistance > cursorSquareDistance ) { squareDistance = cursorSquareDistance; element = cursor.copyCursor(); } } } /* NearestNeighborSearch */ @Override public RealLocalizable getPosition() { return element; } @Override public Sampler< T > getSampler() { return element; } @Override public double getSquareDistance() { return squareDistance; } @Override public double getDistance() { return Math.sqrt( squareDistance ); } @Override public NearestNeighborSearchOnIterableRealInterval< T > copy() { final NearestNeighborSearchOnIterableRealInterval< T > copy = new NearestNeighborSearchOnIterableRealInterval< T >( iterable ); System.arraycopy( referenceLocation, 0, copy.referenceLocation, 0, referenceLocation.length ); copy.element = element; copy.squareDistance = squareDistance; return copy; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/NearestNeighborSearchOnKDTree.java000066400000000000000000000101471316447754700325530ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.KDTree; import net.imglib2.KDTreeNode; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * Implementation of {@link NearestNeighborSearch} search for kd-trees. * * * @author Tobias Pietzsch */ public class NearestNeighborSearchOnKDTree< T > implements NearestNeighborSearch< T > { protected KDTree< T > tree; protected final int n; protected final double[] pos; protected KDTreeNode< T > bestPoint; protected double bestSquDistance; public NearestNeighborSearchOnKDTree( final KDTree< T > tree ) { n = tree.numDimensions(); pos = new double[ n ]; this.tree = tree; } @Override public int numDimensions() { return n; } @Override public void search( final RealLocalizable p ) { p.localize( pos ); bestSquDistance = Double.MAX_VALUE; searchNode( tree.getRoot() ); } protected void searchNode( final KDTreeNode< T > current ) { // consider the current node final double distance = current.squDistanceTo( pos ); if ( distance < bestSquDistance ) { bestSquDistance = distance; bestPoint = current; } final double axisDiff = pos[ current.getSplitDimension() ] - current.getSplitCoordinate(); final double axisSquDistance = axisDiff * axisDiff; final boolean leftIsNearBranch = axisDiff < 0; // search the near branch final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left : current.right; final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right : current.left; if ( nearChild != null ) searchNode( nearChild ); // search the away branch - maybe if ( ( axisSquDistance <= bestSquDistance ) && ( awayChild != null ) ) searchNode( awayChild ); } @Override public Sampler< T > getSampler() { return bestPoint; } @Override public RealLocalizable getPosition() { return bestPoint; } @Override public double getSquareDistance() { return bestSquDistance; } @Override public double getDistance() { return Math.sqrt( bestSquDistance ); } @Override public NearestNeighborSearchOnKDTree< T > copy() { final NearestNeighborSearchOnKDTree< T > copy = new NearestNeighborSearchOnKDTree< T >( tree ); System.arraycopy( pos, 0, copy.pos, 0, pos.length ); copy.bestPoint = bestPoint; copy.bestSquDistance = bestSquDistance; return copy; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/RadiusNeighborSearch.java000066400000000000000000000111141316447754700310400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import net.imglib2.EuclideanSpace; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; /** * Radius neighbor search in an Euclidean space. The interface describes * implementations that perform the search for a specified reference location * and radius, and provide access to the data, location, and distance of the * found neighbors until the next search is performed. For every search, the * user can choose whether the found neighbors are returned in arbitrary order * or sorted by distance to the reference location. * * In a multi-threaded application, each thread will need its own * {@link RadiusNeighborSearch}. * * @author Tobias Pietzsch */ public interface RadiusNeighborSearch< T > extends EuclideanSpace { /** * Perform neighbor search within a radius about a reference coordinate. A * point is considered within radius if its distance to the reference is * smaller or equal the radius. * * @param reference * the reference coordinate. * @param radius * the radius about the reference coordinate that should be * searched for neighbors. * @param sortResults * whether the results should be ordered by ascending distances * to reference. */ public void search( final RealLocalizable reference, final double radius, final boolean sortResults ); /** * Get the number of points found within radius after a * {@link #search(RealLocalizable, double, boolean)}. * * @return the number of points found within radius after a * {@link #search(RealLocalizable, double, boolean)}. */ public int numNeighbors(); /** * Access the data of the ith neighbor within radius. If * {@code sortResults} was set to true, neighbors are ordered by square * Euclidean distance to the reference. Data is accessed through a * {@link Sampler} that guarantees write access if the underlying data set * is writable. */ public Sampler< T > getSampler( final int i ); /** * Access the position of the ith neighbor within * radius. If {@code sortResults} was set to true, neighbors are ordered by * square Euclidean distance to the reference. */ public RealLocalizable getPosition( final int i ); /** * Access the square Euclidean distance between the reference location as * used for the last search and the ith neighbor. If * {@code sortResults} was set to true, neighbors are ordered by square * Euclidean distance to the reference. */ public double getSquareDistance( final int i ); /** * Access the Euclidean distance between the reference location as used for * the last search and the ith neighbor. */ public double getDistance( final int i ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/neighborsearch/RadiusNeighborSearchOnKDTree.java000066400000000000000000000112201316447754700323720ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.neighborsearch; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import net.imglib2.KDTree; import net.imglib2.KDTreeNode; import net.imglib2.RealLocalizable; import net.imglib2.Sampler; import net.imglib2.util.ValuePair; /** * Implementation of {@link RadiusNeighborSearch} search for kd-trees. * * @author Tobias Pietzsch */ public class RadiusNeighborSearchOnKDTree< T > implements RadiusNeighborSearch< T > { protected KDTree< T > tree; protected final int n; protected final double[] pos; protected ArrayList< ValuePair< KDTreeNode< T >, Double > > resultPoints; public RadiusNeighborSearchOnKDTree( final KDTree< T > tree ) { this.tree = tree; this.n = tree.numDimensions(); this.pos = new double[ n ]; this.resultPoints = new ArrayList< ValuePair< KDTreeNode< T >, Double > >(); } @Override public void search( final RealLocalizable reference, final double radius, final boolean sortResults ) { assert radius >= 0; reference.localize( pos ); resultPoints.clear(); searchNode( tree.getRoot(), radius * radius ); if ( sortResults ) { Collections.sort( resultPoints, new Comparator< ValuePair< KDTreeNode< T >, Double > >() { @Override public int compare( final ValuePair< KDTreeNode< T >, Double > o1, final ValuePair< KDTreeNode< T >, Double > o2 ) { return Double.compare( o1.b, o2.b ); } } ); } } @Override public int numDimensions() { return n; } protected void searchNode( final KDTreeNode< T > current, final double squRadius ) { // consider the current node final double squDistance = current.squDistanceTo( pos ); if ( squDistance <= squRadius ) { resultPoints.add( new ValuePair< KDTreeNode< T >, Double >( current, squDistance ) ); } final double axisDiff = pos[ current.getSplitDimension() ] - current.getSplitCoordinate(); final double axisSquDistance = axisDiff * axisDiff; final boolean leftIsNearBranch = axisDiff < 0; // search the near branch final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left : current.right; final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right : current.left; if ( nearChild != null ) searchNode( nearChild, squRadius ); // search the away branch - maybe if ( ( axisSquDistance <= squRadius ) && ( awayChild != null ) ) searchNode( awayChild, squRadius ); } @Override public int numNeighbors() { return resultPoints.size(); } @Override public Sampler< T > getSampler( final int i ) { return resultPoints.get( i ).a; } @Override public RealLocalizable getPosition( final int i ) { return resultPoints.get( i ).a; } @Override public double getSquareDistance( final int i ) { return resultPoints.get( i ).b; } @Override public double getDistance( final int i ) { return Math.sqrt( resultPoints.get( i ).b ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/000077500000000000000000000000001316447754700235305ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/AbstractOutOfBoundsMirror.java000066400000000000000000000162601316447754700314660ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.util.Util; /** * Abstract implementation of shared functions for mirroring out of bounds. * Internally used coordinates use an interval [0n,max * n-minn] and compensate for min-shift on * localization and positioning. * * @param * * @author Stephan Saalfeld */ public abstract class AbstractOutOfBoundsMirror< T > implements OutOfBounds< T > { final protected RandomAccess< T > outOfBoundsRandomAccess; final protected int n; /** * Dimensions of the wrapped {@link RandomAccessible}. */ final protected long[] dimension; /** * Position relative to min, for internal calculations. * zeroMinPos = position - min. */ final protected long[] zeroMinPos; /** * Minimum of the wrapped {@link RandomAccessible}. */ final protected long[] min; /** * Period of the extended interval. This depends on whether boundary pixels * are mirrored. See {@link OutOfBoundsMirrorDoubleBoundary}, see * {@link OutOfBoundsMirrorSingleBoundary}. */ final protected long[] p; /* true when increasing, false when decreasing */ final protected boolean[] inc; final protected boolean[] dimIsOutOfBounds; protected boolean isOutOfBounds = false; protected AbstractOutOfBoundsMirror( final AbstractOutOfBoundsMirror< T > outOfBounds ) { n = outOfBounds.numDimensions(); dimension = new long[ n ]; min = new long[ n ]; zeroMinPos = new long[ n ]; p = new long[ n ]; dimIsOutOfBounds = new boolean[ n ]; inc = new boolean[ n ]; for ( int d = 0; d < n; ++d ) { dimension[ d ] = outOfBounds.dimension[ d ]; min[ d ] = outOfBounds.min[ d ]; zeroMinPos[ d ] = outOfBounds.zeroMinPos[ d ]; p[ d ] = outOfBounds.p[ d ]; dimIsOutOfBounds[ d ] = outOfBounds.dimIsOutOfBounds[ d ]; inc[ d ] = outOfBounds.inc[ d ]; } outOfBoundsRandomAccess = outOfBounds.outOfBoundsRandomAccess.copyRandomAccess(); } public < F extends Interval & RandomAccessible< T > > AbstractOutOfBoundsMirror( final F f ) { n = f.numDimensions(); dimension = new long[ n ]; f.dimensions( dimension ); min = new long[ n ]; f.min( min ); zeroMinPos = new long[ n ]; p = new long[ n ]; dimIsOutOfBounds = new boolean[ n ]; inc = new boolean[ n ]; for ( int i = 0; i < dimension.length; ++i ) inc[ i ] = true; outOfBoundsRandomAccess = f.randomAccess(); } final protected void checkOutOfBounds() { for ( int d = 0; d < n; ++d ) { if ( dimIsOutOfBounds[ d ] ) { isOutOfBounds = true; return; } } isOutOfBounds = false; } /* EuclideanSpace */ @Override public int numDimensions() { return n; } /* OutOfBounds */ @Override public boolean isOutOfBounds() { return isOutOfBounds; } /* Sampler */ @Override public T get() { return outOfBoundsRandomAccess.get(); } @Override abstract public AbstractOutOfBoundsMirror< T > copy(); /* Localizable */ @Override public void localize( final float[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = this.zeroMinPos[ d ] + min[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = this.zeroMinPos[ d ] + min[ d ]; } @Override public void localize( final int[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = ( int ) ( this.zeroMinPos[ d ] + min[ d ] ); } @Override public void localize( final long[] pos ) { for ( int d = 0; d < n; ++d ) pos[ d ] = this.zeroMinPos[ d ] + min[ d ]; } @Override public float getFloatPosition( final int d ) { return zeroMinPos[ d ] + min[ d ]; } @Override public double getDoublePosition( final int d ) { return zeroMinPos[ d ] + min[ d ]; } @Override public int getIntPosition( final int d ) { return ( int ) ( zeroMinPos[ d ] + min[ d ] ); } @Override public long getLongPosition( final int d ) { return zeroMinPos[ d ] + min[ d ]; } /* Positionable */ /** * Override with a more efficient version. */ @Override public void move( final long distance, final int d ) { setPosition( getLongPosition( d ) + distance, d ); } @Override public void move( final int distance, final int d ) { move( ( long ) distance, d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) move( localizable.getLongPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void setPosition( final int position, final int d ) { setPosition( ( long ) position, d ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) setPosition( localizable.getLongPosition( d ), d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } /* Object */ @Override public String toString() { return Util.printCoordinates( zeroMinPos ) + " = " + get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/AbstractOutOfBoundsValue.java000066400000000000000000000142161316447754700312670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.AbstractLocalizable; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.type.Type; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public abstract class AbstractOutOfBoundsValue< T extends Type< T > > extends AbstractLocalizable implements OutOfBounds< T > { final protected RandomAccess< T > sampler; final protected long[] dimension, min, max; final protected boolean[] dimIsOutOfBounds; protected boolean isOutOfBounds = false; protected AbstractOutOfBoundsValue( final AbstractOutOfBoundsValue< T > outOfBounds ) { super( outOfBounds.numDimensions() ); this.sampler = outOfBounds.sampler.copyRandomAccess(); dimension = new long[ n ]; min = new long[ n ]; max = new long[ n ]; dimIsOutOfBounds = new boolean[ n ]; for ( int d = 0; d < n; ++d ) { dimension[ d ] = outOfBounds.dimension[ d ]; min[ d ] = outOfBounds.min[ d ]; max[ d ] = outOfBounds.max[ d ]; position[ d ] = outOfBounds.position[ d ]; dimIsOutOfBounds[ d ] = outOfBounds.dimIsOutOfBounds[ d ]; } } public < F extends Interval & RandomAccessible< T > > AbstractOutOfBoundsValue( final F f ) { super( f.numDimensions() ); this.sampler = f.randomAccess(); dimension = new long[ n ]; f.dimensions( dimension ); min = new long[ n ]; f.min( min ); max = new long[ n ]; f.max( max ); dimIsOutOfBounds = new boolean[ n ]; } final private void checkOutOfBounds() { for ( int d = 0; d < n; ++d ) { if ( dimIsOutOfBounds[ d ] ) { isOutOfBounds = true; return; } } isOutOfBounds = false; } /* OutOfBounds */ @Override public boolean isOutOfBounds() { checkOutOfBounds(); return isOutOfBounds; } /* Positionable */ @Override public void fwd( final int dim ) { final boolean wasOutOfBounds = isOutOfBounds; final long p = ++position[ dim ]; if ( p == min[ dim ] ) { dimIsOutOfBounds[ dim ] = false; checkOutOfBounds(); } else if ( p == max[ dim ] + 1 ) { dimIsOutOfBounds[ dim ] = isOutOfBounds = true; return; } if ( isOutOfBounds ) return; if ( wasOutOfBounds ) sampler.setPosition( position ); else sampler.fwd( dim ); } @Override public void bck( final int dim ) { final boolean wasOutOfBounds = isOutOfBounds; final long p = position[ dim ]--; if ( p == min[ dim ] ) dimIsOutOfBounds[ dim ] = isOutOfBounds = true; else if ( p == max[ dim ] + 1 ) { dimIsOutOfBounds[ dim ] = false; checkOutOfBounds(); } if ( isOutOfBounds ) return; if ( wasOutOfBounds ) sampler.setPosition( position ); else sampler.bck( dim ); } @Override public void move( final long distance, final int dim ) { setPosition( position[ dim ] + distance, dim ); } @Override public void move( final int distance, final int dim ) { move( ( long ) distance, dim ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) move( localizable.getLongPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void setPosition( final long position, final int dim ) { this.position[ dim ] = position; if ( position < min[ dim ] || position > max[ dim ] ) dimIsOutOfBounds[ dim ] = isOutOfBounds = true; else if ( isOutOfBounds ) { dimIsOutOfBounds[ dim ] = false; checkOutOfBounds(); if ( !isOutOfBounds ) sampler.setPosition( this.position ); } else sampler.setPosition( position, dim ); } @Override public void setPosition( final int position, final int dim ) { setPosition( ( long ) position, dim ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) setPosition( localizable.getLongPosition( d ), d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/Bounded.java000066400000000000000000000045041316447754700257560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.Sampler; /** * Interface implemented by entities ({@link Sampler}s, {@link Positionable}s, * {@link Localizable}s) that can tell whether they are currently located * outside of the image boundaries. * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Bounded { /** True if located out of image bounds. */ public boolean isOutOfBounds(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBounds.java000066400000000000000000000040411316447754700266010ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.RandomAccess; /** * * * @author Stephan Saalfeld */ public interface OutOfBounds< T > extends RandomAccess< T >, Bounded { @Override public OutOfBounds< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsBorder.java000066400000000000000000000156501316447754700277470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.AbstractLocalizable; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.util.Util; /** * Repeat the boundary pixels. That is, for every out-of-bounds coordinate * {@link #get()} returns the nearest within-bounds pixel. * * @author Tobias Pietzsch */ public class OutOfBoundsBorder< T > extends AbstractLocalizable implements OutOfBounds< T > { final protected RandomAccess< T > outOfBoundsRandomAccess; /** * Minimum of the wrapped {@link RandomAccessible}. */ final protected long[] min; final protected long[] beforeMin; /** * Maximum of the wrapped {@link RandomAccessible}. */ final protected long[] max; final protected long[] pastMax; final protected boolean[] dimIsOutOfBounds; protected boolean isOutOfBounds = false; public OutOfBoundsBorder( final OutOfBoundsBorder< T > outOfBounds ) { super( outOfBounds.numDimensions() ); min = new long[ n ]; beforeMin = new long[ n ]; max = new long[ n ]; pastMax = new long[ n ]; dimIsOutOfBounds = new boolean[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = outOfBounds.min[ d ]; beforeMin[ d ] = outOfBounds.beforeMin[ d ]; max[ d ] = outOfBounds.max[ d ]; pastMax[ d ] = outOfBounds.pastMax[ d ]; position[ d ] = outOfBounds.position[ d ]; dimIsOutOfBounds[ d ] = outOfBounds.dimIsOutOfBounds[ d ]; } outOfBoundsRandomAccess = outOfBounds.outOfBoundsRandomAccess.copyRandomAccess(); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsBorder( final F f ) { super( f.numDimensions() ); min = new long[ n ]; f.min( min ); max = new long[ n ]; f.max( max ); beforeMin = new long[ n ]; pastMax = new long[ n ]; for ( int d = 0; d < n; ++d ) { beforeMin[ d ] = min[ d ] - 1; pastMax[ d ] = max[ d ] + 1; } dimIsOutOfBounds = new boolean[ n ]; outOfBoundsRandomAccess = f.randomAccess(); } final protected void checkOutOfBounds() { for ( int d = 0; d < n; ++d ) { if ( dimIsOutOfBounds[ d ] ) { isOutOfBounds = true; return; } } isOutOfBounds = false; } /* OutOfBounds */ @Override public boolean isOutOfBounds() { return isOutOfBounds; } /* Sampler */ @Override public T get() { return outOfBoundsRandomAccess.get(); } @Override final public OutOfBoundsBorder< T > copy() { return new OutOfBoundsBorder< T >( this ); } /* RandomAccess */ @Override final public OutOfBoundsBorder< T > copyRandomAccess() { return copy(); } /* Positionable */ @Override final public void fwd( final int d ) { final long p = ++position[ d ]; if ( p == min[ d ] ) { dimIsOutOfBounds[ d ] = false; checkOutOfBounds(); } else if ( p == pastMax[ d ] ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; else if ( !dimIsOutOfBounds[ d ] ) outOfBoundsRandomAccess.fwd( d ); } @Override final public void bck( final int d ) { final long p = --position[ d ]; if ( p == beforeMin[ d ] ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; else if ( p == max[ d ] ) { dimIsOutOfBounds[ d ] = false; checkOutOfBounds(); } else if ( !dimIsOutOfBounds[ d ] ) outOfBoundsRandomAccess.bck( d ); } @Override final public void setPosition( final long position, final int d ) { this.position[ d ] = position; final long minD = min[ d ]; final long maxD = max[ d ]; if ( position < minD ) { outOfBoundsRandomAccess.setPosition( minD, d ); dimIsOutOfBounds[ d ] = isOutOfBounds = true; } else if ( position > maxD ) { outOfBoundsRandomAccess.setPosition( maxD, d ); dimIsOutOfBounds[ d ] = isOutOfBounds = true; } else { outOfBoundsRandomAccess.setPosition( position, d ); if ( isOutOfBounds ) { dimIsOutOfBounds[ d ] = false; checkOutOfBounds(); } } } @Override public void move( final long distance, final int d ) { setPosition( getLongPosition( d ) + distance, d ); } @Override public void move( final int distance, final int d ) { move( ( long ) distance, d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) move( localizable.getLongPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void setPosition( final int position, final int d ) { setPosition( ( long ) position, d ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) setPosition( localizable.getLongPosition( d ), d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } /* Object */ @Override public String toString() { return Util.printCoordinates( position ) + " = " + get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsBorderFactory.java000066400000000000000000000044051316447754700312730ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; /** * Strategy to repeat the boundary pixels (creates {@link OutOfBoundsBorder}). * * @author Tobias Pietzsch */ public class OutOfBoundsBorderFactory< T, F extends Interval & RandomAccessible< T > > implements OutOfBoundsFactory< T, F > { @Override public OutOfBoundsBorder< T > create( final F f ) { return new OutOfBoundsBorder< T >( f ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsConstantValue.java000066400000000000000000000055751316447754700313250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.type.Type; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsConstantValue< T extends Type< T > > extends AbstractOutOfBoundsValue< T > { final protected T value; protected OutOfBoundsConstantValue( final OutOfBoundsConstantValue< T > outOfBounds ) { super( outOfBounds ); this.value = outOfBounds.value.copy(); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsConstantValue( final F f, final T value ) { super( f ); this.value = value; } /* Sampler */ @Override final public T get() { // System.out.println( getLocationAsString() + " " + isOutOfBounds ); if ( isOutOfBounds ) return value; return sampler.get(); } @Override final public OutOfBoundsConstantValue< T > copy() { return new OutOfBoundsConstantValue< T >( this ); } /* RandomAccess */ @Override final public OutOfBoundsConstantValue< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsConstantValueFactory.java000066400000000000000000000050271316447754700326450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.type.Type; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsConstantValueFactory< T extends Type< T >, F extends Interval & RandomAccessible< T > > implements OutOfBoundsFactory< T, F > { protected T value; public OutOfBoundsConstantValueFactory( final T value ) { this.value = value; } public void setValue( final T value ) { this.value = value; } public T getValue() { return value; } @Override public OutOfBoundsConstantValue< T > create( final F f ) { return new OutOfBoundsConstantValue< T >( f, value.copy() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsFactory.java000066400000000000000000000037761316447754700301470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; /** * * @param * @param * * @author Stephan Saalfeld */ public interface OutOfBoundsFactory< T, F > { public OutOfBounds< T > create( F f ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsMirrorDoubleBoundary.java000066400000000000000000000120661316447754700326410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; /** * Coordinates out of image bounds are mirrored between boundary coordinates. So * boundary pixels are repeated. * *
 * {@code
 * Example:
 *
 * width=4
 *
 *                                  |<-inside->|
 * x:    -9 -8 -7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9
 * f(x):  0  0  1  2  3  3  2  1  0  0  1  2  3  3  2  1  0  0  1
 * }
 * 
* * @param * * @author Stephan Saalfeld */ final public class OutOfBoundsMirrorDoubleBoundary< T > extends AbstractOutOfBoundsMirror< T > { protected OutOfBoundsMirrorDoubleBoundary( final OutOfBoundsMirrorDoubleBoundary< T > outOfBounds ) { super( outOfBounds ); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsMirrorDoubleBoundary( final F f ) { super( f ); for ( int i = 0; i < dimension.length; ++i ) p[ i ] = 2 * dimension[ i ]; } /* Sampler */ @Override final public OutOfBoundsMirrorDoubleBoundary< T > copy() { return new OutOfBoundsMirrorDoubleBoundary< T >( this ); } /* RandomAccess */ @Override final public OutOfBoundsMirrorDoubleBoundary< T > copyRandomAccess() { return copy(); } /* Positionable */ @Override final public void fwd( final int d ) { final long x = ++zeroMinPos[ d ]; if ( x == 0 ) { dimIsOutOfBounds[ d ] = false; if ( isOutOfBounds ) checkOutOfBounds(); } else if ( x == dimension[ d ] ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; final long y = outOfBoundsRandomAccess.getLongPosition( d ) - min[ d ]; if ( inc[ d ] ) { if ( y + 1 == dimension[ d ] ) inc[ d ] = false; else outOfBoundsRandomAccess.fwd( d ); } else { if ( y == 0 ) inc[ d ] = true; else outOfBoundsRandomAccess.bck( d ); } } @Override final public void bck( final int d ) { final long x = zeroMinPos[ d ]--; if ( x == 0 ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; else if ( x == dimension[ d ] ) { dimIsOutOfBounds[ d ] = false; if ( isOutOfBounds ) checkOutOfBounds(); } final long y = outOfBoundsRandomAccess.getLongPosition( d ) - min[ d ]; if ( inc[ d ] ) { if ( y == 0 ) inc[ d ] = false; else outOfBoundsRandomAccess.bck( d ); } else { if ( y + 1 == dimension[ d ] ) inc[ d ] = true; else outOfBoundsRandomAccess.fwd( d ); } } @Override final public void setPosition( long position, final int d ) { position -= min[ d ]; this.zeroMinPos[ d ] = position; final long x = this.p[ d ]; final long mod = dimension[ d ]; final boolean pos; if ( position < 0 ) { dimIsOutOfBounds[ d ] = isOutOfBounds = true; position = -position - 1; pos = false; } else pos = true; if ( position >= mod ) { dimIsOutOfBounds[ d ] = isOutOfBounds = true; if ( position < x ) { position = x - position - 1; inc[ d ] = !pos; } else { position %= x; if ( position >= mod ) { position = x - position - 1; inc[ d ] = !pos; } else inc[ d ] = pos; } } else { if ( pos ) { dimIsOutOfBounds[ d ] = false; if ( isOutOfBounds ) checkOutOfBounds(); } inc[ d ] = pos; } outOfBoundsRandomAccess.setPosition( position + min[ d ], d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsMirrorExpWindowing.java000066400000000000000000000122051316447754700323400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.NumericType; import net.imglib2.util.Util; /** * * Adds a exponential windowing to the mirrored content outside the Interval * boundaries * * @param * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsMirrorExpWindowing< T extends NumericType< T > > extends OutOfBoundsMirrorSingleBoundary< T > { final T type; final float[][] weights; final protected long[] max; final float exponent; final int[] fadeOutDistance; public OutOfBoundsMirrorExpWindowing( final OutOfBoundsMirrorExpWindowing< T > outOfBounds ) { super( outOfBounds ); this.type = outOfBounds.type.createVariable(); this.fadeOutDistance = outOfBounds.fadeOutDistance; this.exponent = outOfBounds.exponent; this.max = outOfBounds.max.clone(); // copy lookup table for the weights weights = outOfBounds.weights.clone(); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsMirrorExpWindowing( final F f, final int[] fadeOutDistance, final float exponent ) { super( f ); /* * Sun javac fails to infer return types, so make it explicit, see * https://bugs.eclipse.org/bugs/show_bug.cgi?id=98379 */ this.type = Util.< T, F >getTypeFromInterval( f ).createVariable(); this.fadeOutDistance = fadeOutDistance; this.exponent = exponent; this.max = new long[ n ]; f.max( max ); // create lookup table for the weights weights = preComputeWeights( n, fadeOutDistance, exponent ); } final protected static float[][] preComputeWeights( final int n, final int[] fadeOutDistance, final float exponent ) { // create lookup table for the weights final float[][] weights = new float[ n ][]; for ( int d = 0; d < n; ++d ) weights[ d ] = new float[ Math.max( 1, fadeOutDistance[ d ] ) ]; for ( int d = 0; d < n; ++d ) { final int maxDistance = weights[ d ].length; if ( maxDistance > 1 ) { for ( int pos = 0; pos < maxDistance; ++pos ) { final float relPos = pos / ( float ) ( maxDistance - 1 ); // if exponent equals one means linear function if ( Util.isApproxEqual( exponent, 1f, 0.0001f ) ) weights[ d ][ pos ] = 1 - relPos; else weights[ d ][ pos ] = ( float ) ( 1 - ( 1 / Math.pow( exponent, 1 - relPos ) ) ) * ( 1 + 1 / ( exponent - 1 ) ); } } else { weights[ d ][ 0 ] = 0; } } return weights; } @Override public T get() { if ( isOutOfBounds() ) { type.set( outOfBoundsRandomAccess.get() ); type.mul( getWeight( zeroMinPos ) ); return type; } return outOfBoundsRandomAccess.get(); } final protected float getWeight( final long[] zeroMinPosition ) { float weight = 1; for ( int d = 0; d < n; ++d ) { final int pos = ( int ) zeroMinPosition[ d ]; final int distance; if ( pos < 0 ) distance = -pos - 1; else if ( pos >= dimension[ d ] ) distance = pos - ( int ) dimension[ d ]; else continue; if ( distance < weights[ d ].length ) weight *= weights[ d ][ distance ]; else return 0; } return weight; } @Override public OutOfBoundsMirrorExpWindowing< T > copy() { return new OutOfBoundsMirrorExpWindowing< T >( this ); } @Override public OutOfBoundsMirrorExpWindowing< T > copyRandomAccess() { return copy(); } } OutOfBoundsMirrorExpWindowingFactory.java000066400000000000000000000114051316447754700336120ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.NumericType; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsMirrorExpWindowingFactory< T extends NumericType< T >, F extends Interval & RandomAccessible< T > > implements OutOfBoundsFactory< T, F > { int[] fadeOutDistance = null; int minFadeOutDistance = 6; int commonFadeOutDistance = 6; float commonRelativeDistanceFadeOut = Float.NaN; float exponent = 10; public OutOfBoundsMirrorExpWindowingFactory() {} public OutOfBoundsMirrorExpWindowingFactory( final float relativeDistanceFadeOut ) { this.commonRelativeDistanceFadeOut = relativeDistanceFadeOut; } public OutOfBoundsMirrorExpWindowingFactory( final int fadeOutDistance ) { this.commonFadeOutDistance = fadeOutDistance; } public OutOfBoundsMirrorExpWindowingFactory( final int[] fadeOutDistance ) { this.fadeOutDistance = fadeOutDistance.clone(); } public void setExponent( final float exponent ) { this.exponent = exponent; } public float getExponent() { return exponent; } public void setMinFadeOutDistance( final int minFadeOutDistance ) { this.minFadeOutDistance = minFadeOutDistance; } public long getMinFadeOutDistance() { return minFadeOutDistance; } public void setCommonFadeOutDistance( final int fadeOutDistance ) { this.commonFadeOutDistance = fadeOutDistance; } public long getCommonFadeOutDistance() { return commonFadeOutDistance; } public void setCommonRelativeFadeOutDistance( final float commonRelativeDistanceFadeOut ) { this.commonRelativeDistanceFadeOut = commonRelativeDistanceFadeOut; } public float getCommonRelativeFadeOutDistance() { return commonRelativeDistanceFadeOut; } public void setFadeOutDistance( final int[] fadeOutDistance ) { this.fadeOutDistance = fadeOutDistance.clone(); } public int[] getFadeOutDistance() { return fadeOutDistance.clone(); } @Override public OutOfBoundsMirrorExpWindowing< T > create( final F f ) { final int numDimensions = f.numDimensions(); if ( Float.isNaN( commonRelativeDistanceFadeOut ) ) { if ( fadeOutDistance == null ) { fadeOutDistance = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) fadeOutDistance[ d ] = Math.max( minFadeOutDistance, commonFadeOutDistance ); } else { for ( int d = 0; d < numDimensions; ++d ) fadeOutDistance[ d ] = Math.max( minFadeOutDistance, fadeOutDistance[ d ] ); } } else { if ( commonRelativeDistanceFadeOut <= 0 ) commonRelativeDistanceFadeOut = 0.1f; fadeOutDistance = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) fadeOutDistance[ d ] = Math.max( minFadeOutDistance, Util.round( f.dimension( d ) * commonRelativeDistanceFadeOut ) / 2 ); } return new OutOfBoundsMirrorExpWindowing< T >( f, fadeOutDistance, exponent ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsMirrorFactory.java000066400000000000000000000054371316447754700313360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; /** * Create appropriate strategies that virtually mirror a * {@link RandomAccessible} at its boundaries. Boundary pixels are either * duplicated or not. Note that if boundary pixels should not be duplicated * then all dimensions of the source (F f) must be > 1. * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsMirrorFactory< T, F extends Interval & RandomAccessible< T > > implements OutOfBoundsFactory< T, F > { static public enum Boundary { SINGLE, DOUBLE } final protected Boundary boundary; public OutOfBoundsMirrorFactory( final Boundary boundary ) { this.boundary = boundary; } @Override public AbstractOutOfBoundsMirror< T > create( final F f ) { if ( boundary == Boundary.SINGLE ) return new OutOfBoundsMirrorSingleBoundary< T >( f ); return new OutOfBoundsMirrorDoubleBoundary< T >( f ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsMirrorSingleBoundary.java000066400000000000000000000127041316447754700326470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; /** * Coordinates out of image bounds are mirrored at boundary coordinates. * Boundary pixels are not repeated. Note that this requires that all * dimensions of the source (F f) must be > 1. * *
 * {@code
 * Example:
 *
 * width=4
 *
 *                                  |<-inside->|
 * x:    -9 -8 -7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9
 * f(x):  3  2  1  0  1  2  3  2  1  0  1  2  3  2  1  0  1  2  3
 * }
 * 
* * @param * * @author Stephan Saalfeld */ public class OutOfBoundsMirrorSingleBoundary< T > extends AbstractOutOfBoundsMirror< T > { public OutOfBoundsMirrorSingleBoundary( final OutOfBoundsMirrorSingleBoundary< T > outOfBounds ) { super( outOfBounds ); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsMirrorSingleBoundary( final F f ) { super( f ); for ( int i = 0; i < dimension.length; ++i ) p[ i ] = 2 * dimension[ i ] - 2; } /* Sampler */ @Override public OutOfBoundsMirrorSingleBoundary< T > copy() { return new OutOfBoundsMirrorSingleBoundary< T >( this ); } /* RandomAccess */ @Override public OutOfBoundsMirrorSingleBoundary< T > copyRandomAccess() { return copy(); } /* Positionable */ @Override final public void fwd( final int d ) { final long x = ++zeroMinPos[ d ]; if ( x == 0 ) { dimIsOutOfBounds[ d ] = false; if ( isOutOfBounds ) checkOutOfBounds(); } else if ( x == dimension[ d ] ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; final long y = outOfBoundsRandomAccess.getLongPosition( d ) - min[ d ]; if ( inc[ d ] ) { if ( y + 1 == dimension[ d ] ) { inc[ d ] = false; outOfBoundsRandomAccess.bck( d ); } else outOfBoundsRandomAccess.fwd( d ); } else { if ( y == 0 ) { inc[ d ] = true; outOfBoundsRandomAccess.fwd( d ); } else outOfBoundsRandomAccess.bck( d ); } } @Override final public void bck( final int d ) { final long x = zeroMinPos[ d ]--; if ( x == 0 ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; else if ( x == dimension[ d ] ) { dimIsOutOfBounds[ d ] = false; if ( isOutOfBounds ) checkOutOfBounds(); } final long y = outOfBoundsRandomAccess.getLongPosition( d ) - min[ d ]; if ( inc[ d ] ) { if ( y == 0 ) { inc[ d ] = false; outOfBoundsRandomAccess.fwd( d ); } else outOfBoundsRandomAccess.bck( d ); } else { if ( y + 1 == dimension[ d ] ) { inc[ d ] = true; outOfBoundsRandomAccess.bck( d ); } else outOfBoundsRandomAccess.fwd( d ); } } @Override final public void setPosition( long position, final int d ) { position -= min[ d ]; this.zeroMinPos[ d ] = position; final long mod = dimension[ d ]; final boolean pos; if ( position < 0 ) { dimIsOutOfBounds[ d ] = isOutOfBounds = true; position = -position; pos = false; } else pos = true; if ( position >= mod ) { dimIsOutOfBounds[ d ] = isOutOfBounds = true; final long x = this.p[ d ]; if ( position <= x ) { position = x - position; inc[ d ] = !pos; } else { /* catches mod == 1 to no additional cost */ try { position %= x; if ( position >= mod ) { position = x - position; inc[ d ] = !pos; } else inc[ d ] = pos; } catch ( final ArithmeticException e ) { position = 0; } } } else { if ( pos ) { dimIsOutOfBounds[ d ] = false; if ( isOutOfBounds ) checkOutOfBounds(); } inc[ d ] = pos; } outOfBoundsRandomAccess.setPosition( position += min[ d ], d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsPeriodic.java000066400000000000000000000172201316447754700302630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.AbstractLocalizable; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.util.Util; /** * Coordinates out of image bounds are periodically repeated. * *
 * {@code
 * Example:
 *
 * width=4
 *
 *                                  |<-inside->|
 * x:    -9 -8 -7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9
 * f(x):  3  0  1  2  3  0  1  2  3  0  1  2  3  0  1  2  3  0  1
 * }
 * 
* * @param * * @author Stephan Saalfeld */ public class OutOfBoundsPeriodic< T > extends AbstractLocalizable implements OutOfBounds< T > { final protected RandomAccess< T > outOfBoundsRandomAccess; /** * Dimensions of the wrapped {@link RandomAccessible}. */ final protected long[] dimension; /** * Minimum of the wrapped {@link RandomAccessible}. */ final protected long[] min; final protected long[] beforeMin; /** * Maximum of the wrapped {@link RandomAccessible}. */ final protected long[] max; final protected long[] pastMax; final protected boolean[] dimIsOutOfBounds; protected boolean isOutOfBounds = false; public OutOfBoundsPeriodic( final OutOfBoundsPeriodic< T > outOfBounds ) { super( outOfBounds.numDimensions() ); dimension = new long[ n ]; min = new long[ n ]; beforeMin = new long[ n ]; max = new long[ n ]; pastMax = new long[ n ]; dimIsOutOfBounds = new boolean[ n ]; for ( int d = 0; d < n; ++d ) { dimension[ d ] = outOfBounds.dimension[ d ]; min[ d ] = outOfBounds.min[ d ]; beforeMin[ d ] = outOfBounds.beforeMin[ d ]; max[ d ] = outOfBounds.max[ d ]; pastMax[ d ] = outOfBounds.pastMax[ d ]; position[ d ] = outOfBounds.position[ d ]; dimIsOutOfBounds[ d ] = outOfBounds.dimIsOutOfBounds[ d ]; } outOfBoundsRandomAccess = outOfBounds.outOfBoundsRandomAccess.copyRandomAccess(); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsPeriodic( final F f ) { super( f.numDimensions() ); dimension = new long[ n ]; f.dimensions( dimension ); min = new long[ n ]; f.min( min ); max = new long[ n ]; f.max( max ); beforeMin = new long[ n ]; pastMax = new long[ n ]; for ( int d = 0; d < n; ++d ) { beforeMin[ d ] = min[ d ] - 1; pastMax[ d ] = max[ d ] + 1; } dimIsOutOfBounds = new boolean[ n ]; outOfBoundsRandomAccess = f.randomAccess(); } final protected void checkOutOfBounds() { for ( int d = 0; d < n; ++d ) { if ( dimIsOutOfBounds[ d ] ) { isOutOfBounds = true; return; } } isOutOfBounds = false; } /* OutOfBounds */ @Override public boolean isOutOfBounds() { return isOutOfBounds; } /* Sampler */ @Override public T get() { return outOfBoundsRandomAccess.get(); } @Override final public OutOfBoundsPeriodic< T > copy() { return new OutOfBoundsPeriodic< T >( this ); } /* RandomAccess */ @Override final public OutOfBoundsPeriodic< T > copyRandomAccess() { return copy(); } /* Positionable */ @Override final public void fwd( final int d ) { final long p = ++position[ d ]; if ( p == min[ d ] ) { dimIsOutOfBounds[ d ] = false; checkOutOfBounds(); } else if ( p == pastMax[ d ] ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; final long q = outOfBoundsRandomAccess.getLongPosition( d ); if ( q == max[ d ] ) outOfBoundsRandomAccess.setPosition( min[ d ], d ); else outOfBoundsRandomAccess.fwd( d ); } @Override final public void bck( final int d ) { final long p = --position[ d ]; if ( p == beforeMin[ d ] ) dimIsOutOfBounds[ d ] = isOutOfBounds = true; else if ( p == max[ d ] ) { dimIsOutOfBounds[ d ] = false; checkOutOfBounds(); } final long q = outOfBoundsRandomAccess.getLongPosition( d ); if ( q == min[ d ] ) outOfBoundsRandomAccess.setPosition( max[ d ], d ); else outOfBoundsRandomAccess.bck( d ); } @Override final public void setPosition( final long position, final int d ) { this.position[ d ] = position; final long minD = min[ d ]; final long maxD = max[ d ]; if ( position < minD ) { outOfBoundsRandomAccess.setPosition( maxD - ( maxD - position ) % dimension[ d ], d ); dimIsOutOfBounds[ d ] = isOutOfBounds = true; } else if ( position > maxD ) { outOfBoundsRandomAccess.setPosition( minD + ( position - minD ) % dimension[ d ], d ); dimIsOutOfBounds[ d ] = isOutOfBounds = true; } else { outOfBoundsRandomAccess.setPosition( position, d ); if ( isOutOfBounds ) { dimIsOutOfBounds[ d ] = false; checkOutOfBounds(); } } } @Override public void move( final long distance, final int d ) { setPosition( getLongPosition( d ) + distance, d ); } @Override public void move( final int distance, final int d ) { move( ( long ) distance, d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) move( localizable.getLongPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) move( distance[ d ], d ); } @Override public void setPosition( final int position, final int d ) { setPosition( ( long ) position, d ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) setPosition( localizable.getLongPosition( d ), d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < position.length; ++d ) setPosition( position[ d ], d ); } /* Object */ @Override public String toString() { return Util.printCoordinates( position ) + " = " + get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsPeriodicFactory.java000066400000000000000000000045631316447754700316210ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; /** * Create appropriate strategies that virtually extend a * {@link RandomAccessibleInterval} periodically. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsPeriodicFactory< T, F extends Interval & RandomAccessible< T > > implements OutOfBoundsFactory< T, F > { @Override public OutOfBoundsPeriodic< T > create( final F f ) { return new OutOfBoundsPeriodic< T >( f ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsRandomValue.java000066400000000000000000000064621316447754700307500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import java.util.Random; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.RealType; /** * Return a random value in a certain range when outside of the Interval * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsRandomValue< T extends RealType< T > > extends AbstractOutOfBoundsValue< T > { final T value; final protected double minValue, maxValue, range; final protected Random rnd; protected OutOfBoundsRandomValue( final OutOfBoundsRandomValue< T > outOfBounds ) { super( outOfBounds ); this.value = outOfBounds.value.copy(); this.minValue = outOfBounds.minValue; this.maxValue = outOfBounds.maxValue; this.range = outOfBounds.range; this.rnd = new Random(); } public < F extends Interval & RandomAccessible< T > > OutOfBoundsRandomValue( final F f, final T value, final Random rnd, final double min, final double max ) { super( f ); this.value = value; this.rnd = rnd; this.minValue = min; this.maxValue = max; this.range = max - min; } @Override final public T get() { if ( isOutOfBounds ) { value.setReal( rnd.nextDouble() * range + minValue ); return value; } return sampler.get(); } @Override final public OutOfBoundsRandomValue< T > copy() { return new OutOfBoundsRandomValue< T >( this ); } /* RandomAccess */ @Override final public OutOfBoundsRandomValue< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/OutOfBoundsRandomValueFactory.java000066400000000000000000000054701316447754700322760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import java.util.Random; import net.imglib2.Interval; import net.imglib2.RandomAccessible; import net.imglib2.type.numeric.RealType; /** * * @param * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class OutOfBoundsRandomValueFactory< T extends RealType< T >, F extends Interval & RandomAccessible< T > > implements OutOfBoundsFactory< T, F > { protected T value; protected double min, max; protected Random rnd; public OutOfBoundsRandomValueFactory( final T value, final double min, final double max ) { this.value = value; this.min = min; this.max = max; this.rnd = new Random( System.currentTimeMillis() ); } public void setMinMax( final double min, final double max ) { this.min = min; this.max = max; } public void setRandom( final Random rnd ) { this.rnd = rnd; } @Override public OutOfBoundsRandomValue< T > create( final F f ) { return new OutOfBoundsRandomValue< T >( f, value.copy(), rnd, min, max ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/RealOutOfBounds.java000066400000000000000000000041101316447754700274020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.RealRandomAccess; /** * * @param * * @author Stephan Saalfeld */ public interface RealOutOfBounds< T > extends OutOfBounds< T >, RealRandomAccess< T > { @Override public RealOutOfBounds< T > copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/RealOutOfBoundsFactory.java000066400000000000000000000040061316447754700307360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; /** * * @param * @param * * @author Stephan Saalfeld */ public interface RealOutOfBoundsFactory< T, F > { public RealOutOfBounds< T > create( F f ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/outofbounds/RealOutOfBoundsRealRandomAccess.java000066400000000000000000000142231316447754700324770ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Localizable; import net.imglib2.RealLocalizable; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; /** * @param * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public final class RealOutOfBoundsRealRandomAccess< T > extends AbstractEuclideanSpace implements RealRandomAccess< T >, Bounded { /** * performs the actual moves and generates/queries a Type */ final protected RealOutOfBounds< T > outOfBounds; /** * * @param realOutOfBoundsRealRandomAccess */ public RealOutOfBoundsRealRandomAccess( final RealOutOfBoundsRealRandomAccess< T > realOutOfBoundsRealRandomAccess ) { super( realOutOfBoundsRealRandomAccess.n ); this.outOfBounds = realOutOfBoundsRealRandomAccess.outOfBounds.copy(); } /** * @param n * number of dimensions in the {@link RealRandomAccessible}. * @param outOfBounds */ public RealOutOfBoundsRealRandomAccess( final int n, final RealOutOfBounds< T > outOfBounds ) { super( n ); this.outOfBounds = outOfBounds; } /* Bounded */ @Override public boolean isOutOfBounds() { return outOfBounds.isOutOfBounds(); } /* Sampler */ @Override public T get() { return outOfBounds.get(); } @Override public RealOutOfBoundsRealRandomAccess< T > copy() { return new RealOutOfBoundsRealRandomAccess< T >( this ); } /* RealRandomAccess */ @Override public RealOutOfBoundsRealRandomAccess< T > copyRealRandomAccess() { return copy(); } /* RealLocalizable */ @Override final public void localize( final float[] position ) { outOfBounds.localize( position ); } @Override final public void localize( final double[] position ) { outOfBounds.localize( position ); } @Override final public double getDoublePosition( final int dim ) { return outOfBounds.getDoublePosition( dim ); } @Override final public float getFloatPosition( final int dim ) { return outOfBounds.getFloatPosition( dim ); } /* RealPositionable */ @Override public void move( final float distance, final int d ) { outOfBounds.move( distance, d ); } @Override public void move( final double distance, final int d ) { outOfBounds.move( distance, d ); } @Override public void move( final RealLocalizable localizable ) { outOfBounds.move( localizable ); } @Override public void move( final float[] distance ) { outOfBounds.move( distance ); } @Override public void move( final double[] distance ) { outOfBounds.move( distance ); } @Override public void setPosition( final RealLocalizable localizable ) { outOfBounds.setPosition( localizable ); } @Override public void setPosition( final float[] position ) { outOfBounds.setPosition( position ); } @Override public void setPosition( final double[] position ) { outOfBounds.setPosition( position ); } @Override public void setPosition( final float position, final int d ) { outOfBounds.setPosition( position, d ); } @Override public void setPosition( final double position, final int d ) { outOfBounds.setPosition( position, d ); } /* Positionable */ @Override public void fwd( final int d ) { outOfBounds.fwd( d ); } @Override public void bck( final int d ) { outOfBounds.bck( d ); } @Override public void move( final int distance, final int d ) { outOfBounds.move( distance, d ); } @Override public void move( final long distance, final int d ) { outOfBounds.move( distance, d ); } @Override public void move( final Localizable localizable ) { outOfBounds.move( localizable ); } @Override public void move( final int[] distance ) { outOfBounds.move( distance ); } @Override public void move( final long[] distance ) { outOfBounds.move( distance ); } @Override public void setPosition( final Localizable localizable ) { outOfBounds.setPosition( localizable ); } @Override public void setPosition( final int[] position ) { outOfBounds.setPosition( position ); } @Override public void setPosition( final long[] position ) { outOfBounds.setPosition( position ); } @Override public void setPosition( final int position, final int d ) { outOfBounds.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { outOfBounds.setPosition( position, d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/position/000077500000000000000000000000001316447754700230255ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/position/transform/000077500000000000000000000000001316447754700250405ustar00rootroot00000000000000AbstractPositionableTransform.java000066400000000000000000000125601316447754700336400ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/position/transform/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.position.transform; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.RealLocalizable; import net.imglib2.RealPositionable; /** * A {@link RealPositionable} that drives a {@link Positionable} to somehow * derived discrete coordinates. * * @author Stephan Saalfeld */ public abstract class AbstractPositionableTransform< LocalizablePositionable extends Localizable & Positionable > extends AbstractEuclideanSpace implements RealPositionable, RealLocalizable { final protected LocalizablePositionable target; /* current position, required for relative movement */ final protected double[] position; /* * current discrete position for temporary storage, this field does not * necessarily contain the actual discrete position! */ final protected long[] discrete; public AbstractPositionableTransform( final LocalizablePositionable target ) { super( target.numDimensions() ); this.target = target; position = new double[ n ]; discrete = new long[ n ]; } /* RealLocalizable */ @Override public double getDoublePosition( final int dim ) { return position[ dim ]; } @Override public float getFloatPosition( final int dim ) { return ( float ) position[ dim ]; } @Override public void localize( final float[] pos ) { for ( int d = 0; d < pos.length; ++d ) pos[ d ] = ( float ) this.position[ d ]; } @Override public void localize( final double[] pos ) { for ( int d = 0; d < pos.length; ++d ) pos[ d ] = this.position[ d ]; } /* Positionable */ @Override public void bck( final int dim ) { position[ dim ] -= 1; target.bck( dim ); } @Override public void fwd( final int dim ) { position[ dim ] += 1; target.fwd( dim ); } @Override public void move( final int distance, final int dim ) { position[ dim ] += distance; target.move( distance, dim ); } @Override public void move( final long distance, final int dim ) { position[ dim ] += distance; target.move( distance, dim ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) position[ d ] += localizable.getDoublePosition( d ); target.move( localizable ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) position[ d ] += distance[ d ]; target.move( distance ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) position[ d ] += distance[ d ]; target.move( distance ); } @Override public void setPosition( final Localizable localizable ) { localizable.localize( position ); target.setPosition( localizable ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < n; ++d ) this.position[ d ] = position[ d ]; target.setPosition( position ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < n; ++d ) this.position[ d ] = position[ d ]; target.setPosition( position ); } @Override public void setPosition( final int position, final int d ) { this.position[ d ] = position; target.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { this.position[ d ] = position; target.setPosition( position, d ); } /* Object */ @Override public String toString() { final StringBuffer pos = new StringBuffer( "(" ); pos.append( position[ 0 ] ); for ( int d = 1; d < n; d++ ) pos.append( ", " ).append( position[ d ] ); pos.append( ")" ); return pos.toString(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/position/transform/Floor.java000066400000000000000000000142001316447754700267610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.position.transform; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.RealLocalizable; import net.imglib2.RealPositionable; /** * A {@link RealPositionable} that drives a {@link Positionable} to its floor * discrete coordinates. For practical useage, the floor operation is defined as * the integer smaller than the real value: * * {@code f = r < 0 ? (long)r - 1 : (long)r} * * @author Stephan Saalfeld */ public class Floor< LocalizablePositionable extends Localizable & Positionable > extends AbstractPositionableTransform< LocalizablePositionable > { public Floor( final LocalizablePositionable target ) { super( target ); } public Floor( final RealLocalizable origin, final LocalizablePositionable target ) { super( target ); origin.localize( position ); for ( int d = 0; d < n; ++d ) target.setPosition( floor( position[ d ] ), d ); } public static final long floor( final double r ) { return r < 0 ? ( long ) r - 1 : ( long ) r; } public static final long floor( final float r ) { return r < 0 ? ( long ) r - 1 : ( long ) r; } public static final void floor( final double[] r, final long[] f ) { for ( int d = 0; d < r.length; ++d ) f[ d ] = floor( r[ d ] ); } public static final void floor( final float[] r, final long[] f ) { for ( int d = 0; d < r.length; ++d ) f[ d ] = floor( r[ d ] ); } public static final void floor( final RealLocalizable r, final long[] f ) { for ( int d = 0; d < f.length; ++d ) f[ d ] = floor( r.getDoublePosition( d ) ); } /* RealPositionable */ @Override public void move( final float distance, final int d ) { final double realPosition = position[ d ] + distance; final long floorPosition = floor( realPosition ); position[ d ] = realPosition; final long floorDistance = floorPosition - target.getLongPosition( d ); if ( floorDistance == 0 ) return; target.move( floorDistance, d ); } @Override public void move( final double distance, final int d ) { final double realPosition = position[ d ] + distance; final long floorPosition = floor( realPosition ); position[ d ] = realPosition; final long floorDistance = floorPosition - target.getLongPosition( d ); if ( floorDistance == 0 ) return; target.move( floorDistance, d ); } @Override public void move( final RealLocalizable localizable ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + localizable.getDoublePosition( d ); final long floorPosition = floor( realPosition ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void move( final float[] distance ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + distance[ d ]; final long floorPosition = floor( realPosition ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void move( final double[] distance ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + distance[ d ]; final long floorPosition = floor( realPosition ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void setPosition( final RealLocalizable localizable ) { localizable.localize( position ); for ( int d = 0; d < n; ++d ) discrete[ d ] = floor( position[ d ] ); target.setPosition( discrete ); } @Override public void setPosition( final float[] pos ) { for ( int d = 0; d < n; ++d ) { final float realPosition = pos[ d ]; position[ d ] = realPosition; discrete[ d ] = floor( realPosition ); } target.setPosition( discrete ); } @Override public void setPosition( final double[] position ) { for ( int d = 0; d < n; ++d ) { this.position[ d ] = position[ d ]; discrete[ d ] = floor( position[ d ] ); } target.setPosition( discrete ); } @Override public void setPosition( final float position, final int dim ) { this.position[ dim ] = position; target.setPosition( floor( position ), dim ); } @Override public void setPosition( final double position, final int dim ) { this.position[ dim ] = position; target.setPosition( floor( position ), dim ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/position/transform/FloorOffset.java000066400000000000000000000164551316447754700301460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.position.transform; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.RealLocalizable; import net.imglib2.RealPositionable; /** * A {@link RealPositionable} that drives a {@link Positionable} to its floor * discrete coordinates plus a discrete offset vector. For practical useage, the * floor operation is defined as the integer smaller than the real value: * * {@code f = r < 0 ? (long)r - 1 : (long)r} * * @author Stephan Saalfeld */ public class FloorOffset< LocalizablePositionable extends Localizable & Positionable > extends AbstractPositionableTransform< LocalizablePositionable > { final protected long[] offset; public FloorOffset( final LocalizablePositionable target, final long[] offset ) { super( target ); this.offset = offset.clone(); for ( int d = 0; d < n; ++d ) { discrete[ d ] = offset[ d ]; target.setPosition( offset[ d ], d ); } } public FloorOffset( final LocalizablePositionable target, final Localizable offset ) { super( target ); this.offset = new long[ n ]; for ( int d = 0; d < n; ++d ) { this.offset[ d ] = discrete[ d ] = offset.getLongPosition( d ); target.setPosition( discrete[ d ], d ); } } public FloorOffset( final RealLocalizable origin, final LocalizablePositionable target, final long[] offset ) { super( target ); this.offset = offset.clone(); for ( int d = 0; d < n; ++d ) { position[ d ] = origin.getDoublePosition( d ); discrete[ d ] = f( position[ d ], offset[ d ] ); target.setPosition( discrete[ d ], d ); } } public FloorOffset( final RealLocalizable origin, final LocalizablePositionable target, final Localizable offset ) { super( target ); this.offset = new long[ n ]; for ( int d = 0; d < n; ++d ) { position[ d ] = origin.getDoublePosition( d ); this.offset[ d ] = offset.getLongPosition( d ); discrete[ d ] = f( position[ d ], this.offset[ d ] ); target.setPosition( discrete[ d ], d ); } } final static protected long f( final double r, final long off ) { return r < 0 ? ( long ) r + off - 1 : ( long ) r + off; } final static protected long f( final float r, final long off ) { return r < 0 ? ( long ) r + off - 1 : ( long ) r + off; } protected void f( final double[] r, final long[] f ) { for ( int d = 0; d < r.length; ++d ) f[ d ] = f( r[ d ], offset[ d ] ); } protected void f( final float[] r, final long[] f ) { for ( int d = 0; d < r.length; ++d ) f[ d ] = f( r[ d ], offset[ d ] ); } protected void f( final RealLocalizable r, final long[] f ) { for ( int d = 0; d < f.length; ++d ) f[ d ] = f( r.getDoublePosition( d ), offset[ d ] ); } /* RealPositionable */ @Override public void move( final float distance, final int d ) { final double realPosition = position[ d ] + distance; final long floorPosition = f( realPosition, offset[ d ] ); position[ d ] = realPosition; final long floorDistance = floorPosition - target.getLongPosition( d ); if ( floorDistance == 0 ) return; target.move( floorDistance, d ); } @Override public void move( final double distance, final int d ) { final double realPosition = position[ d ] + distance; final long floorPosition = f( realPosition, offset[ d ] ); position[ d ] = realPosition; final long floorDistance = floorPosition - target.getLongPosition( d ); if ( floorDistance == 0 ) return; target.move( floorDistance, d ); } @Override public void move( final RealLocalizable localizable ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + localizable.getDoublePosition( d ); final long floorPosition = f( realPosition, offset[ d ] ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void move( final float[] distance ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + distance[ d ]; final long floorPosition = f( realPosition, offset[ d ] ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void move( final double[] distance ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + distance[ d ]; final long floorPosition = f( realPosition, offset[ d ] ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void setPosition( final RealLocalizable localizable ) { localizable.localize( position ); for ( int d = 0; d < n; ++d ) discrete[ d ] = f( position[ d ], offset[ d ] ); target.setPosition( discrete ); } @Override public void setPosition( final float[] pos ) { for ( int d = 0; d < n; ++d ) { final float realPosition = pos[ d ]; position[ d ] = realPosition; discrete[ d ] = f( realPosition, offset[ d ] ); } target.setPosition( discrete ); } @Override public void setPosition( final double[] position ) { for ( int d = 0; d < n; ++d ) { this.position[ d ] = position[ d ]; discrete[ d ] = f( position[ d ], offset[ d ] ); } target.setPosition( discrete ); } @Override public void setPosition( final float position, final int d ) { this.position[ d ] = position; target.setPosition( f( position, offset[ d ] ), d ); } @Override public void setPosition( final double position, final int d ) { this.position[ d ] = position; target.setPosition( f( position, offset[ d ] ), d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/position/transform/Round.java000066400000000000000000000141661316447754700270020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.position.transform; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.RealLocalizable; import net.imglib2.RealPositionable; /** * A {@link RealPositionable} that drives a {@link Positionable} to its round * discrete coordinates: * * {@code f = r < 0 ? (long)( r - 0.5 ) : (long)( r + 0.5 )} * * @author Stephan Saalfeld */ public class Round< LocalizablePositionable extends Localizable & Positionable > extends AbstractPositionableTransform< LocalizablePositionable > { public Round( final LocalizablePositionable target ) { super( target ); } public Round( final RealLocalizable origin, final LocalizablePositionable target ) { super( target ); origin.localize( position ); for ( int d = 0; d < n; ++d ) discrete[ d ] = round( position[ d ] ); target.setPosition( discrete ); } public static final long round( final double r ) { return r < 0 ? ( long ) ( r - 0.5 ) : ( long ) ( r + 0.5 ); } public static final long round( final float r ) { return r < 0 ? ( long ) ( r - 0.5f ) : ( long ) ( r + 0.5f ); } public static final void round( final double[] r, final long[] f ) { for ( int d = 0; d < r.length; ++d ) f[ d ] = round( r[ d ] ); } public static final void round( final float[] r, final long[] f ) { for ( int d = 0; d < r.length; ++d ) f[ d ] = round( r[ d ] ); } public static final void round( final RealLocalizable r, final long[] f ) { for ( int d = 0; d < f.length; ++d ) f[ d ] = round( r.getDoublePosition( d ) ); } /* RealPositionable */ @Override public void move( final float distance, final int d ) { final double realPosition = position[ d ] + distance; final long roundPosition = round( realPosition ); position[ d ] = realPosition; final long roundDistance = roundPosition - target.getIntPosition( d ); if ( roundDistance == 0 ) return; target.move( roundDistance, d ); } @Override public void move( final double distance, final int d ) { final double realPosition = position[ d ] + distance; final long roundPosition = round( realPosition ); position[ d ] = realPosition; final long roundDistance = roundPosition - target.getIntPosition( d ); if ( roundDistance == 0 ) return; target.move( roundDistance, d ); } @Override public void move( final RealLocalizable localizable ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + localizable.getDoublePosition( d ); final long floorPosition = round( realPosition ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void move( final float[] distance ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + distance[ d ]; final long floorPosition = round( realPosition ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void move( final double[] distance ) { for ( int d = 0; d < n; ++d ) { final double realPosition = position[ d ] + distance[ d ]; final long floorPosition = round( realPosition ); position[ d ] = realPosition; discrete[ d ] = floorPosition - target.getLongPosition( d ); } target.move( discrete ); } @Override public void setPosition( final RealLocalizable localizable ) { localizable.localize( position ); for ( int d = 0; d < n; ++d ) discrete[ d ] = round( position[ d ] ); target.setPosition( discrete ); } @Override public void setPosition( final float[] pos ) { for ( int d = 0; d < n; ++d ) { final float realPosition = pos[ d ]; position[ d ] = realPosition; discrete[ d ] = round( realPosition ); } target.setPosition( discrete ); } @Override public void setPosition( final double[] pos ) { for ( int d = 0; d < n; ++d ) { final double realPosition = pos[ d ]; position[ d ] = realPosition; discrete[ d ] = round( realPosition ); } target.setPosition( discrete ); } @Override public void setPosition( final float position, final int d ) { this.position[ d ] = position; target.setPosition( round( position ), d ); } @Override public void setPosition( final double position, final int d ) { this.position[ d ] = position; target.setPosition( round( position ), d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/000077500000000000000000000000001316447754700231745ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/InverseTransform.java000066400000000000000000000065761316447754700273640ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform; import net.imglib2.Localizable; import net.imglib2.Positionable; /** * Final implementation of the inverse of an {@link InvertibleTransform} that * simply replaces apply by applyInverse and conversely. The original * {@link InvertibleTransform} is returned on {@link #inverse()}. * * @author Tobias Pietzsch * @author Stephan Saalfeld */ final public class InverseTransform implements InvertibleTransform { private final InvertibleTransform inverse; public InverseTransform( final InvertibleTransform transform ) { inverse = transform; } @Override public int numSourceDimensions() { return inverse.numTargetDimensions(); } @Override public int numTargetDimensions() { return inverse.numSourceDimensions(); } @Override public void apply( final long[] source, final long[] target ) { inverse.applyInverse( target, source ); } @Override public void apply( final int[] source, final int[] target ) { inverse.applyInverse( target, source ); } @Override public void apply( final Localizable source, final Positionable target ) { inverse.applyInverse( target, source ); } @Override public void applyInverse( final long[] source, final long[] target ) { inverse.apply( target, source ); } @Override public void applyInverse( final int[] source, final int[] target ) { inverse.apply( target, source ); } @Override public void applyInverse( final Positionable source, final Localizable target ) { inverse.apply( target, source ); } @Override public InvertibleTransform inverse() { return inverse; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/InvertibleTransform.java000066400000000000000000000070611316447754700300420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform; import net.imglib2.Localizable; import net.imglib2.Positionable; /** * Invertible transformation from Zn to Zm * . * *

* Applying the transformation to a n-dimensional integer * source vector yields a m-dimensional integer * target vector. *

* *

* You can also * {@link InvertibleTransform#applyInverse(Positionable, Localizable) apply the * inverse transformation} to a m-dimensional integer target * vector to get the n-dimensional integer source vector. *

* * @author Tobias Pietzsch * @author Stephan Saalfeld */ public interface InvertibleTransform extends Transform { /** * Apply the inverse transform to a target vector to obtain a source vector. * * @param source * set this to the source coordinates. * @param target * target coordinates. */ public void applyInverse( final long[] source, final long[] target ); /** * Apply the inverse transform to a target vector to obtain a source vector. * * @param source * set this to the source coordinates. * @param target * target coordinates. */ public void applyInverse( final int[] source, final int[] target ); /** * Apply the inverse transform to a target {@link Localizable} to obtain a * source {@link Positionable}. * * @param source * set this to the source coordinates. * @param target * target coordinates. */ public void applyInverse( final Positionable source, final Localizable target ); /** * Get the inverse transform. * * @return the inverse transform */ public InvertibleTransform inverse(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/Transform.java000066400000000000000000000066511316447754700260220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform; import net.imglib2.Localizable; import net.imglib2.Positionable; /** * Transformation from Zn to Zm. * *

* Applying the transformation to a n-dimensional integer * source vector yields a m-dimensional integer * target vector. *

* * @author Tobias Pietzsch * @author Stephan Saalfeld */ public interface Transform { /** * Returns n, the dimension of the source vector. * * @return the dimension of the source vector. */ public int numSourceDimensions(); /** * Returns m, the dimension of the target vector. * * @return the dimension of the target vector. */ public int numTargetDimensions(); /** * Apply the {@link Transform} to a source vector to obtain a target vector. * * @param source * source coordinates. * @param target * set this to the target coordinates. */ public void apply( final long[] source, final long[] target ); /** * Apply the {@link Transform} to a source vector to obtain a target vector. * * @param source * source coordinates. * @param target * set this to the target coordinates. */ public void apply( final int[] source, final int[] target ); /** * Apply the {@link Transform} to a source {@link Localizable} to obtain a * target {@link Positionable}. * * @param source * source coordinates. * @param target * set this to the target coordinates. */ public void apply( final Localizable source, final Positionable target ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/Transformable.java000066400000000000000000000052501316447754700266400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform; /** * A class is transformable if it can produce a copy of itself in the * transformed space using the supplied transform. * * Note that a class may require either a Transform or an InvertibleTransform * depending on whether the strategy is to transform coordinates in the source * space into the destination space or to generate the object in the destination * space by sampling invert-transformed points in the source space. * * * @author Lee Kamentsky */ public interface Transformable< O, T extends Transform > { /** * Generate a copy of the object in the transformed space. * * @param t * the transform that maps points in the source space to those in * the destination space. * @return a copy built to operate similarly in the transformed space. */ public O transform( final T t ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/000077500000000000000000000000001316447754700246315ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/AbstractMixedTransform.java000066400000000000000000000077411316447754700321330ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; /** * TODO * */ public abstract class AbstractMixedTransform implements Mixed { /** * dimension of target vector. */ protected final int numTargetDimensions; protected AbstractMixedTransform( final int numTargetDimensions ) { this.numTargetDimensions = numTargetDimensions; } @Override public int numSourceDimensions() { return numTargetDimensions; } @Override public int numTargetDimensions() { return numTargetDimensions; } @Override public void getTranslation( final long[] translation ) { assert translation.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) translation[ d ] = 0; } @Override public long getTranslation( final int d ) { return 0; } @Override public void getComponentZero( final boolean[] zero ) { assert zero.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) zero[ d ] = false; } @Override public boolean getComponentZero( final int d ) { return false; } @Override public void getComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) component[ d ] = d; } @Override public int getComponentMapping( final int d ) { return d; } @Override public void getComponentInversion( final boolean[] invert ) { assert invert.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) invert[ d ] = false; } @Override public boolean getComponentInversion( final int d ) { return false; } @Override public BoundingBox transform( final BoundingBox boundingBox ) { assert boundingBox.numDimensions() == numSourceDimensions(); if ( numSourceDimensions() == numTargetDimensions ) { // apply in-place final long[] tmp = new long[ numTargetDimensions ]; boundingBox.corner1( tmp ); apply( tmp, boundingBox.corner1 ); boundingBox.corner2( tmp ); apply( tmp, boundingBox.corner2 ); return boundingBox; } final BoundingBox b = new BoundingBox( numTargetDimensions ); apply( boundingBox.corner1, b.corner1 ); apply( boundingBox.corner2, b.corner2 ); return b; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/BoundingBox.java000066400000000000000000000065741316447754700277260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.FinalInterval; import net.imglib2.Interval; /** * TODO * */ public final class BoundingBox { final public int n; final public long[] corner1; final public long[] corner2; public BoundingBox( final int n ) { this.n = n; this.corner1 = new long[ n ]; this.corner2 = new long[ n ]; } public BoundingBox( final long[] corner1, final long[] corner2 ) { assert corner1.length == corner2.length; this.n = corner1.length; this.corner1 = corner1.clone(); this.corner2 = corner2.clone(); } public BoundingBox( final Interval interval ) { this.n = interval.numDimensions(); this.corner1 = new long[ n ]; this.corner2 = new long[ n ]; interval.min( corner1 ); interval.max( corner2 ); } public int numDimensions() { return n; } public void corner1( final long[] c ) { assert c.length >= n; for ( int d = 0; d < n; ++d ) c[ d ] = this.corner1[ d ]; } public void corner2( final long[] c ) { assert c.length >= n; for ( int d = 0; d < n; ++d ) c[ d ] = this.corner2[ d ]; } /** * flip coordinates between corner1 and corner2 such that corner1 is the min * of the bounding box and corner2 is the max. */ public void orderMinMax() { for ( int d = 0; d < n; ++d ) { if ( corner1[ d ] > corner2[ d ] ) { final long tmp = corner1[ d ]; corner1[ d ] = corner2[ d ]; corner2[ d ] = tmp; } } } /** * @return bounding box as an interval. */ public Interval getInterval() { orderMinMax(); return new FinalInterval( corner1, corner2 ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/BoundingBoxTransform.java000066400000000000000000000044421316447754700316120ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; /** * Implemented by Transforms that can transform (easily) a BoundingBox in the * source space to a bounding box in the target space. * * * @author Tobias Pietzsch */ public interface BoundingBoxTransform { /** * Return a transformed bounding box. The transformation can be carried out * in-place. * * @param boundingBox * @return the transformed bounding box */ public BoundingBox transform( BoundingBox boundingBox ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/ComponentMapping.java000066400000000000000000000046201316447754700307540ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; /** * Map the components of the source vector to obtain the target vector, for * instance transform (x,y,z) to (x,z,y). * *

* The intended use of ComponentMapping is as a dimension permutation. The * mapping is implemented as a inverse lookup, i.e., every component of the * target is read from a source component. * Note, that it is not allowed to set this array such that a source component * is mapped to several target components! *

* * * @author Tobias Pietzsch */ public interface ComponentMapping extends Mixed {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/ComponentMappingTransform.java000066400000000000000000000145131316447754700326520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.concatenate.Concatenable; import net.imglib2.concatenate.PreConcatenable; /** * Map the components of the source vector to obtain the target vector, for * instance transform (x,y,z) to (x,z,y). * *

* The intended use of ComponentMapping is as a dimension permutation. The * mapping is implemented as a inverse lookup, i.e., every component of the * target is read from a source component. * Note, that it is not allowed to set this array such that a source component * is mapped to several target components! *

* * * @author Tobias Pietzsch */ public class ComponentMappingTransform extends AbstractMixedTransform implements ComponentMapping, Concatenable< ComponentMapping >, PreConcatenable< ComponentMapping > { /** * for each component of the target vector: from which source vector * component should it be taken. */ protected final int[] component; public ComponentMappingTransform( final int targetDim ) { super( targetDim ); component = new int[ targetDim ]; for ( int d = 0; d < targetDim; ++d ) component[ d ] = d; } /** * @param component * array specifying for each component of the target vector from * which source vector component should it be taken. */ public ComponentMappingTransform( final int[] component ) { super( component.length ); this.component = component.clone(); } @Override public void getComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) component[ d ] = this.component[ d ]; } @Override public int getComponentMapping( final int d ) { assert d <= numTargetDimensions; return component[ d ]; } /** * Set for each target dimensions from which source dimension it is taken. * *

* For instance, if the transform maps 3D (x,y,z) coordinates to 2D (z,x,y) * coordinate this will be [2, 0, 1]. *

* * @param component * array that says for each component of the target vector from * which source vector component it should be taken. */ public void setComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) this.component[ d ] = component[ d ]; } @Override public double[][] getMatrix() { final double[][] mat = new double[ numTargetDimensions + 1 ][ numTargetDimensions + 1 ]; mat[ numTargetDimensions ][ numTargetDimensions ] = 1; for ( int d = 0; d < numTargetDimensions; ++d ) { mat[ d ][ component[ d ] ] = 1; } return mat; } @Override public void apply( final long[] source, final long[] target ) { assert source.length >= numTargetDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target[ d ] = source[ component[ d ] ]; } @Override public void apply( final int[] source, final int[] target ) { assert source.length >= numTargetDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target[ d ] = source[ component[ d ] ]; } @Override public void apply( final Localizable source, final Positionable target ) { assert source.numDimensions() >= numTargetDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target.setPosition( source.getLongPosition( component[ d ] ), d ); } @Override public ComponentMappingTransform concatenate( final ComponentMapping t ) { assert numTargetDimensions == t.numTargetDimensions(); final ComponentMappingTransform result = new ComponentMappingTransform( numTargetDimensions ); for ( int d = 0; d < numTargetDimensions; ++d ) result.component[ d ] = t.getComponentMapping( this.component[ d ] ); return result; } @Override public Class< ComponentMapping > getConcatenableClass() { return ComponentMapping.class; } @Override public ComponentMappingTransform preConcatenate( final ComponentMapping t ) { assert numTargetDimensions == t.numTargetDimensions(); final ComponentMappingTransform result = new ComponentMappingTransform( numTargetDimensions ); for ( int d = 0; d < numTargetDimensions; ++d ) result.component[ d ] = this.component[ t.getComponentMapping( d ) ]; return result; } @Override public Class< ComponentMapping > getPreConcatenableClass() { return ComponentMapping.class; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/Mixed.java000066400000000000000000000124521316447754700265460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.transform.Transform; /** * Mixed transform allows to express common integer view transformations such as * translation, rotation, rotoinversion, and projection. * *

* It transform a n-dimensional source vector to a m-dimensional target vector, * and can be represented as a m+1 × n+1 homogeneous * matrix. The mixed transform can be decomposed as follows: *

*
    *
  1. project down (discard some components of the source vector)
  2. *
  3. component permutation
  4. *
  5. component inversion
  6. *
  7. project up (add zero components in the target vector)
  8. *
  9. translation
  10. *
* * @author Tobias Pietzsch */ public interface Mixed extends Transform, BoundingBoxTransform { /** * Get the translation. Translation is added to the target vector after * applying permutation, projection, inversion operations. * * @param translation * array of size at least the target dimension to store the * result. */ public void getTranslation( final long[] translation ); /** * Get the d-th component of translation (see * {@link #getTranslation(long[])}). * * @param d */ public long getTranslation( final int d ); /** * Get a boolean array indicating which target dimensions are _not_ taken * from source dimensions. * *

* For instance, if the transform maps 2D (x,y) coordinates to the first two * components of a 3D (x,y,z) coordinate, the result will be [false, false, * true] *

* * @param zero * array of size at least the target dimension to store the * result. */ public void getComponentZero( final boolean[] zero ); /** * Get the d-th component of zeroing vector (see {@link * #getComponentZero(boolean[])}). * * @param d */ public boolean getComponentZero( final int d ); /** * Get an array indicating for each target dimensions from which source * dimension it is taken. * *

* For instance, if the transform maps 2D (x,y) coordinates to the first two * components of a 3D (x,y,z) coordinate, the result will be [0, 1, x]. * Here, the value of x is undefined because the third target dimension does * not correspond to any source dimension. See {@link #getComponentZero(boolean[])}. *

* * @param component * array of size at least the target dimension to store the * result. */ public void getComponentMapping( final int[] component ); /** * Get the source dimension which is mapped to the d-th target dimension * (see {@link #getComponentMapping(int[])}). * * @param d */ public int getComponentMapping( final int d ); /** * Get an array indicating for each target component, whether the source * component it is taken from should be inverted. * *

* For instance, if rotating a 2D (x,y) coordinates by 180 degrees will map * it to (-x,-y). In this case, the result will be [true, true]. *

* * @param invert * array of size at least the target dimension to store the * result. */ public void getComponentInversion( final boolean[] invert ); /** * Get the d-th component of inversion vector (see {@link * #getComponentInversion(boolean[])}). * * @param d */ public boolean getComponentInversion( final int d ); /** * Get the matrix that transforms homogeneous source points to homogeneous * target points. For testing purposes. */ public double[][] getMatrix(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/MixedTransform.java000066400000000000000000000331371316447754700304450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.concatenate.Concatenable; import net.imglib2.concatenate.PreConcatenable; /** * Mixed transform allows to express common integer view transformations such as * translation, rotation, rotoinversion, and projection. * *

* It transform a n-dimensional source vector to a m-dimensional target vector, * and can be represented as a m+1 × n+1 homogeneous * matrix. The mixed transform can be decomposed as follows: *

*
    *
  1. project down (discard some components of the source vector)
  2. *
  3. component permutation
  4. *
  5. component inversion
  6. *
  7. project up (add zero components in the target vector)
  8. *
  9. translation
  10. *
* *

* The project down and component permutation steps are implemented by the * {@link #setComponentMapping(int[]) component mapping}. This is a lookup array * that specifies for each target dimension from which source dimension it is * taken. * Note, that it is not allowed to set this array such that a source component * is mapped to several target components! *

* * * @author Tobias Pietzsch */ public class MixedTransform extends AbstractMixedTransform implements Concatenable< Mixed >, PreConcatenable< Mixed > { /** * dimension of source vector. */ protected final int numSourceDimensions; /** * translation is added to the target vector after applying permutation, * projection, inversion operations. */ protected final long[] translation; /** * for each component of the target vector (before translation). should the * value be taken from a source vector component (false) or should it be * zero (true). */ protected final boolean[] zero; /** * for each component of the target vector (before translation). should the * source vector component be inverted (true). */ protected final boolean[] invert; /** * for each component of the target vector (before translation). from which * source vector component should it be taken. */ protected final int[] component; public MixedTransform( final int sourceDim, final int targetDim ) { super( targetDim ); this.numSourceDimensions = sourceDim; translation = new long[ targetDim ]; zero = new boolean[ targetDim ]; invert = new boolean[ targetDim ]; component = new int[ targetDim ]; for ( int d = 0; d < targetDim; ++d ) { if ( d < sourceDim ) { component[ d ] = d; } else { component[ d ] = 0; zero[ d ] = true; } } } @Override public int numSourceDimensions() { return numSourceDimensions; } @Override public void getTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) t[ d ] = translation[ d ]; } @Override public long getTranslation( final int d ) { assert d <= numTargetDimensions; return translation[ d ]; } public void setTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) translation[ d ] = t[ d ]; } public void setInverseTranslation( final long[] tinv ) { assert tinv.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) translation[ d ] = -tinv[ d ]; } @Override public void getComponentZero( final boolean[] zero ) { assert zero.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { zero[ d ] = this.zero[ d ]; } } @Override public boolean getComponentZero( final int d ) { assert d <= numTargetDimensions; return zero[ d ]; } /** * Set which target dimensions are _not_ taken from source dimensions. * *

* For instance, if the transform maps 2D (x,y) coordinates to the first two * components of a 3D (x,y,z) coordinate, this will be [false, false, true] *

* * @param zero * array that says for each component of the target vector * (before translation) whether the value should be taken from a * source vector component (false) or should be set to zero * (true). */ public void setComponentZero( final boolean[] zero ) { assert zero.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { this.zero[ d ] = zero[ d ]; } } @Override public void getComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { component[ d ] = this.component[ d ]; } } @Override public int getComponentMapping( final int d ) { assert d <= numTargetDimensions; return component[ d ]; } /** * Set for each target dimensions from which source dimension it is taken. * *

* For instance, if the transform maps 2D (x,y) coordinates to the first two * components of a 3D (x,y,z) coordinate, this will be [0, 1, x]. Here, x * can be any value because the third target dimension does not correspond * to any source dimension, which can be realized using * {@link #setComponentZero(boolean[])}. *

* *

* Note, that it is not allowed to set the {@code component} array such that * a source component is mapped to several target components! *

* * @param component * array that says for each component of the target vector * (before translation) from which source vector component it * should be taken. */ public void setComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { this.component[ d ] = component[ d ]; } } @Override public void getComponentInversion( final boolean[] invert ) { assert invert.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { invert[ d ] = this.invert[ d ]; } } @Override public boolean getComponentInversion( final int d ) { assert d <= numTargetDimensions; return invert[ d ]; } /** * Set for each target component, whether the source component it is taken * from should be inverted. * *

* For instance, if rotating a 2D (x,y) coordinates by 180 degrees will map * it to (-x,-y). In this case, this will be [true, true]. *

* * @param invert * array that says for each component of the target vector * (before translation) whether the source vector component it is * taken from should be inverted (true). */ public void setComponentInversion( final boolean[] invert ) { assert invert.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { this.invert[ d ] = invert[ d ]; } } @Override public void apply( final long[] source, final long[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { target[ d ] = translation[ d ]; if ( !zero[ d ] ) { final long v = source[ component[ d ] ]; if ( invert[ d ] ) target[ d ] -= v; else target[ d ] += v; } } } @Override public void apply( final int[] source, final int[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { target[ d ] = ( int ) translation[ d ]; if ( !zero[ d ] ) { final long v = source[ component[ d ] ]; if ( invert[ d ] ) target[ d ] -= v; else target[ d ] += v; } } } @Override public void apply( final Localizable source, final Positionable target ) { assert source.numDimensions() >= numSourceDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) { long pos = translation[ d ]; if ( !zero[ d ] ) { final long v = source.getLongPosition( component[ d ] ); if ( invert[ d ] ) pos -= v; else pos += v; } target.setPosition( pos, d ); } } @Override public MixedTransform concatenate( final Mixed t ) { assert this.numSourceDimensions == t.numTargetDimensions(); final MixedTransform result = new MixedTransform( t.numSourceDimensions(), this.numTargetDimensions ); for ( int d = 0; d < result.numTargetDimensions; ++d ) { result.translation[ d ] = this.translation[ d ]; if ( this.zero[ d ] ) { result.zero[ d ] = true; result.invert[ d ] = false; result.component[ d ] = 0; } else { final int c = this.component[ d ]; final long v = t.getTranslation( c ); if ( this.invert[ d ] ) result.translation[ d ] -= v; else result.translation[ d ] += v; if ( t.getComponentZero( c ) ) { result.zero[ d ] = true; result.invert[ d ] = false; result.component[ d ] = 0; } else { result.zero[ d ] = false; result.invert[ d ] = ( this.invert[ d ] != t.getComponentInversion( c ) ); result.component[ d ] = t.getComponentMapping( c ); } } } return result; } @Override public Class< Mixed > getConcatenableClass() { return Mixed.class; } @Override public MixedTransform preConcatenate( final Mixed t ) { assert t.numSourceDimensions() == this.numTargetDimensions; final MixedTransform result = new MixedTransform( this.numSourceDimensions, t.numTargetDimensions() ); for ( int d = 0; d < result.numTargetDimensions; ++d ) { result.translation[ d ] = t.getTranslation( d ); if ( t.getComponentZero( d ) ) { result.zero[ d ] = true; result.invert[ d ] = false; result.component[ d ] = 0; } else { final int c = t.getComponentMapping( d ); final long v = this.translation[ c ]; if ( t.getComponentInversion( d ) ) result.translation[ d ] -= v; else result.translation[ d ] += v; if ( this.zero[ c ] ) { result.zero[ d ] = true; result.invert[ d ] = false; result.component[ d ] = 0; } else { result.zero[ d ] = false; result.invert[ d ] = ( t.getComponentInversion( d ) != this.invert[ c ] ); result.component[ d ] = this.component[ c ]; } } } return result; } @Override public Class< Mixed > getPreConcatenableClass() { return Mixed.class; } /** * set parameters to transform. * * @param transform */ public void set( final Mixed transform ) { assert numSourceDimensions == transform.numSourceDimensions(); assert numTargetDimensions == transform.numTargetDimensions(); transform.getTranslation( translation ); transform.getComponentZero( zero ); transform.getComponentMapping( component ); transform.getComponentInversion( invert ); } /** * Get the matrix that transforms homogeneous source points to homogeneous * target points. For testing purposes. */ @Override public double[][] getMatrix() { final double[][] mat = new double[ numTargetDimensions + 1 ][ numSourceDimensions + 1 ]; mat[ numTargetDimensions ][ numSourceDimensions ] = 1; for ( int d = 0; d < numTargetDimensions; ++d ) { mat[ d ][ numSourceDimensions ] = translation[ d ]; } for ( int d = 0; d < numTargetDimensions; ++d ) { if ( zero[ d ] == false ) { mat[ d ][ component[ d ] ] = invert[ d ] ? -1 : 1; } } return mat; } /** * Check whether the transforms has a full mapping of source to target * components (no source component is discarded). * * @return whether there is a full mapping of source to target components. */ public boolean hasFullSourceMapping() { final boolean[] sourceMapped = new boolean[ numSourceDimensions ]; for ( int d = 0; d < numTargetDimensions; ++d ) { if ( !zero[ d ] ) { sourceMapped[ component[ d ] ] = true; } } for ( int d = 0; d < numSourceDimensions; ++d ) { if ( !sourceMapped[ d ] ) { return false; } } return true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/SequentializeTransform.java000066400000000000000000000173101316447754700322140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.transform.InvertibleTransform; /** * Transform n-dimensional to m-dimensional coordinates {@code (mm}. An example of this transformation is the * way, a 2D image is flattened out as a 1D array in memory. * * @author Tobias Pietzsch */ public class SequentializeTransform implements InvertibleTransform { /** * dimension of source vector. */ protected final int numSourceDimensions; /** * dimension of target vector. */ protected final int numTargetDimensions; protected final int maxSourceDimension; protected final int maxTargetDimension; protected final long[] seqDimensions; protected final InvertibleTransform inverse; public SequentializeTransform( final long[] sourceDimensions, final int numTargetDimensions ) { this.numSourceDimensions = sourceDimensions.length; this.numTargetDimensions = numTargetDimensions; this.maxTargetDimension = numTargetDimensions - 1; this.maxSourceDimension = numSourceDimensions - 1; assert this.numSourceDimensions > this.numTargetDimensions; seqDimensions = new long[ numSourceDimensions ]; for ( int d = maxTargetDimension; d < numSourceDimensions; ++d ) { seqDimensions[ d ] = sourceDimensions[ d ]; } inverse = new InvertibleTransform() { @Override public int numSourceDimensions() { return SequentializeTransform.this.numTargetDimensions(); } @Override public int numTargetDimensions() { return SequentializeTransform.this.numSourceDimensions(); } @Override public void apply( final long[] source, final long[] target ) { SequentializeTransform.this.applyInverse( target, source ); } @Override public void apply( final int[] source, final int[] target ) { SequentializeTransform.this.applyInverse( target, source ); } @Override public void apply( final Localizable source, final Positionable target ) { SequentializeTransform.this.applyInverse( target, source ); } @Override public void applyInverse( final long[] source, final long[] target ) { SequentializeTransform.this.apply( target, source ); } @Override public void applyInverse( final int[] source, final int[] target ) { SequentializeTransform.this.apply( target, source ); } @Override public void applyInverse( final Positionable source, final Localizable target ) { SequentializeTransform.this.apply( target, source ); } @Override public InvertibleTransform inverse() { return SequentializeTransform.this; } }; } @Override public int numSourceDimensions() { return numSourceDimensions; } @Override public int numTargetDimensions() { return numTargetDimensions; } @Override public void apply( final long[] source, final long[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < maxTargetDimension; ++d ) target[ d ] = source[ d ]; long i = source[ maxSourceDimension ]; for ( int d = maxSourceDimension - 1; d >= maxTargetDimension; --d ) i = i * seqDimensions[ d ] + source[ d ]; target[ maxTargetDimension ] = i; } @Override public void apply( final int[] source, final int[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < maxTargetDimension; ++d ) target[ d ] = source[ d ]; int i = source[ maxSourceDimension ]; for ( int d = maxSourceDimension - 1; d >= maxTargetDimension; --d ) i = i * ( int ) seqDimensions[ d ] + source[ d ]; target[ maxTargetDimension ] = i; } @Override public void apply( final Localizable source, final Positionable target ) { assert source.numDimensions() >= numSourceDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < maxTargetDimension; ++d ) target.setPosition( source.getLongPosition( d ), d ); long i = source.getLongPosition( maxSourceDimension ); for ( int d = maxSourceDimension - 1; d >= maxTargetDimension; --d ) i = i * seqDimensions[ d ] + source.getLongPosition( d ); target.setPosition( i, maxTargetDimension ); } @Override public void applyInverse( final long[] source, final long[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < maxTargetDimension; ++d ) source[ d ] = target[ d ]; long i = target[ maxTargetDimension ]; for ( int d = maxTargetDimension; d < maxSourceDimension; ++d ) { final long j = i / seqDimensions[ d ]; source[ d ] = i - j * seqDimensions[ d ]; i = j; } source[ maxSourceDimension ] = i; } @Override public void applyInverse( final int[] source, final int[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < maxTargetDimension; ++d ) source[ d ] = target[ d ]; int i = target[ maxTargetDimension ]; for ( int d = maxTargetDimension; d < maxSourceDimension; ++d ) { final int j = ( int ) ( i / seqDimensions[ d ] ); source[ d ] = ( int ) ( i - j * seqDimensions[ d ] ); i = j; } source[ maxSourceDimension ] = i; } @Override public void applyInverse( final Positionable source, final Localizable target ) { assert source.numDimensions() >= numSourceDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < maxTargetDimension; ++d ) source.setPosition( target.getLongPosition( d ), d ); long i = target.getLongPosition( maxTargetDimension ); for ( int d = maxTargetDimension; d < maxSourceDimension; ++d ) { final long j = ( i / seqDimensions[ d ] ); source.setPosition( i - j * seqDimensions[ d ], d ); i = j; } source.setPosition( i, maxSourceDimension ); } @Override public InvertibleTransform inverse() { return inverse; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/Slicing.java000066400000000000000000000036421316447754700270710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; /** * TODO * */ public interface Slicing extends Mixed {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/SlicingTransform.java000066400000000000000000000264751316447754700307760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.concatenate.Concatenable; import net.imglib2.concatenate.PreConcatenable; /** * Map the components of the source vector to a slice of the target space, for * instance transform (x,y) to (x,C,y) where C is a constant. * *

* A {@link SlicingTransform} transform a n-dimensional source vector to a * m-dimensional target vector, where m ≥ n. It can be represented as a * m+1 × n+1 homogeneous matrix. The * {@link SlicingTransform} can be decomposed as follows: *

*
    *
  1. component permutation
  2. *
  3. project up and position (add constant components in the target vector) *
  4. *
* *

* The component permutation step is implemented by the * {@link #setComponentMapping(int[]) component mapping}. This is a lookup array * that specifies for each target dimension from which source dimension it is * taken. * Note, that it is not allowed to set this array such that a source component * is mapped to several target components! *

* * * @author Tobias Pietzsch */ public class SlicingTransform extends AbstractMixedTransform implements Slicing, Concatenable< Slicing >, PreConcatenable< Slicing > { /** * dimension of source vector. */ protected final int numSourceDimensions; /** * for each component of the target vector (before translation). should the * value be taken from a source vector component (false) or should it be * zero (true). */ protected final boolean[] zero; /** * translation is added to the target vector after applying the permutation * and project-up operations. Only translation values for dimensions that * have not been assigned a source vector component are used. For instance, * if you project (x,y) to (x,y,z) only the translation value for z is used. */ protected final long[] translation; /** * specifies for each component of the target vector from which source * vector component should it be taken. */ protected final int[] component; public SlicingTransform( final int sourceDim, final int targetDim ) { super( targetDim ); assert sourceDim <= targetDim; numSourceDimensions = sourceDim; translation = new long[ targetDim ]; zero = new boolean[ targetDim ]; component = new int[ targetDim ]; for ( int d = 0; d < targetDim; ++d ) { if ( d < sourceDim ) { component[ d ] = d; } else { component[ d ] = 0; zero[ d ] = true; } } } @Override public int numSourceDimensions() { return numSourceDimensions; } @Override public void getTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) t[ d ] = zero[ d ] ? translation[ d ] : 0; } @Override public long getTranslation( final int d ) { assert d <= numTargetDimensions; return zero[ d ] ? translation[ d ] : 0; } public void setTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) translation[ d ] = t[ d ]; } @Override public void getComponentZero( final boolean[] zero ) { assert zero.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) zero[ d ] = this.zero[ d ]; } @Override public boolean getComponentZero( final int d ) { assert d <= numTargetDimensions; return zero[ d ]; } /** * Set which target dimensions are _not_ taken from source dimensions. * *

* For instance, if the transform maps 2D (x,y) coordinates to the first two * components of a 3D (x,y,z) coordinate, this will be [false, false, true] *

* * @param zero * array that says for each component of the target vector * (before translation) whether the value should be taken from a * source vector component (false) or should be set to zero * (true). */ public void setComponentZero( final boolean[] zero ) { assert zero.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) this.zero[ d ] = zero[ d ]; } @Override public void getComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) component[ d ] = this.component[ d ]; } @Override public int getComponentMapping( final int d ) { assert d <= numTargetDimensions; return component[ d ]; } /** * Set for each target dimensions from which source dimension it is taken. * *

* For instance, if the transform maps 2D (x,y) coordinates to the first two * components of a 3D (x,y,z) coordinate, this will be [0, 1, x]. Here, x * can be any value because the third target dimension does not correspond * to any source dimension, which can be realized using * {@link #setComponentZero(boolean[])}. *

* *

* Note, that it is not allowed to set the {@code component} array such that * a source component is mapped to several target components! *

* * @param component * array that says for each component of the target vector * (before translation) from which source vector component it * should be taken. */ public void setComponentMapping( final int[] component ) { assert component.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) this.component[ d ] = component[ d ]; } @Override public void apply( final long[] source, final long[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target[ d ] = zero[ d ] ? translation[ d ] : source[ component[ d ] ]; } @Override public void apply( final int[] source, final int[] target ) { assert source.length >= numSourceDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target[ d ] = zero[ d ] ? ( int ) translation[ d ] : source[ component[ d ] ]; } @Override public void apply( final Localizable source, final Positionable target ) { assert source.numDimensions() >= numSourceDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target.setPosition( zero[ d ] ? ( int ) translation[ d ] : source.getLongPosition( component[ d ] ), d ); } @Override public SlicingTransform concatenate( final Slicing t ) { assert this.numSourceDimensions == t.numTargetDimensions(); final SlicingTransform result = new SlicingTransform( t.numSourceDimensions(), this.numTargetDimensions ); for ( int d = 0; d < result.numTargetDimensions; ++d ) { if ( this.zero[ d ] ) { result.zero[ d ] = true; result.translation[ d ] = this.translation[ d ]; } else { final int c = this.component[ d ]; if ( t.getComponentZero( c ) ) { result.zero[ d ] = true; result.translation[ d ] = t.getTranslation( c ); } else { result.zero[ d ] = false; result.component[ d ] = t.getComponentMapping( c ); } } } return result; } @Override public Class< Slicing > getConcatenableClass() { return Slicing.class; } @Override public SlicingTransform preConcatenate( final Slicing t ) { assert t.numSourceDimensions() == this.numTargetDimensions; final SlicingTransform result = new SlicingTransform( this.numSourceDimensions, t.numTargetDimensions() ); for ( int d = 0; d < result.numTargetDimensions; ++d ) { if ( t.getComponentZero( d ) ) { result.zero[ d ] = true; result.translation[ d ] = t.getTranslation( d ); } else { final int c = t.getComponentMapping( d ); if ( this.zero[ c ] ) { result.zero[ d ] = true; result.translation[ d ] = this.translation[ c ]; } else { result.zero[ d ] = false; result.component[ d ] = this.component[ c ]; } } } return result; } @Override public Class< Slicing > getPreConcatenableClass() { return Slicing.class; } /** * set parameters to transform. * * @param transform */ public void set( final Slicing transform ) { assert numSourceDimensions == transform.numSourceDimensions(); assert numTargetDimensions == transform.numTargetDimensions(); transform.getTranslation( translation ); transform.getComponentZero( zero ); transform.getComponentMapping( component ); } /** * Get the matrix that transforms homogeneous source points to homogeneous * target points. For testing purposes. */ @Override public double[][] getMatrix() { final double[][] mat = new double[ numTargetDimensions + 1 ][ numSourceDimensions + 1 ]; mat[ numTargetDimensions ][ numSourceDimensions ] = 1; for ( int d = 0; d < numTargetDimensions; ++d ) mat[ d ][ numSourceDimensions ] = getTranslation( d ); for ( int d = 0; d < numTargetDimensions; ++d ) if ( zero[ d ] == false ) mat[ d ][ component[ d ] ] = 1; return mat; } /** * Check whether the transforms has a full mapping of source to target * components (no source component is discarded). * * @return whether there is a full mapping of source to target components. */ public boolean hasFullSourceMapping() { final boolean[] sourceMapped = new boolean[ numSourceDimensions ]; for ( int d = 0; d < numTargetDimensions; ++d ) { if ( !zero[ d ] ) { sourceMapped[ component[ d ] ] = true; } } for ( int d = 0; d < numSourceDimensions; ++d ) { if ( !sourceMapped[ d ] ) { return false; } } return true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/Translation.java000066400000000000000000000037561316447754700300050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.transform.InvertibleTransform; /** * TODO * */ public interface Translation extends Mixed, InvertibleTransform {} imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/TranslationTransform.java000066400000000000000000000220051316447754700316650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.transform.integer; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.concatenate.Concatenable; import net.imglib2.concatenate.PreConcatenable; /** * TODO * */ public class TranslationTransform extends AbstractMixedTransform implements Translation, Concatenable< Translation >, PreConcatenable< Translation > { /** * target = source + translation. */ protected final long[] translation; protected final InverseTranslationTransform inverse; public TranslationTransform( final int targetDim ) { super( targetDim ); translation = new long[ targetDim ]; this.inverse = new InverseTranslationTransform( targetDim ); } public TranslationTransform( final long[] translation ) { super( translation.length ); this.translation = translation.clone(); this.inverse = new InverseTranslationTransform( numTargetDimensions ); } @Override public void getTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) t[ d ] = translation[ d ]; } @Override public long getTranslation( final int d ) { assert d <= numTargetDimensions; return translation[ d ]; } public void setTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) translation[ d ] = t[ d ]; } @Override public void apply( final long[] source, final long[] target ) { assert source.length >= numTargetDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target[ d ] = source[ d ] + translation[ d ]; } @Override public void apply( final int[] source, final int[] target ) { assert source.length >= numTargetDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target[ d ] = source[ d ] + ( int ) translation[ d ]; } @Override public void apply( final Localizable source, final Positionable target ) { assert source.numDimensions() >= numTargetDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) target.setPosition( source.getLongPosition( d ) + translation[ d ], d ); } @Override public TranslationTransform concatenate( final Translation t ) { assert numTargetDimensions == t.numTargetDimensions(); final TranslationTransform result = new TranslationTransform( numTargetDimensions ); for ( int d = 0; d < numTargetDimensions; ++d ) result.translation[ d ] = this.translation[ d ] + t.getTranslation( d ); return result; } @Override public Class< Translation > getConcatenableClass() { return Translation.class; } @Override public TranslationTransform preConcatenate( final Translation t ) { return concatenate( t ); } @Override public Class< Translation > getPreConcatenableClass() { return Translation.class; } /** * set parameters to transform. * * @param transform */ public void set( final Translation transform ) { assert numTargetDimensions == transform.numTargetDimensions(); transform.getTranslation( translation ); } /** * Get the matrix that transforms homogeneous source points to homogeneous * target points. For testing purposes. */ @Override public double[][] getMatrix() { final double[][] mat = new double[ numTargetDimensions + 1 ][ numTargetDimensions + 1 ]; mat[ numTargetDimensions ][ numTargetDimensions ] = 1; for ( int d = 0; d < numTargetDimensions; ++d ) { mat[ d ][ numTargetDimensions ] = translation[ d ]; mat[ d ][ d ] = 1; } return mat; } @Override public void applyInverse( final long[] source, final long[] target ) { assert source.length >= numTargetDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) source[ d ] = target[ d ] - translation[ d ]; } @Override public void applyInverse( final int[] source, final int[] target ) { assert source.length >= numTargetDimensions; assert target.length >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) source[ d ] = target[ d ] - ( int ) translation[ d ]; } @Override public void applyInverse( final Positionable source, final Localizable target ) { assert source.numDimensions() >= numTargetDimensions; assert target.numDimensions() >= numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) source.setPosition( target.getLongPosition( d ) - translation[ d ], d ); } public class InverseTranslationTransform extends AbstractMixedTransform implements Translation, Concatenable< Translation >, PreConcatenable< Translation > { InverseTranslationTransform( final int targetDim ) { super( targetDim ); } @Override public void apply( final long[] source, final long[] target ) { TranslationTransform.this.applyInverse( target, source ); } @Override public void apply( final int[] source, final int[] target ) { TranslationTransform.this.applyInverse( target, source ); } @Override public void apply( final Localizable source, final Positionable target ) { TranslationTransform.this.applyInverse( target, source ); } @Override public void applyInverse( final long[] source, final long[] target ) { TranslationTransform.this.apply( target, source ); } @Override public void applyInverse( final int[] source, final int[] target ) { TranslationTransform.this.apply( target, source ); } @Override public void applyInverse( final Positionable source, final Localizable target ) { TranslationTransform.this.apply( target, source ); } @Override public double[][] getMatrix() { final double[][] mat = new double[ numTargetDimensions + 1 ][ numTargetDimensions + 1 ]; mat[ numTargetDimensions ][ numTargetDimensions ] = 1; for ( int d = 0; d < numTargetDimensions; ++d ) { mat[ d ][ numTargetDimensions ] = -translation[ d ]; mat[ d ][ d ] = 1; } return mat; } @Override public TranslationTransform inverse() { return TranslationTransform.this; } @Override public void getTranslation( final long[] t ) { assert t.length == numTargetDimensions; for ( int d = 0; d < numTargetDimensions; ++d ) t[ d ] = -TranslationTransform.this.translation[ d ]; } @Override public long getTranslation( final int d ) { assert d <= numTargetDimensions; return -TranslationTransform.this.translation[ d ]; } @Override public TranslationTransform concatenate( final Translation t ) { assert numTargetDimensions == t.numTargetDimensions(); final TranslationTransform result = new TranslationTransform( numTargetDimensions ); for ( int d = 0; d < numTargetDimensions; ++d ) result.translation[ d ] = t.getTranslation( d ) - TranslationTransform.this.translation[ d ]; return result; } @Override public Class< Translation > getConcatenableClass() { return Translation.class; } @Override public TranslationTransform preConcatenate( final Translation t ) { return concatenate( t ); } @Override public Class< Translation > getPreConcatenableClass() { return Translation.class; } } @Override public InverseTranslationTransform inverse() { return inverse; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/permutation/000077500000000000000000000000001316447754700272005ustar00rootroot00000000000000AbstractPermutationTransform.java000066400000000000000000000100321316447754700356470ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/permutation/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.permutation; import net.imglib2.transform.InvertibleTransform; /** * Bijective integer transform mapping between integer coordinates in [0,n-1]. * Currently, this transform handles only coordinates in the integer range * because it is implemented using primitive arrays with integer indices for * efficiency reasons. Expect this permutation to be transferred to long * coordinates some time in more distant future. * * @author Philipp Hanslovsky * @author Stephan Saalfeld */ public abstract class AbstractPermutationTransform implements InvertibleTransform { final protected int[] lut; final protected int[] inverseLut; /** * @param lut * must be a bijective permutation over its index set, i.e. for a * lut of length n, the sorted content of the array must be * [0,...,n-1] which is the index set of the lut. */ public AbstractPermutationTransform( final int[] lut ) { super(); this.lut = lut.clone(); this.inverseLut = new int[ lut.length ]; for ( int i = 0; i < lut.length; ++i ) this.inverseLut[ lut[ i ] ] = i; } public int apply( final int x ) { return this.lut[ x ]; } public long applyChecked( final int x ) { if ( x < 0 ) return -Long.MAX_VALUE; else if ( x >= this.lut.length ) return Long.MAX_VALUE; else return this.apply( x ); } public int applyInverse( final int y ) { return this.inverseLut[ y ]; } public long applyInverseChecked( final int y ) { if ( y < 0 ) return -Long.MAX_VALUE; else if ( y >= this.lut.length ) return Long.MAX_VALUE; else return this.applyInverse( y ); } public int[] getLutCopy() { return this.lut.clone(); } public int[] getInverseLutCopy() { return this.inverseLut.clone(); } final static public boolean checkBijectivity( final int[] lut ) { final int[] inverseLut = new int[ lut.length ]; try { for ( int i = 0; i < lut.length; ++i ) inverseLut[ i ] = -1; for ( int i = 0; i < lut.length; ++i ) inverseLut[ lut[ i ] ] = i; for ( int i = 0; i < lut.length; ++i ) if ( inverseLut[ i ] == -1 ) return false; return true; } catch ( final ArrayIndexOutOfBoundsException e ) { return false; } } } PermutationTransform.java000066400000000000000000000131061316447754700341700ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/permutation/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.permutation; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.Positionable; /** * Bijective integer transform mapping between integer coordinates in [0,n-1]. * * @author Stephan Saalfeld * @author Philipp Hanslovsky */ public class PermutationTransform extends AbstractPermutationTransform { final protected int numSourceDimensions; final protected int numTargetDimensions; /** * * @param lut * must be a bijective permutation over its index set, i.e. for a * lut of length n, the sorted content the array must be * [0,...,n-1] which is the index set of the lut. * @param numSourceDimensions * @param numTargetDimensions */ public PermutationTransform( final int[] lut, final int numSourceDimensions, final int numTargetDimensions ) { super( lut ); this.numSourceDimensions = numSourceDimensions; this.numTargetDimensions = numTargetDimensions; } @Override public int numSourceDimensions() { return this.numSourceDimensions; } @Override public int numTargetDimensions() { return this.numTargetDimensions; } @Override public void apply( final long[] source, final long[] target ) { assert source.length >= this.numTargetDimensions && target.length >= this.numTargetDimensions: "Dimensions do not match."; for ( int d = 0; d < this.numTargetDimensions; ++d ) target[ d ] = this.apply( ( int ) source[ d ] ); } @Override public void apply( final int[] source, final int[] target ) { assert source.length >= this.numTargetDimensions && target.length >= this.numTargetDimensions: "Dimensions do not match."; for ( int d = 0; d < this.numTargetDimensions; ++d ) target[ d ] = this.apply( this.lut[ source[ d ] ] ); } @Override public void apply( final Localizable source, final Positionable target ) { assert source.numDimensions() >= this.numTargetDimensions && target.numDimensions() >= this.numTargetDimensions: "Dimensions do not match."; for ( int d = 0; d < this.numTargetDimensions; ++d ) target.setPosition( this.apply( source.getIntPosition( d ) ), d ); } @Override public void applyInverse( final long[] source, final long[] target ) { assert source.length >= this.numSourceDimensions && target.length >= this.numSourceDimensions: "Dimensions do not match."; for ( int d = 0; d < this.numSourceDimensions; ++d ) source[ d ] = this.applyInverse( ( int ) target[ d ] ); } @Override public void applyInverse( final int[] source, final int[] target ) { assert source.length >= this.numSourceDimensions && target.length >= this.numSourceDimensions: "Dimensions do not match."; for ( int d = 0; d < this.numSourceDimensions; ++d ) source[ d ] = this.applyInverse( target[ d ] ); } @Override public void applyInverse( final Positionable source, final Localizable target ) { assert source.numDimensions() >= this.numSourceDimensions && target.numDimensions() >= this.numSourceDimensions: "Dimensions do not match."; for ( int d = 0; d < this.numSourceDimensions; ++d ) source.setPosition( this.applyInverse( target.getIntPosition( d ) ), d ); } @Override public PermutationTransform inverse() { return new PermutationTransform( this.inverseLut, this.numTargetDimensions, this.numSourceDimensions ); } /** * Test whether a given lut can be applied to an interval. This means that * the interval is a hypercube at min = 0n with size = * lut.length. * * @param interval * @param lut * @return */ static public boolean checkInterval( final Interval interval, final int[] lut ) { for ( int d = 0; d < interval.numDimensions(); ++d ) { if ( !( interval.min( d ) == 0 && interval.dimension( d ) == lut.length ) ) return false; } return true; } } SingleDimensionPermutationTransform.java000066400000000000000000000110311316447754700371730ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/permutation/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.permutation; import net.imglib2.Localizable; import net.imglib2.Positionable; /** * @author Philipp Hanslovsky * * Apply bijective permutation to one coordinate axis only. * */ public class SingleDimensionPermutationTransform extends AbstractPermutationTransform { final protected int numSourceDimensions; final protected int numTargetDimensions; final protected int d; /** * @param lut * @param numSourceDimensions * dimensionality of source * @param numTargetDimensions * dimensionality of target * @param d * dimension which shall be transformed. Must be smaller than * {@link #numSourceDimensions} and {@link #numTargetDimensions} */ public SingleDimensionPermutationTransform( final int[] lut, final int numSourceDimensions, final int numTargetDimensions, final int d ) { super( lut ); assert d > 0 && d < numTargetDimensions && d < numSourceDimensions; this.numSourceDimensions = numSourceDimensions; this.numTargetDimensions = numTargetDimensions; this.d = d; } @Override public void applyInverse( final long[] source, final long[] target ) { System.arraycopy( target, 0, source, 0, this.numSourceDimensions ); source[ this.d ] = this.applyInverse( ( int ) target[ this.d ] ); } @Override public void applyInverse( final int[] source, final int[] target ) { System.arraycopy( target, 0, source, 0, this.numSourceDimensions ); source[ this.d ] = this.applyInverse( target[ this.d ] ); } @Override public void applyInverse( final Positionable source, final Localizable target ) { source.setPosition( target ); source.setPosition( this.applyInverse( target.getIntPosition( this.d ) ), this.d ); } @Override public SingleDimensionPermutationTransform inverse() { return new SingleDimensionPermutationTransform( this.inverseLut, this.numSourceDimensions, this.numTargetDimensions, this.d ); } @Override public int numSourceDimensions() { return this.numSourceDimensions; } @Override public int numTargetDimensions() { return this.numTargetDimensions; } @Override public void apply( final long[] source, final long[] target ) { System.arraycopy( source, 0, target, 0, this.numTargetDimensions ); target[ this.d ] = this.apply( ( int ) source[ this.d ] ); } @Override public void apply( final int[] source, final int[] target ) { System.arraycopy( source, 0, target, 0, this.numTargetDimensions ); target[ this.d ] = this.apply( source[ this.d ] ); } @Override public void apply( final Localizable source, final Positionable target ) { target.setPosition( source ); target.setPosition( this.apply( source.getIntPosition( this.d ) ), this.d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/shear/000077500000000000000000000000001316447754700257335ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/shear/AbstractShearTransform.java000066400000000000000000000103171316447754700332220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.shear; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.transform.InvertibleTransform; import net.imglib2.transform.integer.BoundingBoxTransform; /** * * Most simple case of a shear transform that just implements * for a integer valued coordinate: * coordinate[ shearDimension ] += coordinate[ referenceDimension ] (forward) * coordinate[ shearDimension ] -= coordinate[ referenceDimension ] (backward) * * This abstract class holds the inverse and implements applyInverse in * terms of inverse.apply * * @author Philipp Hanslovsky * */ public abstract class AbstractShearTransform implements InvertibleTransform, BoundingBoxTransform { protected final int nDim; protected final int shearDimension; protected final int referenceDimension; protected AbstractShearTransform inverse; protected AbstractShearTransform( int nDim, int shearDimension, int referenceDimension ) { this( nDim, shearDimension, referenceDimension, null ); } protected AbstractShearTransform( int nDim, int shearDimension, int referenceDimension, AbstractShearTransform inverse ) { this.nDim = nDim; this.shearDimension = shearDimension; this.referenceDimension = referenceDimension; this.inverse = inverse; } public int getReferenceDimension() { return referenceDimension; } @Override public int numSourceDimensions() { return this.numDimensions(); } @Override public int numTargetDimensions() { return this.numDimensions(); } public int numDimensions() { return nDim; } public int getShearDimension() { return this.shearDimension; } @Override public void applyInverse( long[] source, long[] target ) { // for inverse, source and target need to be switched this.inverse.apply( target, source ); } @Override public void applyInverse(int[] source, int[] target) { // for inverse, source and target need to be switched this.inverse.apply( target, source ); } @Override public void applyInverse( Positionable source, Localizable target ) { // for inverse, source and target need to be switched this.inverse.apply( target, source ); } @Override public AbstractShearTransform inverse() { return this.inverse; } public abstract long[] getShear(); public abstract AbstractShearTransform copy(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/shear/InverseShearTransform.java000066400000000000000000000111711316447754700330710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.shear; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.transform.integer.BoundingBox; /** * Backward implementation of the most simple case of a shear transform: * coordinate[ shearDimension ] -= coordinate[ referenceDimension ] * * * @author Philipp Hanslovsky * */ public class InverseShearTransform extends AbstractShearTransform { /** * @param nDim Number of dimensions (source and target dimensions must be the same) * @param shearDimension Dimension to be sheared. * @param referenceDimension Dimension used as reference for shear. */ public InverseShearTransform( int nDim, int shearDimension, int referenceDimension ) { super( nDim, shearDimension, referenceDimension ); this.inverse = new ShearTransform( nDim, shearDimension, referenceDimension, this ); } /** * Protected constructor for passing an inverse to avoid construction of unnecessary objects. * * @param nDim Number of dimensions (source and target dimensions must be the same) * @param shearDimension Dimension to be sheared. * @param referenceDimension Dimension used as reference for shear. * @param inverse */ protected InverseShearTransform( int nDim, int shearDimension, int referenceDimension, AbstractShearTransform inverse ) { super( nDim, shearDimension, referenceDimension, inverse ); } @Override public void apply( long[] source, long[] target ) { assert source.length >= this.nDim && target.length >= nDim; System.arraycopy( source, 0, target, 0, source.length ); target[ shearDimension ] -= target[ referenceDimension ]; } @Override public void apply( int[] source, int[] target ) { assert source.length >= this.nDim && target.length >= nDim; System.arraycopy( source, 0, target, 0, source.length ); target[ shearDimension ] -= target[ referenceDimension ]; } @Override public void apply( Localizable source, Positionable target ) { assert source.numDimensions() >= this.nDim && target.numDimensions() >= nDim; target.setPosition( source ); target.setPosition( source.getLongPosition( shearDimension ) - source.getLongPosition( referenceDimension ), shearDimension ); } @Override public AbstractShearTransform copy() { return new InverseShearTransform( nDim, shearDimension, referenceDimension ); // return this; ? } @Override public long[] getShear() { long[] shear = new long[ this.nDim ]; shear[ this.shearDimension ] = -1; return shear; } @Override public BoundingBox transform( BoundingBox bb ) { bb.orderMinMax(); long[] c = bb.corner1; // assume that corner2[ i ] > corner1[ i ] long diff = bb.corner2[ this.referenceDimension ] - c[ this.referenceDimension ]; c[ this.shearDimension ] -=diff; return bb; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/transform/integer/shear/ShearTransform.java000066400000000000000000000111631316447754700315360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.shear; import net.imglib2.Localizable; import net.imglib2.Positionable; import net.imglib2.transform.integer.BoundingBox; /** * Forward implementation of the most simple case of a shear transform: * coordinate[ shearDimension ] += coordinate[ referenceDimension ] * * @author Philipp Hanslovsky * */ public class ShearTransform extends AbstractShearTransform { /** * @param nDim Number of dimensions (source and target dimensions must be the same) * @param shearDimension Dimension to be sheared. * @param referenceDimension Dimension used as reference for shear. */ public ShearTransform( int nDim, int shearDimension, int referenceDimension ) { super( nDim, shearDimension, referenceDimension ); this.inverse = new InverseShearTransform( nDim, shearDimension, referenceDimension, this ); } /** * Protected constructor for passing an inverse to avoid construction of unnecessary objects. * * @param nDim Number of dimensions (source and target dimensions must be the same) * @param shearDimension Dimension to be sheared. * @param referenceDimension Dimension used as reference for shear. * @param inverse */ protected ShearTransform( int nDim, int shearDimension, int referenceDimension, AbstractShearTransform inverse ) { super( nDim, shearDimension, referenceDimension, inverse ); } @Override public void apply( long[] source, long[] target ) { assert source.length >= this.nDim && target.length >= nDim; System.arraycopy( source, 0, target, 0, source.length ); target[ shearDimension ] += target[ referenceDimension ]; } @Override public void apply( int[] source, int[] target ) { assert source.length >= this.nDim && target.length >= nDim; System.arraycopy( source, 0, target, 0, source.length ); target[ shearDimension ] += target[ referenceDimension ]; } @Override public void apply( Localizable source, Positionable target ) { assert source.numDimensions() >= this.nDim && target.numDimensions() >= nDim; target.setPosition( source ); target.setPosition( source.getLongPosition( shearDimension ) + source.getLongPosition( referenceDimension ), shearDimension ); } @Override public ShearTransform copy() { // do just return this; ? return new ShearTransform( this.nDim, this.shearDimension, this.referenceDimension ); } @Override public long[] getShear() { long[] shear = new long[ this.nDim ]; shear[ this.shearDimension ] = 1; return shear; } @Override public BoundingBox transform( BoundingBox bb ) { bb.orderMinMax(); long[] c = bb.corner2; // assume that corner2[ i ] > corner1[ i ] long diff = c[ this.referenceDimension ] - bb.corner1[ this.referenceDimension ]; c[ this.shearDimension ] +=diff; return bb; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/000077500000000000000000000000001316447754700221425ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/AbstractBit64Type.java000066400000000000000000000153511316447754700262300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; /** * A {@link Type} with arbitrary bit depth up to maximum 64 bits. * The behavior beyond 64 bits is undefined. * * To set and get bits, we use longs. Therefore not more than 64 bits are supported. The long is not * supposed to have anything to do with math, it is simply an efficient way to hold an array of bits * * The performance of this type is traded off for the gain in memory storage. * The {@link #setBits(long)} operation takes have the time as the {@link #getBits} operation. * The performance may degrade very slightly with increasing bit depth, but the decrease is barely noticeable. * * @author Albert Cardona * @author Stephan Preibisch */ public abstract class AbstractBit64Type> extends AbstractBitType< T > { // A mask for bit and, containing nBits of 1 private final long mask; // The inverse of mask private final long invMask; // this is the constructor if you want it to read from an array public AbstractBit64Type( final NativeImg< ?, ? extends LongAccess > bitStorage, final int nBits ) { super( bitStorage, nBits ); if ( nBits < 1 || nBits > 64 ) throw new IllegalArgumentException( "Supports only bit depths between 1 and 64, can't take " + nBits ); else if ( nBits == 64 ) this.mask = -1l; // all 1s else this.mask = ((long)(Math.pow(2, nBits) -1)); this.invMask = ~mask; } // this is the constructor if you want it to be a variable public AbstractBit64Type( final long value, final int nBits ) { this( ( NativeImg< ?, ? extends LongAccess > ) null, nBits ); updateIndex( 0 ); dataAccess = new LongArray( 1 ); setBits( value ); } // this is the constructor if you want to specify the dataAccess public AbstractBit64Type( final LongAccess access, final int nBits ) { this( ( NativeImg< ?, ? extends LongAccess > ) null, nBits ); updateIndex( 0 ); dataAccess = access; } // this is the constructor if you want it to be a variable public AbstractBit64Type( final int nBits ) { this( 0, nBits ); } /** * Writes the current "subLong" location of the LongAccess into the lower nBits bits of the long value * * Note that "long value" does not refer to math, it is just a way to help to return arbitrary values. It * is basically an array of bits. * * @return */ protected long getBits() { final long k = i * nBits; final int i1 = (int)(k >>> 6); // k / 64; final long shift = k & 63; // Same as k % 64; final long v = dataAccess.getValue(i1); if (0 == shift) { // Number contained in a single long, ending exactly at the first bit return v & mask; } else { final long antiShift = 64 - shift; if (antiShift < nBits) { // Number split between two adjacent long final long v1 = (v >>> shift) & (mask >>> (nBits - antiShift)); // lower part, stored at the upper end final long v2 = (dataAccess.getValue(i1 + 1) & (mask >>> antiShift)) << antiShift; // upper part, stored at the lower end return v1 | v2; } else { // Number contained inside a single long return (v >>> shift) & mask; } } } /** * Sets the lower nBits bits of the long value into the current "subLong" location of the LongAccess * * Note that "long value" does not refer to math, it is just a way to help to set arbitrary values. It * is basically an array of bits. * * @param value */ protected void setBits( final long value ) { final long k = i * nBits; final int i1 = (int)(k >>> 6); // k / 64; final long shift = k & 63; // Same as k % 64; final long safeValue = value & mask; synchronized ( dataAccess ) { if (0 == shift) { // Number contained in a single long, ending exactly at the first bit dataAccess.setValue(i1, (dataAccess.getValue(i1) & invMask) | safeValue); } else { final long antiShift = 64 - shift; final long v = dataAccess.getValue(i1); if (antiShift < nBits) { // Number split between two adjacent longs // 1. Store the lower bits of safeValue at the upper bits of v1 final long v1 = (v & (0xffffffffffffffffL >>> antiShift)) // clear upper bits, keep other values | ((safeValue & (mask >>> (nBits - antiShift))) << shift); // the lower part of safeValue, stored at the upper end dataAccess.setValue(i1, v1); // 2. Store the upper bits of safeValue at the lower bits of v2 final long v2 = (dataAccess.getValue(i1 + 1) & (0xffffffffffffffffL << (nBits - antiShift))) // other | (safeValue >>> antiShift); // upper part of safeValue, stored at the lower end dataAccess.setValue(i1 + 1, v2); } else { // Number contained inside a single long if (0 == v) { // Trivial case dataAccess.setValue(i1, safeValue << shift); } else { // Clear the bits first dataAccess.setValue(i1, (v & ~(mask << shift)) | (safeValue << shift)); } } } } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/AbstractBitType.java000066400000000000000000000065461316447754700260640ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.util.Fraction; /** * Provides basic infrastructure to implement Types based on single bits stored in a LongAccess * * @author Albert Cardona * @author Stephan Preibisch */ public abstract class AbstractBitType< T extends AbstractBitType< T > > implements NativeType< T > { // Maximum count is Integer.MAX_VALUE * (64 / getBitsPerPixel()) protected long i = 0; // the number of bits per pixel protected final int nBits; // the NativeImg that can update the DataAccess (if this instance is not a variable) final protected NativeImg< ?, ? extends LongAccess > img; // the DataAccess that holds the information protected LongAccess dataAccess; // this is the constructor if you want it to read from an array public AbstractBitType( final NativeImg< ?, ? extends LongAccess> bitStorage, final int nBits) { img = bitStorage; this.nBits = nBits; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public int getIndex() { return ( int )i; } @Override public void updateIndex( final int index ) { i = index; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public Fraction getEntitiesPerPixel() { return new Fraction( nBits, 64 ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/AbstractNativeType.java000066400000000000000000000047271316447754700265730ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class AbstractNativeType< T extends AbstractNativeType< T >> implements NativeType< T > { protected int i = 0; @Override public void updateIndex( final int j ) { this.i = j; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public abstract String toString(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/BasePairType.java000066400000000000000000000042501316447754700253360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; import net.imglib2.type.label.BasePairBitType.Base; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface BasePairType< T extends BasePairType< T >> extends Type< T >, Comparable< T > { public void set( final Base base ); public Base get(); public void complement(); byte baseToValue(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/BooleanType.java000066400000000000000000000043151316447754700252310ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; import net.imglib2.type.numeric.RealType; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface BooleanType< T extends BooleanType< T > > extends Type< T >, RealType< T > { public boolean get(); public void set( boolean value ); public void and( T c ); public void or( T c ); public void xor( T c ); public void not(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/NativeType.java000066400000000000000000000177021316447754700251040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.cell.CellCursor; import net.imglib2.img.cell.CellImg; import net.imglib2.util.Fraction; /** * A {@link NativeType} is a {@link Type} that that provides access to data * stored in Java primitive arrays. To this end, implementations maintain a * reference to the current storage array and the index of an element in that * array. * * The {@link NativeType} is positioned on the correct storage array and index * by accessors ({@link Cursor Cursors} and {@link RandomAccess RandomAccesses} * ). * *

* The {@link NativeType} is the only class that is aware of the actual data * type, i.e., which Java primitive type is used to store the data. On the other * hand it does not know the storage layout, i.e., how n-dimensional pixel * coordinates map to indices in the current array. It also doesn't know whether * and how the data is split into multiple chunks. This is determined by the * container implementation (e.g., {@link ArrayImg}, {@link CellImg}, ...). * Separating the storage layout from access and operations on the {@link Type} * avoids re-implementation for each container type. *

* * @author Stephan Preibisch * @author Stephan Saalfeld * @author Tobias Pietzsch */ public interface NativeType< T extends NativeType< T >> extends Type< T > { /** * Get the number of entities in the storage array required to store one * pixel value. A pixel value may be spread over several or less than one * entity. For example, a complex number may require 2 entries of a float[] * array to store one pixel. Or a 12-bit type might need 12/64th entries * of a long[] array. * * @return the number of storage type entities required to store one pixel * value. */ public Fraction getEntitiesPerPixel(); /** * The {@link NativeType} creates the {@link NativeImg} used for storing * image data; based on the given storage strategy and its size. It * basically only decides here which BasicType it uses (float, int, byte, * bit, ...) and how many entities per pixel it needs (e.g. 2 floats per * pixel for a complex number). This enables the separation of containers * and the basic types. * * @param storageFactory * which storage strategy is used * @param dim * the dimensions * * @return the instantiated {@link NativeImg} where only the {@link Type} * knows the BasicType it contains. */ public NativeImg< T, ? > createSuitableNativeImg( final NativeImgFactory< T > storageFactory, final long[] dim ); /** * Creates a new {@link NativeType} which stores in the same physical array. * This is only used internally. * * @return a new {@link NativeType} instance working on the same * {@link NativeImg} */ public T duplicateTypeOnSameNativeImg(); /** * This method is used by an accessor (e.g., a {@link Cursor}) to request an * update of the current data array. * *

* As an example consider a {@link CellCursor} moving on a {@link CellImg}. * The cursor maintains a {@link NativeType} which provides access to the * image data. When the cursor moves from one cell to the next, the * underlying data array of the {@link NativeType} must be switched to the * data array of the new cell. *

*

* To achieve this, the {@link CellCursor} calls {@code updateContainer()} * with itself as the argument. {@code updateContainer()} in turn will call * {@link NativeImg#update(Object)} on it's container, passing along the * reference to the cursor. In this example, the container would be a * {@link CellImg}. While the {@link NativeType} does not know about the * type of the cursor, the container does. {@link CellImg} knows that it is * passed a {@link CellCursor} instance, which can be used to figure out the * current cell and the underlying data array, which is then returned to the * {@link NativeType}. *

*

* The idea behind this concept is maybe not obvious. The {@link NativeType} * knows which basic type is used (float, int, byte, ...). However, it does * not know how the data is stored ({@link ArrayImg}, {@link CellImg}, ...). * This prevents the need for multiple implementations of {@link NativeType} * . *

* * @param c * reference to an accessor which can be passed on to the * container (which will know what to do with it). */ public void updateContainer( Object c ); /** * Set the index into the current data array. * *

* This is used by accessors (e.g., a {@link Cursor}) to position the * {@link NativeType} in the container. * * @param i * the new array index */ public void updateIndex( final int i ); /** * Get the current index into the current data array. * *

* This is used by accessors (e.g., a {@link Cursor}) to position the * {@link NativeType} in the container. * * @return the current index into the underlying data array */ public int getIndex(); /** * Increment the index into the current data array. * *

* This is used by accessors (e.g., a {@link Cursor}) to position the * {@link NativeType} in the container. */ public void incIndex(); /** * Increases the index into the current data array by {@code increment} * steps. * *

* This is used by accessors (e.g., a {@link Cursor}) to position the * {@link NativeType} in the container. * * @param increment * how many steps */ public void incIndex( final int increment ); /** * Decrement the index into the current data array. * *

* This is used by accessors (e.g., a {@link Cursor}) to position the * {@link NativeType} in the container. */ public void decIndex(); /** * Decrease the index into the current data array by {@code decrement} * steps. * *

* This is used by accessors (e.g., a {@link Cursor}) to position the * {@link NativeType} in the container. * * @param decrement * how many steps */ public void decIndex( final int decrement ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/Type.java000066400000000000000000000054321316447754700237320ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type; import net.imglib2.type.operators.ValueEquals; /** * The {@link Type} interface is responsible for accessing and manipulating * (pixel) values. It can be realized as an object instance holding a single * value or as a proxy ({@link NativeType}) mapping values into a Java primitive * type array. * * @param * the specialized version * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface Type< T extends Type< T > > extends ValueEquals< T > { /** * Creates a new {@link Type} variable which can only store one value. * * @return a new {@link Type} variable */ public T createVariable(); /** * Creates a new {@link Type} variable that has the value of this * {@link Type} * * @return a new {@link Type} variable */ public T copy(); /** * Sets the value of another {@link Type}. * * @param c * the new value */ public void set( T c ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/label/000077500000000000000000000000001316447754700232215ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/label/BasePairBitType.java000066400000000000000000000122621316447754700270560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.label; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.type.AbstractBit64Type; import net.imglib2.type.BasePairType; /** * Representation of base pairs using 3 bits per entry, supported characters: gap, N, A, T, G, C, U * Bases are handled using the {@link Base} enumeration. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class BasePairBitType extends AbstractBit64Type< BasePairBitType > implements BasePairType< BasePairBitType > { public static enum Base { gap, N, A, T, G, C, U; } // this is the constructor if you want it to read from an array public BasePairBitType( final NativeImg< ?, ? extends LongAccess > bitStorage ) { super( bitStorage, 3 ); } // this is the constructor if you want it to be a variable public BasePairBitType( final Base value ) { super( value.ordinal() ); } // this is the constructor if you want it to be a variable public BasePairBitType() { this( Base.N ); } @Override public NativeImg< BasePairBitType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< BasePairBitType > storageFactory, final long dim[] ) { // create the container final NativeImg< BasePairBitType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, getEntitiesPerPixel() ); // create a Type that is linked to the container final BasePairBitType linkedType = new BasePairBitType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public BasePairBitType duplicateTypeOnSameNativeImg() { return new BasePairBitType( img ); } @Override public void set( final Base base ) { setBits( base.ordinal() ); } @Override public Base get() { return Base.values()[ (int)getBits() ]; } @Override public int compareTo( final BasePairBitType c ) { final Base input = get(); final Base compare = c.get(); if ( input == compare ) { return 0; } switch ( input ) { case gap: return -1; case N: return compare == Base.gap ? 1 : -1; case A: return compare == Base.gap || compare == Base.N ? 1 : -1; case T: return compare == Base.G || compare == Base.C || compare == Base.U ? -1 : 1; case G: return compare == Base.C || compare == Base.U ? -1 : 1; case C: return compare == Base.U ? -1 : 1; default: return 1; } } @Override public void complement() { final Base base = get(); switch ( base ) { case A: set( Base.T ); break; case T: set( Base.A ); break; case G: set( Base.C ); break; case C: set( Base.G ); break; case U: set( Base.A ); break; default: break; } } @Override public byte baseToValue() { final Base base = get(); switch ( base ) { case N: return 1; case A: return 2; case T: return 3; case G: return 4; case C: return 5; case U: return 6; default: return 0; } } @Override public void set( final BasePairBitType c ) { set( c.get() ); } @Override public BasePairBitType createVariable() { return new BasePairBitType(); } @Override public BasePairBitType copy() { return new BasePairBitType( this.get() ); } @Override public String toString() { return this.get().toString(); } @Override public boolean valueEquals( final BasePairBitType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/label/BasePairCharType.java000066400000000000000000000147521316447754700272230ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.label; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.CharAccess; import net.imglib2.img.basictypeaccess.array.CharArray; import net.imglib2.type.AbstractNativeType; import net.imglib2.type.BasePairType; import net.imglib2.type.label.BasePairBitType.Base; import net.imglib2.util.Fraction; /** * Representation of base pairs using one char per entry, supported characters: gap, N, A, T, G, C, U * Bases are handled using the {@link Base} enumeration. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class BasePairCharType extends AbstractNativeType< BasePairCharType > implements BasePairType< BasePairCharType > { @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } final protected NativeImg< ?, ? extends CharAccess > img; // the DataAccess that holds the information protected CharAccess dataAccess; // this is the constructor if you want it to read from an array public BasePairCharType( final NativeImg< ?, ? extends CharAccess > charStorage ) { img = charStorage; } // this is the constructor if you want it to be a variable public BasePairCharType( final Base value ) { img = null; dataAccess = new CharArray( 1 ); set( value ); } // this is the constructor if you want it to be a variable public BasePairCharType( final char value ) { img = null; dataAccess = new CharArray( 1 ); setChar( value ); } // this is the constructor if you want it to be a variable public BasePairCharType() { this( Base.N ); } @Override public NativeImg< BasePairCharType, ? extends CharAccess > createSuitableNativeImg( final NativeImgFactory< BasePairCharType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createCharInstance( dim, new Fraction() ); // create a Type that is linked to the container final BasePairCharType linkedType = new BasePairCharType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public BasePairCharType duplicateTypeOnSameNativeImg() { return new BasePairCharType( img ); } public char getChar() { return dataAccess.getValue( i ); } public void setChar( final char f ) { dataAccess.setValue( i, f ); } @Override public void set( final Base base ) { switch ( base ) { case A: setChar( 'A' ); return; case T: setChar( 'T' ); return; case G: setChar( 'G' ); return; case C: setChar( 'C' ); return; case U: setChar( 'U' ); return; case gap: setChar( ' ' ); return; default: setChar( 'N' ); return; } } @Override public Base get() { final char value = getChar(); switch ( value ) { case 'A': return Base.A; case 'T': return Base.T; case 'G': return Base.G; case 'C': return Base.C; case 'U': return Base.U; case ' ': return Base.gap; default: return Base.N; } } @Override public void set( final BasePairCharType c ) { dataAccess.setValue( i, c.getChar() ); } @Override public int compareTo( final BasePairCharType c ) { final char input = getChar(); final char compare = c.getChar(); if ( input == compare ) { return 0; } switch ( input ) { case ' ': return -1; case 'N': return compare == ' ' ? 1 : -1; case 'A': return compare == ' ' || compare == 'N' ? 1 : -1; case 'T': return compare == 'G' || compare == 'C' || compare == 'U' ? -1 : 1; case 'G': return compare == 'C' || compare == 'U' ? -1 : 1; case 'C': return compare == 'U' ? -1 : 1; default: return 1; } } @Override public void complement() { final char base = getChar(); switch ( base ) { case 'A': setChar( 'T' ); break; case 'T': setChar( 'A' ); break; case 'G': setChar( 'C' ); break; case 'C': setChar( 'G' ); break; case 'U': setChar( 'A' ); break; } } @Override public byte baseToValue() { final char base = getChar(); switch ( base ) { case 'N': return 1; case 'A': return 2; case 'T': return 3; case 'G': return 4; case 'C': return 5; case 'U': return 6; default: return 0; } } @Override public BasePairCharType createVariable() { return new BasePairCharType( Base.N ); } @Override public BasePairCharType copy() { return new BasePairCharType( get() ); } @Override public String toString() { return "" + get(); } @Override public boolean valueEquals( final BasePairCharType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/logic/000077500000000000000000000000001316447754700232375ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/logic/BitType.java000066400000000000000000000170401316447754700254640ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.logic; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.BooleanType; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.IntegerType; import net.imglib2.type.numeric.integer.AbstractIntegerType; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class BitType extends AbstractIntegerType< BitType > implements BooleanType< BitType >, NativeType< BitType >, IntegerType< BitType > { // Maximum count is Integer.MAX_VALUE * (64 / getBitsPerPixel()) protected int i = 0; final protected NativeImg< ?, ? extends LongAccess > img; // the DataAccess that holds the information protected LongAccess dataAccess; // this is the constructor if you want it to read from an array public BitType( final NativeImg< ?, ? extends LongAccess > bitStorage ) { img = bitStorage; } // this is the constructor if you want it to be a variable public BitType( final boolean value ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public BitType( final LongAccess access ) { this( (NativeImg)null ); dataAccess = access; } // this is the constructor if you want it to be a variable public BitType() { this( false ); } @Override public NativeImg createSuitableNativeImg( final NativeImgFactory storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createLongInstance( dim, new Fraction( 1, 64 ) ); // create a Type that is linked to the container final BitType linkedType = new BitType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public BitType duplicateTypeOnSameNativeImg() { return new BitType( img ); } @Override public boolean get() { return 1 == ((dataAccess.getValue((int)(i >>> 6)) >>> ((i & 63))) & 1l); } // Crops value to within mask @Override public void set( final boolean value ) { /* final int k = i * 2; final int i1 = k >>> 6; // k / 64; final long shift = k % 64; */ // Same as above, minus one multiplication, plus one shift to multiply the reminder by 2 final int i1 = (int)(i >>> 6); // Same as (i * 2) / 64 = (i << 1) >>> 6 final long bit = 1l << (i & 63); synchronized ( dataAccess ) { // Clear or set the bit if ( value ) dataAccess.setValue( i1, dataAccess.getValue(i1) | bit ); else dataAccess.setValue( i1, dataAccess.getValue(i1) & ~bit ); } } @Override public int getInteger() { return get() ? 1 : 0; } @Override public long getIntegerLong() { return get() ? 1 : 0; } @Override public BigInteger getBigInteger() { return get() ? BigInteger.ONE : BigInteger.ZERO; } @Override public void setInteger( final int f ) { if ( f >= 1 ) set( true ); else set( false ); } @Override public void setInteger( final long f ) { if ( f >= 1 ) set( true ); else set( false ); } @Override public void setBigInteger(final BigInteger b) { if ( b.compareTo(BigInteger.ZERO) > 0 ) set ( true ); else set( false ); } @Override public double getMaxValue() { return 1; } @Override public double getMinValue() { return 0; } @Override public void set( final BitType c ) { set( c.get() ); } @Override public void and( final BitType c ) { set( get() && c.get() ); } @Override public void or( final BitType c ) { set( get() || c.get() ); } @Override public void xor( final BitType c ) { set( get() ^ c.get() ); } @Override public void not() { set( !get() ); } @Override public void add( final BitType c ) { xor( c ); } @Override public void div( final BitType c ) { and( c ); } @Override public void mul( final BitType c ) { and( c ); } @Override public void sub( final BitType c ) { xor( c ); } @Override public void mul( final float c ) { if ( c >= 0.5f ) set( get() && true ); else set( false ); } @Override public void mul( final double c ) { if ( c >= 0.5f ) set( get() && true ); else set( false ); } @Override public void setOne() { set( true ); } @Override public void setZero() { set( false ); } @Override public void inc() { not(); } @Override public void dec() { not(); } @Override public int compareTo( final BitType c ) { final boolean b1 = get(); final boolean b2 = c.get(); if ( b1 && !b2 ) return 1; else if ( !b1 && b2 ) return -1; else return 0; } @Override public BitType createVariable() { return new BitType(); } @Override public BitType copy(){ return new BitType( get() ); } @Override public String toString() { final boolean value = get(); return value ? "1" : "0"; } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateIndex( final int index ) { this.i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 1; } @Override public boolean valueEquals( final BitType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/logic/BoolType.java000066400000000000000000000100741316447754700256410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.logic; import java.math.BigInteger; import net.imglib2.type.BooleanType; import net.imglib2.type.numeric.integer.AbstractIntegerType; /** * A {@link BooleanType} wrapping a single primitive {@code boolean} variable. * * @author Tobias Pietzsch */ public class BoolType extends AbstractIntegerType< BoolType > implements BooleanType< BoolType > { boolean value; public BoolType() { this( false ); } public BoolType( final boolean value ) { this.value = value; } public < T extends BooleanType >BoolType( final T type ) { this( type.get() ); } @Override public BoolType createVariable() { return new BoolType(); } @Override public BoolType copy() { return new BoolType( this ); } @Override public void set( final BoolType c ) { value = c.get(); } @Override public int compareTo( final BoolType o ) { if ( value ) return o.value ? 0 : 1; else return o.value ? -1 : 0; } @Override public boolean get() { return value; } @Override public void set( final boolean value ) { this.value = value; } public void and( final boolean b ) { value &= b; } public void or( final boolean b ) { value |= b; } public void xor( final boolean b ) { value ^= b; } @Override public void and( final BoolType c ) { and( c.value ); } @Override public void or( final BoolType c ) { or( c.value ); } @Override public void xor( final BoolType c ) { xor( c.value ); } @Override public void not() { value = !value; } @Override public double getMaxValue() { return 1; } @Override public double getMinValue() { return 0; } @Override public int getBitsPerPixel() { return 1; } @Override public int getInteger() { return get() ? 1 : 0; } @Override public long getIntegerLong() { return get() ? 1 : 0; } @Override public BigInteger getBigInteger() { return get() ? BigInteger.ONE : BigInteger.ZERO; } @Override public void setInteger( final int f ) { set( f >= 1 ); } @Override public void setInteger( final long f ) { set( f >= 1 ); } @Override public void setBigInteger( final BigInteger b ) { set( b.compareTo(BigInteger.ZERO) > 0 ); } @Override public boolean valueEquals( BoolType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/000077500000000000000000000000001316447754700236045ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/ARGBDoubleType.java000066400000000000000000000060461316447754700271650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; /** * * * @author Stephan Saalfeld */ public class ARGBDoubleType extends AbstractARGBDoubleType< ARGBDoubleType > { protected double a, r, g, b; public ARGBDoubleType() {} public ARGBDoubleType( final double a, final double r, final double g, final double b ) { set( a, r, g, b ); } @Override public ARGBDoubleType createVariable() { return new ARGBDoubleType(); } @Override public ARGBDoubleType copy() { return new ARGBDoubleType( a, r, g, b ); } @Override public void set( final double a, final double r, final double g, final double b ) { this.a = a; this.r = r; this.g = g; this.b = b; } public void set( final NativeARGBDoubleType c ) { set( c.getA(), c.getR(), c.getG(), c.getB() ); } @Override public double getA() { return a; } @Override public double getR() { return r; } @Override public double getG() { return g; } @Override public double getB() { return b; } @Override public void setA( final double a ) { this.a = a; } @Override public void setR( final double r ) { this.r = r; } @Override public void setG( final double g ) { this.g = g; } @Override public void setB( final double b ) { this.b = b; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/ARGBType.java000066400000000000000000000162141316447754700260300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.IntAccess; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.AbstractNativeType; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * A {@link NativeType native} {@link NumericType} that encodes four channels at * unsigned byte precision into one 32bit signed integer which is the format * used in most display oriented image processing libraries such as AWT or * ImageJ. {@link ARGBType} implements {@link NumericType} as element-wise * vector algebra. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ARGBType extends AbstractNativeType< ARGBType > implements NumericType< ARGBType > { final protected NativeImg< ?, ? extends IntAccess > img; // the DataAccess that holds the information protected IntAccess dataAccess; // this is the constructor if you want it to read from an array public ARGBType( final NativeImg< ?, ? extends IntAccess > intStorage ) { img = intStorage; } // this is the constructor if you want it to be a variable public ARGBType( final int value ) { img = null; dataAccess = new IntArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public ARGBType( final IntAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public ARGBType() { this( 0 ); } @Override public NativeImg< ARGBType, ? extends IntAccess > createSuitableNativeImg( final NativeImgFactory< ARGBType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createIntInstance( dim, new Fraction() ); // create a Type that is linked to the container final ARGBType linkedType = new ARGBType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public ARGBType duplicateTypeOnSameNativeImg() { return new ARGBType( img ); } final public static int rgba( final int r, final int g, final int b, final int a ) { return ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff ) | ( ( a & 0xff ) << 24 ); } final public static int rgba( final float r, final float g, final float b, final float a ) { return rgba( Util.round( r ), Util.round( g ), Util.round( b ), Util.round( a ) ); } final public static int rgba( final double r, final double g, final double b, final double a ) { return rgba( ( int ) Util.round( r ), ( int ) Util.round( g ), ( int ) Util.round( b ), ( int ) Util.round( a ) ); } final public static int red( final int value ) { return ( value >> 16 ) & 0xff; } final public static int green( final int value ) { return ( value >> 8 ) & 0xff; } final public static int blue( final int value ) { return value & 0xff; } final public static int alpha( final int value ) { return ( value >> 24 ) & 0xff; } public int get() { return dataAccess.getValue( i ); } public void set( final int f ) { dataAccess.setValue( i, f ); } @Override public void mul( final float c ) { final int value = get(); set( rgba( red( value ) * c, green( value ) * c, blue( value ) * c, alpha( value ) * c ) ); } @Override public void mul( final double c ) { final int value = get(); set( rgba( red( value ) * c, green( value ) * c, blue( value ) * c, alpha( value ) * c ) ); } @Override public void add( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) + red( value2 ), green( value1 ) + green( value2 ), blue( value1 ) + blue( value2 ), alpha( value1 ) + alpha( value2 ) ) ); } @Override public void div( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) / red( value2 ), green( value1 ) / green( value2 ), blue( value1 ) / blue( value2 ), alpha( value1 ) / alpha( value2 ) ) ); } @Override public void mul( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) * red( value2 ), green( value1 ) * green( value2 ), blue( value1 ) * blue( value2 ), alpha( value1 ) * alpha( value2 ) ) ); } @Override public void sub( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) - red( value2 ), green( value1 ) - green( value2 ), blue( value1 ) - blue( value2 ), alpha( value1 ) - alpha( value2 ) ) ); } @Override public void set( final ARGBType c ) { set( c.get() ); } @Override public void setOne() { set( rgba( 1, 1, 1, 1 ) ); } @Override public void setZero() { set( 0 ); } @Override public ARGBType createVariable() { return new ARGBType( 0 ); } @Override public ARGBType copy() { return new ARGBType( get() ); } @Override public String toString() { final int rgba = get(); return "(r=" + red( rgba ) + ",g=" + green( rgba ) + ",b=" + blue( rgba ) + ",a=" + alpha( rgba ) + ")"; } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public boolean valueEquals( final ARGBType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/AbstractARGBDoubleType.java000066400000000000000000000103031316447754700306400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; import net.imglib2.util.Util; /** * * @author Stephan Saalfeld */ abstract public class AbstractARGBDoubleType< T extends AbstractARGBDoubleType< T > > implements NumericType< T > { abstract public double getA(); abstract public double getR(); abstract public double getG(); abstract public double getB(); abstract public void setA( final double a ); abstract public void setR( final double r ); abstract public void setG( final double g ); abstract public void setB( final double b ); public void set( final double a, final double r, final double g, final double b ) { setA( a ); setR( r ); setG( g ); setB( b ); } @Override public void set( final T c ) { set( c.getA(), c.getR(), c.getG(), c.getB() ); } @Override public void add( final T c ) { set( getA() + c.getA(), getR() + c.getR(), getG() + c.getG(), getB() + c.getB() ); } @Override public void sub( final T c ) { set( getA() - c.getA(), getR() - c.getR(), getG() - c.getG(), getB() - c.getB() ); } @Override public void mul( final T c ) { set( getA() * c.getA(), getR() * c.getR(), getG() * c.getG(), getB() * c.getB() ); } @Override public void div( final T c ) { set( getA() / c.getA(), getR() / c.getR(), getG() / c.getG(), getB() / c.getB() ); } @Override public void setZero() { set( 0, 0, 0, 0 ); } @Override public void setOne() { set( 1, 1, 1, 1 ); } @Override public void mul( final float c ) { set( getA() * c, getR() * c, getG() * c, getB() * c ); } @Override public void mul( final double c ) { set( getA() * c, getR() * c, getG() * c, getB() * c ); } /** * Create and integer packed representation of this ARGB value. Crop */ public int toARGBInt() { final int a = ( int ) Math.max( 0, Math.min( 255, Util.round( getA() * 255 ) ) ); final int r = ( int ) Math.max( 0, Math.min( 255, Util.round( getR() * 255 ) ) ); final int g = ( int ) Math.max( 0, Math.min( 255, Util.round( getG() * 255 ) ) ); final int b = ( int ) Math.max( 0, Math.min( 255, Util.round( getB() * 255 ) ) ); return ( ( ( ( ( a << 8 ) | r ) << 8 ) | g ) << 8 ) | b; } @Override public boolean valueEquals( T t ) { return ( getA() == t.getA() ) && ( getR() == t.getR() ) && ( getG() == t.getG() ) && ( getB() == t.getB() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/ComplexType.java000066400000000000000000000047671316447754700267360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; /** * TODO * */ public interface ComplexType< T extends ComplexType< T >> extends NumericType< T > { public double getRealDouble(); public float getRealFloat(); public double getImaginaryDouble(); public float getImaginaryFloat(); public void setReal( float f ); public void setReal( double f ); public void setImaginary( float f ); public void setImaginary( double f ); public void setComplexNumber( float r, float i ); public void setComplexNumber( double r, double i ); public float getPowerFloat(); public double getPowerDouble(); public float getPhaseFloat(); public double getPhaseDouble(); public void complexConjugate(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/IntegerType.java000066400000000000000000000042701316447754700267110ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; import java.math.BigInteger; /** * TODO * */ public interface IntegerType< T extends IntegerType< T >> extends RealType< T > { public int getInteger(); public long getIntegerLong(); public BigInteger getBigInteger(); public void setInteger( int f ); public void setInteger( long f ); public void setBigInteger( BigInteger b ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/NativeARGBDoubleType.java000066400000000000000000000130051316447754700303250ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.DoubleAccess; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * * @author Stephan Saalfeld */ public class NativeARGBDoubleType extends AbstractARGBDoubleType< NativeARGBDoubleType > implements NativeType< NativeARGBDoubleType > { private int i = 0; private int ai = 0, ri = 1, gi = 2, bi = 3; final protected NativeImg< ?, ? extends DoubleAccess > img; protected DoubleAccess dataAccess; public NativeARGBDoubleType( final NativeImg< ?, ? extends DoubleAccess > img ) { this.img = img; } public NativeARGBDoubleType( final double a, final double r, final double g, final double b ) { img = null; dataAccess = new DoubleArray( 4 ); set( a, r, g, b ); } public NativeARGBDoubleType( final DoubleAccess access ) { img = null; dataAccess = access; } public NativeARGBDoubleType() { this( 0, 0, 0, 0 ); } @Override public NativeImg< NativeARGBDoubleType, ? extends DoubleAccess > createSuitableNativeImg( final NativeImgFactory< NativeARGBDoubleType > storageFactory, final long dim[] ) { final NativeImg< NativeARGBDoubleType, ? extends DoubleAccess > container = storageFactory.createDoubleInstance( dim, new Fraction( 4, 1 ) ); final NativeARGBDoubleType linkedType = new NativeARGBDoubleType( container ); container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public NativeARGBDoubleType duplicateTypeOnSameNativeImg() { return new NativeARGBDoubleType( img ); } @Override public double getA() { return dataAccess.getValue( ai ); } @Override public double getR() { return dataAccess.getValue( ri ); } @Override public double getG() { return dataAccess.getValue( gi ); } @Override public double getB() { return dataAccess.getValue( bi ); } @Override public void setA( final double a ) { dataAccess.setValue( ai, a ); } @Override public void setR( final double r ) { dataAccess.setValue( ri, r ); } @Override public void setG( final double g ) { dataAccess.setValue( gi, g ); } @Override public void setB( final double b ) { dataAccess.setValue( bi, b ); } @Override public void set( final double a, final double r, final double g, final double b ) { dataAccess.setValue( ai, a ); dataAccess.setValue( ri, r ); dataAccess.setValue( gi, g ); dataAccess.setValue( bi, b ); } public void set( final ARGBDoubleType c ) { set( c.getA(), c.getR(), c.getG(), c.getB() ); } @Override public NativeARGBDoubleType createVariable() { return new NativeARGBDoubleType(); } @Override public NativeARGBDoubleType copy() { return new NativeARGBDoubleType( getA(), getR(), getG(), getB() ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction( 4, 1 ); } @Override public void updateIndex( final int index ) { this.i = index; ai = i * 4; ri = ai + 1; gi = ai + 2; bi = ai + 3; } @Override public void incIndex() { ++i; ai += 4; ri += 4; gi += 4; bi += 4; } @Override public void incIndex( final int increment ) { i += increment; final int inc2 = increment * 4; ai += inc2; ri += inc2; gi += inc2; bi += inc2; } @Override public void decIndex() { --i; ai -= 4; ri -= 4; gi -= 4; bi -= 4; } @Override public void decIndex( final int decrement ) { i -= decrement; final int dec2 = decrement * 4; ai -= dec2; ri -= dec2; gi -= dec2; bi -= dec2; } @Override public int getIndex() { return i; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/NumericType.java000066400000000000000000000045221316447754700267160ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; import net.imglib2.type.Type; import net.imglib2.type.operators.Add; import net.imglib2.type.operators.Div; import net.imglib2.type.operators.Mul; import net.imglib2.type.operators.MulFloatingPoint; import net.imglib2.type.operators.SetOne; import net.imglib2.type.operators.SetZero; import net.imglib2.type.operators.Sub; /** * TODO * */ public interface NumericType< T extends NumericType< T >> extends Type< T >, Add< T >, Mul< T >, Sub< T >, Div< T >, SetOne, SetZero, MulFloatingPoint { } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/RealType.java000066400000000000000000000042701316447754700261770ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public interface RealType< T extends RealType< T >> extends ComplexType< T >, Comparable< T > { public void inc(); public void dec(); public double getMaxValue(); public double getMinValue(); public double getMinIncrement(); public int getBitsPerPixel(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/complex/000077500000000000000000000000001316447754700252535ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/complex/AbstractComplexType.java000066400000000000000000000121341316447754700320540ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.complex; import net.imglib2.type.numeric.ComplexType; /** * TODO * */ public abstract class AbstractComplexType< T extends AbstractComplexType< T >> implements ComplexType< T > { @Override public void set( final T c ) { setReal( c.getRealDouble() ); setImaginary( c.getImaginaryDouble() ); } @Override public void mul( final float c ) { setReal( getRealFloat() * c ); setImaginary( getImaginaryFloat() * c ); } @Override public void mul( final double c ) { setReal( getRealDouble() * c ); setImaginary( getImaginaryDouble() * c ); } @Override public void add( final T c ) { setReal( getRealDouble() + c.getRealDouble() ); setImaginary( getImaginaryDouble() + c.getImaginaryDouble() ); } @Override public void div( final T c ) { final double a1 = getRealDouble(); final double b1 = getImaginaryDouble(); final double c1 = c.getRealDouble(); final double d1 = c.getImaginaryDouble(); setReal( ( a1 * c1 + b1 * d1 ) / ( c1 * c1 + d1 * d1 ) ); setImaginary( ( b1 * c1 - a1 * d1 ) / ( c1 * c1 + d1 * d1 ) ); } @Override public void mul( final T t ) { // a + bi final double a = getRealDouble(); final double b = getImaginaryDouble(); // c + di final double c = t.getRealDouble(); final double d = t.getImaginaryDouble(); setReal( a * c - b * d ); setImaginary( a * d + b * c ); } @Override public void sub( final T c ) { setReal( getRealDouble() - c.getRealDouble() ); setImaginary( getImaginaryDouble() - c.getImaginaryDouble() ); } @Override public void complexConjugate() { setImaginary( -getImaginaryDouble() ); } @Override public float getPowerFloat() { final double real = getRealDouble(); final double imaginary = getImaginaryDouble(); return ( float ) Math.sqrt( real * real + imaginary * imaginary ); } @Override public double getPowerDouble() { final double real = getRealDouble(); final double imaginary = getImaginaryDouble(); return Math.sqrt( real * real + imaginary * imaginary ); } @Override public float getPhaseFloat() { return ( float ) Math.atan2( getImaginaryDouble(), getRealDouble() ); } @Override public double getPhaseDouble() { return Math.atan2( getImaginaryDouble(), getRealDouble() ); } @Override public void setOne() { setReal( 1 ); setImaginary( 0 ); } @Override public void setZero() { setReal( 0 ); setImaginary( 0 ); } @Override public void setComplexNumber( final float r, final float i ) { setReal( r ); setImaginary( i ); } @Override public void setComplexNumber( final double r, final double i ) { setReal( r ); setImaginary( i ); } @Override public boolean equals( final Object o ) { if ( !getClass().isInstance(o) ) return false; @SuppressWarnings("unchecked") final T t = (T) o; return getRealDouble() == t.getRealDouble() && getImaginaryDouble() == t .getImaginaryDouble(); } @Override public int hashCode() { // NB: Compute similar hash code to java.lang.Double#hashCode(). final long rBits = Double.doubleToLongBits(getRealDouble()); final long iBits = Double.doubleToLongBits(getImaginaryDouble()); return (int) (rBits ^ (rBits >>> 32) ^ iBits ^ (iBits >>> 32)); } @Override public String toString() { return "(" + getRealDouble() + ") + (" + getImaginaryDouble() + ")i"; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/complex/ComplexDoubleType.java000066400000000000000000000141541316447754700315270ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.complex; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.DoubleAccess; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ComplexDoubleType extends AbstractComplexType< ComplexDoubleType > implements NativeType< ComplexDoubleType > { private int i = 0; // the indices for real and imaginary value private int realI = 0, imaginaryI = 1; final protected NativeImg< ?, ? extends DoubleAccess > img; // the DataAccess that holds the information protected DoubleAccess dataAccess; // this is the constructor if you want it to read from an array public ComplexDoubleType( final NativeImg< ?, ? extends DoubleAccess > complexfloatStorage ) { img = complexfloatStorage; } // this is the constructor if you want it to be a variable public ComplexDoubleType( final double r, final double i ) { img = null; dataAccess = new DoubleArray( 2 ); set( r, i ); } // this is the constructor if you want to specify the dataAccess public ComplexDoubleType( final DoubleAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public ComplexDoubleType() { this( 0, 0 ); } @Override public NativeImg< ComplexDoubleType, ? extends DoubleAccess > createSuitableNativeImg( final NativeImgFactory< ComplexDoubleType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createDoubleInstance( dim, new Fraction( 2, 1 ) ); // create a Type that is linked to the container final ComplexDoubleType linkedType = new ComplexDoubleType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public ComplexDoubleType duplicateTypeOnSameNativeImg() { return new ComplexDoubleType( img ); } @Override public float getRealFloat() { return ( float ) dataAccess.getValue( realI ); } @Override public double getRealDouble() { return dataAccess.getValue( realI ); } @Override public float getImaginaryFloat() { return ( float ) dataAccess.getValue( imaginaryI ); } @Override public double getImaginaryDouble() { return dataAccess.getValue( imaginaryI ); } @Override public void setReal( final float r ) { dataAccess.setValue( realI, r ); } @Override public void setReal( final double r ) { dataAccess.setValue( realI, r ); } @Override public void setImaginary( final float i ) { dataAccess.setValue( imaginaryI, i ); } @Override public void setImaginary( final double i ) { dataAccess.setValue( imaginaryI, i ); } public void set( final double r, final double i ) { dataAccess.setValue( realI, r ); dataAccess.setValue( imaginaryI, i ); } @Override public void set( final ComplexDoubleType c ) { setReal( c.getRealDouble() ); setImaginary( c.getImaginaryDouble() ); } @Override public ComplexDoubleType createVariable() { return new ComplexDoubleType( 0, 0 ); } @Override public ComplexDoubleType copy() { return new ComplexDoubleType( getRealFloat(), getImaginaryFloat() ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction( 2, 1 ); } @Override public void updateIndex( final int index ) { this.i = index; realI = index * 2; imaginaryI = index * 2 + 1; } @Override public void incIndex() { ++i; realI += 2; imaginaryI += 2; } @Override public void incIndex( final int increment ) { i += increment; final int inc2 = 2 * increment; realI += inc2; imaginaryI += inc2; } @Override public void decIndex() { --i; realI -= 2; imaginaryI -= 2; } @Override public void decIndex( final int decrement ) { i -= decrement; final int dec2 = 2 * decrement; realI -= dec2; imaginaryI -= dec2; } @Override public int getIndex() { return i; } @Override public boolean valueEquals( final ComplexDoubleType t ) { return ( getRealDouble() == t.getRealDouble() ) && ( getImaginaryDouble() == t.getImaginaryDouble() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/complex/ComplexFloatType.java000066400000000000000000000163771316447754700313730ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.complex; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.FloatAccess; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ComplexFloatType extends AbstractComplexType< ComplexFloatType > implements NativeType< ComplexFloatType > { private int i = 0; // the indices for real and imaginary number private int realI = 0, imaginaryI = 1; final protected NativeImg< ?, ? extends FloatAccess > img; // the DataAccess that holds the information protected FloatAccess dataAccess; // this is the constructor if you want it to read from an array public ComplexFloatType( final NativeImg< ?, ? extends FloatAccess > complexfloatStorage ) { img = complexfloatStorage; } // this is the constructor if you want it to be a variable public ComplexFloatType( final float r, final float i ) { img = null; dataAccess = new FloatArray( 2 ); set( r, i ); } // this is the constructor if you want to specify the dataAccess public ComplexFloatType( final FloatAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public ComplexFloatType() { this( 0, 0 ); } @Override public NativeImg< ComplexFloatType, ? extends FloatAccess > createSuitableNativeImg( final NativeImgFactory< ComplexFloatType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createFloatInstance( dim, new Fraction( 2, 1 ) ); // create a Type that is linked to the container final ComplexFloatType linkedType = new ComplexFloatType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public ComplexFloatType duplicateTypeOnSameNativeImg() { return new ComplexFloatType( img ); } @Override public float getRealFloat() { return dataAccess.getValue( realI ); } @Override public double getRealDouble() { return dataAccess.getValue( realI ); } @Override public float getImaginaryFloat() { return dataAccess.getValue( imaginaryI ); } @Override public double getImaginaryDouble() { return dataAccess.getValue( imaginaryI ); } @Override public void setReal( final float r ) { dataAccess.setValue( realI, r ); } @Override public void setReal( final double r ) { dataAccess.setValue( realI, ( float ) r ); } @Override public void setImaginary( final float i ) { dataAccess.setValue( imaginaryI, i ); } @Override public void setImaginary( final double i ) { dataAccess.setValue( imaginaryI, ( float ) i ); } public void set( final float r, final float i ) { dataAccess.setValue( realI, r ); dataAccess.setValue( imaginaryI, i ); } @Override public void add( final ComplexFloatType c ) { setReal( getRealFloat() + c.getRealFloat() ); setImaginary( getImaginaryFloat() + c.getImaginaryFloat() ); } @Override public void div( final ComplexFloatType c ) { final float a1 = getRealFloat(); final float b1 = getImaginaryFloat(); final float c1 = c.getRealFloat(); final float d1 = c.getImaginaryFloat(); setReal( ( a1 * c1 + b1 * d1 ) / ( c1 * c1 + d1 * d1 ) ); setImaginary( ( b1 * c1 - a1 * d1 ) / ( c1 * c1 + d1 * d1 ) ); } @Override public void mul( final ComplexFloatType t ) { // a + bi final float a = getRealFloat(); final float b = getImaginaryFloat(); // c + di final float c = t.getRealFloat(); final float d = t.getImaginaryFloat(); setReal( a * c - b * d ); setImaginary( a * d + b * c ); } @Override public void sub( final ComplexFloatType c ) { setReal( getRealFloat() - c.getRealFloat() ); setImaginary( getImaginaryFloat() - c.getImaginaryFloat() ); } @Override public void complexConjugate() { setImaginary( -getImaginaryFloat() ); } public void switchRealComplex() { final float a = getRealFloat(); setReal( getImaginaryFloat() ); setImaginary( a ); } @Override public void set( final ComplexFloatType c ) { setReal( c.getRealFloat() ); setImaginary( c.getImaginaryFloat() ); } @Override public ComplexFloatType createVariable() { return new ComplexFloatType( 0, 0 ); } @Override public ComplexFloatType copy() { return new ComplexFloatType( getRealFloat(), getImaginaryFloat() ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction( 2, 1 ); } @Override public void updateIndex( final int index ) { this.i = index; realI = index * 2; imaginaryI = index * 2 + 1; } @Override public void incIndex() { ++i; realI += 2; imaginaryI += 2; } @Override public void incIndex( final int increment ) { i += increment; final int inc2 = 2 * increment; realI += inc2; imaginaryI += inc2; } @Override public void decIndex() { --i; realI -= 2; imaginaryI -= 2; } @Override public void decIndex( final int decrement ) { i -= decrement; final int dec2 = 2 * decrement; realI -= dec2; imaginaryI -= dec2; } @Override public int getIndex() { return i; } @Override public boolean valueEquals( final ComplexFloatType t ) { return ( getRealFloat() == t.getRealFloat() ) && ( getImaginaryFloat() == t.getImaginaryFloat() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/000077500000000000000000000000001316447754700252415ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/AbstractIntegerBitType.java000066400000000000000000000142001316447754700324630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.type.AbstractBitType; import net.imglib2.type.numeric.IntegerType; import net.imglib2.util.Util; /** * The performance of this type is traded off for the gain in memory storage. * * @author Albert Cardona */ public abstract class AbstractIntegerBitType> extends AbstractBitType implements IntegerType { // Maximum count is Integer.MAX_VALUE * (64 / getBitsPerPixel()) //protected long i = 0; //final protected NativeImg img; // the DataAccess that holds the information //protected LongAccess dataAccess; // this is the constructor if you want it to read from an array public AbstractIntegerBitType( final NativeImg< ?, ? extends LongAccess > bitStorage, final int nBits ) { super( bitStorage, nBits ); } public abstract long get(); public abstract void set( final long value ); @Override public int getBitsPerPixel() { return nBits; } @Override public double getMinIncrement() { return 1; } @Override public void mul( final float c ) { setReal( getRealDouble() * c ); } @Override public void mul( final double c ) { setReal( getRealDouble() * c ); } @Override public float getRealFloat() { return getIntegerLong(); } @Override public double getRealDouble() { return getIntegerLong(); } @Override public void setReal( final float real ){ setInteger( Util.round( real ) ); } @Override public void setReal( final double real ){ setInteger( Util.round( real ) ); } @Override public void setZero() { setInteger( 0 ); } @Override public void setOne() { setInteger( 1 ); } @Override public boolean equals( final Object o ) { if ( !getClass().isInstance(o) ) return false; @SuppressWarnings("unchecked") final T t = (T) o; return compareTo(t) == 0; } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Long#hashCode(). final long value = get(); return (int) (value ^ (value >>> 32)); } @Override public int compareTo( final T c ) { final long a = getIntegerLong(); final long b = c.getIntegerLong(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public String toString() { return "" + getIntegerLong(); } @Override public int getInteger() { return (int)get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( f ); } @Override public void setBigInteger( final BigInteger b) { set( b.longValue() ); } /** The maximum value that can be stored is {@code Math.pow(2, nBits) -1}. */ @Override public double getMaxValue() { return Math.pow(2, getBitsPerPixel()) -1; } @Override public double getMinValue() { return 0; } @Override public void inc() { set(get() + 1); } @Override public void dec() { set(get() - 1); } @Override public void add(final T t) { set(get() + t.get()); } @Override public void sub(final T t) { set(get() - t.get()); } @Override public void mul(final T t) { set(get() * t.get()); } @Override public void div(final T t) { set(get() / t.get()); } @Override public void set( final T c ) { set( c.get() ); } @Override public float getImaginaryFloat() { return 0; } @Override public double getImaginaryDouble() { return 0; } @Override public void setImaginary( final float complex ){} @Override public void setImaginary( final double complex ){} @Override public float getPhaseFloat() { return 0; } @Override public double getPhaseDouble() { return 0; } @Override public float getPowerFloat() { return getRealFloat(); } @Override public double getPowerDouble() { return getRealDouble(); } @Override public void setComplexNumber( final float r, final float i ) { setReal( r ); } @Override public void setComplexNumber( final double r, final double i ) { setReal( r ); } @Override public void complexConjugate(){} /** * Default test at long precision. Please override for types longer than 64bit. * * @param t * @return */ @Override public boolean valueEquals( final T t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/AbstractIntegerType.java000066400000000000000000000064011316447754700320300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.type.numeric.IntegerType; import net.imglib2.type.numeric.real.AbstractRealType; import net.imglib2.util.Util; /** * TODO * */ public abstract class AbstractIntegerType< T extends AbstractIntegerType< T > > extends AbstractRealType< T > implements IntegerType< T > { @Override public double getMinIncrement() { return 1; } @Override public float getRealFloat() { return getIntegerLong(); } @Override public double getRealDouble() { return getIntegerLong(); } @Override public void setReal( final float real ) { setInteger( Util.round( real ) ); } @Override public void setReal( final double real ) { setInteger( Util.round( real ) ); } @Override public void inc() { setInteger( getIntegerLong() + 1 ); } @Override public void dec() { setInteger( getIntegerLong() - 1 ); } @Override public void setZero() { setInteger( 0 ); } @Override public void setOne() { setInteger( 1 ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Long#hashCode(). final long value = getIntegerLong(); return ( int ) ( value ^ ( value >>> 32 ) ); } @Override public int compareTo( final T c ) { final long a = getIntegerLong(); final long b = c.getIntegerLong(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public String toString() { return "" + getIntegerLong(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/ByteType.java000066400000000000000000000102111316447754700276440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.ByteAccess; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ByteType extends GenericByteType< ByteType > { // this is the constructor if you want it to read from an array public ByteType( final NativeImg< ?, ? extends ByteAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public ByteType( final byte value ) { super( value ); } // this is the constructor if you want to specify the dataAccess public ByteType( final ByteAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public ByteType() { super( ( byte ) 0 ); } @Override public NativeImg< ByteType, ? extends ByteAccess > createSuitableNativeImg( final NativeImgFactory< ByteType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createByteInstance( dim, new Fraction() ); // create a Type that is linked to the container final ByteType linkedType = new ByteType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public ByteType duplicateTypeOnSameNativeImg() { return new ByteType( img ); } public byte get() { return getByte(); } public void set( final byte b ) { setByte( b ); } @Override public int getInteger() { return get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( ( byte ) f ); } @Override public void setInteger( final long f ) { set( ( byte ) f ); } @Override public void setBigInteger( final BigInteger b ) { set( b.byteValue() ); } @Override public double getMaxValue() { return Byte.MAX_VALUE; } @Override public double getMinValue() { return Byte.MIN_VALUE; } @Override public ByteType createVariable() { return new ByteType( ( byte ) 0 ); } @Override public ByteType copy() { return new ByteType( getByte() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/GenericByteType.java000066400000000000000000000134661316447754700311600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.ByteAccess; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class GenericByteType< T extends GenericByteType< T >> extends AbstractIntegerType< T > implements NativeType< T > { int i = 0; final protected NativeImg< ?, ? extends ByteAccess > img; // the DataAccess that holds the information protected ByteAccess dataAccess; // this is the constructor if you want it to read from an array public GenericByteType( final NativeImg< ?, ? extends ByteAccess > byteStorage ) { img = byteStorage; } // this is the constructor if you want it to be a variable public GenericByteType( final byte value ) { img = null; dataAccess = new ByteArray( 1 ); setByte( value ); } // this is the constructor if you want to specify the dataAccess public GenericByteType( final ByteAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public GenericByteType() { this( ( byte ) 0 ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } /** * @deprecated Use {@link #getByte()} instead. */ @Deprecated protected byte getValue() { return dataAccess.getValue( i ); } /** * @deprecated Use {@link #setByte(byte)} instead. */ @Deprecated protected void setValue( final byte f ) { dataAccess.setValue( i, f ); } /** * Returns the primitive byte value that is used to store this type. * * @return primitive byte value */ public byte getByte() { return dataAccess.getValue( i ); } /** * Sets the primitive byte value that is used to store this type. */ public void setByte( final byte f ) { dataAccess.setValue( i, f ); } @Override public void mul( final float c ) { final byte a = getByte(); setByte( ( byte ) Util.round( a * c ) ); } @Override public void mul( final double c ) { final byte a = getByte(); setByte( ( byte ) Util.round( a * c ) ); } @Override public void add( final T c ) { final byte a = getByte(); setByte( ( byte ) ( a + c.getByte() ) ); } @Override public void div( final T c ) { final byte a = getByte(); setByte( ( byte ) ( a / c.getByte() ) ); } @Override public void mul( final T c ) { final byte a = getByte(); setByte( ( byte ) ( a * c.getByte() ) ); } @Override public void sub( final T c ) { final byte a = getByte(); setByte( ( byte ) ( a - c.getByte() ) ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Byte#hashCode(). return getByte(); } @Override public int compareTo( final T c ) { final byte a = getByte(); final byte b = c.getByte(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public void set( final T c ) { setByte( c.getByte() ); } @Override public void setOne() { setByte( ( byte ) 1 ); } @Override public void setZero() { setByte( ( byte ) 0 ); } @Override public void inc() { byte a = getByte(); setByte( ++a ); } @Override public void dec() { byte a = getByte(); setByte( --a ); } @Override public String toString() { return "" + getByte(); } @Override public void updateIndex( final int index ) { i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 8; } @Override public boolean valueEquals( final T t ) { return getByte() == t.getByte(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/GenericIntType.java000066400000000000000000000132341316447754700310000ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.IntAccess; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class GenericIntType< T extends GenericIntType< T >> extends AbstractIntegerType< T > implements NativeType< T > { int i = 0; final protected NativeImg< ?, ? extends IntAccess > img; // the DataAccess that holds the information protected IntAccess dataAccess; // this is the constructor if you want it to read from an array public GenericIntType( final NativeImg< ?, ? extends IntAccess > intStorage ) { img = intStorage; } // this is the constructor if you want it to be a variable public GenericIntType( final int value ) { img = null; dataAccess = new IntArray( 1 ); setInt( value ); } // this is the constructor if you want to specify the dataAccess public GenericIntType( final IntAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public GenericIntType() { this( 0 ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } /** * @deprecated Use {@link #getInt()} instead. */ @Deprecated protected int getValue() { return dataAccess.getValue( i ); } /** * @deprecated Use {@link #setInt(int)} instead. */ @Deprecated protected void setValue( final int f ) { dataAccess.setValue( i, f ); } /** * Returns the primitive int value that is used to store this type. * * @return primitive int value */ public int getInt() { return dataAccess.getValue( i ); } /** * Sets the primitive int value that is used to store this type. */ public void setInt( final int f ) { dataAccess.setValue( i, f ); } @Override public void mul( final float c ) { final int a = getInt(); setInt( Util.round( a * c ) ); } @Override public void mul( final double c ) { final int a = getInt(); setInt( ( int ) Util.round( a * c ) ); } @Override public void add( final T c ) { final int a = getInt(); setInt( a + c.getInt() ); } @Override public void div( final T c ) { final int a = getInt(); setInt( a / c.getInt() ); } @Override public void mul( final T c ) { final int a = getInt(); setInt( a * c.getInt() ); } @Override public void sub( final T c ) { final int a = getInt(); setInt( a - c.getInt() ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Integer#hashCode(). return getInt(); } @Override public int compareTo( final T c ) { final int a = getInt(); final int b = c.getInt(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public void set( final T c ) { setInt( c.getInt() ); } @Override public void setOne() { setInt( 1 ); } @Override public void setZero() { setInt( 0 ); } @Override public void inc() { int a = getInt(); setInt( ++a ); } @Override public void dec() { int a = getInt(); setInt( --a ); } @Override public String toString() { return "" + getInt(); } @Override public void updateIndex( final int index ) { i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 32; } @Override public boolean valueEquals( final T t ) { return getInt() == t.getInt(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/GenericLongType.java000066400000000000000000000131611316447754700311440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * Abstract superclass for Long types. * * @author Mark Hiner */ public abstract class GenericLongType < T extends GenericLongType< T >> extends AbstractIntegerType< T > implements NativeType< T > { int i = 0; final protected NativeImg< ?, ? extends LongAccess > img; // the DataAccess that holds the information protected LongAccess dataAccess; // this is the constructor if you want it to read from an array public GenericLongType( final NativeImg< ?, ? extends LongAccess > longStorage ) { img = longStorage; } // this is the constructor if you want it to be a variable public GenericLongType( final long value ) { img = null; dataAccess = new LongArray( 1 ); setLong( value ); } // this is the constructor if you want to specify the dataAccess public GenericLongType( final LongAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public GenericLongType() { this( 0 ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } /** * @deprecated Use {@link #getLong()} instead. */ @Deprecated protected long getValue() { return dataAccess.getValue( i ); } /** * @deprecated Use {@link #setLong(long)} instead. */ @Deprecated protected void setValue( final long f ) { dataAccess.setValue( i, f ); } /** * Returns the primitive long value that is used to store this type. * * @return primitive long value */ public long getLong() { return dataAccess.getValue( i ); } /** * Sets the primitive long value that is used to store this type. */ public void setLong( final long f ) { dataAccess.setValue( i, f ); } @Override public void mul( final float c ) { setLong( Util.round( getLong() * c ) ); } @Override public void mul( final double c ) { setLong( Util.round( getLong() * c ) ); } @Override public void add( final T c ) { setLong( getLong() + c.getLong() ); } @Override public void div( final T c ) { setLong( getLong() / c.getLong() ); } @Override public void mul( final T c ) { setLong( getLong() * c.getLong() ); } @Override public void sub( final T c ) { setLong( getLong() - c.getLong() ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Long#hashCode(). return ( (Long)getLong() ).hashCode(); } @Override public int compareTo( final T c ) { final long a = getLong(); final long b = c.getLong(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public void set( final T c ) { setLong( c.getLong() ); } @Override public void setOne() { setLong( 1 ); } @Override public void setZero() { setLong( 0 ); } @Override public void inc() { long a = getLong(); setLong( ++a ); } @Override public void dec() { long a = getLong(); setLong( --a ); } @Override public String toString() { return "" + getLong(); } @Override public void updateIndex( final int index ) { i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 64; } @Override public boolean valueEquals( final T t ) { return getLong() == t.getLong(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/GenericShortType.java000066400000000000000000000140511316447754700313430ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.img.NativeImg; import net.imglib2.img.basictypeaccess.ShortAccess; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.IntegerType; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * Abstract base class for {@link NativeType native} {@link IntegerType}s that * encode their value into a 16bit short. * * @author Stephan Preibisch * @author Stephan Saalfeld */ public abstract class GenericShortType< T extends GenericShortType< T > > extends AbstractIntegerType< T > implements NativeType< T > { int i = 0; final protected NativeImg< ?, ? extends ShortAccess > img; // the DataAccess that holds the information protected ShortAccess dataAccess; // this is the constructor if you want it to read from an array public GenericShortType( final NativeImg< ?, ? extends ShortAccess > shortStorage ) { img = shortStorage; } // this is the constructor if you want it to be a variable public GenericShortType( final short value ) { img = null; dataAccess = new ShortArray( 1 ); setShort( value ); } // this is the constructor if you want to specify the dataAccess public GenericShortType( final ShortAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public GenericShortType() { this( ( short ) 0 ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } /** * @deprecated Use {@link #getShort()} instead. */ @Deprecated protected short getValue() { return dataAccess.getValue( i ); } /** * @deprecated Use {@link #setShort(short)} instead. */ @Deprecated protected void setValue( final short f ) { dataAccess.setValue( i, f ); } /** * Returns the primitive short value that is used to store this type. * * @return primitive short value */ public short getShort() { return dataAccess.getValue( i ); } /** * Sets the primitive short value that is used to store this type. */ public void setShort( final short f ) { dataAccess.setValue( i, f ); } @Override public void mul( final float c ) { final short a = getShort(); setShort( ( short ) Util.round( a * c ) ); } @Override public void mul( final double c ) { final short a = getShort(); setShort( ( short ) Util.round( a * c ) ); } @Override public void add( final T c ) { final short a = getShort(); setShort( ( short ) ( a + c.getShort() ) ); } @Override public void div( final T c ) { final short a = getShort(); setShort( ( short ) ( a / c.getShort() ) ); } @Override public void mul( final T c ) { final short a = getShort(); setShort( ( short ) ( a * c.getShort() ) ); } @Override public void sub( final T c ) { final short a = getShort(); setShort( ( short ) ( a - c.getShort() ) ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Short#hashCode(). return getShort(); } @Override public int compareTo( final T c ) { final short a = getShort(); final short b = c.getShort(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public void set( final T c ) { setShort( c.getShort() ); } @Override public void setOne() { setShort( ( short ) 1 ); } @Override public void setZero() { setShort( ( short ) 0 ); } @Override public void inc() { short a = getShort(); setShort( ++a ); } @Override public void dec() { short a = getShort(); setShort( --a ); } @Override public String toString() { return "" + getShort(); } @Override public void updateIndex( final int index ) { i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 16; } @Override public boolean valueEquals( final T t ) { return getShort() == t.getShort(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/IntType.java000066400000000000000000000101221316447754700274740ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.IntAccess; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class IntType extends GenericIntType< IntType > { // this is the constructor if you want it to read from an array public IntType( final NativeImg< ?, ? extends IntAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public IntType( final int value ) { super( value ); } // this is the constructor if you want to specify the dataAccess public IntType( final IntAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public IntType() { super( 0 ); } @Override public NativeImg< IntType, ? extends IntAccess > createSuitableNativeImg( final NativeImgFactory< IntType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createIntInstance( dim, new Fraction() ); // create a Type that is linked to the container final IntType linkedType = new IntType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public IntType duplicateTypeOnSameNativeImg() { return new IntType( img ); } public int get() { return getInt(); } public void set( final int b ) { setInt( b ); } @Override public int getInteger() { return get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( ( int ) f ); } @Override public void setBigInteger(final BigInteger b) { set( b.intValue() ); } @Override public double getMaxValue() { return Integer.MAX_VALUE; } @Override public double getMinValue() { return Integer.MIN_VALUE; } @Override public IntType createVariable() { return new IntType( 0 ); } @Override public IntType copy() { return new IntType( getInt() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/LongType.java000066400000000000000000000110221316447754700276410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Mark Hiner */ public class LongType extends GenericLongType { // this is the constructor if you want it to read from an array public LongType( final NativeImg< ?, ? extends LongAccess > longStorage ) { super( longStorage ); } // this is the constructor if you want to specify the dataAccess public LongType( final LongAccess access ) { super ( access ); } // this is the constructor if you want it to be a variable public LongType( final long value ) { super( value ); } // this is the constructor if you want it to be a variable public LongType() { super( 0 ); } @Override public NativeImg< LongType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< LongType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createLongInstance( dim, new Fraction() ); // create a Type that is linked to the container final LongType linkedType = new LongType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public LongType duplicateTypeOnSameNativeImg() { return new LongType( img ); } public long get() { return dataAccess.getValue( i ); } public void set( final long f ) { dataAccess.setValue( i, f ); } @Override public int getInteger() { return ( int ) get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( f ); } @Override public void setBigInteger( BigInteger b ) { set( b.longValue() ); } @Override public double getMaxValue() { return Long.MAX_VALUE; } @Override public double getMinValue() { return Long.MIN_VALUE; } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Long#hashCode(). final long value = get(); return (int) (value ^ (value >>> 32)); } @Override public int compareTo( final LongType c ) { final long a = get(); final long b = c.get(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public LongType createVariable() { return new LongType( 0 ); } @Override public LongType copy() { return new LongType( get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/ShortType.java000066400000000000000000000102541316447754700300470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.ShortAccess; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class ShortType extends GenericShortType< ShortType > { // this is the constructor if you want it to read from an array public ShortType( final NativeImg< ?, ? extends ShortAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public ShortType( final short value ) { super( value ); } // this is the constructor if you want to specify the dataAccess public ShortType( final ShortAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public ShortType() { this( ( short ) 0 ); } @Override public NativeImg< ShortType, ? extends ShortAccess > createSuitableNativeImg( final NativeImgFactory< ShortType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createShortInstance( dim, new Fraction() ); // create a Type that is linked to the container final ShortType linkedType = new ShortType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public ShortType duplicateTypeOnSameNativeImg() { return new ShortType( img ); } public short get() { return getShort(); } public void set( final short b ) { setShort( b ); } @Override public int getInteger() { return get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( ( short ) f ); } @Override public void setInteger( final long f ) { set( ( short ) f ); } @Override public void setBigInteger( final BigInteger b) { set( b.shortValue() ); } @Override public double getMaxValue() { return Short.MAX_VALUE; } @Override public double getMinValue() { return Short.MIN_VALUE; } @Override public ShortType createVariable() { return new ShortType( ( short ) 0 ); } @Override public ShortType copy() { return new ShortType( getShort() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/Unsigned128BitType.java000066400000000000000000000263631316447754700314260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigDecimal; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.NativeType; import net.imglib2.type.Type; import net.imglib2.type.numeric.NumericType; import net.imglib2.util.Fraction; /** * A {@link Type} with a bit depth of 128. * Each value is stored in two adjacent long in an array, * with the lower long first, then the upper long. * Currently the math methods defined in the superinterface {@link NumericType} are implemented using {@link BigInteger} and {@link BigDecimal}. * This class is not {@link Thread}-safe; do a {@link #copy()} first to operate on a different {@link Thread}. * * @author Albert Cardona */ public class Unsigned128BitType extends AbstractIntegerType implements NativeType { private int i = 0; final protected NativeImg< ?, ? extends LongAccess > img; // 17, so the first byte is 0 to mean positive integer final protected byte[] bytes = new byte[17]; // the DataAccess that holds the information protected LongAccess dataAccess; // this is the constructor if you want it to read from an array public Unsigned128BitType( final NativeImg< ?, ? extends LongAccess > bitStorage ) { img = bitStorage; } // this is the constructor if you want it to be a variable public Unsigned128BitType( final long lower, final long upper ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 2 ); set( lower, upper ); } // this is the constructor if you want it to be a variable public Unsigned128BitType( final BigInteger value ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 2 ); set( value ); } // this is the constructor if you want to specify the dataAccess public Unsigned128BitType( final LongAccess access ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = access; } // this is the constructor if you want it to be a variable public Unsigned128BitType( ) { this( 0, 0 ); } @Override public NativeImg< Unsigned128BitType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< Unsigned128BitType > storageFactory, final long dim[] ) { // create the container: final NativeImg< Unsigned128BitType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, new Fraction( 2, 1 ) ); // create a Type that is linked to the container final Unsigned128BitType linkedType = new Unsigned128BitType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public Unsigned128BitType duplicateTypeOnSameNativeImg() { return new Unsigned128BitType( img ); } private final void intoBytes( final long lower, final long upper ) { bytes[ 0] = 0; // so the number is non-negative bytes[ 1] = (byte)((upper >>> 56) & 0xffL); bytes[ 2] = (byte)((upper >>> 48) & 0xffL); bytes[ 3] = (byte)((upper >>> 40) & 0xffL); bytes[ 4] = (byte)((upper >>> 32) & 0xffL); bytes[ 5] = (byte)((upper >>> 24) & 0xffL); bytes[ 6] = (byte)((upper >>> 16) & 0xffL); bytes[ 7] = (byte)((upper >>> 8) & 0xffL); bytes[ 8] = (byte) (upper & 0xffL); bytes[ 9] = (byte)((lower >>> 56) & 0xffL); bytes[10] = (byte)((lower >>> 48) & 0xffL); bytes[11] = (byte)((lower >>> 40) & 0xffL); bytes[12] = (byte)((lower >>> 32) & 0xffL); bytes[13] = (byte)((lower >>> 24) & 0xffL); bytes[14] = (byte)((lower >>> 16) & 0xffL); bytes[15] = (byte)((lower >>> 8) & 0xffL); bytes[16] = (byte) (lower & 0xffL); } /** The first byte is the most significant byte, like in {@link BigInteger#toByteArray()}. * Only the last 16 bytes are read, if there are more. */ public void set( final byte[] bytes ) { final int k = i * 2; int b = bytes.length - 1; for ( int offset = 0; offset < 2; ++offset ) { final int cut = Math.max( -1, b - 8 ); long u = 0; for ( int p = 0; b > cut; --b, p += 8 ) { u |= ( bytes[ b ] & 0xffL ) << p; } dataAccess.setValue( k + offset, u ); } } public BigInteger get() { final int k = i * 2; intoBytes( dataAccess.getValue( k ), dataAccess.getValue( k + 1 ) ); return new BigInteger( bytes ); } public void set( final BigInteger value ) { set( value.toByteArray() ); } public void set( final long lower, final long upper ) { final int k = i * 2; dataAccess.setValue( k, lower ); dataAccess.setValue( k + 1, upper ); } /** Return the lowest 32 bits, like {@link BigInteger#intValue()}. */ @Override public int getInteger() { return (int)(dataAccess.getValue( i * 2 ) & 0xffffffffL); } /** Return the lowest 64 bits, like {@link BigInteger#intValue()}. */ @Override public long getIntegerLong() { return dataAccess.getValue( i * 2 ); } @Override public BigInteger getBigInteger() { return get(); } @Override public void setInteger( final int value ) { final int k = i * 2; dataAccess.setValue( k, value ); dataAccess.setValue( k + 1, 0 ); } @Override public void setInteger( final long value ) { final int k = i * 2; dataAccess.setValue( k, value ); dataAccess.setValue( k + 1, 0 ); } @Override public void setBigInteger(final BigInteger b) { set( b ); } /** The maximum value that can be stored is {@code Math.pow(2, 128) -1}, * which cannot be represented with precision using a double */ @Override public double getMaxValue() { return Math.pow( 2, 128 ) - 1; } // imprecise /** The true maximum value, unlike {@link #getMaxValue()} which cannot represent * it in a {@code double}. */ public BigInteger getMaxBigIntegerValue() { bytes[0] = 0; for (int b=1; b { // A mask for bit and, containing nBits of 1 private final long mask; // this is the constructor if you want it to read from an array public Unsigned12BitType( final NativeImg< ?, ? extends LongAccess > bitStorage ) { super( bitStorage, 12 ); this.mask = 4095; // 111111111111 in binary } // this is the constructor if you want it to be a variable public Unsigned12BitType( final long value ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public Unsigned12BitType( final LongAccess access ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = access; } // this is the constructor if you want it to be a variable public Unsigned12BitType() { this( 0 ); } @Override public NativeImg< Unsigned12BitType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< Unsigned12BitType > storageFactory, final long dim[] ) { // create the container final NativeImg< Unsigned12BitType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, new Fraction( getBitsPerPixel(), 64 ) ); // create a Type that is linked to the container final Unsigned12BitType linkedType = new Unsigned12BitType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public Unsigned12BitType duplicateTypeOnSameNativeImg() { return new Unsigned12BitType( img ); } @Override public long get() { final long k = i * 12; final int i1 = (int)(k >>> 6); // k / 64; final long shift = k & 63; // k % 64; final long v = dataAccess.getValue(i1); final long antiShift = 64 - shift; if (antiShift < 12) { // Number split between two adjacent long final long v1 = (v >>> shift) & (mask >>> (12 - antiShift)); // lower part, stored at the upper end final long v2 = (dataAccess.getValue(i1 + 1) & (mask >>> antiShift)) << antiShift; // upper part, stored at the lower end return v1 | v2; } else { // Number contained inside a single long return (v >>> shift) & mask; } } // Crops value to within mask @Override public void set( final long value ) { final long k = i * 12; final int i1 = (int)(k >>> 6); // k / 64; final long shift = k & 63; // k % 64; final long safeValue = value & mask; final long antiShift = 64 - shift; synchronized ( dataAccess ) { final long v = dataAccess.getValue(i1); if (antiShift < 12) { // Number split between two adjacent longs // 1. Store the lower bits of safeValue at the upper bits of v1 final long v1 = (v & (0xffffffffffffffffL >>> antiShift)) // clear upper bits, keep other values | ((safeValue & (mask >>> (12 - antiShift))) << shift); // the lower part of safeValue, stored at the upper end dataAccess.setValue(i1, v1); // 2. Store the upper bits of safeValue at the lower bits of v2 final long v2 = (dataAccess.getValue(i1 + 1) & (0xffffffffffffffffL << (12 - antiShift))) // other | (safeValue >>> antiShift); // upper part of safeValue, stored at the lower end dataAccess.setValue(i1 + 1, v2); } else { // Number contained inside a single long if (0 == v) { // Trivial case dataAccess.setValue(i1, safeValue << shift); } else { // Clear the bits first dataAccess.setValue(i1, (v & ~(mask << shift)) | (safeValue << shift)); } } } } @Override public Unsigned12BitType createVariable(){ return new Unsigned12BitType( 0 ); } @Override public Unsigned12BitType copy(){ return new Unsigned12BitType( get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/Unsigned2BitType.java000066400000000000000000000120411316447754700312410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.Type; import net.imglib2.util.Fraction; /** * A {@link Type} with a bit depth of 2. * * The performance of this type is traded off for the gain in memory storage. * * @author Albert Cardona */ public class Unsigned2BitType extends AbstractIntegerBitType { // A mask for bit and, containing nBits of 1 private final static long mask = 3; // 11 in binary // this is the constructor if you want it to read from an array public Unsigned2BitType( final NativeImg< ?, ? extends LongAccess > bitStorage ) { super( bitStorage, 2 ); } // this is the constructor if you want it to be a variable public Unsigned2BitType( final long value ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public Unsigned2BitType( final LongAccess access ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = access; } // this is the constructor if you want it to be a variable public Unsigned2BitType() { this( 0 ); } @Override public NativeImg< Unsigned2BitType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< Unsigned2BitType > storageFactory, final long dim[] ) { // create the container final NativeImg< Unsigned2BitType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, new Fraction( getBitsPerPixel(), 64 ) ); // create a Type that is linked to the container final Unsigned2BitType linkedType = new Unsigned2BitType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public Unsigned2BitType duplicateTypeOnSameNativeImg() { return new Unsigned2BitType( img ); } @Override public long get() { /* final int k = i * 2; return (dataAccess.getValue(k >>> 6) >>> (k % 64)) & mask; */ // Same as above minus one multiplication, plus one shift to multiply the reminder by 2 //return (dataAccess.getValue((int)(i >>> 5)) >>> ((i % 32) << 1)) & mask; // Even less operations // div 32 == shr 5 return (dataAccess.getValue((int)(i >>> 5)) >>> ((i & 31) << 1)) & mask; } // Crops value to within mask @Override public void set( final long value ) { /* final int k = i * 2; final int i1 = k >>> 6; // k / 64; final long shift = k % 64; */ // Same as above, minus one multiplication, plus one shift to multiply the reminder by 2 final int i1 = (int)(i >>> 5); // Same as (i * 2) / 64 = (i << 1) >>> 6 final long shift = (i << 1) & 63; // Same as (i * 2) % 64 // Clear the bits first, then or the masked value final long bitsToRetain = ~(mask << shift); final long bitsToSet = (value & mask) << shift; synchronized ( dataAccess ) { dataAccess.setValue(i1, (dataAccess.getValue(i1) & bitsToRetain) | bitsToSet); } } @Override public Unsigned2BitType createVariable(){ return new Unsigned2BitType( 0 ); } @Override public Unsigned2BitType copy(){ return new Unsigned2BitType( get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/Unsigned4BitType.java000066400000000000000000000113471316447754700312530ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.Type; import net.imglib2.util.Fraction; /** * A {@link Type} with a bit depth of 4. * * The performance of this type is traded off for the gain in memory storage. * * @author Albert Cardona */ public class Unsigned4BitType extends AbstractIntegerBitType { // A mask for bit and, containing nBits of 1 private final static long mask = 15; // 1111 in binary // this is the constructor if you want it to read from an array public Unsigned4BitType( final NativeImg< ?, ? extends LongAccess > bitStorage ) { super( bitStorage, 4 ); } // this is the constructor if you want it to be a variable public Unsigned4BitType( final long value ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public Unsigned4BitType( final LongAccess access ) { this( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = access; } // this is the constructor if you want it to be a variable public Unsigned4BitType() { this( 0 ); } @Override public NativeImg< Unsigned4BitType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< Unsigned4BitType > storageFactory, final long dim[] ) { // create the container final NativeImg< Unsigned4BitType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, new Fraction( getBitsPerPixel(), 64 ) ); // create a Type that is linked to the container final Unsigned4BitType linkedType = new Unsigned4BitType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public Unsigned4BitType duplicateTypeOnSameNativeImg() { return new Unsigned4BitType( img ); } @Override public long get() { return (dataAccess.getValue((int)(i >>> 4)) >>> ((i & 15) << 2)) & mask; } // Crops value to within mask @Override public void set( final long value ) { /* final int k = i * 4; final int i1 = k >>> 6; // k / 64; final long shift = k % 64; */ // Same as above minus one multiplication, plus one shift (to multiply by 4) final int i1 = (int)(i >>> 4); // Same as (i * 4) / 64 = ((i << 2) >>> 6) final long shift = (i << 2) & 63; // Same as (i * 4) % 64 // Clear the bits first, then or the masked value final long bitsToRetain = ~(mask << shift); final long bitsToSet = (value & mask) << shift; synchronized ( dataAccess ) { dataAccess.setValue(i1, (dataAccess.getValue(i1) & bitsToRetain) | bitsToSet); } } @Override public Unsigned4BitType createVariable(){ return new Unsigned4BitType( 0 ); } @Override public Unsigned4BitType copy(){ return new Unsigned4BitType( get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/UnsignedByteType.java000066400000000000000000000134401316447754700313500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.ByteAccess; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class UnsignedByteType extends GenericByteType< UnsignedByteType > { // this is the constructor if you want it to read from an array public UnsignedByteType( final NativeImg< ?, ? extends ByteAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public UnsignedByteType( final int value ) { super( getCodedSignedByte( value ) ); } // this is the constructor if you want to specify the dataAccess public UnsignedByteType( final ByteAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public UnsignedByteType() { this( 0 ); } public static byte getCodedSignedByteChecked( int unsignedByte ) { if ( unsignedByte < 0 ) unsignedByte = 0; else if ( unsignedByte > 255 ) unsignedByte = 255; return getCodedSignedByte( unsignedByte ); } public static byte getCodedSignedByte( final int unsignedByte ) { return ( byte ) ( unsignedByte & 0xff ); } public static int getUnsignedByte( final byte signedByte ) { return signedByte & 0xff; } @Override public NativeImg< UnsignedByteType, ? extends ByteAccess > createSuitableNativeImg( final NativeImgFactory< UnsignedByteType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createByteInstance( dim, new Fraction() ); // create a Type that is linked to the container final UnsignedByteType linkedType = new UnsignedByteType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public UnsignedByteType duplicateTypeOnSameNativeImg() { return new UnsignedByteType( img ); } @Override public void mul( final float c ) { final int a = getUnsignedByte( getByte() ); setByte( getCodedSignedByte( Util.round( a * c ) ) ); } @Override public void mul( final double c ) { final int a = getUnsignedByte( getByte() ); setByte( getCodedSignedByte( ( int ) Util.round( a * c ) ) ); } @Override public void add( final UnsignedByteType c ) { set( get() + c.get() ); } @Override public void div( final UnsignedByteType c ) { set( get() / c.get() ); } @Override public void mul( final UnsignedByteType c ) { set( get() * c.get() ); } @Override public void sub( final UnsignedByteType c ) { set( get() - c.get() ); } public int get() { return getUnsignedByte( getByte() ); } public void set( final int f ) { setByte( getCodedSignedByte( f ) ); } @Override public int getInteger() { return get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( ( int ) f ); } @Override public void setBigInteger(final BigInteger b) { set( b.intValue() ); } @Override public double getMaxValue() { return -Byte.MIN_VALUE + Byte.MAX_VALUE; } @Override public double getMinValue() { return 0; } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Integer#hashCode(). return get(); } @Override public int compareTo( final UnsignedByteType c ) { final int a = get(); final int b = c.get(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public UnsignedByteType createVariable() { return new UnsignedByteType( 0 ); } @Override public UnsignedByteType copy() { return new UnsignedByteType( get() ); } @Override public String toString() { return "" + get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/UnsignedIntType.java000066400000000000000000000140031316447754700311730ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.IntAccess; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class UnsignedIntType extends GenericIntType< UnsignedIntType > { // this is the constructor if you want it to read from an array public UnsignedIntType( final NativeImg< ?, ? extends IntAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public UnsignedIntType( final long value ) { super( getCodedSignedInt( value ) ); } // this is the constructor if you want to specify the dataAccess public UnsignedIntType( final IntAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public UnsignedIntType() { this( 0 ); } public static int getCodedSignedIntChecked( long unsignedInt ) { if ( unsignedInt < 0 ) unsignedInt = 0; else if ( unsignedInt > 0xffffffffL ) unsignedInt = 0xffffffffL; return getCodedSignedInt( unsignedInt ); } public static int getCodedSignedInt( final long unsignedInt ) { return ( int ) ( unsignedInt & 0xffffffff ); } public static long getUnsignedInt( final int signedInt ) { return signedInt & 0xffffffffL; } @Override public NativeImg< UnsignedIntType, ? extends IntAccess > createSuitableNativeImg( final NativeImgFactory< UnsignedIntType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createIntInstance( dim, new Fraction() ); // create a Type that is linked to the container final UnsignedIntType linkedType = new UnsignedIntType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public UnsignedIntType duplicateTypeOnSameNativeImg() { return new UnsignedIntType( img ); } @Override public void mul( final float c ) { final long a = getUnsignedInt( getInt() ); setInt( getCodedSignedInt( Util.round( a * c ) ) ); } @Override public void mul( final double c ) { final long a = getUnsignedInt( getInt() ); setInt( getCodedSignedInt( ( int ) Util.round( a * c ) ) ); } @Override public void add( final UnsignedIntType c ) { set( get() + c.get() ); } @Override public void div( final UnsignedIntType c ) { set( get() / c.get() ); } @Override public void mul( final UnsignedIntType c ) { set( get() * c.get() ); } @Override public void sub( final UnsignedIntType c ) { set( get() - c.get() ); } @Override public void setOne() { set( 1 ); } @Override public void setZero() { set( 0 ); } @Override public void inc() { set( get() + 1 ); } @Override public void dec() { set( get() - 1 ); } @Override public String toString() { return "" + get(); } public long get() { return getUnsignedInt( getInt() ); } public void set( final long f ) { setInt( getCodedSignedInt( f ) ); } @Override public int getInteger() { return ( int ) get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( f ); } @Override public void setBigInteger(final BigInteger b) { set( b.longValue() ); } @Override public double getMaxValue() { return 0xffffffffL; } @Override public double getMinValue() { return 0; } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Long#hashCode(). final long value = get(); return (int) (value ^ (value >>> 32)); } @Override public int compareTo( final UnsignedIntType c ) { final long a = get(); final long b = c.get(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public UnsignedIntType createVariable() { return new UnsignedIntType( 0 ); } @Override public UnsignedIntType copy() { return new UnsignedIntType( get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/UnsignedLongType.java000066400000000000000000000176551316447754700313600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Albert Cardona * @author Mark Hiner */ public class UnsignedLongType extends GenericLongType< UnsignedLongType > { // this is the constructor if you want it to read from an array public UnsignedLongType( final NativeImg< ?, ? extends LongAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public UnsignedLongType( final long value ) { super( value ); } // this is the constructor if you want it to be a variable public UnsignedLongType( final BigInteger value ) { super( ( NativeImg< ?, ? extends LongAccess > ) null ); dataAccess = new LongArray( 1 ); set( value.longValue() ); } // this is the constructor if you want to specify the dataAccess public UnsignedLongType( final LongAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public UnsignedLongType() { this( 0 ); } @Override public NativeImg< UnsignedLongType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< UnsignedLongType > storageFactory, final long dim[] ) { // create the container final NativeImg< UnsignedLongType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, new Fraction() ); // create a Type that is linked to the container final UnsignedLongType linkedType = new UnsignedLongType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public UnsignedLongType duplicateTypeOnSameNativeImg() { return new UnsignedLongType( img ); } @Override public void mul( final float c ) { set( Util.round( ( double ) ( get() * c ) ) ); } @Override public void mul( final double c ) { set( Util.round( ( get() * c ) ) ); } @Override public void add( final UnsignedLongType c ) { set( get() + c.get() ); } /** * @see #divide(long, long) */ @Override public void div( final UnsignedLongType c ) { set( divide( get(), c.get() ) ); } /** * Unsigned division of {@code d1} by {@code d2}. * * See "Division by Invariant Integers using Multiplication", by Torbjorn * Granlund and Peter L. Montgomery, 1994. * http://gmplib.org/~tege/divcnst-pldi94.pdf * * @throws ArithmeticException * when c equals zero. */ static public final long divide( final long d1, final long d2 ) { if ( d2 < 0 ) { // d2 is larger than the maximum signed long value if ( -1 == compare( d1, d2 ) ) { // d1 is smaller than d2 return 0; } else { // d1 is larger or equal than d2 return 1; } } if ( d1 < 0 ) { // Approximate division: exact or one less than the actual value final long quotient = ( ( d1 >>> 1 ) / d2 ) << 1; final long reminder = d1 - quotient * d2; return quotient + ( -1 == compare( d2, reminder ) ? 0 : 1 ); } // Exact division, given that both d1 and d2 are smaller than // or equal to the maximum signed long value return d1 / d2; } @Override public void mul( final UnsignedLongType c ) { set( get() * c.get() ); } @Override public void sub( final UnsignedLongType c ) { set( get() - c.get() ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Long#hashCode(). final long value = get(); return ( int ) ( value ^ ( value >>> 32 ) ); } @Override public void setOne() { set( 1 ); } @Override public void setZero() { set( 0 ); } @Override public void inc() { set( get() + 1 ); } @Override public void dec() { set( get() - 1 ); } @Override public String toString() { return "" + get(); } /** * This method returns the value of the UnsignedLongType as a signed long. * To get the unsigned value, use {@link #getBigInteger()}. */ public long get() { return dataAccess.getValue( i ); } /** * This method returns the unsigned representation of this UnsignedLongType * as a {@code BigInteger}. */ @Override public BigInteger getBigInteger() { final BigInteger mask = new BigInteger( "FFFFFFFFFFFFFFFF", 16 ); return BigInteger.valueOf( get() ).and( mask ); } public void set( final long value ) { dataAccess.setValue( i, value ); } @Override public int getInteger() { return ( int ) get(); } @Override public long getIntegerLong() { return get(); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( f ); } @Override public void setBigInteger( final BigInteger b ) { set( b.longValue() ); } public void set( final BigInteger bi ) { set( bi.longValue() ); } /** * The maximum value that can be stored is {@code Math.pow( 2, 64 ) - 1}, * which can't be represented with exact precision using a double */ @Override public double getMaxValue() { return Math.pow( 2, 64 ) - 1; } // imprecise /** * Returns the true maximum value as a BigInteger, since it cannot be * precisely represented as a {@code double}. */ public BigInteger getMaxBigIntegerValue() { return new BigInteger( "+FFFFFFFFFFFFFFFF", 16 ); } @Override public double getMinValue() { return 0; } @Override public int compareTo( final UnsignedLongType c ) { return compare( get(), c.get() ); } /** * * @param a * @param b * @return -1 if {@code a < b}, 0 if {@code a == b}, 1 if {@code a > b}. */ static public final int compare( final long a, final long b ) { if ( a == b ) return 0; else { boolean test = ( a < b ); if ( ( a < 0 ) != ( b < 0 ) ) { test = !test; } return test ? -1 : 1; } } @Override public UnsignedLongType createVariable() { return new UnsignedLongType( 0 ); } @Override public UnsignedLongType copy() { return new UnsignedLongType( get() ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/UnsignedShortType.java000066400000000000000000000135071316447754700315500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.ShortAccess; import net.imglib2.util.Fraction; import net.imglib2.util.Util; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class UnsignedShortType extends GenericShortType< UnsignedShortType > { // this is the constructor if you want it to read from an array public UnsignedShortType( final NativeImg< ?, ? extends ShortAccess > img ) { super( img ); } // this is the constructor if you want it to be a variable public UnsignedShortType( final int value ) { super( getCodedSignedShort( value ) ); } // this is the constructor if you want to specify the dataAccess public UnsignedShortType( final ShortAccess access ) { super( access ); } // this is the constructor if you want it to be a variable public UnsignedShortType() { this( 0 ); } public static short getCodedSignedShortChecked( int unsignedShort ) { if ( unsignedShort < 0 ) unsignedShort = 0; else if ( unsignedShort > 65535 ) unsignedShort = 65535; return getCodedSignedShort( unsignedShort ); } public static short getCodedSignedShort( final int unsignedShort ) { return ( short ) ( unsignedShort & 0xffff ); } public static int getUnsignedShort( final short signedShort ) { return signedShort & 0xffff; } @Override public NativeImg< UnsignedShortType, ? extends ShortAccess > createSuitableNativeImg( final NativeImgFactory< UnsignedShortType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createShortInstance( dim, new Fraction() ); // create a Type that is linked to the container final UnsignedShortType linkedType = new UnsignedShortType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public UnsignedShortType duplicateTypeOnSameNativeImg() { return new UnsignedShortType( img ); } @Override public void mul( final float c ) { set( Util.round( get() * c ) ); } @Override public void mul( final double c ) { set( ( int ) Util.round( get() * c ) ); } @Override public void add( final UnsignedShortType c ) { set( get() + c.get() ); } @Override public void div( final UnsignedShortType c ) { set( get() / c.get() ); } @Override public void mul( final UnsignedShortType c ) { set( get() * c.get() ); } @Override public void sub( final UnsignedShortType c ) { set( get() - c.get() ); } @Override public void inc() { set( get() + 1 ); } @Override public void dec() { set( get() - 1 ); } public int get() { return getUnsignedShort( getShort() ); } public void set( final int f ) { setShort( getCodedSignedShort( f ) ); } @Override public int getInteger() { return get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { set( f ); } @Override public void setInteger( final long f ) { set( ( int ) f ); } @Override public void setBigInteger(final BigInteger b) { set( b.intValue() ); } @Override public double getMaxValue() { return -Short.MIN_VALUE + Short.MAX_VALUE; } @Override public double getMinValue() { return 0; } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Integer#hashCode(). return get(); } @Override public int compareTo( final UnsignedShortType c ) { final int a = get(); final int b = c.get(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public UnsignedShortType createVariable() { return new UnsignedShortType( 0 ); } @Override public UnsignedShortType copy() { return new UnsignedShortType( get() ); } @Override public String toString() { return "" + get(); } } UnsignedVariableBitLengthType.java000066400000000000000000000175021316447754700337170ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/integer/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import java.math.BigInteger; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.LongAccess; import net.imglib2.type.AbstractBit64Type; import net.imglib2.type.Type; import net.imglib2.type.numeric.IntegerType; import net.imglib2.util.Util; /** * A {@link Type} with arbitrary bit depth up to maximum 64 bits. * The behavior beyond 64 bits is undefined. * * The performance of this type is traded off for the gain in memory storage. * The {@link #set(long)} operation takes have the time as the {@link #get} operation. * The performance may degrade very slightly with increasing bit depth, but the decrease is barely noticeable. * * @author Albert Cardona * @author Stephan Preibisch */ public class UnsignedVariableBitLengthType extends AbstractBit64Type implements IntegerType< UnsignedVariableBitLengthType > { // this is the constructor if you want it to read from an array public UnsignedVariableBitLengthType( final NativeImg< ?, ? extends LongAccess > bitStorage, final int nBits ) { super( bitStorage, nBits ); } // this is the constructor if you want it to be a variable public UnsignedVariableBitLengthType( final long value, final int nBits ) { super( value, nBits ); } // this is the constructor if you want to specify the dataAccess public UnsignedVariableBitLengthType( final LongAccess access, final int nBits ) { super( access, nBits ); } // this is the constructor if you want it to be a variable public UnsignedVariableBitLengthType( final int nBits ) { super(nBits ); } @Override public NativeImg< UnsignedVariableBitLengthType, ? extends LongAccess > createSuitableNativeImg( final NativeImgFactory< UnsignedVariableBitLengthType > storageFactory, final long dim[] ) { // create the container final NativeImg< UnsignedVariableBitLengthType, ? extends LongAccess > container = storageFactory.createLongInstance( dim, getEntitiesPerPixel() ); // create a Type that is linked to the container final UnsignedVariableBitLengthType linkedType = new UnsignedVariableBitLengthType( container, nBits ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } public void set( final long value ) { setBits( value ); } public long get() { return getBits(); } @Override public void set( final UnsignedVariableBitLengthType c ) { setBits( c.getBits() ); } @Override public UnsignedVariableBitLengthType duplicateTypeOnSameNativeImg() { return new UnsignedVariableBitLengthType( img, nBits ); } @Override public UnsignedVariableBitLengthType createVariable(){ return new UnsignedVariableBitLengthType( nBits ); } @Override public UnsignedVariableBitLengthType copy(){ return new UnsignedVariableBitLengthType( getBits(), nBits ); } /** @see UnsignedLongType#divide(long, long) */ @Override public void div(final UnsignedVariableBitLengthType t) { setBits( UnsignedLongType.divide( getBits(), t.getBits() ) ); } /** @see UnsignedLongType#compare(long, long) */ @Override public int compareTo( final UnsignedVariableBitLengthType t ) { return UnsignedLongType.compare( getBits(), t.getBits() ); } @Override public void mul( final float c ) { setReal( getRealDouble() * c ); } @Override public void mul( final double c ) { setReal( getRealDouble() * c ); } @Override public float getRealFloat() { return getIntegerLong(); } @Override public double getRealDouble() { return getIntegerLong(); } @Override public void setReal( final float real ){ setInteger( Util.round( real ) ); } @Override public void setReal( final double real ){ setInteger( Util.round( real ) ); } @Override public void setZero() { setInteger( 0 ); } @Override public void setOne() { setInteger( 1 ); } @Override public int getBitsPerPixel() { return nBits; } @Override public double getMinIncrement() { return 1; } @Override public String toString() { return "" + getIntegerLong(); } @Override public int getInteger() { return (int)get(); } @Override public long getIntegerLong() { return get(); } @Override public BigInteger getBigInteger() { if( get() < 0 ) return BigInteger.valueOf(get()).add(new BigInteger("2", 10).pow(nBits)); return BigInteger.valueOf( get() ); } @Override public void setInteger( final int f ) { setBits( f ); } @Override public void setInteger( final long f ) { setBits( f ); } @Override public void setBigInteger(final BigInteger b) { setBits( b.longValue() ); } /** The maximum value that can be stored is {@code Math.pow(2, nBits) -1}. */ @Override public double getMaxValue() { return Math.pow( 2, getBitsPerPixel() ) -1; } @Override public double getMinValue() { return 0; } @Override public void inc() { setBits(get() + 1); } @Override public void dec() { set(get() - 1); } @Override public void add(final UnsignedVariableBitLengthType t) { set(get() + t.get()); } @Override public void sub(final UnsignedVariableBitLengthType t) { set(get() - t.get()); } @Override public void mul(final UnsignedVariableBitLengthType t) { set(get() * t.get()); } @Override public float getImaginaryFloat() { return 0; } @Override public double getImaginaryDouble() { return 0; } @Override public void setImaginary( final float complex ){} @Override public void setImaginary( final double complex ){} @Override public float getPhaseFloat() { return 0; } @Override public double getPhaseDouble() { return 0; } @Override public float getPowerFloat() { return getRealFloat(); } @Override public double getPowerDouble() { return getRealDouble(); } @Override public void setComplexNumber( final float r, final float i ) { setReal( r ); } @Override public void setComplexNumber( final double r, final double i ) { setReal( r ); } @Override public void complexConjugate(){} /** * Default test at long precision. Please override for types longer than 64bit. * * @param t * @return */ @Override public boolean valueEquals( final UnsignedVariableBitLengthType t ) { return getBits() == t.getBits(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/real/000077500000000000000000000000001316447754700245275ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/real/AbstractRealType.java000066400000000000000000000102511316447754700306020ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.real; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.complex.AbstractComplexType; /** * TODO * */ public abstract class AbstractRealType< T extends AbstractRealType< T >> extends AbstractComplexType< T > implements RealType< T > { @Override public float getImaginaryFloat() { return 0; } @Override public double getImaginaryDouble() { return 0; } @Override public void setImaginary( final float complex ) {} @Override public void setImaginary( final double complex ) {} @Override public void inc() { setReal( getRealDouble() + 1 ); } @Override public void dec() { setReal( getRealDouble() - 1 ); } @Override public void set( final T c ) { setReal( c.getRealDouble() ); } @Override public void mul( final float c ) { setReal( getRealDouble() * c ); } @Override public void mul( final double c ) { setReal( getRealDouble() * c ); } @Override public void add( final T c ) { setReal( getRealDouble() + c.getRealDouble() ); } @Override public void div( final T c ) { setReal( getRealDouble() / c.getRealDouble() ); } @Override public void mul( final T c ) { setReal( getRealDouble() * c.getRealDouble() ); } @Override public void sub( final T c ) { setReal( getRealDouble() - c.getRealDouble() ); } @Override public void setZero() { setReal( 0 ); } @Override public void setOne() { setReal( 1 ); } @Override public boolean equals( final Object o ) { if ( !getClass().isInstance(o) ) return false; @SuppressWarnings("unchecked") final T t = (T) o; return compareTo(t) == 0; } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Double#hashCode(). final long bits = Double.doubleToLongBits(getRealDouble()); return (int) (bits ^ (bits >>> 32)); } @Override public int compareTo( final T c ) { final double a = getRealDouble(); final double b = c.getRealDouble(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public float getPowerFloat() { return getRealFloat(); } @Override public double getPowerDouble() { return getRealDouble(); } @Override public float getPhaseFloat() { return 0; } @Override public double getPhaseDouble() { return 0; } @Override public String toString() { return "" + getRealDouble(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/real/DoubleType.java000066400000000000000000000122261316447754700274510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.real; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.DoubleAccess; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class DoubleType extends AbstractRealType< DoubleType > implements NativeType< DoubleType > { private int i = 0; final protected NativeImg< ?, ? extends DoubleAccess > img; // the DataAccess that holds the information protected DoubleAccess dataAccess; // this is the constructor if you want it to read from an array public DoubleType( final NativeImg< ?, ? extends DoubleAccess > doubleStorage ) { img = doubleStorage; } // this is the constructor if you want it to be a variable public DoubleType( final double value ) { img = null; dataAccess = new DoubleArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public DoubleType( final DoubleAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public DoubleType() { this( 0 ); } @Override public NativeImg< DoubleType, ? extends DoubleAccess > createSuitableNativeImg( final NativeImgFactory< DoubleType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createDoubleInstance( dim, new Fraction() ); // create a Type that is linked to the container final DoubleType linkedType = new DoubleType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public DoubleType duplicateTypeOnSameNativeImg() { return new DoubleType( img ); } public double get() { return dataAccess.getValue( i ); } public void set( final double f ) { dataAccess.setValue( i, f ); } @Override public float getRealFloat() { return ( float ) get(); } @Override public double getRealDouble() { return get(); } @Override public void setReal( final float real ) { set( real ); } @Override public void setReal( final double real ) { set( real ); } @Override public double getMaxValue() { return Double.MAX_VALUE; } @Override public double getMinValue() { return -Double.MAX_VALUE; } @Override public double getMinIncrement() { return Double.MIN_VALUE; } @Override public DoubleType createVariable() { return new DoubleType( 0 ); } @Override public DoubleType copy() { return new DoubleType( get() ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateIndex( final int index ) { i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 64; } @Override public boolean valueEquals( DoubleType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/numeric/real/FloatType.java000066400000000000000000000143451316447754700273100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.real; import net.imglib2.img.NativeImg; import net.imglib2.img.NativeImgFactory; import net.imglib2.img.basictypeaccess.FloatAccess; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.type.NativeType; import net.imglib2.util.Fraction; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class FloatType extends AbstractRealType< FloatType > implements NativeType< FloatType > { private int i = 0; final protected NativeImg< ?, ? extends FloatAccess > img; // the DataAccess that holds the information protected FloatAccess dataAccess; // this is the constructor if you want it to read from an array public FloatType( final NativeImg< ?, ? extends FloatAccess > floatStorage ) { img = floatStorage; } // this is the constructor if you want it to be a variable public FloatType( final float value ) { img = null; dataAccess = new FloatArray( 1 ); set( value ); } // this is the constructor if you want to specify the dataAccess public FloatType( final FloatAccess access ) { img = null; dataAccess = access; } // this is the constructor if you want it to be a variable public FloatType() { this( 0 ); } @Override public NativeImg< FloatType, ? extends FloatAccess > createSuitableNativeImg( final NativeImgFactory< FloatType > storageFactory, final long dim[] ) { // create the container final NativeImg container = storageFactory.createFloatInstance( dim, new Fraction() ); // create a Type that is linked to the container final FloatType linkedType = new FloatType( container ); // pass it to the NativeContainer container.setLinkedType( linkedType ); return container; } @Override public void updateContainer( final Object c ) { dataAccess = img.update( c ); } @Override public FloatType duplicateTypeOnSameNativeImg() { return new FloatType( img ); } public float get() { return dataAccess.getValue( i ); } public void set( final float f ) { dataAccess.setValue( i, f ); } @Override public float getRealFloat() { return get(); } @Override public double getRealDouble() { return get(); } @Override public void setReal( final float real ) { set( real ); } @Override public void setReal( final double real ) { set( ( float ) real ); } @Override public double getMaxValue() { return Float.MAX_VALUE; } @Override public double getMinValue() { return -Float.MAX_VALUE; } @Override public double getMinIncrement() { return Float.MIN_VALUE; } @Override public void mul( final float c ) { set( get() * c ); } @Override public void mul( final double c ) { set( ( float ) ( get() * c ) ); } @Override public void add( final FloatType c ) { set( get() + c.get() ); } @Override public void div( final FloatType c ) { set( get() / c.get() ); } @Override public void mul( final FloatType c ) { set( get() * c.get() ); } @Override public void sub( final FloatType c ) { set( get() - c.get() ); } @Override public int hashCode() { // NB: Use the same hash code as java.lang.Float#hashCode(). return Float.floatToIntBits(get()); } @Override public int compareTo( final FloatType c ) { final float a = get(); final float b = c.get(); if ( a > b ) return 1; else if ( a < b ) return -1; else return 0; } @Override public void set( final FloatType c ) { set( c.get() ); } @Override public void setOne() { set( 1 ); } @Override public void setZero() { set( 0 ); } @Override public void inc() { float a = get(); set( ++a ); } @Override public void dec() { float a = get(); set( --a ); } @Override public FloatType createVariable() { return new FloatType( 0 ); } @Override public FloatType copy() { return new FloatType( get() ); } @Override public Fraction getEntitiesPerPixel() { return new Fraction(); } @Override public void updateIndex( final int index ) { i = index; } @Override public int getIndex() { return i; } @Override public void incIndex() { ++i; } @Override public void incIndex( final int increment ) { i += increment; } @Override public void decIndex() { --i; } @Override public void decIndex( final int decrement ) { i -= decrement; } @Override public int getBitsPerPixel() { return 32; } @Override public boolean valueEquals( FloatType t ) { return get() == t.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/000077500000000000000000000000001316447754700241605ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/Add.java000066400000000000000000000037151316447754700255210ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch * * @param */ public interface Add< T > { public void add( T c ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/Div.java000066400000000000000000000037151316447754700255530ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch * * @param */ public interface Div< T > { public void div( T c ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/Mul.java000066400000000000000000000037151316447754700255660ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch * * @param */ public interface Mul< T > { public void mul( T c ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/MulFloatingPoint.java000066400000000000000000000037461316447754700302700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch */ public interface MulFloatingPoint { public void mul( float c ); public void mul( double c ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/SetOne.java000066400000000000000000000036701316447754700262260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch */ public interface SetOne { public void setOne(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/SetZero.java000066400000000000000000000036721316447754700264260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch */ public interface SetZero { public void setZero(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/Sub.java000066400000000000000000000037151316447754700255620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * @author Stephan Preibisch * * @param */ public interface Sub< T > { public void sub( T c ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/operators/ValueEquals.java000066400000000000000000000042311316447754700272520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.operators; /** * Tests equivalency of values. This is related to * {@link Object#equals(Object)} but for typed parameters, without reference * equality, and without side effects in the JDK when done otherwise. * * @author Stephan Saalfeld */ public interface ValueEquals< T > { public boolean valueEquals( T t ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/volatiles/000077500000000000000000000000001316447754700241445ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/volatiles/AbstractVolatileNumericType.java000066400000000000000000000065051316447754700324450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.volatiles; import net.imglib2.Volatile; import net.imglib2.type.numeric.NumericType; /** * Abstract base class for {@link VolatileNumericType}s that wrap a * {@link NumericType} that is either VALID or INVALID. * * @param * wrapped {@link NumericType}. * @param * type of derived concrete class. * * @author Stephan Saalfeld */ abstract public class AbstractVolatileNumericType< N extends NumericType< N >, T extends AbstractVolatileNumericType< N, T > > extends Volatile< N > implements NumericType< T > { public AbstractVolatileNumericType( final N t, final boolean valid ) { super( t, valid ); } public AbstractVolatileNumericType( final N t ) { this( t, false ); } @Override public void set( final T c ) { t.set( c.t ); valid = c.valid; } @Override public void add( final T c ) { t.add( c.t ); valid &= c.valid; } @Override public void sub( final T c ) { t.sub( c.t ); valid &= c.valid; } @Override public void mul( final T c ) { t.mul( c.t ); valid &= c.valid; } @Override public void div( final T c ) { t.div( c.t ); valid &= c.valid; } @Override public void setZero() { t.setZero(); } @Override public void setOne() { t.setOne(); } @Override public void mul( final float c ) { t.mul( c ); } @Override public void mul( final double c ) { t.mul( c ); } @Override public boolean valueEquals( T other ) { return ( isValid() && other.isValid() ) && t.valueEquals( other.t ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/volatiles/AbstractVolatileRealType.java000066400000000000000000000116241316447754700317240ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.volatiles; import net.imglib2.Volatile; import net.imglib2.type.numeric.RealType; /** * Abstract base class for {@link VolatileRealType}s that wrap {@link RealType}. * * @param * wrapped {@link RealType}. * @param * type of derived concrete class. * * @author Tobias Pietzsch * @author Stephan Saalfeld */ public abstract class AbstractVolatileRealType< R extends RealType< R >, T extends AbstractVolatileRealType< R, T > > extends Volatile< R > implements RealType< T > { public AbstractVolatileRealType( final R t, final boolean valid ) { super( t, valid ); } @Override public double getRealDouble() { return t.getRealDouble(); } @Override public float getRealFloat() { return t.getRealFloat(); } @Override public double getImaginaryDouble() { return t.getImaginaryDouble(); } @Override public float getImaginaryFloat() { return t.getImaginaryFloat(); } @Override public void setReal( final float f ) { t.setReal( f ); } @Override public void setReal( final double f ) { t.setReal( f ); } @Override public void setImaginary( final float f ) { t.setImaginary( f ); } @Override public void setImaginary( final double f ) { t.setImaginary( f ); } @Override public void setComplexNumber( final float r, final float i ) { t.setComplexNumber( r, i ); } @Override public void setComplexNumber( final double r, final double i ) { t.setComplexNumber( r, i ); } @Override public float getPowerFloat() { return t.getPowerFloat(); } @Override public double getPowerDouble() { return t.getPowerDouble(); } @Override public float getPhaseFloat() { return t.getPhaseFloat(); } @Override public double getPhaseDouble() { return t.getPhaseDouble(); } @Override public void complexConjugate() { t.complexConjugate(); } @Override public int compareTo( final T o ) { return t.compareTo( o.t ); } @Override public void inc() { t.inc(); } @Override public void dec() { t.dec(); } @Override public double getMaxValue() { return t.getMaxValue(); } @Override public double getMinValue() { return t.getMinValue(); } @Override public double getMinIncrement() { return t.getMinIncrement(); } @Override public int getBitsPerPixel() { return t.getBitsPerPixel(); } @Override public void set( final T c ) { t.set( c.t ); valid = c.valid; } @Override public void add( final T c ) { t.add( c.t ); valid &= c.valid; } @Override public void sub( final T c ) { t.sub( c.t ); valid &= c.valid; } @Override public void mul( final T c ) { t.mul( c.t ); valid &= c.valid; } @Override public void div( final T c ) { t.div( c.t ); valid &= c.valid; } @Override public void setZero() { t.setZero(); } @Override public void setOne() { t.setOne(); } @Override public void mul( final float c ) { t.mul( c ); } @Override public void mul( final double c ) { t.mul( c ); } @Override public boolean valueEquals( T other ) { return ( isValid() && other.isValid() ) && t.valueEquals( other.t ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/volatiles/VolatileNumericType.java000066400000000000000000000050351316447754700307560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.volatiles; import net.imglib2.type.numeric.NumericType; /** * Something volatile that has a value and is either VALID or INVALID. * * @author Stephan Saalfeld */ public class VolatileNumericType< T extends NumericType< T > > extends AbstractVolatileNumericType< T, VolatileNumericType< T > > { public VolatileNumericType( final T t, final boolean valid ) { super( t, valid ); } public VolatileNumericType( final T t ) { this( t, false ); } @Override public VolatileNumericType< T > createVariable() { return new VolatileNumericType< T >( t.createVariable(), false ); } @Override public VolatileNumericType< T > copy() { return new VolatileNumericType< T >( t.copy(), false ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/type/volatiles/VolatileRealType.java000066400000000000000000000047741316447754700302500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.volatiles; import net.imglib2.type.numeric.RealType; /** * Something volatile that has a value and is either VALID or INVALID. * * @author Stephan Saalfeld */ public class VolatileRealType< T extends RealType< T > > extends AbstractVolatileRealType< T, VolatileRealType< T > > { public VolatileRealType( final T t, final boolean valid ) { super( t, valid ); } public VolatileRealType( final T t ) { this( t, false ); } @Override public VolatileRealType< T > createVariable() { return new VolatileRealType< T >( t.createVariable(), false ); } @Override public VolatileRealType< T > copy() { return new VolatileRealType< T >( t.copy(), false ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/000077500000000000000000000000001316447754700221365ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/BenchmarkHelper.java000066400000000000000000000104721316447754700260370ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import java.util.ArrayList; import java.util.Collections; /** * Tools for setting up basic benchmarks. * * Call {@link #benchmark(int, Runnable)} with the number of iterations and a * {@link Runnable} to benchmark to obtain a list of run-times in milliseconds. * * @author Tobias Pietzsch */ public class BenchmarkHelper { /** * Run a benchmark numRuns times and record the milliseconds taken for each * run. * * @param numRuns * how many times to run the benchmark. * @param benchmark * the benchmark. * @return run-times for each run (in milliseconds). */ public static ArrayList< Long > benchmark( final int numRuns, final Runnable benchmark ) { final ArrayList< Long > times = new ArrayList< Long >( numRuns ); for ( int i = 0; i < numRuns; ++i ) { final long startTime = System.currentTimeMillis(); benchmark.run(); final long endTime = System.currentTimeMillis(); times.add( endTime - startTime ); } return times; } /** * Run a benchmark numRuns times and print the results to {@link System#out} * . * * @param numRuns * how many times to run the benchmark. * @param printIndividualTimes * whether to print the time for every individual run or just the * median. * @param b * the benchmark. */ public static void benchmarkAndPrint( final int numRuns, final boolean printIndividualTimes, final Runnable b ) { final ArrayList< Long > times = new ArrayList< Long >( 100 ); for ( int i = 0; i < numRuns; ++i ) { final long startTime = System.currentTimeMillis(); b.run(); final long endTime = System.currentTimeMillis(); times.add( endTime - startTime ); } if ( printIndividualTimes ) { for ( int i = 0; i < numRuns; ++i ) System.out.println( "run " + i + ": " + times.get( i ) + " ms" ); System.out.println(); } Collections.sort( times ); System.out.println( "median: " + median( times ) + " ms" ); System.out.println( "best: " + times.get( 0 ) + " ms" ); System.out.println(); } /** * Compute median of a sorted list of {@link Long}s. * * @param values * sorted list of values. * @return median of the values. */ private static long median( final ArrayList< Long > values ) { if ( values.size() % 2 == 1 ) return values.get( ( values.size() + 1 ) / 2 - 1 ); final long lower = values.get( values.size() / 2 - 1 ); final long upper = values.get( values.size() / 2 ); return ( lower + upper ) / 2; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/Binning.java000066400000000000000000000101751316447754700243710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; /** * Static utility methods to convert from a value to a bin, useful for dealing * with histograms and LUTs. * * @author Aivar Grislis */ public class Binning { // -- Utility methods -- /** * Convert value to bin number. *

* This variant is inclusive, it assigns all values to the range * 0..(bins-1). * * @param bins * @param min * @param max * @param value * @return bin number 0...(bins-1) */ public static int valueToBin( final int bins, final double min, final double max, final double value ) { int bin = exclusiveValueToBin( bins, min, max, value ); bin = Math.max( bin, 0 ); bin = Math.min( bin, bins - 1 ); return bin; } /** * Convert value to bin number. *

* This variant is exclusive, not all values map to the range 0...(bins-1). */ public static int exclusiveValueToBin( final int bins, final double min, final double max, final double value ) { int bin; if ( max != min ) { if ( value != max ) { // convert in-range values to 0.0...1.0 final double temp = ( value - min ) / ( max - min ); // note multiply by bins, not (bins - 1) // note floor is needed so that small negative values go to -1 bin = ( int ) Math.floor( temp * bins ); } else { // value == max, special case, otherwise 1.0 * bins is bins bin = bins - 1; } } else { // max == min, degenerate case bin = bins / 2; } return bin; } /** * Returns array of left edge values for each bin. */ public static double[] edgeValuesPerBin( final int bins, final double min, final double max ) { final double[] edgeValues = new double[ bins ]; for ( int i = 0; i < bins; ++i ) { edgeValues[ i ] = min + ( max - min ) * i / bins; } return edgeValues; } /** * Returns array of center values for each bin. */ public static double[] centerValuesPerBin( final int bins, final double min, final double max ) { final double[] edgeValues = edgeValuesPerBin( bins, min, max ); final double[] centerValues = new double[ bins ]; // average the edge values to get centers for ( int i = 0; i < bins - 1; ++i ) { centerValues[ i ] = ( edgeValues[ i ] + edgeValues[ i + 1 ] ) / 2; } // special case for last bin centerValues[ bins - 1 ] = ( edgeValues[ bins - 1 ] + max ) / 2; return centerValues; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/ConstantUtils.java000066400000000000000000000104531316447754700256160ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import net.imglib2.Interval; import net.imglib2.Point; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.RealInterval; import net.imglib2.RealPoint; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; import net.imglib2.view.Views; public class ConstantUtils { public static < T > RandomAccessible< T > constantRandomAccessible( final T constant, final int numDimensions ) { return new RandomAccessible< T >() { @Override public int numDimensions() { return numDimensions; } final class ConstantRandomAccess extends Point implements RandomAccess< T > { public ConstantRandomAccess() { super( numDimensions ); } @Override public T get() { return constant; } @Override public ConstantRandomAccess copy() { return new ConstantRandomAccess(); } @Override public ConstantRandomAccess copyRandomAccess() { return copy(); } } @Override public RandomAccess< T > randomAccess() { return new ConstantRandomAccess(); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return randomAccess(); } }; } public static < T > RandomAccessibleInterval< T > constantRandomAccessibleInterval( final T constant, final int numDimensions, final Interval interval ) { return Views.interval( constantRandomAccessible( constant, numDimensions ), interval ); } public static < T > RealRandomAccessible< T > constantRealRandomAccessible( final T constant, final int numDimensions ) { return new RealRandomAccessible< T >() { @Override public int numDimensions() { return numDimensions; } final class ConstantRealRandomAccess extends RealPoint implements RealRandomAccess< T > { public ConstantRealRandomAccess() { super( numDimensions ); } @Override public T get() { return constant; } @Override public ConstantRealRandomAccess copy() { return new ConstantRealRandomAccess(); } @Override public ConstantRealRandomAccess copyRealRandomAccess() { return copy(); } } @Override public ConstantRealRandomAccess realRandomAccess() { return new ConstantRealRandomAccess(); } @Override public ConstantRealRandomAccess realRandomAccess( final RealInterval interval ) { return realRandomAccess(); } }; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/Fraction.java000066400000000000000000000072261316447754700245550ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; /** * Implements the concept of fractions * * @author Stephan Preibisch */ public class Fraction { long numerator, denominator; /** * Creates a new fraction with the respective values * * @param numerator (above fraction bar) * @param denominator (below fraction bar) */ public Fraction( final long numerator, final long denominator ) { this.numerator = numerator; this.denominator = denominator; } /** * Instantiate a {@link Fraction} with a value of 1 */ public Fraction() { this( 1, 1 ); } /** * @return - the numerator (above the fraction bar) */ public long getNumerator() { return numerator; } /** * @return - the denominator (below the fraction bar) */ public long getDenominator() { return denominator; } /** * @return - an estimate of the ratio in double, i.e. numerator/denominator */ public double getRatio() { return (double)numerator / (double)denominator; } /** * Inverts this fraction by exchanging numerator and denominator */ public void invert() { final long tmp = numerator; numerator = denominator; denominator = tmp; } public void mul( final Fraction fraction ) { this.numerator *= fraction.getNumerator(); this.denominator *= fraction.getDenominator(); } public void div( final Fraction fraction ) { this.numerator *= fraction.getDenominator(); this.denominator *= fraction.getNumerator(); } /** * Multiply the value with this fraction. Return the ceiled * value (e.g. 10.2 = 11) if the result is a fraction. * * @param value * @return */ public long mulCeil( final long value ) { final long tmp = value * numerator; if ( tmp % denominator != 0 ) return tmp / denominator + 1; else return tmp / denominator; } @Override public Fraction clone() { return new Fraction( numerator, denominator ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/ImgUtil.java000066400000000000000000000230461316447754700243600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import net.imglib2.Cursor; import net.imglib2.img.Img; import net.imglib2.type.BooleanType; import net.imglib2.type.numeric.IntegerType; import net.imglib2.type.numeric.RealType; /** * This class contains static methods for copying image data to and from Img * instances. It was developed to support access to imglib from applications * that can't rely on JIT compilation and that access imglib via the JVM or * through JNI (specifically CellProfiler). * * * @author Tobias Pietzsch * @author Stephan Preibisch * @author Stephan Saalfeld * @author Lee Kamentsky */ public class ImgUtil { /** * Copy a flat array of doubles into an Img. * * The flat array should be visualized as a series of concatenated rasters. * Each raster element has an associated coordinate location. The stride * array provides the address of that element: multiply the coordinate at * each dimension by its corresponding stride and sum the result to get the * address of the raster element. * * For instance, a 10 x 10 raster image has a stride of { 1, 10 }. * * @param * - the type of the destination image data * @param src * - the source of the data. This array must be large enough to * encompass all addressed elements. * @param offset * - the offset to the element at the origin * @param stride * - for each dimension, the multiplier in that dimension to * address an axis element in that dimension * @param dest * - the destination for the copy */ public static < T extends RealType< T >> void copy( final double[] src, final int offset, final int[] stride, final Img< T > dest ) { final Cursor< T > c = dest.localizingCursor(); final int[] location = new int[ dest.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } t.setReal( src[ this_offset ] ); } } /** * @see ImgUtil#copy(double[], int, int[], Img) */ public static < T extends RealType< T >> void copy( final float[] src, final int offset, final int[] stride, final Img< T > dest ) { final Cursor< T > c = dest.localizingCursor(); final int[] location = new int[ dest.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } t.setReal( src[ this_offset ] ); } } /** * @see ImgUtil#copy(double[], int, int[], Img) */ public static < T extends IntegerType< T >> void copy( final long[] src, final int offset, final int[] stride, final Img< T > dest ) { final Cursor< T > c = dest.localizingCursor(); final int[] location = new int[ dest.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } t.setInteger( src[ this_offset ] ); } } /** * @see ImgUtil#copy(double[], int, int[], Img) */ public static < T extends IntegerType< T >> void copy( final int[] src, final int offset, final int[] stride, final Img< T > dest ) { final Cursor< T > c = dest.localizingCursor(); final int[] location = new int[ dest.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } t.setInteger( src[ this_offset ] ); } } /** * @see ImgUtil#copy(double[], int, int[], Img) */ public static < T extends BooleanType< T >> void copy( final boolean[] src, final int offset, final int[] stride, final Img< T > dest ) { final Cursor< T > c = dest.localizingCursor(); final int[] location = new int[ dest.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } t.set( src[ this_offset ] ); } } /** * Copy the contents of an Img to a double array * * @param * the Img's type * @param src * copy data from this Img * @param dest * the destination array * @param offset * the offset to the origin element in the destination array * @param stride * the stride into the destination array for each dimension * * @see ImgUtil#copy(double[], int, int[], Img) for a more comprehensive * description of addressing */ public static < T extends RealType< T >> void copy( final Img< T > src, final double[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.getRealDouble(); } } /** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends RealType< T >> void copy( final Img< T > src, final float[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.getRealFloat(); } } /** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends IntegerType< T >> void copy( final Img< T > src, final long[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.getIntegerLong(); } } /** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends IntegerType< T >> void copy( final Img< T > src, final int[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.getInteger(); } } /** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends BooleanType< T >> void copy( final Img< T > src, final boolean[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.get(); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/IntervalIndexer.java000066400000000000000000000303671316447754700261150ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import net.imglib2.Dimensions; import net.imglib2.Localizable; import net.imglib2.Positionable; /** * N-dimensional data is often stored in a flat 1-dimensional array. This class * provides convenience methods to translate between N-dimensional indices * (positions) and 1-dimensional indices. * * * @author Tobias Pietzsch */ public class IntervalIndexer { final static public int positionToIndex( final int[] position, final int[] dimensions ) { final int maxDim = dimensions.length - 1; int i = position[ maxDim ]; for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions[ d ] + position[ d ]; return i; } final static public int positionToIndex( final long[] position, final int[] dimensions ) { final int maxDim = dimensions.length - 1; int i = ( int ) position[ maxDim ]; for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions[ d ] + ( int ) position[ d ]; return i; } final static public long positionToIndex( final long[] position, final long[] dimensions ) { final int maxDim = dimensions.length - 1; long i = position[ maxDim ]; for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions[ d ] + position[ d ]; return i; } final static public long positionToIndex( final Localizable position, final Dimensions dimensions ) { final int maxDim = dimensions.numDimensions() - 1; long i = position.getLongPosition( maxDim ); for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions.dimension( d ) + position.getLongPosition( d ); return i; } final static public long positionWithOffsetToIndex( final long[] position, final long[] dimensions, final long[] offsets ) { final int maxDim = dimensions.length - 1; long i = position[ maxDim ] - offsets[ maxDim ]; for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions[ d ] + position[ d ] - offsets[ d ]; return i; } final static public int positionWithOffsetToIndex( final long[] position, final int[] dimensions, final long[] offsets ) { final int maxDim = dimensions.length - 1; int i = ( int ) ( position[ maxDim ] - offsets[ maxDim ] ); for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions[ d ] + ( int ) ( position[ d ] - offsets[ d ] ); return i; } final static public int positionWithOffsetToIndex( final int[] position, final int[] dimensions, final int[] offsets ) { final int maxDim = dimensions.length - 1; int i = position[ maxDim ] - offsets[ maxDim ]; for ( int d = maxDim - 1; d >= 0; --d ) i = i * dimensions[ d ] + position[ d ] - offsets[ d ]; return i; } final static public void indexToPosition( int index, final int[] dimensions, final int[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final int j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPosition( long index, final long[] dimensions, final int[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = ( int ) ( index - j * dimensions[ d ] ); index = j; } position[ maxDim ] = ( int ) index; } final static public void indexToPosition( int index, final int[] dimensions, final long[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final int j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPosition( long index, final long[] dimensions, final long[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPosition( long index, final Dimensions dimensions, final Positionable position ) { final int maxDim = dimensions.numDimensions() - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions.dimension( d ); position.setPosition( index - j * dimensions.dimension( d ), d ); index = j; } position.setPosition( index, maxDim ); } final static public void indexToPosition( int index, final int[] dimensions, final float[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final int j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPosition( long index, final long[] dimensions, final float[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPosition( int index, final int[] dimensions, final double[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final int j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPosition( long index, final long[] dimensions, final double[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ]; index = j; } position[ maxDim ] = index; } final static public void indexToPositionWithOffset( int index, final int[] dimensions, final int[] offsets, final int[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final int j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ] + offsets[ d ]; index = j; } position[ maxDim ] = index + offsets[ maxDim ]; } final static public void indexToPositionWithOffset( int index, final int[] dimensions, final long[] offsets, final long[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final int j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ] + offsets[ d ]; index = j; } position[ maxDim ] = index + offsets[ maxDim ]; } final static public void indexToPositionWithOffset( long index, final long[] dimensions, final long[] offsets, final long[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ] + offsets[ d ]; index = j; } position[ maxDim ] = index + offsets[ maxDim ]; } final static public void indexToPositionWithOffset( long index, final long[] dimensions, final long[] offsets, final int[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = ( int ) ( index - j * dimensions[ d ] + offsets[ d ] ); index = j; } position[ maxDim ] = ( int ) ( index + offsets[ maxDim ] ); } final static public void indexToPositionWithOffset( long index, final long[] dimensions, final long[] offsets, final float[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ] + offsets[ d ]; index = j; } position[ maxDim ] = index + offsets[ maxDim ]; } final static public void indexToPositionWithOffset( long index, final long[] dimensions, final long[] offsets, final double[] position ) { final int maxDim = dimensions.length - 1; for ( int d = 0; d < maxDim; ++d ) { final long j = index / dimensions[ d ]; position[ d ] = index - j * dimensions[ d ] + offsets[ d ]; index = j; } position[ maxDim ] = index + offsets[ maxDim ]; } final static public int indexToPosition( final int index, final int[] dimensions, final int dimension ) { int step = 1; for ( int d = 0; d < dimension; ++d ) step *= dimensions[ d ]; return ( index / step ) % dimensions[ dimension ]; } final static public long indexToPosition( final long index, final long[] dimensions, final int dimension ) { int step = 1; for ( int d = 0; d < dimension; ++d ) step *= dimensions[ d ]; return ( index / step ) % dimensions[ dimension ]; } final static public int indexToPositionWithOffset( final int index, final int[] dimensions, final int[] offsets, final int dimension ) { return indexToPosition( index, dimensions, dimension ) + offsets[ dimension ]; } final static public int indexToPosition( final int index, final int[] dimensions, final int[] steps, final int dimension ) { return ( index / steps[ dimension ] ) % dimensions[ dimension ]; } final static public long indexToPosition( final long index, final long[] dimensions, final long[] steps, final int dimension ) { return ( index / steps[ dimension ] ) % dimensions[ dimension ]; } final static public int indexToPositionWithOffset( final int index, final int[] dimensions, final int[] steps, final int[] offset, final int dimension ) { return indexToPosition( index, dimensions, steps, dimension ) + offset[ dimension ]; } public static long indexToPositionWithOffset( final int index, final int[] dimensions, final int[] steps, final long[] offset, final int dimension ) { return indexToPosition( index, dimensions, steps, dimension ) + offset[ dimension ]; } final static public long indexToPositionWithOffset( final long index, final long[] dimensions, final long[] steps, final long[] offsets, final int dimension ) { return indexToPosition( index, dimensions, steps, dimension ) + offsets[ dimension ]; } /** * Create allocation step array from the dimensions of an N-dimensional * array. * * @param dimensions * @param steps */ public static void createAllocationSteps( final long[] dimensions, final long[] steps ) { steps[ 0 ] = 1; for ( int d = 1; d < dimensions.length; ++d ) steps[ d ] = steps[ d - 1 ] * dimensions[ d - 1 ]; } /** * Create allocation step array from the dimensions of an N-dimensional * array. * * @param dimensions * @param steps */ public static void createAllocationSteps( final int[] dimensions, final int[] steps ) { steps[ 0 ] = 1; for ( int d = 1; d < dimensions.length; ++d ) steps[ d ] = steps[ d - 1 ] * dimensions[ d - 1 ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/Intervals.java000066400000000000000000000554041316447754700247600ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import net.imglib2.Dimensions; import net.imglib2.FinalDimensions; import net.imglib2.FinalInterval; import net.imglib2.FinalRealInterval; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RealInterval; import net.imglib2.RealLocalizable; /** * Convenience methods for manipulating {@link Interval Intervals}. * * @author Tobias Pietzsch */ public class Intervals { /** * Create a {@link FinalInterval} from a parameter list comprising minimum * coordinates and size. For example, to create a 2D interval from (10, 10) * to (20, 40) use createMinSize( 10, 10, 11, 31 ). * * @param minsize * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the dimensions of the interval. * @return interval with the specified boundaries */ public static FinalInterval createMinSize( final long... minsize ) { return FinalInterval.createMinSize( minsize ); } /** * Create a {@link FinalInterval} from a parameter list comprising minimum * and maximum coordinates. For example, to create a 2D interval from (10, * 10) to (20, 40) use createMinMax( 10, 10, 20, 40 ). * * @param minmax * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the maximum of the interval. * @return interval with the specified boundaries */ public static FinalInterval createMinMax( final long... minmax ) { return FinalInterval.createMinMax( minmax ); } /** * THIS METHOD WILL BE REMOVED IN A FUTURE RELEASE. It was mistakenly * introduced, analogous to {@link #createMinSize(long...)} for integer * intervals. Dimension is not defined for {@link RealInterval} and * computing the max as min + dim - 1 does not make sense. * *

* Create a {@link FinalRealInterval} from a parameter list comprising * minimum coordinates and size. For example, to create a 2D interval from * (10, 10) to (20, 40) use createMinSize( 10, 10, 11, 31 ). * * @param minsize * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the dimensions of the interval. * @return interval with the specified boundaries */ @Deprecated public static FinalRealInterval createMinSizeReal( final double... minsize ) { return FinalRealInterval.createMinSize( minsize ); } /** * Create a {@link FinalRealInterval} from a parameter list comprising * minimum and maximum coordinates. For example, to create a 2D interval * from (10, 10) to (20, 40) use createMinMax( 10, 10, 20, 40 ). * * @param minmax * a list of 2*n parameters to create a n * -dimensional interval. The first n parameters specify * the minimum of the interval, the next n parameters * specify the maximum of the interval. * @return interval with the specified boundaries */ public static FinalRealInterval createMinMaxReal( final double... minmax ) { return FinalRealInterval.createMinMax( minmax ); } /** * Grow/shrink an interval in all dimensions. * * Create a {@link FinalInterval} , which is the input interval plus border * pixels on every side, in every dimension. * * @param interval * the input interval * @param border * how many pixels to add on every side * @return expanded interval */ public static FinalInterval expand( final Interval interval, final long border ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); for ( int d = 0; d < n; ++d ) { min[ d ] -= border; max[ d ] += border; } return new FinalInterval( min, max ); } /** * Grow/shrink an interval in all dimensions. * * Create a {@link FinalInterval}, which is the input interval plus border * pixels on every side, in every dimension. * * @param interval * the input interval * @param border * how many pixels to add on every side * @return expanded interval */ public static FinalInterval expand( final Interval interval, final long ... border ) { return expand(interval, new FinalDimensions( border )); } /** * Grow/shrink an interval in all dimensions. * * Create a {@link FinalInterval}, which is the input interval plus border * pixels on every side, in every dimension. * * @param interval * the input interval * @param border * how many pixels to add on every side * @return expanded interval */ public static FinalInterval expand( final Interval interval, final Dimensions border ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); for ( int d = 0; d < n; ++d ) { min[ d ] -= border.dimension( d ); max[ d ] += border.dimension( d ); } return new FinalInterval( min, max ); } /** * Grow/shrink an interval in one dimensions. * * Create a {@link FinalInterval} , which is the input interval plus border * pixels on every side, in dimension d. * * @param interval * the input interval * @param border * how many pixels to add on every side * @param d * in which dimension * @return expanded interval */ public static FinalInterval expand( final Interval interval, final long border, final int d ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); min[ d ] -= border; max[ d ] += border; return new FinalInterval( min, max ); } /** * Translate an interval in one dimension. * * Create a {@link FinalInterval} , which is the input interval shifted by t * in dimension d. * * @param interval * the input interval * @param t * by how many pixels to shift the interval * @param d * in which dimension * @return translated interval */ public static FinalInterval translate( final Interval interval, final long t, final int d ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); min[ d ] += t; max[ d ] += t; return new FinalInterval( min, max ); } /** * Compute the intersection of two intervals. * * Create a {@link FinalInterval} , which is the intersection of the input * intervals (i.e., the area contained in both input intervals). * * @param intervalA * input interval * @param intervalB * input interval * @return intersection of input intervals */ public static FinalInterval intersect( final Interval intervalA, final Interval intervalB ) { assert intervalA.numDimensions() == intervalB.numDimensions(); final int n = intervalA.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Math.max( intervalA.min( d ), intervalB.min( d ) ); max[ d ] = Math.min( intervalA.max( d ), intervalB.max( d ) ); } return new FinalInterval( min, max ); } /** * Compute the intersection of two intervals. * * Create a {@link RealInterval} , which is the intersection of the input * intervals (i.e., the area contained in both input intervals). * * @param intervalA * input interval * @param intervalB * input interval * @return intersection of input intervals */ public static FinalRealInterval intersect( final RealInterval intervalA, final RealInterval intervalB ) { assert intervalA.numDimensions() == intervalB.numDimensions(); final int n = intervalA.numDimensions(); final double[] min = new double[ n ]; final double[] max = new double[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Math.max( intervalA.realMin( d ), intervalB.realMin( d ) ); max[ d ] = Math.min( intervalA.realMax( d ), intervalB.realMax( d ) ); } return new FinalRealInterval( min, max ); } /** * Compute the smallest interval that contains both input intervals. * * Create a {@link FinalInterval} that represents that interval. * * @param intervalA * input interval * @param intervalB * input interval * @return union of input intervals */ public static FinalInterval union( final Interval intervalA, final Interval intervalB ) { assert intervalA.numDimensions() == intervalB.numDimensions(); final int n = intervalA.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Math.min( intervalA.min( d ), intervalB.min( d ) ); max[ d ] = Math.max( intervalA.max( d ), intervalB.max( d ) ); } return new FinalInterval( min, max ); } /** * Compute the smallest interval that contains both input intervals. * * Create a {@link RealInterval} that represents that interval. * * @param intervalA * input interval * @param intervalB * input interval * @return union of input intervals */ public static FinalRealInterval union( final RealInterval intervalA, final RealInterval intervalB ) { assert intervalA.numDimensions() == intervalB.numDimensions(); final int n = intervalA.numDimensions(); final double[] min = new double[ n ]; final double[] max = new double[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = Math.min( intervalA.realMin( d ), intervalB.realMin( d ) ); max[ d ] = Math.max( intervalA.realMax( d ), intervalB.realMax( d ) ); } return new FinalRealInterval( min, max ); } /** * Compute the smallest {@link Interval} containing the specified * {@link RealInterval}. * * @param ri * input interval. * @return the smallest integer interval that completely contains the input * interval. */ public static Interval smallestContainingInterval( final RealInterval ri ) { final int n = ri.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = ( long ) Math.floor( ri.realMin( d ) ); max[ d ] = ( long ) Math.ceil( ri.realMax( d ) ); } return new FinalInterval( min, max ); } /** * Compute the largest {@link Interval} that is contained in the specified * {@link RealInterval}. * * @param ri * input interval. * @return the largest integer interval that is completely contained in the * input interval. */ public static Interval largestContainedInterval( final RealInterval ri ) { final int n = ri.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) { min[ d ] = ( long ) Math.ceil( ri.realMin( d ) ); max[ d ] = ( long ) Math.floor( ri.realMax( d ) ); } return new FinalInterval( min, max ); } /** * Check whether the given interval is empty, that is, the maximum is * smaller than the minimum in some dimension. * * @param interval * interval to check * @return true when the interval is empty, that is, the maximum is smaller * than the minimum in some dimension. */ public static boolean isEmpty( final Interval interval ) { final int n = interval.numDimensions(); for ( int d = 0; d < n; ++d ) if ( interval.min( d ) > interval.max( d ) ) return true; return false; } /** * Check whether the given interval is empty, that is, the maximum is * smaller than the minimum in some dimension. * * @param interval * interval to check * @return true when the interval is empty, that is, the maximum is smaller * than the minimum in some dimension. */ public static boolean isEmpty( final RealInterval interval ) { final int n = interval.numDimensions(); for ( int d = 0; d < n; ++d ) if ( interval.realMin( d ) > interval.realMax( d ) ) return true; return false; } /** * Test whether the {@code containing} interval contains the * {@code contained} point. The interval is closed, that is, boundary points * are contained. * * @return true, iff {@code contained} is in {@code containing}. */ public static boolean contains( final Interval containing, final Localizable contained ) { assert containing.numDimensions() == contained.numDimensions(); final int n = containing.numDimensions(); for ( int d = 0; d < n; ++d ) { final long p = contained.getLongPosition( d ); if ( p < containing.min( d ) || p > containing.max( d ) ) return false; } return true; } /** * Test whether the {@code containing} interval contains the * {@code contained} point. The interval is closed, that is, boundary points * are contained. * * @return true, iff {@code contained} is in {@code containing}. */ public static boolean contains( final RealInterval containing, final RealLocalizable contained ) { assert containing.numDimensions() == contained.numDimensions(); final int n = containing.numDimensions(); for ( int d = 0; d < n; ++d ) { final double p = contained.getDoublePosition( d ); if ( p < containing.realMin( d ) || p > containing.realMax( d ) ) return false; } return true; } /** * Test whether the {@code containing} interval completely contains the * {@code contained} interval. */ final static public boolean contains( final Interval containing, final Interval contained ) { assert containing.numDimensions() == contained.numDimensions(); final int n = containing.numDimensions(); for ( int d = 0; d < n; ++d ) { if ( containing.min( d ) > contained.min( d ) || containing.max( d ) < contained.max( d ) ) return false; } return true; } /** * Test whether the {@code containing} interval completely contains the * {@code contained} interval. */ final static public boolean contains( final RealInterval containing, final RealInterval contained ) { assert containing.numDimensions() == contained.numDimensions(); final int n = containing.numDimensions(); for ( int d = 0; d < n; ++d ) { if ( containing.realMin( d ) > contained.realMin( d ) || containing.realMax( d ) < contained.realMax( d ) ) return false; } return true; } /** * Compute the number of elements contained in an (integer) {@link Interval} * . * * @return number of elements in {@code interval}. */ public static long numElements( final Dimensions interval ) { long numPixels = interval.dimension( 0 ); final int n = interval.numDimensions(); for ( int d = 1; d < n; ++d ) numPixels *= interval.dimension( d ); return numPixels; } /** * Compute the number of elements contained in an (integer) interval. * * @param dimensions * dimensions of the interval. * @return number of elements in the interval. */ public static long numElements( final int... dimensions ) { long numPixels = dimensions[ 0 ]; for ( int d = 1; d < dimensions.length; ++d ) numPixels *= dimensions[ d ]; return numPixels; } /** * Compute the number of elements contained in an (integer) interval. * * @param dimensions * dimensions of the interval. * @return number of elements in the interval. */ public static long numElements( final long... dimensions ) { long numPixels = dimensions[ 0 ]; for ( int d = 1; d < dimensions.length; ++d ) numPixels *= dimensions[ d ]; return numPixels; } /** * Tests weather two intervals are equal in their min / max */ public static boolean equals( final Interval a, final Interval b ) { if ( a.numDimensions() != b.numDimensions() ) return false; for ( int d = 0; d < a.numDimensions(); ++d ) if ( a.min( d ) != b.min( d ) || a.max( d ) != b.max( d ) ) return false; return true; } /** * Tests weather two intervals have equal dimensions (same size) */ public static boolean equalDimensions( final Interval a, final Interval b ) { if ( a.numDimensions() != b.numDimensions() ) return false; for ( int d = 0; d < a.numDimensions(); ++d ) if ( a.dimension( d ) != b.dimension( d ) ) return false; return true; } /** * Create a long[] with the dimensions of a {@link Dimensions}. * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. See * {@link Dimensions#dimensions(long[])}. *

* * @param dimensions * something which has dimensions * * @return dimensions as a new long[] */ public static long[] dimensionsAsLongArray( final Dimensions dimensions ) { final long[] dims = new long[ dimensions.numDimensions() ]; dimensions.dimensions( dims ); return dims; } /** * Create a int[] with the dimensions of an {@link Interval}. * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. *

* * @param dimensions * something which has dimensions * * @return dimensions as a new int[] */ public static int[] dimensionsAsIntArray( final Dimensions dimensions ) { final int n = dimensions.numDimensions(); final int[] dims = new int[ n ]; for ( int d = 0; d < n; ++d ) dims[ d ] = ( int ) dimensions.dimension( d ); return dims; } /** * Create a long[] with the minimum of an {@link Interval}. * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. See {@link Interval#min(long[])}. *

* * @param interval * something with interval boundaries * * @return minimum as a new long[] */ public static long[] minAsLongArray( final Interval interval ) { final long[] min = new long[ interval.numDimensions() ]; interval.min( min ); return min; } /** * Create a int[] with the minimum of an {@link Interval}. * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. *

* * @param interval * something with interval boundaries * * @return minimum as a new int[] */ public static int[] minAsIntArray( final Interval interval ) { final int n = interval.numDimensions(); final int[] min = new int[ n ]; for ( int d = 0; d < n; ++d ) min[ d ] = ( int ) interval.min( d ); return min; } /** * Create a long[] with the maximum of an {@link Interval}. * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. See {@link Interval#max(long[])}. *

* * @param interval * something with interval boundaries * * @return maximum as a new long[] */ public static long[] maxAsLongArray( final Interval interval ) { final long[] max = new long[ interval.numDimensions() ]; interval.max( max ); return max; } /** * Create a int[] with the maximum of an {@link Interval}. * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. *

* * @param interval * something with interval boundaries * * @return maximum as a new int[] */ public static int[] maxAsIntArray( final Interval interval ) { final int n = interval.numDimensions(); final int[] max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) interval.max( d ); return max; } /** * Create a double[] with the maximum of a {@link RealInterval} * . * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. See * {@link RealInterval#realMax(double[])}. *

* * @param interval * something with interval boundaries * * @return maximum as a new double[] */ public static double[] maxAsDoubleArray( final RealInterval interval ) { final double[] max = new double[ interval.numDimensions() ]; interval.realMax( max ); return max; } /** * Create a double[] with the minimum of a {@link RealInterval} * . * *

* Keep in mind that creating arrays wildly is not good practice and * consider using the interval directly. See * {@link RealInterval#realMin(double[])}. *

* * @param interval * something with interval boundaries * * @return minimum as a new double[] */ public static double[] minAsDoubleArray( final RealInterval interval ) { final double[] min = new double[ interval.numDimensions() ]; interval.realMin( min ); return min; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/IterablePair.java000066400000000000000000000032231316447754700253440ustar00rootroot00000000000000package net.imglib2.util; import java.util.Iterator; /** * An {@link Iterable} which is backed by two other {@link Iterable}s, whose * iteration produces a {@link Pair} of objects corresponding to those given by * the two respective iterations of the backing {@link Iterable}s. That is: the * two backing {@link Iterable}s are iterated in synchrony, and their elements * combined into a single {@link Pair} accessor object. *

* When two {@link Iterable}s are given which produce an unequal number of * elements, the iteration of the {@code IterablePair} ends when either * of the two backing iterations ends. *

* * @author Curtis Rueden * @author Ellen T Arena * * @param * @param */ public class IterablePair implements Iterable> { private final Iterable iter1; private final Iterable iter2; public IterablePair(final Iterable iter1, final Iterable iter2) { this.iter1 = iter1; this.iter2 = iter2; } @Override public Iterator> iterator() { return new Iterator>() { private final Iterator i1 = iter1.iterator(); private final Iterator i2 = iter2.iterator(); private A e1; private B e2; private final Pair value = new Pair() { @Override public A getA() { return e1; } @Override public B getB() { return e2; } @Override public String toString() { return e1 + ", " + e2; } }; @Override public boolean hasNext() { return i1.hasNext() && i2.hasNext(); } @Override public Pair next() { e1 = i1.next(); e2 = i2.next(); return value; } }; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/KthElement.java000066400000000000000000000655301316447754700250520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import static net.imglib2.util.Partition.partitionSubList; import java.util.Comparator; import java.util.List; import java.util.ListIterator; /** * TODO * */ public class KthElement { /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final byte[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final byte[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final short[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final short[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final int[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final int[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final long[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final long[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final float[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final float[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final double[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final double[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a subarray of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static void kthElement( int i, int j, final int k, final char[] values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition an array of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.length}. * @param values * array */ public static void kthElement( final int k, final char[] values ) { kthElement( 0, values.length - 1, k, values ); } /** * Partition a sublist of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array * @param comparator * ordering function on T */ public static < T > void kthElement( int i, int j, final int k, final List< T > values, final Comparator< ? super T > comparator ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values, comparator ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition a list of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.size()}. * @param values * array * @param comparator * ordering function on T */ public static < T > void kthElement( final int k, final List< T > values, final Comparator< ? super T > comparator ) { kthElement( 0, values.size() - 1, k, values, comparator ); } /** * Partition a sublist of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array */ public static < T extends Comparable< T > > void kthElement( int i, int j, final int k, final List< T > values ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition a list of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * * @param k * index for k-th smallest value. {@code 0 <= k < values.size()}. * @param values * array */ public static < T extends Comparable< T > > void kthElement( final int k, final List< T > values ) { kthElement( 0, values.size() - 1, k, values ); } /** * Partition a sublist such that the k-th smallest value is at position * {@code k}, elements before the k-th are smaller or equal, and elements * after the k-th are larger or equal. * *

* After the function returns, the iterator {@code i} is on the k-th * element. That is, {@code i.next()} gives the (k+1)-th element. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param k * index for k-th smallest value. * {@code i.nextIndex() <= k <= j.previousIndex()}. * @param comparator * ordering function on T */ public static < T > void kthElement( final ListIterator< T > i, final ListIterator< T > j, final int k, final Comparator< ? super T > comparator ) { while ( true ) { final int iPos = i.nextIndex(); final int jPos = j.previousIndex(); partitionSubList( i, j, comparator ); final int pivotpos = i.nextIndex() - 1; if ( pivotpos > k ) { // partition lower half for ( int c = i.nextIndex() - iPos; c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - ( pivotpos - 1 ); c > 0; --c ) j.previous(); } else if ( pivotpos < k ) { // partition upper half for ( int c = i.nextIndex() - ( pivotpos + 1 ); c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - jPos; c > 0; --c ) j.previous(); } else return; } } /** * Partition a sublist such that the k-th smallest value is at position * {@code k}, elements before the k-th are smaller or equal, and elements * after the k-th are larger or equal. * *

* After the function returns, the iterator {@code i} is on the k-th * element. That is, {@code i.next()} gives the (k+1)-th element. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param k * index for k-th smallest value. {@code i.nextIndex() <= k <= * j.previousIndex()}. */ public static < T extends Comparable< T > > void kthElement( final ListIterator< T > i, final ListIterator< T > j, final int k ) { while ( true ) { final int iPos = i.nextIndex(); final int jPos = j.previousIndex(); partitionSubList( i, j ); final int pivotpos = i.nextIndex() - 1; if ( pivotpos > k ) { // partition lower half for ( int c = i.nextIndex() - iPos; c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - ( pivotpos - 1 ); c > 0; --c ) j.previous(); } else if ( pivotpos < k ) { // partition upper half for ( int c = i.nextIndex() - ( pivotpos + 1 ); c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - jPos; c > 0; --c ) j.previous(); } else return; } } /** * Partition a sublist of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use {@code kthElement} to * sort the keys, we want to reorder the values in the same manner. We pass * an indices array [0, 1, 2, ...] and use the permutation of the indices to * permute the values list. *

* * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array * @param permutation * elements of this array are permuted in the same way as the * elements in the values list * @param comparator * ordering function on T */ public static < T > void kthElement( int i, int j, final int k, final List< T > values, final int[] permutation, final Comparator< ? super T > comparator ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values, permutation, comparator ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition a list of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use {@code kthElement} to * sort the keys, we want to reorder the values in the same manner. We pass * an indices array [0, 1, 2, ...] and use the permutation of the indices to * permute the values list. *

* * @param k * index for k-th smallest value. {@code 0 <= k < values.size()}. * @param values * array * @param permutation * elements of this array are permuted in the same way as the * elements in the values list * @param comparator * ordering function on T */ public static < T > void kthElement( final int k, final List< T > values, final int[] permutation, final Comparator< ? super T > comparator ) { kthElement( 0, values.size() - 1, k, values, permutation, comparator ); } /** * Partition a sublist of {@code values} such that the k-th smallest value * is at position {@code k}, elements before the k-th are smaller or equal * and elements after the k-th are larger or equal. * *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use {@code kthElement} to * sort the keys, we want to reorder the values in the same manner. We pass * an indices array [0, 1, 2, ...] and use the permutation of the indices to * permute the values list. *

* * @param i * index of first element of subarray * @param j * index of last element of subarray * @param k * index for k-th smallest value. {@code i <= k <= j}. * @param values * array * @param permutation * elements of this array are permuted in the same way as the * elements in the values list */ public static < T extends Comparable< T > > void kthElement( int i, int j, final int k, final List< T > values, final int[] permutation ) { while ( true ) { final int pivotpos = partitionSubList( i, j, values, permutation ); if ( pivotpos > k ) { // partition lower half j = pivotpos - 1; } else if ( pivotpos < k ) { // partition upper half i = pivotpos + 1; } else return; } } /** * Partition a list of {@code values} such that the k-th smallest value is * at position {@code k}, elements before the k-th are smaller or equal and * elements after the k-th are larger or equal. * *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use {@code kthElement} to * sort the keys, we want to reorder the values in the same manner. We pass * an indices array [0, 1, 2, ...] and use the permutation of the indices to * permute the values list. *

* * @param k * index for k-th smallest value. {@code 0 <= k < values.size()}. * @param values * array * @param permutation * elements of this array are permuted in the same way as the * elements in the values list */ public static < T extends Comparable< T > > void kthElement( final int k, final List< T > values, final int[] permutation ) { kthElement( 0, values.size() - 1, k, values, permutation ); } /** * Partition a sublist such that the k-th smallest value is at position * {@code k}, elements before the k-th are smaller or equal, and elements * after the k-th are larger or equal. * *

* After the function returns, the iterator {@code i} is on the k-th * element. That is, {@code i.next()} gives the (k+1)-th element. *

* *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use {@code kthElement} to * sort the keys, we want to reorder the values in the same manner. We pass * an indices array [0, 1, 2, ...] and use the permutation of the indices to * permute the values list. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param k * index for k-th smallest value. {@code i.nextIndex() <= k <= * j.previousIndex()}. * @param permutation * elements of this array are permuted in the same way as the * elements in the values list * @param comparator * ordering function on T */ public static < T > void kthElement( final ListIterator< T > i, final ListIterator< T > j, final int k, final int[] permutation, final Comparator< ? super T > comparator ) { while ( true ) { final int iPos = i.nextIndex(); final int jPos = j.previousIndex(); partitionSubList( i, j, permutation, comparator ); final int pivotpos = i.nextIndex() - 1; if ( pivotpos > k ) { // partition lower half for ( int c = i.nextIndex() - iPos; c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - ( pivotpos - 1 ); c > 0; --c ) j.previous(); } else if ( pivotpos < k ) { // partition upper half for ( int c = i.nextIndex() - ( pivotpos + 1 ); c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - jPos; c > 0; --c ) j.previous(); } else return; } } /** * Partition a sublist such that the k-th smallest value is at position * {@code k}, elements before the k-th are smaller or equal, and elements * after the k-th are larger or equal. * *

* After the function returns, the iterator {@code i} is on the k-th * element. That is, {@code i.next()} gives the (k+1)-th element. *

* *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use {@code kthElement} to * sort the keys, we want to reorder the values in the same manner. We pass * an indices array [0, 1, 2, ...] and use the permutation of the indices to * permute the values list. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param k * index for k-th smallest value. {@code i.nextIndex() <= k <= * j.previousIndex()}. * @param permutation * elements of this array are permuted in the same way as the * elements in the values list */ public static < T extends Comparable< T > > void kthElement( final ListIterator< T > i, final ListIterator< T > j, final int k, final int[] permutation ) { while ( true ) { final int iPos = i.nextIndex(); final int jPos = j.previousIndex(); partitionSubList( i, j, permutation ); final int pivotpos = i.nextIndex() - 1; if ( pivotpos > k ) { // partition lower half for ( int c = i.nextIndex() - iPos; c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - ( pivotpos - 1 ); c > 0; --c ) j.previous(); } else if ( pivotpos < k ) { // partition upper half for ( int c = i.nextIndex() - ( pivotpos + 1 ); c > 0; --c ) i.previous(); for ( int c = j.previousIndex() - jPos; c > 0; --c ) j.previous(); } else return; } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/LinAlgHelpers.java000066400000000000000000000603241316447754700254770ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; /** * Basic vector and matrix operations implemented on double[] and double[][]. * * @author Tobias Pietzsch * @author Stephan Saalfeld */ public class LinAlgHelpers { public static int rows( final double[] a ) { return a.length; } public static int rows( final double[][] A ) { return A.length; } public static int cols( final double[][] A ) { return A[ 0 ].length; } /** * get the squared length of a. * * @param a */ public static double squareLength( final double[] a ) { final int rows = rows( a ); double squ_len = 0.0; for ( int i = 0; i < rows; ++i ) squ_len += a[ i ] * a[ i ]; return squ_len; } /** * get the length of a. * * @param a */ public static double length( final double[] a ) { return Math.sqrt( squareLength( a ) ); } /** * get the squared length of (a - b). * * @param a * @param b */ public static double squareDistance( final double[] a, final double[] b ) { assert rows( a ) == rows( b ); final int rows = rows( a ); double squ_len = 0.0; for ( int i = 0; i < rows; ++i ) squ_len += ( a[ i ] - b[ i ] ) * ( a[ i ] - b[ i ] ); return squ_len; } /** * get the length of (a - b). * * @param a * @param b */ public static double distance( final double[] a, final double[] b ) { return Math.sqrt( squareDistance( a, b ) ); } /** * set c = a * b, where a is a vector and b is scalar. Dimensions of a and c * must match. In place scaling (c==a) is permitted. * * @param a * @param b * @param c */ public static void scale( final double[] a, final double b, final double[] c ) { assert rows( a ) == rows( c ); final int rows = rows( a ); for ( int i = 0; i < rows; ++i ) c[ i ] = a[ i ] * b; } /** * set C = A * b, where A is a matrix and b is scalar. Dimensions of A and C * must match. In place scaling (C==A) is permitted. * * @param A * @param b * @param C */ public static void scale( final double[][] A, final double b, final double[][] C ) { assert rows( A ) == rows( C ) && cols( A ) == cols( C ); final int rows = rows( A ); final int cols = cols( A ); for ( int i = 0; i < rows; ++i ) for ( int j = 0; j < cols; ++j ) C[ i ][ j ] = A[ i ][ j ] * b; } /** * set C = A, where A is a matrix. Dimensions of A and C must match. * * @param A * @param C */ public static void copy( final double[][] A, final double[][] C ) { assert rows( A ) == rows( C ) && cols( A ) == cols( C ); final int rows = rows( A ); final int cols = cols( A ); for ( int i = 0; i < rows; ++i ) for ( int j = 0; j < cols; ++j ) C[ i ][ j ] = A[ i ][ j ]; } /** * set c = a - b. Dimensions of a, b, and c must match. In place subtraction * (c==a) is permitted. * * @param a * @param b * @param c */ public static void subtract( final double[] a, final double[] b, final double[] c ) { assert ( rows( a ) == rows( b ) ) && ( rows( a ) == rows( c ) ); final int rows = rows( a ); for ( int i = 0; i < rows; ++i ) c[ i ] = a[ i ] - b[ i ]; } /** * set c = a + b. Dimensions of a, b, and c must match. In place addition * (c==a) is permitted. * * @param a * @param b * @param c */ public static void add( final double[] a, final double[] b, final double[] c ) { assert ( rows( a ) == rows( b ) ) && ( rows( a ) == rows( c ) ); final int rows = rows( a ); for ( int i = 0; i < rows; ++i ) c[ i ] = a[ i ] + b[ i ]; } /** * set c = A * b. * * Dimensions of A, b, and c must match. That is, cols(A) == rows(b), and * rows(c) == rows(A). * * @param A * @param b * @param c */ public static void mult( final double[][] A, final double[] b, final double[] c ) { assert cols( A ) == rows( b ); assert rows( c ) == rows( A ); final int rows = rows( c ); final int Acols = cols( A ); for ( int i = 0; i < rows; ++i ) { double sum = 0; for ( int k = 0; k < Acols; ++k ) sum += A[ i ][ k ] * b[ k ]; c[ i ] = sum; } } /** * set c = A^T * b. * * Dimensions of A, b, and c must match. That is, rows(A) == rows(b), and * rows(c) == cols(A). * * @param A * @param b * @param c */ public static void multT( final double[][] A, final double[] b, final double[] c ) { assert rows( A ) == rows( b ); assert rows( c ) == cols( A ); final int rows = rows( c ); final int Arows = rows( A ); for ( int i = 0; i < rows; ++i ) { double sum = 0; for ( int k = 0; k < Arows; ++k ) sum += A[ k ][ i ] * b[ k ]; c[ i ] = sum; } } /** * set C = A * B. * * Dimensions of A, B, and C must match. That is, cols(A) == rows(B), * rows(C) == rows(A), and cols(C) == cols(B). * * @param A * @param B * @param C */ public static void mult( final double[][] A, final double[][] B, final double[][] C ) { assert cols( A ) == rows( B ); assert ( rows( C ) == rows( A ) ) && ( cols( C ) == cols( B ) ); final int cols = cols( C ); final int rows = rows( C ); final int Acols = cols( A ); for ( int i = 0; i < rows; ++i ) { for ( int j = 0; j < cols; ++j ) { double sum = 0; for ( int k = 0; k < Acols; ++k ) sum += A[ i ][ k ] * B[ k ][ j ]; C[ i ][ j ] = sum; } } } /** * set C = A * B^T. * * Dimensions of A, B, and C must match. That is, cols(A) == cols(B), * rows(C) == rows(A), and cols(C) == rows(B). * * @param A * @param B * @param C */ public static void multABT( final double[][] A, final double[][] B, final double[][] C ) { assert cols( A ) == cols( B ); assert ( rows( C ) == rows( A ) ) && ( cols( C ) == rows( B ) ); final int cols = cols( C ); final int rows = rows( C ); final int Acols = cols( A ); for ( int i = 0; i < rows; ++i ) { for ( int j = 0; j < cols; ++j ) { double sum = 0; for ( int k = 0; k < Acols; ++k ) sum += A[ i ][ k ] * B[ j ][ k ]; C[ i ][ j ] = sum; } } } /** * set C = A^T * B. * * Dimensions of A, B, and C must match. That is, rows(A) == rows(B), * rows(C) == cols(A), and cols(C) == cols(B). * * @param A * @param B * @param C */ public static void multATB( final double[][] A, final double[][] B, final double[][] C ) { assert rows( A ) == rows( B ); assert ( rows( C ) == cols( A ) ) && ( cols( C ) == cols( B ) ); final int cols = cols( C ); final int rows = rows( C ); final int Arows = rows( A ); for ( int i = 0; i < rows; ++i ) { for ( int j = 0; j < cols; ++j ) { double sum = 0; for ( int k = 0; k < Arows; ++k ) sum += A[ k ][ i ] * B[ k ][ j ]; C[ i ][ j ] = sum; } } } /** * set C = A + B. * * Dimensions of A, B, and C must match. In place addition (C==A or C==B) is * permitted. * * @param A * @param B * @param C */ public static void add( final double[][] A, final double[][] B, final double[][] C ) { assert rows( A ) == rows( B ) && rows( A ) == rows( C ); assert cols( A ) == cols( B ) && cols( A ) == cols( C ); final int rows = rows( A ); final int cols = cols( A ); for ( int i = 0; i < rows; ++i ) for ( int j = 0; j < cols; ++j ) C[ i ][ j ] = A[ i ][ j ] + B[ i ][ j ]; } /** * extract column c of A into vector b. * * Dimensions of A and b must match. That is, rows(A) == rows(b). * * @param c * @param A * @param b */ public static void getCol( final int c, final double[][] A, final double[] b ) { assert rows( A ) == rows( b ); assert cols( A ) > c && c >= 0; final int rows = rows( A ); for ( int i = 0; i < rows; ++i ) b[ i ] = A[ i ][ c ]; } /** * set column c of B to vector a. * * Dimensions of a and B must match. That is, rows(a) == rows(B). * * @param c * @param a * @param B */ public static void setCol( final int c, final double[] a, final double[][] B ) { assert rows( B ) == rows( a ); assert cols( B ) > c && c >= 0; final int rows = rows( B ); for ( int i = 0; i < rows; ++i ) B[ i ][ c ] = a[ i ]; } /** * extract row r of A into vector b. * * Dimensions of A and b must match. That is, cols(A) == rows(b). * * @param r * @param A * @param b */ public static void getRow( final int r, final double[][] A, final double[] b ) { assert cols( A ) == rows( b ); assert rows( A ) > r && r >= 0; final int cols = cols( A ); for ( int i = 0; i < cols; ++i ) b[ i ] = A[ r ][ i ]; } /** * set row r of B to vector a. * * Dimensions of a and B must match. That is, rows(a) == cols(B). * * @param r * @param a * @param B */ public static void setRow( final int r, final double[] a, final double[][] B ) { assert cols( B ) == rows( a ); assert rows( B ) > r && r >= 0; final int cols = cols( B ); for ( int i = 0; i < cols; ++i ) B[ r ][ i ] = a[ i ]; } /** * normalize a, i.e., scale to unit length. * * @param a */ public static void normalize( final double[] a ) { final int rows = rows( a ); final double len = length( a ); for ( int i = 0; i < rows; ++i ) a[ i ] /= len; } /** * compute dot product a * b. * * Dimensions of a and b must match. * * @param a * @param b */ public static double dot( final double[] a, final double[] b ) { assert rows( a ) == rows( b ); final int rows = rows( a ); double sum = 0; for ( int i = 0; i < rows; ++i ) sum += a[ i ] * b[ i ]; return sum; } /** * compute cross product, set c = a ^ b. * * Dimensions of a, b, and c must equal 3. * * @param a * @param b */ public static void cross( final double[] a, final double[] b, final double[] c ) { c[ 0 ] = a[ 1 ] * b[ 2 ] - a[ 2 ] * b[ 1 ]; c[ 1 ] = a[ 2 ] * b[ 0 ] - a[ 0 ] * b[ 2 ]; c[ 2 ] = a[ 0 ] * b[ 1 ] - a[ 1 ] * b[ 0 ]; } /** * compute outer product, set C = a * b^T. * * Dimensions of a, b, and C must match. That is, rows(a) == rows(C), and * rows(b) == cols(C). * * @param a * @param b * @param C */ public static void outer( final double[] a, final double[] b, final double[][] C ) { assert rows( a ) == rows( C ) && rows( b ) == cols( C ); final int rows = rows( a ); final int cols = rows( b ); for ( int i = 0; i < rows; ++i ) for ( int j = 0; j < cols; ++j ) C[ i ][ j ] = a[ i ] * b[ j ]; } /** * compute the angle of rotation from a rotation matrix. The returned value * is in the range [0, PI]. * * @param R * rotation matrix */ public static double angleFromR( final double[][] R ) { assert cols( R ) >= 3; assert rows( R ) >= 3; final double tr = R[ 0 ][ 0 ] + R[ 1 ][ 1 ] + R[ 2 ][ 2 ]; final double theta = Math.acos( ( tr - 1.0 ) / 2.0 ); return theta; } /** * compute the axis of rotation from a rotation matrix. * * @param R * rotation matrix * @param a * rotation axis is stored here */ public static void axisFromR( final double[][] R, final double[] a ) { assert cols( R ) >= 3; assert rows( R ) >= 3; assert rows( a ) >= 3; final double s = 1.0 / ( 2.0 * Math.sin( angleFromR( R ) ) ); a[ 0 ] = s * ( R[ 2 ][ 1 ] - R[ 1 ][ 2 ] ); a[ 1 ] = s * ( R[ 0 ][ 2 ] - R[ 2 ][ 0 ] ); a[ 2 ] = s * ( R[ 1 ][ 0 ] - R[ 0 ][ 1 ] ); } /** * compute a unit quaternion from a rotation matrix. * * @param R * rotation matrix. * @param q * unit quaternion (w, x, y, z) is stored here. */ public static void quaternionFromR( final double[][] R, final double[] q ) { assert cols( R ) >= 3; assert rows( R ) >= 3; assert rows( q ) >= 4; // The trace determines the method of decomposition final double d0 = R[ 0 ][ 0 ], d1 = R[ 1 ][ 1 ], d2 = R[ 2 ][ 2 ]; final double rr = d0 + d1 + d2; if ( rr > 0 ) { final double s = 0.5 / Math.sqrt( 1.0 + rr ); q[ 1 ] = ( R[ 2 ][ 1 ] - R[ 1 ][ 2 ] ) * s; q[ 2 ] = ( R[ 0 ][ 2 ] - R[ 2 ][ 0 ] ) * s; q[ 3 ] = ( R[ 1 ][ 0 ] - R[ 0 ][ 1 ] ) * s; q[ 0 ] = 0.25 / s; } else { // Trace is less than zero, so need to determine which // major diagonal is largest if ( ( d0 > d1 ) && ( d0 > d2 ) ) { final double s2 = Math.sqrt( 1 + d0 - d1 - d2 ); final double s = 0.5 / s2; q[ 1 ] = 0.5 * s2; q[ 2 ] = ( R[ 0 ][ 1 ] + R[ 1 ][ 0 ] ) * s; q[ 3 ] = ( R[ 2 ][ 0 ] + R[ 0 ][ 2 ] ) * s; q[ 0 ] = ( R[ 2 ][ 1 ] - R[ 1 ][ 2 ] ) * s; } else if ( d1 > d2 ) { final double s2 = Math.sqrt( 1 - d0 + d1 - d2 ); final double s = 0.5 / s2; q[ 1 ] = ( R[ 0 ][ 1 ] + R[ 1 ][ 0 ] ) * s; q[ 2 ] = 0.5 * s2; q[ 3 ] = ( R[ 1 ][ 2 ] + R[ 2 ][ 1 ] ) * s; q[ 0 ] = ( R[ 0 ][ 2 ] - R[ 2 ][ 0 ] ) * s; } else { final double s2 = Math.sqrt( 1 - d0 - d1 + d2 ); final double s = 0.5 / s2; q[ 1 ] = ( R[ 2 ][ 0 ] + R[ 0 ][ 2 ] ) * s; q[ 2 ] = ( R[ 1 ][ 2 ] + R[ 2 ][ 1 ] ) * s; q[ 3 ] = 0.5 * s2; q[ 0 ] = ( R[ 1 ][ 0 ] - R[ 0 ][ 1 ] ) * s; } } } /** * compute a rotation matrix from a unit quaternion. * * @param q * unit quaternion (w, x, y, z). * @param R * rotation matrix is stored here. */ public static void quaternionToR( final double[] q, final double[][] R ) { assert rows( q ) >= 4; assert cols( R ) >= 3; assert rows( R ) >= 3; final double w = q[ 0 ]; final double x = q[ 1 ]; final double y = q[ 2 ]; final double z = q[ 3 ]; R[ 0 ][ 0 ] = w * w + x * x - y * y - z * z; R[ 0 ][ 1 ] = 2.0 * ( x * y - w * z ); R[ 0 ][ 2 ] = 2.0 * ( x * z + w * y ); R[ 1 ][ 0 ] = 2.0 * ( y * x + w * z ); R[ 1 ][ 1 ] = w * w - x * x + y * y - z * z; R[ 1 ][ 2 ] = 2.0 * ( y * z - w * x ); R[ 2 ][ 0 ] = 2.0 * ( z * x - w * y ); R[ 2 ][ 1 ] = 2.0 * ( z * y + w * x ); R[ 2 ][ 2 ] = w * w - x * x - y * y + z * z; } /** * compute a quaternion from rotation axis and angle. * * @param axis * rotation axis as a unit vector. * @param angle * rotation angle [rad]. * @param q * unit quaternion (w, x, y, z) is stored here. */ public static void quaternionFromAngleAxis( final double[] axis, final double angle, final double[] q ) { assert rows( axis ) >= 3; assert rows( q ) >= 4; final double s = Math.sin( 0.5 * angle ); q[ 0 ] = Math.cos( 0.5 * angle ); q[ 1 ] = s * axis[ 0 ]; q[ 2 ] = s * axis[ 1 ]; q[ 3 ] = s * axis[ 2 ]; } /** * compute the quaternion product pq = p * q. applying rotation pq * corresponds to applying first q, then p (i.e. same as multiplication of * rotation matrices). * * @param p * unit quaternion (w, x, y, z). * @param q * unit quaternion (w, x, y, z). * @param pq * quaternion product p * q is stored here. */ public static void quaternionMultiply( final double[] p, final double[] q, final double[] pq ) { assert rows( p ) >= 4; assert rows( q ) >= 4; assert rows( pq ) >= 4; final double pw = p[ 0 ]; final double px = p[ 1 ]; final double py = p[ 2 ]; final double pz = p[ 3 ]; final double qw = q[ 0 ]; final double qx = q[ 1 ]; final double qy = q[ 2 ]; final double qz = q[ 3 ]; pq[ 0 ] = pw * qw - px * qx - py * qy - pz * qz; pq[ 1 ] = pw * qx + px * qw + py * qz - pz * qy; pq[ 2 ] = pw * qy + py * qw + pz * qx - px * qz; pq[ 3 ] = pw * qz + pz * qw + px * qy - py * qx; } /** * compute the power of a quaternion q raised to the exponent a. * * @param q * unit quaternion (w, x, y, z). * @param a * exponent. * @param qa * q^a is stored here. */ public static void quaternionPower( final double[] q, final double a, final double[] qa ) { assert rows( q ) >= 4; assert rows( qa ) >= 4; final double theta2 = Math.acos( q[ 0 ] ); final double s = Math.sin( a * theta2 ) / Math.sin( theta2 ); if ( Double.isNaN( s ) ) { qa[ 0 ] = 1; qa[ 1 ] = 0; qa[ 2 ] = 0; qa[ 3 ] = 0; } else { qa[ 0 ] = Math.cos( a * theta2 ); qa[ 1 ] = s * q[ 1 ]; qa[ 2 ] = s * q[ 2 ]; qa[ 3 ] = s * q[ 3 ]; } } /** * invert quaternion, set q = p^{-1}. In place inversion (p==q) is * permitted. * * @param p * unit quaternion (w, x, y, z). * @param q * inverse of p is stored here. */ public static void quaternionInvert( final double[] p, final double[] q ) { assert rows( p ) >= 4; assert rows( q ) >= 4; q[ 0 ] = p[ 0 ]; q[ 1 ] = -p[ 1 ]; q[ 2 ] = -p[ 2 ]; q[ 3 ] = -p[ 3 ]; } /** * Apply quaternion rotation q to 3D point p, set qp = q * p. In place * rotation (p==qp) is permitted. * * @param q * unit quaternion (w, x, y, z). * @param p * 3D point. * @param qp * rotated 3D point is stored here. */ public static void quaternionApply( final double[] q, final double[] p, final double[] qp ) { assert rows( q ) >= 4; assert rows( p ) >= 3; assert rows( qp ) >= 3; final double w = q[ 0 ]; final double x = q[ 1 ]; final double y = q[ 2 ]; final double z = q[ 3 ]; final double q0 = -x * p[ 0 ] - y * p[ 1 ] - z * p[ 2 ]; final double q1 = w * p[ 0 ] + y * p[ 2 ] - z * p[ 1 ]; final double q2 = w * p[ 1 ] + z * p[ 0 ] - x * p[ 2 ]; final double q3 = w * p[ 2 ] + x * p[ 1 ] - y * p[ 0 ]; qp[ 0 ] = -q0 * x + q1 * w - q2 * z + q3 * y; qp[ 1 ] = -q0 * y + q2 * w - q3 * x + q1 * z; qp[ 2 ] = -q0 * z + q3 * w - q1 * y + q2 * x; } /** * Calculates the determinant of a 3x3 matrix given as a double[] (row major). * * @param a * * @return determinant */ final static public double det3x3( final double[] a ) { assert a.length >= 9 : "Not enough coordinates."; return a[ 0 ] * a[ 4 ] * a[ 8 ] + a[ 3 ] * a[ 7 ] * a[ 2 ] + a[ 6 ] * a[ 1 ] * a[ 5 ] - a[ 2 ] * a[ 4 ] * a[ 6 ] - a[ 5 ] * a[ 7 ] * a[ 0 ] - a[ 8 ] * a[ 1 ] * a[ 3 ]; } /** * Calculate the determinant of a 3x3 matrix. * * @param m00 * @param m01 * @param m02 * @param m10 * @param m11 * @param m12 * @param m20 * @param m21 * @param m22 * * @return */ final static public double det3x3( final double m00, final double m01, final double m02, final double m10, final double m11, final double m12, final double m20, final double m21, final double m22 ) { return m00 * m11 * m22 + m10 * m21 * m02 + m20 * m01 * m12 - m02 * m11 * m20 - m12 * m21 * m00 - m22 * m01 * m10; } /** * Invert a 3x3 matrix given as row major double[] in place. * * @param m matrix * * @throws IllegalArgumentException if matrix is not invertible */ final static public void invert3x3( final double[] m ) throws IllegalArgumentException { assert m.length >= 9 : "Not enough coordinates."; final double det = det3x3( m ); if ( det == 0 ) throw new IllegalArgumentException( "Matrix not invertible." ); final double i00 = ( m[ 4 ] * m[ 8 ] - m[ 5 ] * m[ 7 ] ) / det; final double i01 = ( m[ 2 ] * m[ 7 ] - m[ 1 ] * m[ 8 ] ) / det; final double i02 = ( m[ 1 ] * m[ 5 ] - m[ 2 ] * m[ 4 ] ) / det; final double i10 = ( m[ 5 ] * m[ 6 ] - m[ 3 ] * m[ 8 ] ) / det; final double i11 = ( m[ 0 ] * m[ 8 ] - m[ 2 ] * m[ 6 ] ) / det; final double i12 = ( m[ 2 ] * m[ 3 ] - m[ 0 ] * m[ 5 ] ) / det; final double i20 = ( m[ 3 ] * m[ 7 ] - m[ 4 ] * m[ 6 ] ) / det; final double i21 = ( m[ 1 ] * m[ 6 ] - m[ 0 ] * m[ 7 ] ) / det; final double i22 = ( m[ 0 ] * m[ 4 ] - m[ 1 ] * m[ 3 ] ) / det; m[ 0 ] = i00; m[ 1 ] = i01; m[ 2 ] = i02; m[ 3 ] = i10; m[ 4 ] = i11; m[ 5 ] = i12; m[ 6 ] = i20; m[ 7 ] = i21; m[ 8 ] = i22; } /** * Invert a 3x3 matrix given as elements in row major order. * * @return inverted matrix as row major double[] * * @throws IllegalArgumentException if matrix is not invertible */ final static public double[] invert3x3( final double m00, final double m01, final double m02, final double m10, final double m11, final double m12, final double m20, final double m21, final double m22 ) throws IllegalArgumentException { final double det = det3x3( m00, m01, m02, m10, m11, m12, m20, m21, m22 ); if ( det == 0 ) throw new IllegalArgumentException( "Matrix not invertible." ); return new double[]{ ( m11 * m22 - m12 * m21 ) / det, ( m02 * m21 - m01 * m22 ) / det, ( m01 * m12 - m02 * m11 ) / det, ( m12 * m20 - m10 * m22 ) / det, ( m00 * m22 - m02 * m20 ) / det, ( m02 * m10 - m00 * m12 ) / det, ( m10 * m21 - m11 * m20 ) / det, ( m01 * m20 - m00 * m21 ) / det, ( m00 * m11 - m01 * m10 ) / det }; } /** * Inverts a (invertible) symmetric 3x3 matrix. * * @param m * symmetric matrix to invert. * @param inverse * inverse of {@code m} is stored here. */ public static void invertSymmetric3x3( final double[][] m, final double[][] inverse ) { final double a00 = m[ 2 ][ 2 ] * m[ 1 ][ 1 ] - m[ 1 ][ 2 ] * m[ 1 ][ 2 ]; final double a01 = m[ 0 ][ 2 ] * m[ 1 ][ 2 ] - m[ 2 ][ 2 ] * m[ 0 ][ 1 ]; final double a02 = m[ 0 ][ 1 ] * m[ 1 ][ 2 ] - m[ 0 ][ 2 ] * m[ 1 ][ 1 ]; final double a11 = m[ 2 ][ 2 ] * m[ 0 ][ 0 ] - m[ 0 ][ 2 ] * m[ 0 ][ 2 ]; final double a12 = m[ 0 ][ 1 ] * m[ 0 ][ 2 ] - m[ 0 ][ 0 ] * m[ 1 ][ 2 ]; final double a22 = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 0 ][ 1 ]; final double Dinv = 1.0 / ( ( m[ 0 ][ 0 ] * a00 ) + ( m[ 1 ][ 0 ] * a01 ) + ( m[ 0 ][ 2 ] * a02 ) ); inverse[ 0 ][ 0 ] = a00 * Dinv; inverse[ 1 ][ 0 ] = inverse[ 0 ][ 1 ] = a01 * Dinv; inverse[ 2 ][ 0 ] = inverse[ 0 ][ 2 ] = a02 * Dinv; inverse[ 1 ][ 1 ] = a11 * Dinv; inverse[ 2 ][ 1 ] = inverse[ 1 ][ 2 ] = a12 * Dinv; inverse[ 2 ][ 2 ] = a22 * Dinv; } /** * Inverts a (invertible) symmetric 2x2 matrix. * * @param m * symmetric matrix to invert. * @param inverse * inverse of {@code m} is stored here. */ public static void invertSymmetric2x2( final double[][] m, final double[][] inverse ) { final double Dinv = 1.0 / ( m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 1 ][ 0 ] * m[ 1 ][ 0 ] ); inverse[ 0 ][ 0 ] = m[ 1 ][ 1 ] * Dinv; inverse[ 1 ][ 0 ] = inverse[ 0 ][ 1 ] = -m[ 1 ][ 0 ] * Dinv; inverse[ 1 ][ 1 ] = m[ 0 ][ 0 ] * Dinv; } public static String toString( final double[][] A ) { return toString( A, "%6.3f " ); } public static String toString( final double[][] A, final String format ) { final int rows = rows( A ); final int cols = cols( A ); String result = ""; for ( int i = 0; i < rows; ++i ) { for ( int j = 0; j < cols; ++j ) result += String.format( format, A[ i ][ j ] ); result += "\n"; } return result; } public static String toString( final double[] a ) { return toString( a, "%6.3f " ); } public static String toString( final double[] a, final String format ) { final int rows = rows( a ); String result = ""; for ( int i = 0; i < rows; ++i ) result += String.format( format, a[ i ] ); result += "\n"; return result; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/Pair.java000066400000000000000000000036361316447754700237040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; public interface Pair< A, B > { public A getA(); public B getB(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/Partition.java000066400000000000000000000742411316447754700247620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import java.util.Comparator; import java.util.List; import java.util.ListIterator; /** * TODO * */ public class Partition { /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final byte[] values ) { final int pivotIndex = j; final byte pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final byte ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final byte tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final byte tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final short[] values ) { final int pivotIndex = j; final short pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final short ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final short tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final short tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final int[] values ) { final int pivotIndex = j; final int pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final int ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final int tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final int tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final long[] values ) { final int pivotIndex = j; final long pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final long ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final long tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final long tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final float[] values ) { final int pivotIndex = j; final float pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final float ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final float tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final float tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final double[] values ) { final int pivotIndex = j; final double pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final double ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final double tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final double tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a subarray of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of subarray * @param j * index of last element of subarray * @param values * array * @return index of pivot element */ public static int partitionSubList( int i, int j, final char[] values ) { final int pivotIndex = j; final char pivot = values[ j-- ]; A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final char ti = values[ i ]; if ( ti >= pivot ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final char tj = values[ j ]; if ( tj < pivot ) { // swap [j] with [i] final char tmp = values[ i ]; values[ i ] = values[ j ]; values[ j ] = tmp; ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. if ( i != pivotIndex ) { values[ pivotIndex ] = values[ i ]; values[ i ] = pivot; } return i; } /** * Partition a sublist of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of the sublist * @param j * index of last element of the sublist * @param values * the list * @param compare * ordering function on T * @return index of pivot element */ public static < T > int partitionSubList( int i, int j, final List< T > values, final Comparator< ? super T > compare ) { final int pivotIndex = j; final T pivot = values.get( j-- ); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final T ti = values.get( i ); if ( compare.compare( ti, pivot ) >= 0 ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = values.get( j ); if ( compare.compare( tj, pivot ) < 0 ) { // swap [j] with [i] final T tmp = values.get( i ); values.set( i, values.get( j ) ); values.set( j, tmp ); ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. // check whether the element at iLastIndex is < if ( i != pivotIndex ) { values.set( pivotIndex, values.get( i ) ); values.set( i, pivot ); } return i; } /** * Partition a sublist of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * * @param i * index of first element of the sublist * @param j * index of last element of the sublist * @param values * the list * @return index of pivot element */ public static < T extends Comparable< T > > int partitionSubList( int i, int j, final List< T > values ) { final int pivotIndex = j; final T pivot = values.get( j-- ); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final T ti = values.get( i ); if ( ti.compareTo( pivot ) >= 0 ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = values.get( j ); if ( tj.compareTo( pivot ) < 0 ) { // swap [j] with [i] final T tmp = values.get( i ); values.set( i, values.get( j ) ); values.set( j, tmp ); ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. // check whether the element at iLastIndex is < if ( i != pivotIndex ) { values.set( pivotIndex, values.get( i ) ); values.set( i, pivot ); } return i; } /** * Partition a sublist. * * The element at {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * *

* After the function returns, the iterator {@code i} is on the pivot * element. That is, {@code i.next()} gives the element after the * pivot. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param compare * ordering function on T */ public static < T > void partitionSubList( final ListIterator< T > i, final ListIterator< T > j, final Comparator< ? super T > compare ) { final int pivotIndex = j.previousIndex(); final T pivot = j.previous(); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i.nextIndex() - 1 <= j.previousIndex() ) { final T ti = i.next(); if ( compare.compare( ti, pivot ) >= 0 ) { i.previous(); break; } } // now [i] is the place where the next value < pivot is to be // inserted // (via i.next() i.set() if ( i.nextIndex() > j.previousIndex() ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = j.previous(); if ( compare.compare( tj, pivot ) < 0 ) { // swap [j] with [i] final T ti = i.next(); i.set( tj ); j.set( ti ); break; } else if ( j.previousIndex() == i.nextIndex() - 1 ) { break A; } } } // we are done. put the pivot element here. if ( i.nextIndex() - 1 != pivotIndex ) { for ( int c = pivotIndex - j.nextIndex() + 1; c > 0; --c ) j.next(); j.set( i.next() ); i.set( pivot ); } return; } /** * Partition a sublist. * * The element at {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller, and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * *

* After the function returns, the iterator {@code i} is on the pivot * element. That is, {@code i.next()} gives the element after the * pivot. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. */ public static < T extends Comparable< T > > void partitionSubList( final ListIterator< T > i, final ListIterator< T > j ) { final int pivotIndex = j.previousIndex(); final T pivot = j.previous(); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i.nextIndex() - 1 <= j.previousIndex() ) { final T ti = i.next(); if ( ti.compareTo( pivot ) >= 0 ) { i.previous(); break; } } // now [i] is the place where the next value < pivot is to be // inserted // (via i.next() i.set() if ( i.nextIndex() > j.previousIndex() ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = j.previous(); if ( tj.compareTo( pivot ) < 0 ) { // swap [j] with [i] final T ti = i.next(); i.set( tj ); j.set( ti ); break; } else if ( j.previousIndex() == i.nextIndex() - 1 ) { break A; } } } // we are done. put the pivot element here. if ( i.nextIndex() - 1 != pivotIndex ) { for ( int c = pivotIndex - j.nextIndex() + 1; c > 0; --c ) j.next(); j.set( i.next() ); i.set( pivot ); } return; } /** * Partition a sublist of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use * {@code partitionSubList} to sort the keys, we want to reorder the values * in the same manner. We pass an indices array [0, 1, 2, ...] and use the * permutation of the indices to permute the values list. *

* * @param i * index of first element of the sublist * @param j * index of last element of the sublist * @param values * the list * @param permutation * elements of this array are permuted in the same way as the * elements in the values list * @param compare * ordering function on T * @return index of pivot element */ public static < T > int partitionSubList( int i, int j, final List< T > values, final int[] permutation, final Comparator< ? super T > compare ) { final int pivotIndex = j; final int permutationPivot = permutation[ j ]; final T pivot = values.get( j-- ); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final T ti = values.get( i ); if ( compare.compare( ti, pivot ) >= 0 ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = values.get( j ); if ( compare.compare( tj, pivot ) < 0 ) { // swap [j] with [i] final int indicesTmp = permutation[ i ]; permutation[ i ] = permutation[ j ]; permutation[ j ] = indicesTmp; final T tmp = values.get( i ); values.set( i, values.get( j ) ); values.set( j, tmp ); ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. // check whether the element at iLastIndex is < if ( i != pivotIndex ) { values.set( pivotIndex, values.get( i ) ); values.set( i, pivot ); permutation[ pivotIndex ] = permutation[ i ]; permutation[ i ] = permutationPivot; } return i; } /** * Partition a sublist of {@code values}. * * The element at index {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use * {@code partitionSubList} to sort the keys, we want to reorder the values * in the same manner. We pass an indices array [0, 1, 2, ...] and use the * permutation of the indices to permute the values list. *

* * @param i * index of first element of the sublist * @param j * index of last element of the sublist * @param values * the list * @param permutation * elements of this array are permuted in the same way as the * elements in the values list * @return index of pivot element */ public static < T extends Comparable< T > > int partitionSubList( int i, int j, final List< T > values, final int[] permutation ) { final int pivotIndex = j; final int permutationPivot = permutation[ j ]; final T pivot = values.get( j-- ); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i <= j ) { final T ti = values.get( i ); if ( ti.compareTo( pivot ) >= 0 ) break; ++i; } // now [i] is the place where the next value < pivot is to be // inserted if ( i > j ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = values.get( j ); if ( tj.compareTo( pivot ) < 0 ) { // swap [j] with [i] final int indicesTmp = permutation[ i ]; permutation[ i ] = permutation[ j ]; permutation[ j ] = indicesTmp; final T tmp = values.get( i ); values.set( i, values.get( j ) ); values.set( j, tmp ); ++i; --j; break; } else if ( j == i ) { break A; } --j; } } // we are done. put the pivot element here. // check whether the element at iLastIndex is < if ( i != pivotIndex ) { values.set( pivotIndex, values.get( i ) ); values.set( i, pivot ); permutation[ pivotIndex ] = permutation[ i ]; permutation[ i ] = permutationPivot; } return i; } /** * Partition a sublist. * * The element at {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * *

* After the function returns, the iterator {@code i} is on the pivot * element. That is, {@code i.next()} gives the element after the * pivot. *

* *

* The {@code permutation} array is permuted in the same way as the list. * Usually, this will be an array of indices, so that the partition * operation can be mirrored in another list: Suppose, we have a list of * keys and a lists (or several) of values. If we use * {@code partitionSubList} to sort the keys, we want to reorder the values * in the same manner. We pass an indices array [0, 1, 2, ...] and use the * permutation of the indices to permute the values list. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param permutation * elements of this array are permuted in the same way as the * elements in the values list * @param compare * ordering function on T */ public static < T > void partitionSubList( final ListIterator< T > i, final ListIterator< T > j, final int[] permutation, final Comparator< ? super T > compare ) { final int pivotIndex = j.previousIndex(); final int permutationPivot = permutation[ pivotIndex ]; final T pivot = j.previous(); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i.nextIndex() - 1 <= j.previousIndex() ) { final T ti = i.next(); if ( compare.compare( ti, pivot ) >= 0 ) { i.previous(); break; } } // now [i] is the place where the next value < pivot is to be // inserted // (via i.next() i.set() if ( i.nextIndex() > j.previousIndex() ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = j.previous(); if ( compare.compare( tj, pivot ) < 0 ) { // swap [j] with [i] final int iIndex = i.nextIndex(); final int jIndex = j.nextIndex(); final int indicesTmp = permutation[ iIndex ]; permutation[ iIndex ] = permutation[ jIndex ]; permutation[ jIndex ] = indicesTmp; final T ti = i.next(); i.set( tj ); j.set( ti ); break; } else if ( j.previousIndex() == i.nextIndex() - 1 ) { break A; } } } // we are done. put the pivot element here. if ( i.nextIndex() - 1 != pivotIndex ) { for ( int c = pivotIndex - j.nextIndex() + 1; c > 0; --c ) j.next(); final int iIndex = i.nextIndex(); j.set( i.next() ); i.set( pivot ); permutation[ pivotIndex ] = permutation[ iIndex ]; permutation[ iIndex ] = permutationPivot; } return; } /** * Partition a sublist. * * The element at {@code j} is taken as the pivot value. The elements * {@code [i,j]} are reordered, such that all elements before the pivot are * smaller, and all elements after the pivot are equal or larger than the * pivot. The index of the pivot element is returned. * *

* After the function returns, the iterator {@code i} is on the pivot * element. That is, {@code i.next()} gives the element after the * pivot. *

* * @param i * iterator pointing before first element of the sublist, that * is, {@code i.next()} gives you the first element. * @param j * iterator pointing behind the last element of the sublist, that * is, {@code i.previous()} gives you the last element. * @param permutation * elements of this array are permuted in the same way as the * elements in the values list */ public static < T extends Comparable< T > > void partitionSubList( final ListIterator< T > i, final ListIterator< T > j, final int[] permutation ) { final int pivotIndex = j.previousIndex(); final int permutationPivot = permutation[ pivotIndex ]; final T pivot = j.previous(); A: while ( true ) { // move i forward while < pivot (and not at j) while ( i.nextIndex() - 1 <= j.previousIndex() ) { final T ti = i.next(); if ( ti.compareTo( pivot ) >= 0 ) { i.previous(); break; } } // now [i] is the place where the next value < pivot is to be // inserted // (via i.next() i.set() if ( i.nextIndex() > j.previousIndex() ) break; // move j backward while >= pivot (and not at i) while ( true ) { final T tj = j.previous(); if ( tj.compareTo( pivot ) < 0 ) { // swap [j] with [i] final int iIndex = i.nextIndex(); final int jIndex = j.nextIndex(); final int indicesTmp = permutation[ iIndex ]; permutation[ iIndex ] = permutation[ jIndex ]; permutation[ jIndex ] = indicesTmp; final T ti = i.next(); i.set( tj ); j.set( ti ); break; } else if ( j.previousIndex() == i.nextIndex() - 1 ) { break A; } } } // we are done. put the pivot element here. if ( i.nextIndex() - 1 != pivotIndex ) { for ( int c = pivotIndex - j.nextIndex() + 1; c > 0; --c ) j.next(); final int iIndex = i.nextIndex(); j.set( i.next() ); i.set( pivot ); permutation[ pivotIndex ] = permutation[ iIndex ]; permutation[ iIndex ] = permutationPivot; } return; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/RealSum.java000066400000000000000000000105441316447754700243550ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; /** * {@link RealSum} implements a method to reduce numerical instabilities when * summing up a very large number of double precision numbers. Numerical * problems occur when a small number is added to an already very large sum. In * such case, the reduced accuracy of the very large number may lead to the * small number being entirely ignored. The method here stores and updates * intermediate sums for all power of two elements such that the final sum can * be generated from intermediate sums that result from equal number of * summands. * * @author Stephan Saalfeld */ public class RealSum { protected boolean[] flags; protected double[] sums; /** * Create a new {@link RealSum}. The fields for intermediate sums is * initialized with a single element and expanded on demand as new elements * are added. */ public RealSum() { flags = new boolean[ 1 ]; sums = new double[ 1 ]; } /** * Create a new {@link RealSum}. The fields for intermediate sums is * initialized with a given number of elements and will only be expanded on * demand as new elements are added and the number of existing elements is * not sufficient. This may be faster in cases where the required number of * elements is known in prior. * * @param capacity */ public RealSum( final int capacity ) { final int ldu = Util.ldu( capacity ) + 1; flags = new boolean[ ldu ]; sums = new double[ ldu ]; } /** * Get the current sum by summing up all intermediate sums. Do not call this * method repeatedly when the sum has not changed. */ final public double getSum() { double sum = 0; for ( final double s : sums ) sum += s; return sum; } final protected void expand( final double s ) { final double[] oldSums = sums; sums = new double[ oldSums.length + 1 ]; System.arraycopy( oldSums, 0, sums, 0, oldSums.length ); sums[ oldSums.length ] = s; final boolean[] oldFlags = flags; flags = new boolean[ sums.length ]; System.arraycopy( oldFlags, 0, flags, 0, oldFlags.length ); flags[ oldSums.length ] = true; } /** * Add an element to the sum. All intermediate sums are updated and the * capacity is increased on demand. * * @param a * the summand to be added */ final public void add( final double a ) { int i = 0; double s = a; try { while ( flags[ i ] ) { flags[ i ] = false; s += sums[ i ]; sums[ i ] = 0.0; ++i; } flags[ i ] = true; sums[ i ] = s; return; } catch ( final IndexOutOfBoundsException e ) { expand( s ); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/Util.java000066400000000000000000000505051316447754700237230ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import java.util.List; import net.imglib2.Dimensions; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.RealInterval; import net.imglib2.RealLocalizable; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.type.NativeType; import net.imglib2.type.Type; /** * TODO * * @author Stephan Preibisch * @author Stephan Saalfeld */ public class Util { @SuppressWarnings( "unchecked" ) public static < T > T[] genericArray( final int length ) { return ( T[] ) ( new Object[ length ] ); } public static double log2( final double value ) { return Math.log( value ) / Math.log( 2.0 ); } // TODO: move to ArrayUtil? public static double[] getArrayFromValue( final double value, final int numDimensions ) { final double[] values = new double[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) values[ d ] = value; return values; } // TODO: move to ArrayUtil? public static float[] getArrayFromValue( final float value, final int numDimensions ) { final float[] values = new float[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) values[ d ] = value; return values; } // TODO: move to ArrayUtil? public static int[] getArrayFromValue( final int value, final int numDimensions ) { final int[] values = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) values[ d ] = value; return values; } // TODO: move to ArrayUtil? public static long[] getArrayFromValue( final long value, final int numDimensions ) { final long[] values = new long[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) values[ d ] = value; return values; } final public static double distance( final RealLocalizable position1, final RealLocalizable position2 ) { double dist = 0; final int n = position1.numDimensions(); for ( int d = 0; d < n; ++d ) { final double pos = position2.getDoublePosition( d ) - position1.getDoublePosition( d ); dist += pos * pos; } return Math.sqrt( dist ); } final public static double distance( final long[] position1, final long[] position2 ) { double dist = 0; for ( int d = 0; d < position1.length; ++d ) { final long pos = position2[ d ] - position1[ d ]; dist += pos * pos; } return Math.sqrt( dist ); } /** * Computes the percentile of a collection of doubles (percentile 0.5 * roughly corresponds to median) * * @param values * - the values * @param percentile * - the percentile [0...1] * @return the corresponding value */ public static double percentile( final double[] values, final double percentile ) { final double temp[] = values.clone(); final int length = temp.length; quicksort( temp ); return temp[ Math.min( length - 1, Math.max( 0, ( int ) Math.round( ( length - 1 ) * percentile ) ) ) ]; } public static double averageDouble( final List< Double > values ) { final double size = values.size(); double avg = 0; for ( final double v : values ) avg += v / size; return avg; } public static float averageFloat( final List< Float > values ) { final double size = values.size(); double avg = 0; for ( final double v : values ) avg += v / size; return ( float ) avg; } public static float min( final List< Float > values ) { float min = Float.MAX_VALUE; for ( final float v : values ) if ( v < min ) min = v; return min; } public static float max( final List< Float > values ) { float max = -Float.MAX_VALUE; for ( final float v : values ) if ( v > max ) max = v; return max; } public static float average( final float[] values ) { final double size = values.length; double avg = 0; for ( final float v : values ) avg += v / size; return ( float ) avg; } public static double average( final double[] values ) { final double size = values.length; double avg = 0; for ( final double v : values ) avg += v / size; return avg; } public static double min( final double[] values ) { double min = values[ 0 ]; for ( final double v : values ) if ( v < min ) min = v; return min; } public static double max( final double[] values ) { double max = values[ 0 ]; for ( final double v : values ) if ( v > max ) max = v; return max; } public static long median( final long[] values ) { final long temp[] = values.clone(); long median; final int length = temp.length; quicksort( temp, 0, length - 1 ); if ( length % 2 == 1 ) // odd length median = temp[ length / 2 ]; else // even length median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2; return median; } public static double median( final double[] values ) { final double temp[] = values.clone(); double median; final int length = temp.length; quicksort( temp, 0, length - 1 ); if ( length % 2 == 1 ) // odd length median = temp[ length / 2 ]; else // even length median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2; return median; } public static float median( final float[] values ) { final float temp[] = values.clone(); float median; final int length = temp.length; quicksort( temp, 0, length - 1 ); if ( length % 2 == 1 ) // odd length median = temp[ length / 2 ]; else // even length median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2; return median; } public static void quicksort( final long[] data, final int left, final int right ) { if ( data == null || data.length < 2 ) return; int i = left, j = right; final long x = data[ ( left + right ) / 2 ]; do { while ( data[ i ] < x ) i++; while ( x < data[ j ] ) j--; if ( i <= j ) { final long temp = data[ i ]; data[ i ] = data[ j ]; data[ j ] = temp; i++; j--; } } while ( i <= j ); if ( left < j ) quicksort( data, left, j ); if ( i < right ) quicksort( data, i, right ); } public static void quicksort( final double[] data ) { quicksort( data, 0, data.length - 1 ); } public static void quicksort( final double[] data, final int left, final int right ) { if ( data == null || data.length < 2 ) return; int i = left, j = right; final double x = data[ ( left + right ) / 2 ]; do { while ( data[ i ] < x ) i++; while ( x < data[ j ] ) j--; if ( i <= j ) { final double temp = data[ i ]; data[ i ] = data[ j ]; data[ j ] = temp; i++; j--; } } while ( i <= j ); if ( left < j ) quicksort( data, left, j ); if ( i < right ) quicksort( data, i, right ); } public static void quicksort( final float[] data ) { quicksort( data, 0, data.length - 1 ); } public static void quicksort( final float[] data, final int left, final int right ) { if ( data == null || data.length < 2 ) return; int i = left, j = right; final float x = data[ ( left + right ) / 2 ]; do { while ( data[ i ] < x ) i++; while ( x < data[ j ] ) j--; if ( i <= j ) { final float temp = data[ i ]; data[ i ] = data[ j ]; data[ j ] = temp; i++; j--; } } while ( i <= j ); if ( left < j ) quicksort( data, left, j ); if ( i < right ) quicksort( data, i, right ); } public static void quicksort( final double[] data, final int[] sortAlso, final int left, final int right ) { if ( data == null || data.length < 2 ) return; int i = left, j = right; final double x = data[ ( left + right ) / 2 ]; do { while ( data[ i ] < x ) i++; while ( x < data[ j ] ) j--; if ( i <= j ) { final double temp = data[ i ]; data[ i ] = data[ j ]; data[ j ] = temp; final int temp2 = sortAlso[ i ]; sortAlso[ i ] = sortAlso[ j ]; sortAlso[ j ] = temp2; i++; j--; } } while ( i <= j ); if ( left < j ) quicksort( data, sortAlso, left, j ); if ( i < right ) quicksort( data, sortAlso, i, right ); } public static double gLog( final double z, final double c ) { if ( c == 0 ) return z; return Math.log10( ( z + Math.sqrt( z * z + c * c ) ) / 2.0 ); } public static float gLog( final float z, final float c ) { if ( c == 0 ) return z; return ( float ) Math.log10( ( z + Math.sqrt( z * z + c * c ) ) / 2.0 ); } public static double gLogInv( final double w, final double c ) { if ( c == 0 ) return w; return Math.pow( 10, w ) - ( ( ( c * c ) * Math.pow( 10, -w ) ) / 4.0 ); } public static double gLogInv( final float w, final float c ) { if ( c == 0 ) return w; return Math.pow( 10, w ) - ( ( ( c * c ) * Math.pow( 10, -w ) ) / 4.0 ); } public static boolean isApproxEqual( final float a, final float b, final float threshold ) { if ( a == b ) return true; else if ( a + threshold > b && a - threshold < b ) return true; else return false; } public static boolean isApproxEqual( final double a, final double b, final double threshold ) { if ( a == b ) return true; else if ( a + threshold > b && a - threshold < b ) return true; else return false; } public static int round( final float value ) { return ( int ) ( value + ( 0.5f * Math.signum( value ) ) ); } public static long round( final double value ) { return ( long ) ( value + ( 0.5d * Math.signum( value ) ) ); } /** * This method creates a gaussian kernel * * @param sigma * Standard Derivation of the gaussian function * @param normalize * Normalize integral of gaussian function to 1 or not... * @return double[] The gaussian kernel * */ public static double[] createGaussianKernel1DDouble( final double sigma, final boolean normalize ) { int size = 3; final double[] gaussianKernel; if ( sigma <= 0 ) { gaussianKernel = new double[ 3 ]; gaussianKernel[ 1 ] = 1; } else { size = Math.max( 3, ( 2 * ( int ) ( 3 * sigma + 0.5 ) + 1 ) ); final double two_sq_sigma = 2 * sigma * sigma; gaussianKernel = new double[ size ]; for ( int x = size / 2; x >= 0; --x ) { final double val = Math.exp( -( x * x ) / two_sq_sigma ); gaussianKernel[ size / 2 - x ] = val; gaussianKernel[ size / 2 + x ] = val; } } if ( normalize ) { double sum = 0; for ( final double value : gaussianKernel ) sum += value; for ( int i = 0; i < gaussianKernel.length; ++i ) gaussianKernel[ i ] /= sum; } return gaussianKernel; } public static int getSuggestedKernelDiameter( final double sigma ) { int size = 3; if ( sigma > 0 ) size = Math.max( 3, ( 2 * ( int ) ( 3 * sigma + 0.5 ) + 1 ) ); return size; } public static String printCoordinates( final float[] value ) { String out = "(Array empty)"; if ( value == null || value.length == 0 ) return out; out = "(" + value[ 0 ]; for ( int i = 1; i < value.length; i++ ) out += ", " + value[ i ]; out += ")"; return out; } public static String printCoordinates( final double[] value ) { String out = "(Array empty)"; if ( value == null || value.length == 0 ) return out; out = "(" + value[ 0 ]; for ( int i = 1; i < value.length; i++ ) out += ", " + value[ i ]; out += ")"; return out; } public static String printCoordinates( final RealLocalizable localizable ) { String out = "(RealLocalizable empty)"; if ( localizable == null || localizable.numDimensions() == 0 ) return out; out = "(" + localizable.getFloatPosition( 0 ); for ( int i = 1; i < localizable.numDimensions(); i++ ) out += ", " + localizable.getFloatPosition( i ); out += ")"; return out; } public static String printInterval( final Interval interval ) { String out = "(Interval empty)"; if ( interval == null || interval.numDimensions() == 0 ) return out; out = "[" + interval.min( 0 ); for ( int i = 1; i < interval.numDimensions(); i++ ) out += ", " + interval.min( i ); out += "] -> [" + interval.max( 0 ); for ( int i = 1; i < interval.numDimensions(); i++ ) out += ", " + interval.max( i ); out += "], dimensions (" + interval.dimension( 0 ); for ( int i = 1; i < interval.numDimensions(); i++ ) out += ", " + interval.dimension( i ); out += ")"; return out; } public static String printCoordinates( final int[] value ) { String out = "(Array empty)"; if ( value == null || value.length == 0 ) return out; out = "(" + value[ 0 ]; for ( int i = 1; i < value.length; i++ ) out += ", " + value[ i ]; out += ")"; return out; } public static String printCoordinates( final long[] value ) { String out = "(Array empty)"; if ( value == null || value.length == 0 ) return out; out = "(" + value[ 0 ]; for ( int i = 1; i < value.length; i++ ) out += ", " + value[ i ]; out += ")"; return out; } public static String printCoordinates( final boolean[] value ) { String out = "(Array empty)"; if ( value == null || value.length == 0 ) return out; out = "("; if ( value[ 0 ] ) out += "1"; else out += "0"; for ( int i = 1; i < value.length; i++ ) { out += ", "; if ( value[ i ] ) out += "1"; else out += "0"; } out += ")"; return out; } public static int pow( final int a, final int b ) { if ( b == 0 ) return 1; else if ( b == 1 ) return a; else { int result = a; for ( int i = 1; i < b; i++ ) result *= a; return result; } } public static < T extends Type< T > & Comparable< T > > T max( final T value1, final T value2 ) { if ( value1.compareTo( value2 ) >= 0 ) return value1; else return value2; } public static < T extends Type< T > & Comparable< T > > T min( final T value1, final T value2 ) { if ( value1.compareTo( value2 ) <= 0 ) return value1; else return value2; } final static public int[] long2int( final long[] a ) { final int[] i = new int[ a.length ]; for ( int d = 0; d < a.length; ++d ) i[ d ] = ( int ) a[ d ]; return i; } final static public long[] int2long( final int[] i ) { final long[] l = new long[ i.length ]; for ( int d = 0; d < l.length; ++d ) l[ d ] = i[ d ]; return l; } /** * Gets an instance of T from the {@link RandomAccessibleInterval} by * querying the value at the min coordinate * * @param * - the T * @param rai * - the {@link RandomAccessibleInterval} * @return - an instance of T */ final public static < T, F extends Interval & RandomAccessible< T > > T getTypeFromInterval( final F rai ) { // create RandomAccess final RandomAccess< T > randomAccess = rai.randomAccess(); // place it at the first pixel rai.min( randomAccess ); return randomAccess.get(); } /** * Gets an instance of T from the {@link RandomAccessibleInterval} by * querying the value at the min coordinate * * @param * - the T * @param rai * - the {@link RandomAccessibleInterval} * @return - an instance of T */ final public static < T, F extends RealInterval & RealRandomAccessible< T >> T getTypeFromRealInterval( final F rai ) { // create RealRandomAccess final RealRandomAccess< T > realRandomAccess = rai.realRandomAccess(); // place it at the first pixel rai.realMin( realRandomAccess ); return realRandomAccess.get(); } /** * Create an {@link ArrayImgFactory} if an image of the requested * targetSize could be held in an {@link ArrayImg}. Otherwise * return a {@link CellImgFactory} with as large as possible cell size. * * @param targetSize * size of image that the factory should be able to create. * @param type * type of the factory. * @return an {@link ArrayImgFactory} or a {@link CellImgFactory}. */ public static < T extends NativeType< T > > ImgFactory< T > getArrayOrCellImgFactory( final Dimensions targetSize, final T type ) { if ( Intervals.numElements( targetSize ) <= Integer.MAX_VALUE ) return new ArrayImgFactory< T >(); final int cellSize = ( int ) Math.pow( Integer.MAX_VALUE / type.getEntitiesPerPixel().getRatio(), 1.0 / targetSize.numDimensions() ); return new CellImgFactory< T >( cellSize ); } /** * Create an {@link ArrayImgFactory} if an image of the requested * targetSize could be held in an {@link ArrayImg}. Otherwise * return a {@link CellImgFactory} with cell size * targetCellSize (or as large as possible if * targetCellSize is too large). * * @param targetSize * size of image that the factory should be able to create. * @param targetCellSize * if a {@link CellImgFactory} is created, what should be the * cell size. * @param type * type of the factory. * @return an {@link ArrayImgFactory} or a {@link CellImgFactory}. */ public static < T extends NativeType< T > > ImgFactory< T > getArrayOrCellImgFactory( final Dimensions targetSize, final int targetCellSize, final T type ) { if ( Intervals.numElements( targetSize ) <= Integer.MAX_VALUE ) return new ArrayImgFactory< T >(); final int cellSize; if ( Math.pow( targetCellSize, targetSize.numDimensions() ) <= Integer.MAX_VALUE ) cellSize = targetCellSize; else cellSize = ( int ) Math.pow( Integer.MAX_VALUE / type.getEntitiesPerPixel().getRatio(), 1.0 / targetSize.numDimensions() ); return new CellImgFactory< T >( cellSize ); } /** * (Hopefully) fast floor log2 of an unsigned(!) integer value. * * @param v * unsigned integer * @return floor log2 */ final static public int ldu( int v ) { int c = 0; do { v >>= 1; ++c; } while ( v > 1 ); return c; } /** * Checks whether n {@link IterableInterval} have the same iteration order. */ public static boolean equalIterationOrder( final IterableInterval< ? >... intervals ) { final Object order = intervals[ 0 ].iterationOrder(); for ( int i = 1; i < intervals.length; i++ ) { if ( !order.equals( intervals[ i ].iterationOrder() ) ) return false; } return true; } /** * Writes min(a,b) into a * * @param a * @param b */ final static public void min( final double[] a, final double[] b ) { for ( int i = 0; i < a.length; ++i ) if ( b[ i ] < a[ i ] ) a[ i ] = b[ i ]; } /** * Writes max(a,b) into a * * @param a * @param b */ final static public void max( final double[] a, final double[] b ) { for ( int i = 0; i < a.length; ++i ) if ( b[ i ] > a[ i ] ) a[ i ] = b[ i ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/util/ValuePair.java000066400000000000000000000055071316447754700247000ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; /** * TODO * */ public class ValuePair< A, B > implements Pair< A, B > { final public A a; final public B b; public ValuePair( final A a, final B b ) { this.a = a; this.b = b; } @Override public A getA() { return a; } @Override public B getB() { return b; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ( ( a == null ) ? 0 : a.hashCode() ); result = prime * result + ( ( b == null ) ? 0 : b.hashCode() ); return result; } @Override public boolean equals(Object obj) { if ( this == obj ) return true; if ( obj == null ) return false; if ( !(obj instanceof Pair) ) return false; Pair other = (Pair) obj; if ( a == null ) { if ( other.getA() != null ) return false; } else if ( !a.equals( other.getA() ) ) return false; if ( b == null ) { if ( other.getB() != null ) return false; } else if ( !b.equals( other.getB() ) ) return false; return true; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/000077500000000000000000000000001316447754700221335ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/ExtendedRandomAccessibleInterval.java000066400000000000000000000065051316447754700313700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; import net.imglib2.outofbounds.OutOfBounds; import net.imglib2.outofbounds.OutOfBoundsFactory; import net.imglib2.util.Intervals; /** * Implements {@link RandomAccessible} for a {@link RandomAccessibleInterval} * through an {@link OutOfBoundsFactory}. Note that it is not an Interval * itself. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ final public class ExtendedRandomAccessibleInterval< T, F extends RandomAccessibleInterval< T > > implements RandomAccessible< T >, View { final protected F source; final protected OutOfBoundsFactory< T, ? super F > factory; public ExtendedRandomAccessibleInterval( final F source, final OutOfBoundsFactory< T, ? super F > factory ) { this.source = source; this.factory = factory; } @Override final public int numDimensions() { return source.numDimensions(); } @Override final public OutOfBounds< T > randomAccess() { return factory.create( source ); } @Override final public RandomAccess< T > randomAccess( final Interval interval ) { assert source.numDimensions() == interval.numDimensions(); if ( Intervals.contains( source, interval ) ) { return source.randomAccess( interval ); } return randomAccess(); } public F getSource() { return source; } public OutOfBoundsFactory< T, ? super F > getOutOfBoundsFactory() { return factory; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/ExtendedRealRandomAccessibleRealInterval.java000066400000000000000000000067271316447754700330060ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.RealInterval; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; import net.imglib2.RealRandomAccessibleRealInterval; import net.imglib2.outofbounds.RealOutOfBoundsFactory; import net.imglib2.outofbounds.RealOutOfBoundsRealRandomAccess; import net.imglib2.util.Intervals; /** * Implements {@link RealRandomAccessible} for a * {@link RealRandomAccessibleRealInterval} through an * {@link RealOutOfBoundsFactory}. Note that it is not a RealInterval itself. * * @author Stephan Saalfeld */ final public class ExtendedRealRandomAccessibleRealInterval< T, F extends RealRandomAccessibleRealInterval< T > > implements RealRandomAccessible< T > { final protected F source; final protected RealOutOfBoundsFactory< T, ? super F > factory; public ExtendedRealRandomAccessibleRealInterval( final F source, final RealOutOfBoundsFactory< T, ? super F > factory ) { this.source = source; this.factory = factory; } @Override final public int numDimensions() { return source.numDimensions(); } @Override final public RealOutOfBoundsRealRandomAccess< T > realRandomAccess() { return new RealOutOfBoundsRealRandomAccess< T >( source.numDimensions(), factory.create( source ) ); } @Override final public RealRandomAccess< T > realRandomAccess( final RealInterval interval ) { assert source.numDimensions() == interval.numDimensions(); if ( Intervals.contains( source, interval ) ) { return source.realRandomAccess(); } return realRandomAccess(); } public F getSource() { return source; } public RealOutOfBoundsFactory< T, ? super F > getOutOfBoundsFactory() { return factory; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/FullSourceMapMixedRandomAccess.java000066400000000000000000000253061316447754700307770ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.transform.integer.Mixed; /** * Wrap a {@code source} RandomAccess which is related to this by a * {@link Mixed} {@code transformToSource}. This is for {@link Mixed} transforms * that feature a full mapping of source to target components. That is, there is * no down-projection, no source component is discarded. In this case, the * current position can be recovered from the position of the source * RandomAccess. Localize can be implemented via localize on the source * RandomAccess. * *

* For the general case, see {@link MixedRandomAccess}. *

* * @param * @author Tobias Pietzsch */ public final class FullSourceMapMixedRandomAccess< T > extends AbstractEuclideanSpace implements RandomAccess< T > { /** * source RandomAccess. note that this is the target of the * transformToSource. */ private final RandomAccess< T > s; /** * number of dimensions of source RandomAccess, respectively * numTargetDimensions of the Mixed transform. */ private final int m; private final long[] translation; /** * for each component of the source vector: should the target vector * component be inverted (true). */ private final boolean[] sourceInv; /** * for each component of the source vector: to which target vector component * should it be taken. */ private final int[] sourceComponent; private final long[] tmpPosition; private final long[] tmpDistance; FullSourceMapMixedRandomAccess( final RandomAccess< T > source, final Mixed transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); translation = new long[ m ]; final boolean[] targetZero = new boolean[ m ]; final boolean[] targetInv = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getTranslation( translation ); transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); transformToSource.getComponentInversion( targetInv ); sourceInv = new boolean[ n ]; sourceComponent = new int[ n ]; for ( int d = 0; d < m; ++d ) { if ( targetZero[ d ] ) { s.setPosition( translation[ d ], d ); } else { final int e = targetComponent[ d ]; // sourceZero[ e ] = false; sourceInv[ e ] = targetInv[ d ]; sourceComponent[ e ] = d; } } tmpPosition = translation.clone(); tmpDistance = new long[ m ]; } protected FullSourceMapMixedRandomAccess( final FullSourceMapMixedRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); this.s = randomAccess.s.copyRandomAccess(); this.m = randomAccess.m; this.translation = randomAccess.translation.clone(); this.sourceInv = randomAccess.sourceInv.clone(); this.sourceComponent = randomAccess.sourceComponent.clone(); tmpPosition = translation.clone(); tmpDistance = new long[ m ]; } @Override public void localize( final int[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getIntPosition( d ); } @Override public void localize( final long[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getLongPosition( d ); } @Override public int getIntPosition( final int d ) { assert d < n; final int td = sourceComponent[ d ]; final int v = s.getIntPosition( td ) - ( int ) translation[ td ]; return sourceInv[ d ] ? -v : v; } @Override public long getLongPosition( final int d ) { assert d < n; final int td = sourceComponent[ d ]; final long v = s.getLongPosition( td ) - translation[ td ]; return sourceInv[ d ] ? -v : v; } @Override public void localize( final float[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getFloatPosition( d ); } @Override public void localize( final double[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getDoublePosition( d ); } @Override public float getFloatPosition( final int d ) { return getLongPosition( d ); } @Override public double getDoublePosition( final int d ) { return getLongPosition( d ); } @Override public void fwd( final int d ) { assert d < n; if ( sourceInv[ d ] ) s.bck( sourceComponent[ d ] ); else s.fwd( sourceComponent[ d ] ); } @Override public void bck( final int d ) { assert d < n; if ( sourceInv[ d ] ) s.fwd( sourceComponent[ d ] ); else s.bck( sourceComponent[ d ] ); } @Override public void move( final int distance, final int d ) { assert d < n; s.move( sourceInv[ d ] ? -distance : distance, sourceComponent[ d ] ); } @Override public void move( final long distance, final int d ) { assert d < n; s.move( sourceInv[ d ] ? -distance : distance, sourceComponent[ d ] ); } @Override public void move( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { final int td = sourceComponent[ d ]; final long p = localizable.getLongPosition( d ); tmpDistance[ td ] = sourceInv[ d ] ? -p : p; } s.move( tmpDistance ); } @Override public void move( final int[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { final int td = sourceComponent[ d ]; tmpDistance[ td ] = sourceInv[ d ] ? -distance[ d ] : distance[ d ]; } s.move( tmpDistance ); } @Override public void move( final long[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { final int td = sourceComponent[ d ]; tmpDistance[ td ] = sourceInv[ d ] ? -distance[ d ] : distance[ d ]; } s.move( tmpDistance ); } @Override public void setPosition( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final int td = sourceComponent[ d ]; final long p = localizable.getLongPosition( d ); tmpPosition[ td ] = translation[ td ] + ( sourceInv[ d ] ? -p : p ); } s.setPosition( tmpPosition ); } @Override public void setPosition( final int[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final int td = sourceComponent[ d ]; tmpPosition[ td ] = translation[ td ] + ( sourceInv[ d ] ? -position[ d ] : position[ d ] ); } s.setPosition( tmpPosition ); } @Override public void setPosition( final long[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final int td = sourceComponent[ d ]; tmpPosition[ td ] = translation[ td ] + ( sourceInv[ d ] ? -position[ d ] : position[ d ] ); } s.setPosition( tmpPosition ); } @Override public void setPosition( final int position, final int d ) { assert d < n; final int td = sourceComponent[ d ]; final int targetPos = ( int ) translation[ td ] + ( sourceInv[ d ] ? -position : position ); s.setPosition( targetPos, td ); } @Override public void setPosition( final long position, final int d ) { assert d < n; final int td = sourceComponent[ d ]; final long targetPos = translation[ td ] + ( sourceInv[ d ] ? -position : position ); s.setPosition( targetPos, td ); } @Override public T get() { return s.get(); } @Override public FullSourceMapMixedRandomAccess< T > copy() { return new FullSourceMapMixedRandomAccess< T >( this ); } @Override public FullSourceMapMixedRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/FullSourceMapSlicingRandomAccess.java000066400000000000000000000223501316447754700313150ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.transform.integer.Slicing; /** * Wrap a {@code source} RandomAccess which is related to this by a * {@link Slicing} {@code transformToSource}. This is for {@link Slicing} transforms * that feature a full mapping of source to target components. That is, there is * no down-projection, no source component is discarded. In this case, the * current position can be recovered from the position of the source * RandomAccess. Localize can be implemented via localize on the source * RandomAccess. * *

* For the general case, see {@link SlicingRandomAccess}. *

* * @param * @author Tobias Pietzsch */ public class FullSourceMapSlicingRandomAccess< T > extends AbstractEuclideanSpace implements RandomAccess< T > { /** * source RandomAccess. note that this is the target of the * transformToSource. */ private final RandomAccess< T > s; /** * number of dimensions of source RandomAccess, respectively * numTargetDimensions of the Slicing transform. */ private final int m; /** * for each component of the source vector: to which target vector component * should it be taken. */ private final int[] sourceComponent; private final long[] tmpPosition; private final long[] tmpDistance; FullSourceMapSlicingRandomAccess( final RandomAccess< T > source, final Slicing transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); final boolean[] targetZero = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); sourceComponent = new int[ n ]; for ( int d = 0; d < m; ++d ) if ( transformToSource.getComponentZero( d ) ) s.setPosition( transformToSource.getTranslation( d ), d ); else sourceComponent[ transformToSource.getComponentMapping( d ) ] = d; tmpPosition = new long[ m ]; transformToSource.getTranslation( tmpPosition ); tmpDistance = new long[ m ]; } protected FullSourceMapSlicingRandomAccess( final FullSourceMapSlicingRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); s = randomAccess.s.copyRandomAccess(); m = randomAccess.m; sourceComponent = randomAccess.sourceComponent.clone(); tmpPosition = randomAccess.tmpPosition.clone(); tmpDistance = randomAccess.tmpDistance.clone(); } @Override public void localize( final int[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getIntPosition( d ); } @Override public void localize( final long[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getLongPosition( d ); } @Override public int getIntPosition( final int d ) { assert d < n; return s.getIntPosition( sourceComponent[ d ] ); } @Override public long getLongPosition( final int d ) { assert d < n; return s.getLongPosition( sourceComponent[ d ] ); } @Override public void localize( final float[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getFloatPosition( d ); } @Override public void localize( final double[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getDoublePosition( d ); } @Override public float getFloatPosition( final int d ) { assert d < n; return s.getFloatPosition( sourceComponent[ d ] ); } @Override public double getDoublePosition( final int d ) { assert d < n; return s.getDoublePosition( sourceComponent[ d ] ); } @Override public void fwd( final int d ) { s.fwd( sourceComponent[ d ] ); } @Override public void bck( final int d ) { s.bck( sourceComponent[ d ] ); } @Override public void move( final int distance, final int d ) { assert d < n; s.move( distance, sourceComponent[ d ] ); } @Override public void move( final long distance, final int d ) { assert d < n; s.move( distance, sourceComponent[ d ] ); } @Override public void move( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) tmpDistance[ sourceComponent[ d ] ] = localizable.getLongPosition( d ); s.move( tmpDistance ); } @Override public void move( final int[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) tmpDistance[ sourceComponent[ d ] ] = distance[ d ]; s.move( tmpDistance ); } @Override public void move( final long[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) tmpDistance[ sourceComponent[ d ] ] = distance[ d ]; s.move( tmpDistance ); } @Override public void setPosition( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) tmpPosition[ sourceComponent[ d ] ] = localizable.getLongPosition( d ); s.setPosition( tmpPosition ); } @Override public void setPosition( final int[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) tmpPosition[ sourceComponent[ d ] ] = position[ d ]; s.setPosition( tmpPosition ); } @Override public void setPosition( final long[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) tmpPosition[ sourceComponent[ d ] ] = position[ d ]; s.setPosition( tmpPosition ); } @Override public void setPosition( final int position, final int d ) { assert d < n; s.setPosition( position, sourceComponent[ d ] ); } @Override public void setPosition( final long position, final int d ) { assert d < n; s.setPosition( position, sourceComponent[ d ] ); } @Override public T get() { return s.get(); } @Override public FullSourceMapSlicingRandomAccess< T > copy() { return new FullSourceMapSlicingRandomAccess< T >( this ); } @Override public FullSourceMapSlicingRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/HyperSlice.java000066400000000000000000000140411316447754700250450ustar00rootroot00000000000000package net.imglib2.view; import java.util.Arrays; import net.imglib2.FinalInterval; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; /** * @author Stephan Saalfeld <saalfelds@janelia.hhmi.org> * */ public class HyperSlice< T > implements RandomAccessible< T > { final protected RandomAccessible< T > source; final protected int numDimensions; /* in the hyperslice */ final protected int[] axes; /* absolute position including internal axes that are ignored */ final protected long[] position; /** * Generates a {@link FinalInterval} whose boundaries are the current * position of the hyperslice and {@link Interval interval} on the * hyperslice. * * @param interval * @return */ private Interval sourceInterval( final Interval interval ) { assert interval.numDimensions() == axes.length : "Interval dimensions do not match Hyperslice dimensions."; final long[] min = new long[ numDimensions ]; final long[] max = new long[ numDimensions ]; for ( int d = 0; d < position.length; ++d ) min[ d ] = max[ d ] = position[ d ]; for ( int d = 0; d < interval.numDimensions(); ++d ) { min[ axes[ d ] ] = interval.min( d ); max[ axes[ d ] ] = interval.max( d ); } return new FinalInterval( min, max ); } public class HyperSliceRandomAccess implements RandomAccess< T > { final protected RandomAccess< T > sourceAccess; public HyperSliceRandomAccess() { sourceAccess = source.randomAccess(); sourceAccess.setPosition( position ); } public HyperSliceRandomAccess( final Interval interval ) { sourceAccess = source.randomAccess( sourceInterval( interval ) ); sourceAccess.setPosition( position ); } @Override public void localize( int[] position ) { for ( int d = 0; d < numDimensions; ++d ) position[ d ] = sourceAccess.getIntPosition( axes[ d ] ); } @Override public void localize( long[] position ) { for ( int d = 0; d < numDimensions; ++d ) position[ d ] = sourceAccess.getLongPosition( axes[ d ] ); } @Override public int getIntPosition( int d ) { return sourceAccess.getIntPosition( axes[ d ] ); } @Override public long getLongPosition( int d ) { return sourceAccess.getLongPosition( axes[ d ] ); } @Override public void localize( float[] position ) { for ( int d = 0; d < numDimensions; ++d ) position[ d ] = sourceAccess.getFloatPosition( axes[ d ] ); } @Override public void localize( double[] position ) { for ( int d = 0; d < numDimensions; ++d ) position[ d ] = sourceAccess.getDoublePosition( axes[ d ] ); } @Override public float getFloatPosition( int d ) { return sourceAccess.getFloatPosition( axes[ d ] ); } @Override public double getDoublePosition( int d ) { return sourceAccess.getDoublePosition( axes[ d ] ); } @Override public int numDimensions() { return numDimensions; } @Override public void fwd( int d ) { sourceAccess.fwd( axes[ d ] ); } @Override public void bck( int d ) { sourceAccess.bck( axes[ d ] ); } @Override public void move( int distance, int d ) { sourceAccess.move( distance, axes[ d ] ); } @Override public void move( long distance, int d ) { sourceAccess.move( distance, axes[ d ] ); } @Override public void move( Localizable localizable ) { for ( int d = 0; d < numDimensions; ++d ) sourceAccess.move( localizable.getLongPosition( d ), axes[ d ] ); } @Override public void move( int[] distance ) { for ( int d = 0; d < numDimensions; ++d ) sourceAccess.move( distance[ d ], axes[ d ] ); } @Override public void move( long[] distance ) { for ( int d = 0; d < numDimensions; ++d ) sourceAccess.move( distance[ d ], axes[ d ] ); } @Override public void setPosition( Localizable localizable ) { for ( int d = 0; d < numDimensions; ++d ) sourceAccess.setPosition( localizable.getLongPosition( d ), axes[ d ] ); } @Override public void setPosition( int[] position ) { for ( int d = 0; d < numDimensions; ++d ) sourceAccess.setPosition( position[ d ], axes[ d ] ); } @Override public void setPosition( long[] position ) { for ( int d = 0; d < numDimensions; ++d ) sourceAccess.setPosition( position[ d ], axes[ d ] ); } @Override public void setPosition( int position, int d ) { sourceAccess.setPosition( position, axes[ d ] ); } @Override public void setPosition( long position, int d ) { sourceAccess.setPosition( position, axes[ d ] ); } @Override public T get() { return sourceAccess.get(); } @Override public HyperSliceRandomAccess copy() { return new HyperSliceRandomAccess(); } @Override public HyperSliceRandomAccess copyRandomAccess() { return copy(); } } /** * Create a new HyperSlice at a position. The position is passed as * position vector in source space, i.e. the positions along fixed axes * are ignored. * * @param source * @param fixedAxes * @param position */ public HyperSlice( final RandomAccessible< T > source, final int[] fixedAxes, final long[] position ) { this.source = source; final int[] sortedFixedAxes = fixedAxes.clone(); Arrays.sort( sortedFixedAxes ); numDimensions = source.numDimensions() - fixedAxes.length; axes = new int[ numDimensions ]; this.position = new long[ position.length ]; for ( int d = 0, da = 0, db = 0; d < source.numDimensions(); ++d ) { if ( da < sortedFixedAxes.length && sortedFixedAxes[ da ] == d ) { ++da; this.position[ d ] = position[ d ]; } else axes[ db++ ] = d; } // System.out.println( "axes " + Arrays.toString( axes ) ); // System.out.println( "fixed axes " + Arrays.toString( sortedFixedAxes ) ); } @Override public int numDimensions() { return axes.length; } @Override public HyperSliceRandomAccess randomAccess() { return new HyperSliceRandomAccess(); } @Override public RandomAccess< T > randomAccess( Interval interval ) { return new HyperSliceRandomAccess(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/HyperSlicesView.java000066400000000000000000000045211316447754700260650ustar00rootroot00000000000000/** * */ package net.imglib2.view; import java.util.Arrays; import net.imglib2.Interval; import net.imglib2.Point; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; /** * {@link HyperSlicesView} is a {@link RandomAccessible} of all * {@link HyperSlice hyperslices}. This implementation creates a new and * therefore independent {@link HyperSlice} per {@code get()} at the correct * position. * * @author Stephan Saalfeld <saalfelds@janelia.hhmi.org> * */ public class HyperSlicesView< T > implements RandomAccessible< HyperSlice< T > > { final protected RandomAccessible< T > source; final protected int numDimensions; /* outside of the hyperslice */ final protected int[] accessAxes; public class HyperSlicesViewRandomAccess extends Point implements RandomAccess< HyperSlice< T > > { public HyperSlicesViewRandomAccess() { super( numDimensions ); } @Override public HyperSlice< T > get() { final long[] position = new long[ source.numDimensions() ]; for ( int d = 0; d < numDimensions; ++d ) position[ accessAxes[ d ] ] = getLongPosition( d ); return new HyperSlice< T >( source, accessAxes, position ); } @Override public HyperSlicesViewRandomAccess copy() { final HyperSlicesViewRandomAccess copy = new HyperSlicesViewRandomAccess(); copy.setPosition( this ); return copy; } @Override public HyperSlicesViewRandomAccess copyRandomAccess() { return copy(); } } public HyperSlicesView( final RandomAccessible< T > source, final int... axes ) { this.source = source; final int[] sortedAxes = axes.clone(); Arrays.sort( sortedAxes ); numDimensions = source.numDimensions() - sortedAxes.length; accessAxes = new int[ numDimensions ]; for ( int d = 0, da = 0, db = 0; d < source.numDimensions(); ++d ) { if ( da < sortedAxes.length && sortedAxes[ da ] == d ) ++da; else accessAxes[ db++ ] = d; } } @Override public int numDimensions() { return numDimensions; } @Override public HyperSlicesViewRandomAccess randomAccess() { return new HyperSlicesViewRandomAccess(); } @Override public HyperSlicesViewRandomAccess randomAccess( final Interval interval ) { /* intervals only matter inside hyperslice space as the slice itself is only * one pixel thick (constant) in all outer dimensions */ return randomAccess(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/IntervalView.java000066400000000000000000000125751316447754700254270ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.Iterator; import net.imglib2.AbstractInterval; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; import net.imglib2.view.iteration.IterableTransformBuilder; /** * IntervalView is a view that puts {@link Interval} boundaries on its source * {@link RandomAccessible}. IntervalView uses {@link TransformBuilder} to * create efficient {@link RandomAccess accessors}. Usually an IntervalView is * created through the {@link Views#interval(RandomAccessible, Interval)} method * instead. */ public class IntervalView< T > extends AbstractInterval implements RandomAccessibleInterval< T >, IterableInterval< T >, View { /** * The source {@link RandomAccessible}. */ protected final RandomAccessible< T > source; /** * TODO Javadoc */ protected RandomAccessible< T > fullViewRandomAccessible; /** * TODO Javadoc */ protected IterableInterval< T > fullViewIterableInterval; /** * Create a view that defines an interval on a source. It is the callers * responsibility to ensure that the source is defined in the specified * interval. * * @see Views#interval(RandomAccessible, Interval) */ public IntervalView( final RandomAccessible< T > source, final Interval interval ) { super( interval ); assert ( source.numDimensions() == interval.numDimensions() ); this.source = source; this.fullViewRandomAccessible = null; } /** * Create a view that defines an interval on a source. It is the callers * responsibility to ensure that the source is defined in the specified * interval. * * @see Views#interval(RandomAccessible, Interval) * * @param min * minimum coordinate of the interval. * @param max * maximum coordinate of the interval. */ public IntervalView( final RandomAccessible< T > source, final long[] min, final long[] max ) { super( min, max ); assert ( source.numDimensions() == min.length ); this.source = source; this.fullViewRandomAccessible = null; } /** * Gets the underlying source {@link RandomAccessible}. * * @return the source {@link RandomAccessible}. */ public RandomAccessible< T > getSource() { return source; } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return TransformBuilder.getEfficientRandomAccessible( interval, this ).randomAccess(); } @Override public RandomAccess< T > randomAccess() { if ( fullViewRandomAccessible == null ) fullViewRandomAccessible = TransformBuilder.getEfficientRandomAccessible( this, this ); return fullViewRandomAccessible.randomAccess(); } protected IterableInterval< T > getFullViewIterableInterval() { if ( fullViewIterableInterval == null ) fullViewIterableInterval = IterableTransformBuilder.getEfficientIterableInterval( this, this ); return fullViewIterableInterval; } @Override public long size() { return getFullViewIterableInterval().size(); } @Override public T firstElement() { return getFullViewIterableInterval().firstElement(); } @Override public Object iterationOrder() { return getFullViewIterableInterval().iterationOrder(); } @Override public Iterator< T > iterator() { return getFullViewIterableInterval().iterator(); } @Override public Cursor< T > cursor() { return getFullViewIterableInterval().cursor(); } @Override public Cursor< T > localizingCursor() { return getFullViewIterableInterval().localizingCursor(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/IterableRandomAccessibleInterval.java000066400000000000000000000074541316447754700313630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.Iterator; import net.imglib2.AbstractWrappedInterval; import net.imglib2.Cursor; import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; /** * Generates {@link Cursor Cursors} that iterate a * {@link RandomAccessibleInterval} in flat order, that is: row by row, plane by * plane, cube by cube, ... * * @author Stephan Saalfeld */ public class IterableRandomAccessibleInterval< T > extends AbstractWrappedInterval< RandomAccessibleInterval< T > > implements IterableInterval< T >, RandomAccessibleInterval< T >, View { final long size; public static < T > IterableRandomAccessibleInterval< T > create( final RandomAccessibleInterval< T > interval ) { return new IterableRandomAccessibleInterval< T >( interval ); } public IterableRandomAccessibleInterval( final RandomAccessibleInterval< T > interval ) { super( interval ); final int n = numDimensions(); long s = interval.dimension( 0 ); for ( int d = 1; d < n; ++d ) s *= interval.dimension( d ); size = s; } @Override public long size() { return size; } @Override public T firstElement() { // we cannot simply create an randomaccessible on interval // this does not ensure it will be placed at the first element return cursor().next(); } @Override public FlatIterationOrder iterationOrder() { return new FlatIterationOrder( sourceInterval ); } @Override public Iterator< T > iterator() { return cursor(); } @Override public Cursor< T > cursor() { return new RandomAccessibleIntervalCursor< T >( sourceInterval ); } @Override public Cursor< T > localizingCursor() { return cursor(); } @Override public RandomAccess< T > randomAccess() { return sourceInterval.randomAccess(); } @Override public RandomAccess< T > randomAccess( final Interval i ) { return sourceInterval.randomAccess( i ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/MixedRandomAccess.java000066400000000000000000000241311316447754700263300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractLocalizable; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.transform.integer.Mixed; /** * Wrap a {@code source} RandomAccess which is related to this by a * {@link Mixed} {@code transformToSource}. * * @param * @author Tobias Pietzsch */ public final class MixedRandomAccess< T > extends AbstractLocalizable implements RandomAccess< T > { /** * source RandomAccess. note that this is the target of the * transformToSource. */ private final RandomAccess< T > s; /** * number of dimensions of source RandomAccess, respectively * numTargetDimensions of the Mixed transform. */ private final int m; private final long[] translation; /** * for each component of the source vector: should the value be taken to a * target vector component (false) or should it be discarded (true). */ private final boolean[] sourceZero; /** * for each component of the source vector: should the target vector * component be inverted (true). */ private final boolean[] sourceInv; /** * for each component of the source vector: to which target vector component * should it be taken. */ private final int[] sourceComponent; private final long[] tmpPosition; private final long[] tmpDistance; MixedRandomAccess( final RandomAccess< T > source, final Mixed transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); translation = new long[ m ]; final boolean[] targetZero = new boolean[ m ]; final boolean[] targetInv = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getTranslation( translation ); transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); transformToSource.getComponentInversion( targetInv ); sourceZero = new boolean[ n ]; sourceInv = new boolean[ n ]; sourceComponent = new int[ n ]; for ( int e = 0; e < n; ++e ) { sourceZero[ e ] = true; } for ( int d = 0; d < m; ++d ) { if ( targetZero[ d ] ) { s.setPosition( translation[ d ], d ); } else { final int e = targetComponent[ d ]; sourceZero[ e ] = false; sourceInv[ e ] = targetInv[ d ]; sourceComponent[ e ] = d; } } tmpPosition = translation.clone(); tmpDistance = new long[ m ]; } protected MixedRandomAccess( final MixedRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); this.s = randomAccess.s.copyRandomAccess(); this.m = randomAccess.m; this.translation = randomAccess.translation.clone(); this.sourceZero = randomAccess.sourceZero.clone(); this.sourceInv = randomAccess.sourceInv.clone(); this.sourceComponent = randomAccess.sourceComponent.clone(); tmpPosition = translation.clone(); tmpDistance = new long[ m ]; } @Override public void fwd( final int d ) { assert d < n; position[ d ] += 1; if ( !sourceZero[ d ] ) { if ( sourceInv[ d ] ) { s.bck( sourceComponent[ d ] ); } else { s.fwd( sourceComponent[ d ] ); } } } @Override public void bck( final int d ) { assert d < n; position[ d ] -= 1; if ( !sourceZero[ d ] ) { if ( sourceInv[ d ] ) { s.fwd( sourceComponent[ d ] ); } else { s.bck( sourceComponent[ d ] ); } } } @Override public void move( final int distance, final int d ) { assert d < n; position[ d ] += distance; if ( !sourceZero[ d ] ) s.move( sourceInv[ d ] ? -distance : distance, sourceComponent[ d ] ); } @Override public void move( final long distance, final int d ) { assert d < n; position[ d ] += distance; if ( !sourceZero[ d ] ) s.move( sourceInv[ d ] ? -distance : distance, sourceComponent[ d ] ); } @Override public void move( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { final long distance = localizable.getLongPosition( d ); position[ d ] += distance; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; tmpDistance[ td ] = sourceInv[ d ] ? -distance : distance; } } s.move( tmpDistance ); } @Override public void move( final int[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { position[ d ] += distance[ d ]; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; tmpDistance[ td ] = sourceInv[ d ] ? -distance[ d ] : distance[ d ]; } } s.move( tmpDistance ); } @Override public void move( final long[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { position[ d ] += distance[ d ]; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; tmpDistance[ td ] = sourceInv[ d ] ? -distance[ d ] : distance[ d ]; } } s.move( tmpDistance ); } @Override public void setPosition( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final long p = localizable.getLongPosition( d ); this.position[ d ] = p; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; tmpPosition[ td ] = translation[ td ] + ( sourceInv[ d ] ? -p : p ); } } s.setPosition( tmpPosition ); } @Override public void setPosition( final int[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final long p = position[ d ]; this.position[ d ] = p; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; tmpPosition[ td ] = translation[ td ] + ( sourceInv[ d ] ? -p : p ); } } s.setPosition( tmpPosition ); } @Override public void setPosition( final long[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final long p = position[ d ]; this.position[ d ] = p; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; tmpPosition[ td ] = translation[ td ] + ( sourceInv[ d ] ? -p : p ); } } s.setPosition( tmpPosition ); } @Override public void setPosition( final int position, final int d ) { assert d < n; this.position[ d ] = position; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; final long targetPos = translation[ td ] + ( sourceInv[ d ] ? -position : position ); s.setPosition( targetPos, td ); } } @Override public void setPosition( final long position, final int d ) { assert d < n; this.position[ d ] = position; if ( !sourceZero[ d ] ) { final int td = sourceComponent[ d ]; final long targetPos = translation[ td ] + ( sourceInv[ d ] ? -position : position ); s.setPosition( targetPos, td ); } } @Override public T get() { return s.get(); } @Override public MixedRandomAccess< T > copy() { return new MixedRandomAccess< T >( this ); } @Override public MixedRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/MixedTransformView.java000066400000000000000000000100321316447754700265670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.View; import net.imglib2.transform.integer.Mixed; import net.imglib2.transform.integer.MixedTransform; /** * TODO * */ public class MixedTransformView< T > implements TransformedRandomAccessible< T > { protected final int n; protected final RandomAccessible< T > source; protected final MixedTransform transformToSource; protected RandomAccessible< T > fullViewRandomAccessible; public MixedTransformView( RandomAccessible< T > source, final Mixed transformToSource ) { assert source.numDimensions() == transformToSource.numTargetDimensions(); this.n = transformToSource.numSourceDimensions(); while ( IntervalView.class.isInstance( source ) ) { source = ( ( IntervalView< T > ) source ).getSource(); } if ( MixedTransformView.class.isInstance( source ) ) { final MixedTransformView< T > v = ( MixedTransformView< T > ) source; this.source = v.getSource(); this.transformToSource = v.getTransformToSource().concatenate( transformToSource ); } else { this.source = source; final int sourceDim = this.source.numDimensions(); this.transformToSource = new MixedTransform( n, sourceDim ); this.transformToSource.set( transformToSource ); } fullViewRandomAccessible = null; } @Override public int numDimensions() { return n; } @Override public String toString() { String className = this.getClass().getCanonicalName(); className = className.substring( className.lastIndexOf( "." ) + 1, className.length() ); return className + "(" + super.toString() + ")"; } @Override public RandomAccessible< T > getSource() { return source; } @Override public MixedTransform getTransformToSource() { return transformToSource; } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return TransformBuilder.getEfficientRandomAccessible( interval, this ).randomAccess(); } @Override public RandomAccess< T > randomAccess() { if ( fullViewRandomAccessible == null ) fullViewRandomAccessible = TransformBuilder.getEfficientRandomAccessible( null, this ); return fullViewRandomAccessible.randomAccess(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/RandomAccessibleIntervalCursor.java000066400000000000000000000130021316447754700310730ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractInterval; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.util.IntervalIndexer; /** * A {@link Cursor} that iterates any {@link RandomAccessibleInterval} by moving * a {@link RandomAccess} in flat iteration order. {@link Localizable} calls are * forwarded to the {@link RandomAccess}. * * @author Tobias Pietzsch * @author Stephan Saalfeld */ public final class RandomAccessibleIntervalCursor< T > extends AbstractInterval implements Cursor< T > { private final RandomAccess< T > randomAccess; private final long[] dimensions; private final long[] tmp; private long index; private final long maxIndex; private long maxIndexOnLine; public < I extends RandomAccessible< T > & Interval > RandomAccessibleIntervalCursor( final I interval ) { super( interval ); randomAccess = interval.randomAccess(); dimensions = new long[ n ]; dimensions( dimensions ); tmp = new long[ n ]; long size = dimensions[ 0 ]; for ( int d = 1; d < n; ++d ) size *= dimensions[ d ]; maxIndex = size - 1; reset(); } protected RandomAccessibleIntervalCursor( final RandomAccessibleIntervalCursor< T > cursor ) { super( cursor ); this.randomAccess = cursor.randomAccess.copyRandomAccess(); dimensions = cursor.dimensions.clone(); tmp = new long[ n ]; index = cursor.index; maxIndex = cursor.maxIndex; maxIndexOnLine = cursor.maxIndexOnLine; } @Override public T get() { return randomAccess.get(); } @Override public void jumpFwd( final long steps ) { index += steps; final long l = index / dimensions[ 0 ]; maxIndexOnLine = ( l < 0 ) ? ( l * dimensions[ 0 ] ) : ( ( 1 + l ) * dimensions[ 0 ] - 1 ); IntervalIndexer.indexToPositionWithOffset( index, dimensions, min, tmp ); randomAccess.setPosition( tmp ); } @Override public void fwd() { randomAccess.fwd( 0 ); if ( ++index > maxIndexOnLine ) nextLine(); } private void nextLine() { randomAccess.setPosition( min[ 0 ], 0 ); maxIndexOnLine += dimensions[ 0 ]; for ( int d = 1; d < n; ++d ) { randomAccess.fwd( d ); if ( randomAccess.getLongPosition( d ) > max[ d ] ) randomAccess.setPosition( min[ d ], d ); else break; } } @Override public void reset() { index = -1; maxIndexOnLine = dimensions[ 0 ] - 1; randomAccess.setPosition( min ); randomAccess.bck( 0 ); } @Override public boolean hasNext() { return index < maxIndex; } @Override public T next() { fwd(); return get(); } @Override public void remove() {} @Override public RandomAccessibleIntervalCursor< T > copy() { return new RandomAccessibleIntervalCursor< T >( this ); } @Override public RandomAccessibleIntervalCursor< T > copyCursor() { return copy(); } @Override public void localize( final float[] position ) { randomAccess.localize( position ); } @Override public void localize( final double[] position ) { randomAccess.localize( position ); } @Override public float getFloatPosition( final int d ) { return randomAccess.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return randomAccess.getDoublePosition( d ); } @Override public void localize( final int[] position ) { randomAccess.localize( position ); } @Override public void localize( final long[] position ) { randomAccess.localize( position ); } @Override public int getIntPosition( final int d ) { return randomAccess.getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return randomAccess.getLongPosition( d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/RandomAccessibleOnRealRandomAccessible.java000066400000000000000000000143711316447754700324220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RealRandomAccess; import net.imglib2.RealRandomAccessible; import net.imglib2.View; /** * {@link RandomAccessible} on a {@link RealRandomAccessible}. For optimal * performance, no integer coordinates are stored in the {@link RandomAccess} * but only method calls passed through to an actual {@link RealRandomAccess}. * Therefore, localization into integer fields performs a Math.round operation * per field and is thus not very efficient. Localization into real fields, * however, is passed through and thus performs optimally. * * @author Stephan Saalfeld */ public class RandomAccessibleOnRealRandomAccessible< T > extends AbstractEuclideanSpace implements RandomAccessible< T >, View { final protected RealRandomAccessible< T > source; final protected class RandomAccessOnRealRandomAccessible implements RandomAccess< T > { final protected RealRandomAccess< T > sourceAccess; public RandomAccessOnRealRandomAccessible( final RealRandomAccess< T > sourceAccess ) { this.sourceAccess = sourceAccess; } @Override public void localize( final int[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = ( int ) Math.round( sourceAccess.getDoublePosition( d ) ); } @Override public void localize( final long[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = Math.round( sourceAccess.getDoublePosition( d ) ); } @Override public int getIntPosition( final int d ) { return ( int ) Math.round( sourceAccess.getDoublePosition( d ) ); } @Override public long getLongPosition( final int d ) { return Math.round( sourceAccess.getDoublePosition( d ) ); } @Override public void localize( final float[] position ) { sourceAccess.localize( position ); } @Override public void localize( final double[] position ) { sourceAccess.localize( position ); } @Override public float getFloatPosition( final int d ) { return sourceAccess.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return sourceAccess.getDoublePosition( d ); } @Override public void fwd( final int d ) { sourceAccess.fwd( d ); } @Override public void bck( final int d ) { sourceAccess.bck( d ); } @Override public void move( final int distance, final int d ) { sourceAccess.move( distance, d ); } @Override public void move( final long distance, final int d ) { sourceAccess.move( distance, d ); } @Override public void move( final Localizable localizable ) { sourceAccess.move( localizable ); } @Override public void move( final int[] distance ) { sourceAccess.move( distance ); } @Override public void move( final long[] distance ) { sourceAccess.move( distance ); } @Override public void setPosition( final Localizable localizable ) { sourceAccess.setPosition( localizable ); } @Override public void setPosition( final int[] position ) { sourceAccess.setPosition( position ); } @Override public void setPosition( final long[] position ) { sourceAccess.setPosition( position ); } @Override public void setPosition( final int position, final int d ) { sourceAccess.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { sourceAccess.setPosition( position, d ); } @Override public T get() { return sourceAccess.get(); } @Override public RandomAccessOnRealRandomAccessible copy() { return new RandomAccessOnRealRandomAccessible( sourceAccess.copyRealRandomAccess() ); } @Override public RandomAccessOnRealRandomAccessible copyRandomAccess() { return copy(); } @Override public int numDimensions() { return n; } } public RealRandomAccessible< T > getSource() { return source; } public RandomAccessibleOnRealRandomAccessible( final RealRandomAccessible< T > source ) { super( source.numDimensions() ); this.source = source; } @Override public RandomAccess< T > randomAccess() { return new RandomAccessOnRealRandomAccessible( source.realRandomAccess() ); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return new RandomAccessOnRealRandomAccessible( source.realRandomAccess( interval ) ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/RandomAccessiblePair.java000066400000000000000000000135351316447754700270170ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccessible; import net.imglib2.util.Pair; /** * A {@link RandomAccessible} over two independent * {@link RandomAccessible RandomAccessibles} whose type is the {@link Pair} of * corresponding values at the same coordinates in either of the two sources. * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class RandomAccessiblePair< A, B > implements RandomAccessible< Pair< A, B > > { final protected RandomAccessible< A > sourceA; final protected RandomAccessible< B > sourceB; public class RandomAccess implements Pair< A, B >, net.imglib2.RandomAccess< Pair< A, B > > { final protected net.imglib2.RandomAccess< A > a; final protected net.imglib2.RandomAccess< B > b; public RandomAccess() { a = sourceA.randomAccess(); b = sourceB.randomAccess(); } @Override public A getA() { return a.get(); } @Override public B getB() { return b.get(); } @Override public void localize( final int[] position ) { a.localize( position ); } @Override public void localize( final long[] position ) { a.localize( position ); } @Override public int getIntPosition( final int d ) { return a.getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return a.getLongPosition( d ); } @Override public void localize( final float[] position ) { a.localize( position ); } @Override public void localize( final double[] position ) { a.localize( position ); } @Override public float getFloatPosition( final int d ) { return a.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return a.getDoublePosition( d ); } @Override public int numDimensions() { return RandomAccessiblePair.this.numDimensions(); } @Override public void fwd( final int d ) { a.fwd( d ); b.fwd( d ); } @Override public void bck( final int d ) { a.bck( d ); b.bck( d ); } @Override public void move( final int distance, final int d ) { a.move( distance, d ); b.move( distance, d ); } @Override public void move( final long distance, final int d ) { a.move( distance, d ); b.move( distance, d ); } @Override public void move( final Localizable localizable ) { a.move( localizable ); b.move( localizable ); } @Override public void move( final int[] distance ) { a.move( distance ); b.move( distance ); } @Override public void move( final long[] distance ) { a.move( distance ); b.move( distance ); } @Override public void setPosition( final Localizable localizable ) { a.setPosition( localizable ); b.setPosition( localizable ); } @Override public void setPosition( final int[] position ) { a.setPosition( position ); b.setPosition( position ); } @Override public void setPosition( final long[] position ) { a.setPosition( position ); b.setPosition( position ); } @Override public void setPosition( final int position, final int d ) { a.setPosition( position, d ); b.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { a.setPosition( position, d ); b.setPosition( position, d ); } @Override public RandomAccess get() { return this; } @Override public RandomAccess copy() { final RandomAccess copy = new RandomAccess(); copy.setPosition( this ); return copy; } @Override public RandomAccess copyRandomAccess() { return copy(); } } public RandomAccessiblePair( final RandomAccessible< A > sourceA, final RandomAccessible< B > sourceB ) { this.sourceA = sourceA; this.sourceB = sourceB; } @Override public int numDimensions() { return sourceA.numDimensions(); } @Override public RandomAccess randomAccess() { return new RandomAccess(); } @Override public RandomAccess randomAccess( final Interval interval ) { return new RandomAccess(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/SlicingRandomAccess.java000066400000000000000000000213201316447754700266470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.Arrays; import net.imglib2.AbstractLocalizable; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.transform.integer.Slicing; /** * Wrap a {@code source} RandomAccess which is related to this by a * {@link Slicing} {@code transformToSource}. * * @param * @author Tobias Pietzsch */ public class SlicingRandomAccess< T > extends AbstractLocalizable implements RandomAccess< T > { /** * source RandomAccess. note that this is the target of the * transformToSource. */ private final RandomAccess< T > s; /** * number of dimensions of source RandomAccess, respectively * numTargetDimensions of the Slicing transform. */ private final int m; /** * for each component of the source vector: should the value be taken to a * target vector component (false) or should it be discarded (true). */ private final boolean[] sourceZero; /** * for each component of the source vector: to which target vector component * should it be taken. */ private final int[] sourceComponent; private final long[] tmpPosition; private final long[] tmpDistance; SlicingRandomAccess( final RandomAccess< T > source, final Slicing transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); final boolean[] targetZero = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); sourceZero = new boolean[ n ]; sourceComponent = new int[ n ]; Arrays.fill( sourceZero, true ); for ( int d = 0; d < m; ++d ) if ( targetZero[ d ] ) s.setPosition( transformToSource.getTranslation( d ), d ); else { final int e = targetComponent[ d ]; sourceZero[ e ] = false; sourceComponent[ e ] = d; } tmpPosition = new long[ m ]; transformToSource.getTranslation( tmpPosition ); tmpDistance = new long[ m ]; } protected SlicingRandomAccess( final SlicingRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); s = randomAccess.s.copyRandomAccess(); m = randomAccess.m; sourceZero = randomAccess.sourceZero.clone(); sourceComponent = randomAccess.sourceComponent.clone(); tmpPosition = randomAccess.tmpPosition.clone(); tmpDistance = randomAccess.tmpDistance.clone(); } @Override public void fwd( final int d ) { assert d < n; ++position[ d ]; if ( !sourceZero[ d ] ) s.fwd( sourceComponent[ d ] ); } @Override public void bck( final int d ) { assert d < n; --position[ d ]; if ( !sourceZero[ d ] ) s.bck( sourceComponent[ d ] ); } @Override public void move( final int distance, final int d ) { assert d < n; position[ d ] += distance; if ( !sourceZero[ d ] ) s.move( distance, sourceComponent[ d ] ); } @Override public void move( final long distance, final int d ) { assert d < n; position[ d ] += distance; if ( !sourceZero[ d ] ) s.move( distance, sourceComponent[ d ] ); } @Override public void move( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { final long distance = localizable.getLongPosition( d ); position[ d ] += distance; if ( !sourceZero[ d ] ) tmpDistance[ sourceComponent[ d ] ] = distance; } s.move( tmpDistance ); } @Override public void move( final int[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { position[ d ] += distance[ d ]; if ( !sourceZero[ d ] ) tmpDistance[ sourceComponent[ d ] ] = distance[ d ]; } s.move( tmpDistance ); } @Override public void move( final long[] distance ) { assert distance.length >= n; // we just loop over the source dimension. // this may not assign all components of the target distance in // tmpDistance[]. // however, the missing components are already assigned to 0 for ( int d = 0; d < n; ++d ) { position[ d ] += distance[ d ]; if ( !sourceZero[ d ] ) tmpDistance[ sourceComponent[ d ] ] = distance[ d ]; } s.move( tmpDistance ); } @Override public void setPosition( final Localizable localizable ) { assert localizable.numDimensions() >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final long p = localizable.getLongPosition( d ); position[ d ] = p; if ( !sourceZero[ d ] ) tmpPosition[ sourceComponent[ d ] ] = p; } s.setPosition( tmpPosition ); } @Override public void setPosition( final int[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final long p = position[ d ]; this.position[ d ] = p; if ( !sourceZero[ d ] ) tmpPosition[ sourceComponent[ d ] ] = p; } s.setPosition( tmpPosition ); } @Override public void setPosition( final long[] position ) { assert position.length >= n; // we just loop over the source dimension. // this may not assign all components of the target position in // tmpPosition[]. // however, the missing components are already assigned to the correct // translation components. for ( int d = 0; d < n; ++d ) { final long p = position[ d ]; this.position[ d ] = p; if ( !sourceZero[ d ] ) tmpPosition[ sourceComponent[ d ] ] = p; } s.setPosition( tmpPosition ); } @Override public void setPosition( final int position, final int d ) { assert d < n; this.position[ d ] = position; if ( !sourceZero[ d ] ) s.setPosition( position, sourceComponent[ d ] ); } @Override public void setPosition( final long position, final int d ) { assert d < n; this.position[ d ] = position; if ( !sourceZero[ d ] ) s.setPosition( position, sourceComponent[ d ] ); } @Override public T get() { return s.get(); } @Override public SlicingRandomAccess< T > copy() { return new SlicingRandomAccess< T >( this ); } @Override public SlicingRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/StackView.java000066400000000000000000000456141316447754700247100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.Arrays; import java.util.List; import net.imglib2.AbstractInterval; import net.imglib2.FinalInterval; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.View; import net.imglib2.util.Util; /** * A stack of n-dimensional {@link RandomAccessibleInterval}s, forming * a (n+1)-dimensional {@link RandomAccessibleInterval}. * * @param * the pixel type. * * @author Tobias Pietzsch */ public class StackView< T > extends AbstractInterval implements RandomAccessibleInterval< T >, View { /** * Describes how a {@link RandomAccess} on the (n+1)-dimensional * {@link StackView} maps position changes into position changes of the * underlying n-dimensional {@link RandomAccess}es. * *

* Each {@link RandomAccess} on a {@link StackView} keeps a list of * {@link RandomAccess}es on all constituent hyper-slices of the * {@link StackView}. */ public static enum StackAccessMode { /** * The default behavior is the following. * *

* There is one "active" slice {@link RandomAccess}, namely the * zth {@link RandomAccess}, where z denotes the * (n+1)th dimension of the current position. * *

* When changing any dimension of the position, except the * (n+1)th, this position change is applied to the active slice * {@link RandomAccess}. When changing the (n+1)th dimension of * the position, a new slice {@link RandomAccess} becomes active is set * to the position of the previously active slice {@link RandomAccess}. */ DEFAULT, /** * Alternative behavior for some special cases; this is faster assuming * that we access in a loop over dimensions with the last dimension (the * hyper-slice dimension) in the inner loop. Works as follows. * *

* When changing any dimension of the position, except the * (n+1)th, this position change is applied to the all * slice {@link RandomAccess}es. The current (n+1)th dimension * of the position is maintained as an index. When {@code get()} is * called it is forwarded to the slice {@link RandomAccess} at that * index. * *

* The potential advantage of this approach is that it does not need to * do a full {@code setPosition()} when changing slices. Only use this * if you know what you are doing. */ MOVE_ALL_SLICE_ACCESSES } private final RandomAccessibleInterval< T >[] slices; private final StackAccessMode stackAccessMode; public StackView( final List< ? extends RandomAccessibleInterval< T > > hyperslices ) { this( hyperslices, StackAccessMode.DEFAULT ); } @SuppressWarnings( "unchecked" ) public StackView( final List< ? extends RandomAccessibleInterval< T > > hyperslices, final StackAccessMode stackAccessMode ) { super( hyperslices.get( 0 ).numDimensions() + 1 ); this.stackAccessMode = stackAccessMode; slices = hyperslices.toArray( new RandomAccessibleInterval[ hyperslices.size() ] ); for ( int d = 0; d < n - 1; ++d ) { min[ d ] = slices[ 0 ].min( d ); max[ d ] = slices[ 0 ].max( d ); } min[ n - 1 ] = 0; max[ n - 1 ] = slices.length - 1; } @Override public RandomAccess< T > randomAccess() { return stackAccessMode == StackAccessMode.MOVE_ALL_SLICE_ACCESSES ? new MoveAllSlicesRA< T >( slices ) : new DefaultRA< T >( slices ); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return stackAccessMode == StackAccessMode.MOVE_ALL_SLICE_ACCESSES ? new MoveAllSlicesRA< T >( slices, interval ) : new DefaultRA< T >( slices, interval ); } /** * Get the source slices that are stacked in this {@link StackView}. These * are {@code (numDimensions() - 1)} dimensional * {@link RandomAccessibleInterval}s. * * @return list of source hyperslices. */ public List< RandomAccessibleInterval< T > > getSourceSlices() { return Arrays.asList( slices ); } /** * @return {@link StackAccessMode} defined in constructor */ public StackAccessMode getStackAccessMode() { return stackAccessMode; } /** * A {@link RandomAccess} on a {@link StackView}. It keeps a list of * {@link RandomAccess}es on all constituent hyper-slices of the * {@link StackView}. * *

* When changing any dimension of the position, except the (n+1)th, * this position change is applied to the active slice {@link RandomAccess}. * When changing the (n+1)th dimension of the position, a new slice * {@link RandomAccess} becomes active is set to the position of the * previously active slice {@link RandomAccess}. * * @param * the pixel type */ public static final class DefaultRA< T > implements RandomAccess< T > { private final int n; private final int sd; private int slice; private final long[] tmpLong; private final int[] tmpInt; private final RandomAccess< T >[] sliceAccesses; private RandomAccess< T > sliceAccess; public DefaultRA( final RandomAccessibleInterval< T >[] slices ) { this( slices, null ); } @SuppressWarnings( "unchecked" ) public DefaultRA( final RandomAccessibleInterval< T >[] slices, final Interval interval ) { n = slices[ 0 ].numDimensions() + 1; sd = n - 1; slice = 0; tmpLong = new long[ sd ]; tmpInt = new int[ sd ]; sliceAccesses = new RandomAccess[ slices.length ]; if ( interval == null ) { for ( int i = 0; i < slices.length; ++i ) sliceAccesses[ i ] = slices[ i ].randomAccess(); } else { final long[] smin = new long[ sd ]; final long[] smax = new long[ sd ]; for ( int d = 0; d < sd; ++d ) { smin[ d ] = interval.min( d ); smax[ d ] = interval.max( d ); } final Interval sliceInterval = new FinalInterval( smin, smax ); for ( int i = 0; i < slices.length; ++i ) sliceAccesses[ i ] = slices[ i ].randomAccess( sliceInterval ); } sliceAccess = sliceAccesses[ slice ]; } private DefaultRA( final DefaultRA< T > a ) { sliceAccesses = Util.genericArray( a.sliceAccesses.length ); for ( int i = 0; i < sliceAccesses.length; ++i ) sliceAccesses[ i ] = a.sliceAccesses[ i ].copyRandomAccess(); slice = a.slice; sliceAccess = sliceAccesses[ slice ]; n = a.n; sd = a.sd; tmpLong = a.tmpLong.clone(); tmpInt = a.tmpInt.clone(); } @Override public void localize( final int[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccess.getIntPosition( d ); position[ sd ] = slice; } @Override public void localize( final long[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccess.getLongPosition( d ); position[ sd ] = slice; } @Override public int getIntPosition( final int d ) { return ( d < sd ) ? sliceAccess.getIntPosition( d ) : slice; } @Override public long getLongPosition( final int d ) { return ( d < sd ) ? sliceAccess.getLongPosition( d ) : slice; } @Override public void localize( final float[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccess.getLongPosition( d ); position[ sd ] = slice; } @Override public void localize( final double[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccess.getLongPosition( d ); position[ sd ] = slice; } @Override public float getFloatPosition( final int d ) { return getLongPosition( d ); } @Override public double getDoublePosition( final int d ) { return getLongPosition( d ); } @Override public int numDimensions() { return n; } @Override public void fwd( final int d ) { if ( d < sd ) sliceAccess.fwd( d ); else setSlice( slice + 1 ); } @Override public void bck( final int d ) { if ( d < sd ) sliceAccess.bck( d ); else setSlice( slice - 1 ); } @Override public void move( final int distance, final int d ) { if ( d < sd ) sliceAccess.move( distance, d ); else setSlice( slice + distance ); } @Override public void move( final long distance, final int d ) { if ( d < sd ) sliceAccess.move( distance, d ); else setSlice( slice + ( int ) distance ); } @Override public void move( final Localizable distance ) { for ( int d = 0; d < sd; ++d ) sliceAccess.move( distance.getLongPosition( d ), d ); setSlice( slice + distance.getIntPosition( sd ) ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < sd; ++d ) sliceAccess.move( distance[ d ], d ); setSlice( slice + distance[ sd ] ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < sd; ++d ) sliceAccess.move( distance[ d ], d ); setSlice( slice + ( int ) distance[ sd ] ); } @Override public void setPosition( final Localizable position ) { for ( int d = 0; d < sd; ++d ) tmpLong[ d ] = position.getLongPosition( d ); sliceAccess.setPosition( tmpLong ); setSlice( position.getIntPosition( sd ) ); } @Override public void setPosition( final int[] position ) { System.arraycopy( position, 0, tmpInt, 0, sd ); sliceAccess.setPosition( tmpInt ); setSlice( position[ sd ] ); } @Override public void setPosition( final long[] position ) { System.arraycopy( position, 0, tmpLong, 0, sd ); sliceAccess.setPosition( tmpLong ); setSlice( position[ sd ] ); } @Override public void setPosition( final int position, final int d ) { if ( d < sd ) sliceAccess.setPosition( position, d ); else setSlice( position ); } @Override public void setPosition( final long position, final int d ) { if ( d < sd ) sliceAccess.setPosition( position, d ); else setSlice( position ); } private void setSlice( final int i ) { if ( i != slice ) { slice = i; if ( slice >= 0 && slice < sliceAccesses.length ) { sliceAccesses[ slice ].setPosition( sliceAccess ); sliceAccess = sliceAccesses[ slice ]; } } } private void setSlice( final long i ) { setSlice( ( int ) i ); } @Override public T get() { return sliceAccess.get(); } @Override public DefaultRA< T > copy() { return new DefaultRA< T >( this ); } @Override public DefaultRA< T > copyRandomAccess() { return copy(); } } /** * A {@link RandomAccess} on a {@link StackView}. It keeps a list of * {@link RandomAccess}es on all constituent hyper-slices of the * {@link StackView}. * *

* When changing any dimension of the position, except the (n+1)th, * this position change is applied to the all slice * {@link RandomAccess}es. The current (n+1)th dimension of the * position is maintained as an index. When {@code get()} is called it is * forwarded to the slice {@link RandomAccess} at that index. * *

* The potential advantage of this approach is that it does not need to do a * full {@code setPosition()} when changing slices.This is faster assuming * that we access in a loop over dimensions with the last dimension (the * hyper-slice dimension) in the inner loop. * *

* Only use this if you know what you are doing. * * @param * the pixel type */ public static class MoveAllSlicesRA< T > implements RandomAccess< T > { private final int n; private final int sd; private int slice; private final long[] tmpLong; private final int[] tmpInt; private final RandomAccess< T >[] sliceAccesses; public MoveAllSlicesRA( final RandomAccessibleInterval< T >[] slices ) { this( slices, null ); } @SuppressWarnings( "unchecked" ) public MoveAllSlicesRA( final RandomAccessibleInterval< T >[] slices, final Interval interval ) { n = slices[ 0 ].numDimensions() + 1; sd = n - 1; slice = 0; tmpLong = new long[ sd ]; tmpInt = new int[ sd ]; sliceAccesses = new RandomAccess[ slices.length ]; if ( interval == null ) { for ( int i = 0; i < slices.length; ++i ) sliceAccesses[ i ] = slices[ i ].randomAccess(); } else { final long[] smin = new long[ sd ]; final long[] smax = new long[ sd ]; for ( int d = 0; d < sd; ++d ) { smin[ d ] = interval.min( d ); smax[ d ] = interval.max( d ); } final Interval sliceInterval = new FinalInterval( smin, smax ); for ( int i = 0; i < slices.length; ++i ) sliceAccesses[ i ] = slices[ i ].randomAccess( sliceInterval ); } } private MoveAllSlicesRA( final MoveAllSlicesRA< T > a ) { sliceAccesses = Util.genericArray( a.sliceAccesses.length ); for ( int i = 0; i < sliceAccesses.length; ++i ) sliceAccesses[ i ] = a.sliceAccesses[ i ].copyRandomAccess(); slice = a.slice; n = a.n; sd = a.sd; tmpLong = a.tmpLong.clone(); tmpInt = a.tmpInt.clone(); } @Override public void localize( final int[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccesses[ 0 ].getIntPosition( d ); position[ sd ] = slice; } @Override public void localize( final long[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccesses[ 0 ].getLongPosition( d ); position[ sd ] = slice; } @Override public int getIntPosition( final int d ) { return ( d < sd ) ? sliceAccesses[ 0 ].getIntPosition( d ) : slice; } @Override public long getLongPosition( final int d ) { return ( d < sd ) ? sliceAccesses[ 0 ].getLongPosition( d ) : slice; } @Override public void localize( final float[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccesses[ 0 ].getLongPosition( d ); position[ sd ] = slice; } @Override public void localize( final double[] position ) { for ( int d = 0; d < sd; ++d ) position[ d ] = sliceAccesses[ 0 ].getLongPosition( d ); position[ sd ] = slice; } @Override public float getFloatPosition( final int d ) { return getLongPosition( d ); } @Override public double getDoublePosition( final int d ) { return getLongPosition( d ); } @Override public int numDimensions() { return n; } @Override public void fwd( final int d ) { if ( d < sd ) for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].fwd( d ); else ++slice; } @Override public void bck( final int d ) { if ( d < sd ) for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].bck( d ); else --slice; } @Override public void move( final int distance, final int d ) { if ( d < sd ) for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].move( distance, d ); else slice += distance; } @Override public void move( final long distance, final int d ) { if ( d < sd ) for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].move( distance, d ); else slice += ( int ) distance; } @Override public void move( final Localizable distance ) { for ( int s = 0; s < sliceAccesses.length; ++s ) for ( int d = 0; d < sd; ++d ) sliceAccesses[ s ].move( distance.getLongPosition( d ), d ); slice += distance.getIntPosition( sd ); } @Override public void move( final int[] distance ) { for ( int s = 0; s < sliceAccesses.length; ++s ) for ( int d = 0; d < sd; ++d ) sliceAccesses[ s ].move( distance[ d ], d ); slice += distance[ sd ]; } @Override public void move( final long[] distance ) { for ( int s = 0; s < sliceAccesses.length; ++s ) for ( int d = 0; d < sd; ++d ) sliceAccesses[ s ].move( distance[ d ], d ); slice += ( int ) distance[ sd ]; } @Override public void setPosition( final Localizable position ) { for ( int d = 0; d < sd; ++d ) tmpLong[ d ] = position.getLongPosition( d ); for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].setPosition( tmpLong ); slice = position.getIntPosition( sd ); } @Override public void setPosition( final int[] position ) { System.arraycopy( position, 0, tmpInt, 0, sd ); for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].setPosition( tmpInt ); slice = position[ sd ]; } @Override public void setPosition( final long[] position ) { System.arraycopy( position, 0, tmpLong, 0, sd ); for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].setPosition( tmpLong ); slice = ( int ) position[ sd ]; } @Override public void setPosition( final int position, final int d ) { if ( d < sd ) for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].setPosition( position, d ); else slice = position; } @Override public void setPosition( final long position, final int d ) { if ( d < sd ) for ( int s = 0; s < sliceAccesses.length; ++s ) sliceAccesses[ s ].setPosition( position, d ); else slice = ( int ) position; } @Override public T get() { return sliceAccesses[ slice ].get(); } @Override public MoveAllSlicesRA< T > copy() { return new MoveAllSlicesRA< T >( this ); } @Override public MoveAllSlicesRA< T > copyRandomAccess() { return copy(); } } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/SubsampleIntervalView.java000066400000000000000000000123031316447754700272700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.RealPositionable; /** * {@link SubsampleIntervalView} is a view that provides access to only every * sdth value of a source * {@link RandomAccessibleInterval}. Its transformed origin is at the min * coordinate of the source {@link Interval}. This is effectively an integer * scaling and optional offset transformation. Localization calls to the * {@link RandomAccess} and {@link Interval} dimension calls to the * {@link SubsampleIntervalView} return scaled and translated coordinates that * are generated on-the-fly. Localization is thus moderately inefficient to the * benefit of faster positioning. Don't ask for what you already know ;). * * @author Stephan Saalfeld */ public class SubsampleIntervalView< T > extends SubsampleView< T > implements RandomAccessibleInterval< T > { final protected long[] dimensions; final protected long[] max; public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long step ) { super( Views.zeroMin( source ), step ); dimensions = new long[ steps.length ]; max = new long[ steps.length ]; for ( int d = 0; d < steps.length; ++d ) { steps[ d ] = step; dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / step ); max[ d ] = dimensions[ d ] - 1; } } public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long... steps ) { super( Views.zeroMin( source ), steps ); dimensions = new long[ steps.length ]; max = new long[ steps.length ]; for ( int d = 0; d < steps.length; ++d ) { this.steps[ d ] = steps[ d ]; dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / steps[ d ]); max[ d ] = dimensions[ d ] - 1; } } @Override public long min( final int d ) { return 0; } @Override public void min( final long[] min ) { for ( int d = 0; d < steps.length; ++d ) min[ d ] = 0; } @Override public void min( final Positionable min ) { for ( int d = 0; d < steps.length; ++d ) min.setPosition( 0, d ); } @Override public long max( final int d ) { return max[ d ]; } @Override public void max( final long[] m ) { for ( int d = 0; d < steps.length; ++d ) m[ d ] = this.max[ d ]; } @Override public void max( final Positionable m ) { for ( int d = 0; d < steps.length; ++d ) m.setPosition( this.max[ d ], d ); } @Override public double realMin( final int d ) { return 0; } @Override public void realMin( final double[] min ) { for ( int d = 0; d < steps.length; ++d ) min[ d ] = 0; } @Override public void realMin( final RealPositionable min ) { for ( int d = 0; d < steps.length; ++d ) min.setPosition( 0, d ); } @Override public double realMax( final int d ) { return max[ d ]; } @Override public void realMax( final double[] m ) { for ( int d = 0; d < steps.length; ++d ) m[ d ] = this.max[ d ]; } @Override public void realMax( final RealPositionable m ) { for ( int d = 0; d < steps.length; ++d ) m.setPosition( this.max[ d ], d ); } @Override public void dimensions( final long[] dim ) { for ( int d = 0; d < steps.length; ++d ) dim[ d ] = this.dimensions[ d ]; } @Override public long dimension( final int d ) { return dimensions[ d ]; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/SubsampleView.java000066400000000000000000000171231316447754700255700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.View; /** * {@link SubsampleView} is a view that provides access to only every * sdth value of a source * {@link RandomAccessible}. This is effectively an integer scaling * transformation. Localization calls to the {@link RandomAccess} return scaled * coordinates that are generated on-the-fly. Localization is thus moderately * inefficient to the benefit of faster positioning. Don't ask for what you * already know ;). * * @author Stephan Saalfeld */ public class SubsampleView< T > implements RandomAccessible< T >, View { final protected RandomAccessible< T > source; final protected long[] steps; public class SubsampleRandomAccess implements RandomAccess< T > { final protected RandomAccess< T > sourceRandomAccess; final protected long[] tmp = new long[ source.numDimensions() ]; protected SubsampleRandomAccess( final RandomAccess< T > sourceRandomAccess ) { this.sourceRandomAccess = sourceRandomAccess; } public SubsampleRandomAccess() { this( source.randomAccess() ); } public SubsampleRandomAccess( final Interval interval ) { this( source.randomAccess( interval ) ); } @Override public void localize( final int[] position ) { for ( int d = 0; d < steps.length; ++d ) position[ d ] = sourceRandomAccess.getIntPosition( d ) / ( int ) steps[ d ]; } @Override public void localize( final long[] position ) { for ( int d = 0; d < steps.length; ++d ) position[ d ] = sourceRandomAccess.getLongPosition( d ) / steps[ d ]; } @Override public int getIntPosition( final int d ) { return sourceRandomAccess.getIntPosition( d ) / ( int ) steps[ d ]; } @Override public long getLongPosition( final int d ) { return sourceRandomAccess.getLongPosition( d ) / steps[ d ]; } @Override public void localize( final float[] position ) { for ( int d = 0; d < steps.length; ++d ) position[ d ] = sourceRandomAccess.getFloatPosition( d ) / steps[ d ]; } @Override public void localize( final double[] position ) { for ( int d = 0; d < steps.length; ++d ) position[ d ] = sourceRandomAccess.getDoublePosition( d ) / steps[ d ]; } @Override public float getFloatPosition( final int d ) { return sourceRandomAccess.getFloatPosition( d ) / steps[ d ]; } @Override public double getDoublePosition( final int d ) { return sourceRandomAccess.getDoublePosition( d ) / steps[ d ]; } @Override public int numDimensions() { return source.numDimensions(); } @Override public void fwd( final int d ) { sourceRandomAccess.move( steps[ d ], d ); } @Override public void bck( final int d ) { sourceRandomAccess.move( -steps[ d ], d ); } @Override public void move( final int distance, final int d ) { sourceRandomAccess.move( distance * steps[ d ], d ); } @Override public void move( final long distance, final int d ) { sourceRandomAccess.move( distance * steps[ d ], d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < steps.length; ++d ) tmp[ d ] = localizable.getLongPosition( d ) * steps[ d ]; sourceRandomAccess.move( tmp ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < steps.length; ++d ) tmp[ d ] = distance[ d ] * steps[ d ]; sourceRandomAccess.move( tmp ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < steps.length; ++d ) tmp[ d ] = distance[ d ] * steps[ d ]; sourceRandomAccess.move( tmp ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < steps.length; ++d ) tmp[ d ] = localizable.getLongPosition( d ) * steps[ d ]; sourceRandomAccess.setPosition( tmp ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < steps.length; ++d ) tmp[ d ] = position[ d ] * steps[ d ]; sourceRandomAccess.setPosition( tmp ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < steps.length; ++d ) tmp[ d ] = position[ d ] * steps[ d ]; sourceRandomAccess.setPosition( tmp ); } @Override public void setPosition( final int position, final int d ) { sourceRandomAccess.setPosition( position * steps[ d ], d ); } @Override public void setPosition( final long position, final int d ) { sourceRandomAccess.setPosition( position * steps[ d ], d ); } @Override public T get() { return sourceRandomAccess.get(); } @Override public SubsampleRandomAccess copy() { return new SubsampleRandomAccess( sourceRandomAccess.copyRandomAccess() ); } @Override public SubsampleRandomAccess copyRandomAccess() { return copy(); } } public SubsampleView( final RandomAccessible< T > source, final long step ) { this.source = source; this.steps = new long[ source.numDimensions() ]; for ( int d = 0; d < steps.length; ++d ) steps[ d ] = step; } public SubsampleView( final RandomAccessible< T > source, final long... steps ) { assert steps.length >= source.numDimensions(): "Dimensions do not match."; this.source = source; this.steps = steps.clone(); } @Override public int numDimensions() { return source.numDimensions(); } @Override public RandomAccess< T > randomAccess() { return new SubsampleRandomAccess(); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return new SubsampleRandomAccess( interval ); } public RandomAccessible< T > getSource() { return source; } /** * @return sub-sampling steps */ public long[] getSteps() { return steps.clone(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/TransformBuilder.java000066400000000000000000000354161316447754700262710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.LinkedList; import java.util.ListIterator; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.WrappedImg; import net.imglib2.transform.Transform; import net.imglib2.transform.integer.BoundingBox; import net.imglib2.transform.integer.BoundingBoxTransform; import net.imglib2.transform.integer.Mixed; import net.imglib2.transform.integer.MixedTransform; import net.imglib2.transform.integer.SlicingTransform; import net.imglib2.transform.integer.TranslationTransform; import net.imglib2.util.Intervals; /** * The "brain" of the Views framework. Simplifies View cascades to provide the * most efficient accessor for a specified Interval. * * @see #getEfficientRandomAccessible(Interval, RandomAccessible) * * @author Tobias Pietzsch */ public class TransformBuilder< T > { /** * Get a RandomAccessible which provides RandomAccess to the specified * {@code interval} of {@code randomAccessible}. * *

* Create a new TransformBuilder that traverses the view hierarchy starting * from {@code randomAccessible}. {@link #build()} an efficient * RandomAccessible by joining and simplifying the collected * transformations. *

* * @param interval * The interval in which access is needed. * @param randomAccessible */ public static < S > RandomAccessible< S > getEfficientRandomAccessible( final Interval interval, final RandomAccessible< S > randomAccessible ) { return new TransformBuilder< S >( interval, randomAccessible ).build(); } /** * Provides the untransformed random access. */ protected RandomAccessible< T > source; /** * Interval transformed to the currently visited view. null means that the * interval is infinite. */ protected BoundingBox boundingBox; /** * List of transforms that have to be applied when wrapping the * {@link #source} RandomAccess to obtain a RandomAccess in the target * coordinate system. */ protected LinkedList< Transform > transforms; /** * Create a new TransformBuilder. Starting from {@code randomAccessible}, go * down the view hierarchy to the RandomAccessible that will provide the * source RandomAccess into the specified {@code interval}. While traversing * the view hierarchy transforms are collected into the {@link #transforms} * list. These transforms have to be applied when wrapping the source * RandomAccess to obtain a RandomAccess in the coordinate system of * {@code randomAccessible}. * * @param interval * The interval in which access is needed. This is converted to a * bounding box which is propagated through the transforms down * the view hierarchy. * @param randomAccessible */ protected TransformBuilder( final Interval interval, final RandomAccessible< T > randomAccessible ) { transforms = new LinkedList< Transform >(); boundingBox = ( interval == null ) ? null : new BoundingBox( interval ); // System.out.println( randomAccessible ); visit( randomAccessible ); simplifyTransforms(); } /** * Prepend a transform to the {@link #transforms} list. Also apply the * transform to {@link #boundingBox}, which will be used to specify the * interval for the RandomAccess on the final source (at the end of the view * chain). This is called while traversing the view hierarchy. * * @param t * the transform to add. */ protected void prependTransform( final Transform t ) { if ( BoundingBoxTransform.class.isInstance( t ) && ( boundingBox != null ) ) boundingBox = ( ( BoundingBoxTransform ) t ).transform( boundingBox ); else boundingBox = null; transforms.addFirst( t ); } /** * Visit a RandomAccessible (while traversing the view hierarchy). The * {@code randomAccessible} is handled by * {@link #visitTransformed(TransformedRandomAccessible)} or * {@link #visitExtended(ExtendedRandomAccessibleInterval)} when it has the * appropriate type. Otherwise, the traversal stops and * {@code randomAccessible} is set as the {@link #source}. * * @param randomAccessible */ @SuppressWarnings( "unchecked" ) protected void visit( final RandomAccessible< T > randomAccessible ) { if ( TransformedRandomAccessible.class.isInstance( randomAccessible ) ) { visitTransformed( ( TransformedRandomAccessible< T > ) randomAccessible ); } else if ( ExtendedRandomAccessibleInterval.class.isInstance( randomAccessible ) ) { visitExtended( ( ExtendedRandomAccessibleInterval< T, ? > ) randomAccessible ); } else if ( IntervalView.class.isInstance( randomAccessible ) ) { visit( ( ( IntervalView< T > ) randomAccessible ).getSource() ); } else if ( WrappedImg.class.isInstance( randomAccessible ) ) { visit( ( ( WrappedImg< T > ) randomAccessible ).getImg() ); } else { source = randomAccessible; } } /** * Visit a TransformedRandomAccessible (while traversing the view * hierarchy). Append the view's transform to the list and * {@link #visit(RandomAccessible)} the view's source. * * @param randomAccessible */ protected void visitTransformed( final TransformedRandomAccessible< T > randomAccessible ) { prependTransform( randomAccessible.getTransformToSource() ); visit( randomAccessible.getSource() ); } /** * Visit a ExtendedRandomAccessibleInterval (while traversing the view * hierarchy). If the no out-of-bounds extension is needed for the current * bounding box, {@link #visit(RandomAccessible)} the view's source. * Otherwise, the traversal stops and {@code randomAccessible} is set as the * {@link #source}. * * @param randomAccessible */ protected void visitExtended( final ExtendedRandomAccessibleInterval< T, ? > randomAccessible ) { final RandomAccessibleInterval< T > sourceInterval = randomAccessible.getSource(); if ( ( boundingBox != null ) && Intervals.contains( sourceInterval, boundingBox.getInterval() ) ) visit( sourceInterval ); else source = randomAccessible; } public static boolean isIdentity( final Mixed t ) { final int n = t.numSourceDimensions(); final int m = t.numTargetDimensions(); if ( n != m ) return false; for ( int d = 0; d < m; ++d ) { if ( t.getTranslation( d ) != 0 ) return false; if ( t.getComponentZero( d ) ) return false; if ( t.getComponentInversion( d ) ) return false; if ( t.getComponentMapping( d ) != d ) return false; } return true; } public static boolean isTranslation( final Mixed t ) { final int n = t.numSourceDimensions(); final int m = t.numTargetDimensions(); if ( n != m ) return false; for ( int d = 0; d < m; ++d ) { if ( t.getComponentZero( d ) ) return false; if ( t.getComponentInversion( d ) ) return false; if ( t.getComponentMapping( d ) != d ) return false; } return true; } public static boolean isComponentMapping( final Mixed t ) { final int m = t.numTargetDimensions(); for ( int d = 0; d < m; ++d ) { if ( t.getTranslation( d ) != 0 ) return false; if ( t.getComponentZero( d ) ) return false; if ( t.getComponentInversion( d ) ) return false; } return true; } public static boolean isSlicing( final Mixed t ) { final int n = t.numSourceDimensions(); final int m = t.numTargetDimensions(); if ( n > m ) return false; for ( int d = 0; d < m; ++d ) { if ( t.getTranslation( d ) != 0 && ( !t.getComponentZero( d ) ) ) return false; if ( t.getComponentInversion( d ) ) return false; } return true; } /** * Simplify the {@link #transforms} list. First, concatenate neighboring * transforms if possible. Then, for every {@link Mixed} transform: *
    *
  • remove it if it is the identity transforms. *
  • replace it by a {@link TranslationTransform} if it is a pure * translation. *
  • replace it by a {@link SlicingTransform} if it is a pure slicing. *
*/ protected void simplifyTransforms() { net.imglib2.concatenate.ConcatenateUtils.join( transforms ); for ( final ListIterator< Transform > i = transforms.listIterator(); i.hasNext(); ) { final Transform t = i.next(); if ( Mixed.class.isInstance( t ) ) { final Mixed mixed = ( Mixed ) t; if ( isIdentity( mixed ) ) { // found identity // remove from transforms list i.remove(); } else if ( isTranslation( mixed ) ) { // found pure translation // replace by a TranslationTransform final long[] translation = new long[ mixed.numTargetDimensions() ]; mixed.getTranslation( translation ); i.set( new TranslationTransform( translation ) ); } // else if ( isComponentMapping( mixed ) ) // { // // found pure component mapping // // replace by a ComponentMappingTransform // final int[] component = new int[ mixed.numTargetDimensions() ]; // mixed.getComponentMapping( component ); // i.set( new ComponentMappingTransform( component ) ); // } else if ( isSlicing( mixed ) ) { // found pure slicing // replace by a SlicingTransform final int m = mixed.numTargetDimensions(); final long[] translation = new long[ m ]; final boolean[] zero = new boolean[ m ]; final int[] component = new int[ m ]; mixed.getTranslation( translation ); mixed.getComponentZero( zero ); mixed.getComponentMapping( component ); final SlicingTransform sl = new SlicingTransform( mixed.numSourceDimensions(), m ); sl.setTranslation( translation ); sl.setComponentZero( zero ); sl.setComponentMapping( component ); i.set( sl ); } } } } /** * Create a sequence of wrapped RandomAccessibles from the * {@link #transforms} list. * * @return RandomAccessible on the interval specified in the constructor. */ protected RandomAccessible< T > build() { RandomAccessible< T > result = source; for ( final ListIterator< Transform > i = transforms.listIterator(); i.hasNext(); ) { final Transform t = i.next(); if ( MixedTransform.class.isInstance( t ) ) result = wrapMixedTransform( result, ( MixedTransform ) t ); else if ( TranslationTransform.class.isInstance( t ) ) result = wrapTranslationTransform( result, ( TranslationTransform ) t ); else if ( SlicingTransform.class.isInstance( t ) ) result = wrapSlicingTransform( result, ( SlicingTransform ) t ); else result = wrapGenericTransform( result, t ); } return result; } protected RandomAccessible< T > wrapGenericTransform( final RandomAccessible< T > s, final Transform t ) { return new RandomAccessible< T >() { @Override public int numDimensions() { return t.numSourceDimensions(); } @Override public RandomAccess< T > randomAccess() { return new TransformRandomAccess< T >( s.randomAccess(), t ); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return new TransformRandomAccess< T >( s.randomAccess(), t ); } }; } protected RandomAccessible< T > wrapMixedTransform( final RandomAccessible< T > s, final MixedTransform t ) { final boolean full = t.hasFullSourceMapping(); return new RandomAccessible< T >() { @Override public int numDimensions() { return t.numSourceDimensions(); } @Override public RandomAccess< T > randomAccess() { if ( full ) return new FullSourceMapMixedRandomAccess< T >( s.randomAccess(), t ); return new MixedRandomAccess< T >( s.randomAccess(), t ); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { if ( full ) return new FullSourceMapMixedRandomAccess< T >( s.randomAccess(), t ); return new MixedRandomAccess< T >( s.randomAccess(), t ); } }; } protected RandomAccessible< T > wrapTranslationTransform( final RandomAccessible< T > s, final TranslationTransform t ) { return new RandomAccessible< T >() { @Override public int numDimensions() { return t.numSourceDimensions(); } @Override public TranslationRandomAccess< T > randomAccess() { return new TranslationRandomAccess< T >( s.randomAccess(), t ); } @Override public TranslationRandomAccess< T > randomAccess( final Interval interval ) { return new TranslationRandomAccess< T >( s.randomAccess(), t ); } }; } protected RandomAccessible< T > wrapSlicingTransform( final RandomAccessible< T > s, final SlicingTransform t ) { final boolean full = t.hasFullSourceMapping(); return new RandomAccessible< T >() { @Override public int numDimensions() { return t.numSourceDimensions(); } @Override public RandomAccess< T > randomAccess() { if ( full ) return new FullSourceMapSlicingRandomAccess< T >( s.randomAccess(), t ); return new SlicingRandomAccess< T >( s.randomAccess(), t ); } @Override public RandomAccess< T > randomAccess( final Interval interval ) { if ( full ) return new FullSourceMapSlicingRandomAccess< T >( s.randomAccess(), t ); return new SlicingRandomAccess< T >( s.randomAccess(), t ); } }; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/TransformRandomAccess.java000066400000000000000000000131431316447754700272360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractLocalizable; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.transform.Transform; /** * Wrap a {@code source} RandomAccess which is related to this by a generic * {@link Transform} {@code transformToSource}. * * {@link TransformRandomAccess} gets called by {@link Cursor} implementations * over {@link RandomAccess} that initialize at the {@link Interval} min * position - 1, i.e. they call {@link #bck(int) bck(0)} after * {@link #setPosition(long[]) setPosition(min)}. Transforms are not * necessarily defined at this position and may throw an exception. Therefore, * position update must not apply the transformation! Instead, the * transformation is applied at {@link #get()}. So don't call {@link #get()} * more than once at the same place (generally a good idea). * * @author Stephan Saalfeld * @author Philipp Hanslovsky * @author Tobias Pietzsch */ public final class TransformRandomAccess< T > extends AbstractLocalizable implements RandomAccess< T > { /** * source RandomAccess. note that this is the target of the * transformToSource. */ private final RandomAccess< T > source; private final Transform transformToSource; private final long[] tmp; TransformRandomAccess( final RandomAccess< T > source, final Transform transformToSource ) { super( transformToSource.numSourceDimensions() ); this.source = source; this.transformToSource = transformToSource; this.tmp = new long[ transformToSource.numTargetDimensions() ]; } protected TransformRandomAccess( final TransformRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); this.source = randomAccess.source.copyRandomAccess(); this.transformToSource = randomAccess.transformToSource; this.tmp = new long[ randomAccess.tmp.length ]; } @Override public void fwd( final int d ) { assert d < n; position[ d ] += 1; } @Override public void bck( final int d ) { assert d < n; position[ d ] -= 1; } @Override public void move( final int distance, final int d ) { assert d < n; position[ d ] += distance; } @Override public void move( final long distance, final int d ) { assert d < n; position[ d ] += distance; } @Override public void move( final Localizable localizable ) { assert localizable.numDimensions() >= n; for ( int d = 0; d < n; ++d ) position[ d ] += localizable.getLongPosition( d ); } @Override public void move( final int[] distance ) { assert distance.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] += distance[ d ]; } @Override public void move( final long[] distance ) { assert distance.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] += distance[ d ]; } @Override public void setPosition( final Localizable localizable ) { assert localizable.numDimensions() == n; localizable.localize( position ); } @Override public void setPosition( final int[] pos ) { assert pos.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = pos[ d ]; } @Override public void setPosition( final long[] pos ) { assert pos.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = pos[ d ]; } @Override public void setPosition( final int pos, final int d ) { assert d < n; position[ d ] = pos; } @Override public void setPosition( final long pos, final int d ) { assert d < n; position[ d ] = pos; } @Override public T get() { transformToSource.apply( position, tmp ); source.setPosition( tmp ); return source.get(); } @Override public TransformRandomAccess< T > copy() { return new TransformRandomAccess< T >( this ); } @Override public TransformRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/TransformView.java000066400000000000000000000065401316447754700256110ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.transform.Transform; /** * Wrap a {@code source} RandomAccessible which is related to this by a generic * {@link Transform} {@code transformToSource}. * * * @author Tobias Pietzsch */ public class TransformView< T > implements TransformedRandomAccessible< T > { protected final int n; protected final RandomAccessible< T > source; protected final Transform transformToSource; protected RandomAccessible< T > fullViewRandomAccessible; public TransformView( final RandomAccessible< T > source, final Transform transformToSource ) { assert source.numDimensions() == transformToSource.numTargetDimensions(); this.n = transformToSource.numSourceDimensions(); this.source = source; this.transformToSource = transformToSource; fullViewRandomAccessible = null; } @Override public int numDimensions() { return n; } @Override public RandomAccessible< T > getSource() { return source; } @Override public Transform getTransformToSource() { return transformToSource; } @Override public RandomAccess< T > randomAccess( final Interval interval ) { return TransformBuilder.getEfficientRandomAccessible( interval, this ).randomAccess(); } @Override public RandomAccess< T > randomAccess() { if ( fullViewRandomAccessible == null ) fullViewRandomAccessible = TransformBuilder.getEfficientRandomAccessible( null, this ); return fullViewRandomAccessible.randomAccess(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/TransformedRandomAccessible.java000066400000000000000000000055251316447754700304100ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.RandomAccessible; import net.imglib2.View; import net.imglib2.transform.Transform; /** * A view of a RandomAccessible which is related by a coordinate * {@link Transform} to its source. * * * @author Tobias Pietzsch */ public interface TransformedRandomAccessible< T > extends RandomAccessible< T >, View { /** * Get the source of the TransformedRandomAccessible. This is the next * element in the view hierarchy, for example, the next * ExtendedRandomAccessibleInterval or the underlying Img. * * @return the source {@link RandomAccessible}. */ public RandomAccessible< T > getSource(); /** * Get the transformation from view coordinates into {@link #getSource() * source} coordinates. * *

* Note that this is the inverse of the ''view transform'' which maps source * to view coordinates. *

* * @return transformation from view coordinates into {@link #getSource() * source} coordinates. */ public Transform getTransformToSource(); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/TranslationRandomAccess.java000066400000000000000000000135231316447754700275630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.transform.integer.Translation; /** * TODO * */ public final class TranslationRandomAccess< T > extends AbstractEuclideanSpace implements RandomAccess< T > { private final RandomAccess< T > s; private final long[] translation; private final long[] tmp; TranslationRandomAccess( final RandomAccess< T > source, final Translation transformToSource ) { super( transformToSource.numSourceDimensions() ); assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; translation = new long[ n ]; transformToSource.getTranslation( translation ); tmp = new long[ n ]; } protected TranslationRandomAccess( final TranslationRandomAccess< T > randomAccess ) { super( randomAccess.numDimensions() ); s = randomAccess.s.copyRandomAccess(); translation = randomAccess.translation.clone(); tmp = new long[ n ]; } @Override public void localize( final int[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = s.getIntPosition( d ) - ( int ) translation[ d ]; } @Override public void localize( final long[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = s.getLongPosition( d ) - ( int ) translation[ d ]; } @Override public int getIntPosition( final int d ) { assert d <= n; return s.getIntPosition( d ) - ( int ) translation[ d ]; } @Override public long getLongPosition( final int d ) { assert d <= n; return s.getLongPosition( d ) - ( int ) translation[ d ]; } @Override public void localize( final float[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = s.getFloatPosition( d ) - translation[ d ]; } @Override public void localize( final double[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = s.getDoublePosition( d ) - translation[ d ]; } @Override public float getFloatPosition( final int d ) { assert d <= n; return s.getFloatPosition( d ) - translation[ d ]; } @Override public double getDoublePosition( final int d ) { assert d <= n; return s.getDoublePosition( d ) - translation[ d ]; } @Override public void fwd( final int d ) { s.fwd( d ); } @Override public void bck( final int d ) { s.bck( d ); } @Override public void move( final int distance, final int d ) { s.move( distance, d ); } @Override public void move( final long distance, final int d ) { s.move( distance, d ); } @Override public void move( final Localizable localizable ) { s.move( localizable ); } @Override public void move( final int[] distance ) { s.move( distance ); } @Override public void move( final long[] distance ) { s.move( distance ); } @Override public void setPosition( final Localizable localizable ) { assert localizable.numDimensions() == n; localizable.localize( tmp ); for ( int d = 0; d < n; ++d ) tmp[ d ] += translation[ d ]; s.setPosition( tmp ); } @Override public void setPosition( final int[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) tmp[ d ] = position[ d ] + translation[ d ]; s.setPosition( tmp ); } @Override public void setPosition( final long[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) tmp[ d ] = position[ d ] + translation[ d ]; s.setPosition( tmp ); } @Override public void setPosition( final int position, final int d ) { assert d <= n; s.setPosition( position + translation[ d ], d ); } @Override public void setPosition( final long position, final int d ) { assert d <= n; s.setPosition( position + translation[ d ], d ); } @Override public T get() { return s.get(); } @Override public TranslationRandomAccess< T > copy() { return new TranslationRandomAccess< T >( this ); } @Override public TranslationRandomAccess< T > copyRandomAccess() { return copy(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/Views.java000066400000000000000000001624251316447754700241050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import net.imglib2.EuclideanSpace; import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.RealRandomAccessible; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.interpolation.Interpolant; import net.imglib2.interpolation.InterpolatorFactory; import net.imglib2.outofbounds.OutOfBoundsBorderFactory; import net.imglib2.outofbounds.OutOfBoundsConstantValueFactory; import net.imglib2.outofbounds.OutOfBoundsFactory; import net.imglib2.outofbounds.OutOfBoundsMirrorFactory; import net.imglib2.outofbounds.OutOfBoundsPeriodicFactory; import net.imglib2.outofbounds.OutOfBoundsRandomValueFactory; import net.imglib2.transform.integer.BoundingBox; import net.imglib2.transform.integer.MixedTransform; import net.imglib2.transform.integer.permutation.AbstractPermutationTransform; import net.imglib2.transform.integer.permutation.PermutationTransform; import net.imglib2.transform.integer.permutation.SingleDimensionPermutationTransform; import net.imglib2.transform.integer.shear.InverseShearTransform; import net.imglib2.transform.integer.shear.ShearTransform; import net.imglib2.type.Type; import net.imglib2.type.numeric.NumericType; import net.imglib2.type.numeric.RealType; import net.imglib2.util.Intervals; import net.imglib2.util.Pair; import net.imglib2.util.Util; import net.imglib2.view.StackView.StackAccessMode; import net.imglib2.view.composite.CompositeIntervalView; import net.imglib2.view.composite.CompositeView; import net.imglib2.view.composite.GenericComposite; import net.imglib2.view.composite.NumericComposite; import net.imglib2.view.composite.RealComposite; /** * Create light-weight views into {@link RandomAccessible RandomAccessibles}. * * A view is itself a {@link RandomAccessible} or * {@link RandomAccessibleInterval} that provides {@link RandomAccess accessors} * that transform coordinates on-the-fly without copying the underlying data. * Consecutive transformations are concatenated and simplified to provide * optimally efficient accessors. Note, that accessors provided by a view are * read/write. Changing pixels in a view changes the underlying image data. * * @author Tobias Pietzsch * @author Stephan Saalfeld * @author Philipp Hanslovsky */ public class Views { /** * Returns a {@link RealRandomAccessible} using interpolation * * @param source * the {@link EuclideanSpace} to be interpolated * @param factory * the {@link InterpolatorFactory} to provide interpolators for * source * @return */ public static < T, F extends EuclideanSpace > RealRandomAccessible< T > interpolate( final F source, final InterpolatorFactory< T, F > factory ) { return new Interpolant< T, F >( source, factory ); } /** * Turns a {@link RealRandomAccessible} into a {@link RandomAccessible}, * providing {@link RandomAccess} at integer coordinates. * * @see #interpolate(net.imglib2.EuclideanSpace, * net.imglib2.interpolation.InterpolatorFactory) * * @param source * the {@link RealRandomAccessible} to be rasterized. * @return a {@link RandomAccessibleOnRealRandomAccessible} wrapping source. */ public static < T > RandomAccessibleOnRealRandomAccessible< T > raster( final RealRandomAccessible< T > source ) { return new RandomAccessibleOnRealRandomAccessible< T >( source ); } /** * Extend a RandomAccessibleInterval with an out-of-bounds strategy. * * @param source * the interval to extend. * @param factory * the out-of-bounds strategy. * @return (unbounded) RandomAccessible which extends the input interval to * infinity. */ public static < T, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extend( final F source, final OutOfBoundsFactory< T, ? super F > factory ) { return new ExtendedRandomAccessibleInterval< T, F >( source, factory ); } /** * Extend a RandomAccessibleInterval with a mirroring out-of-bounds * strategy. Boundary pixels are not repeated. Note that this requires that * all dimensions of the source (F source) must be > 1. * * @param source * the interval to extend. * @return (unbounded) RandomAccessible which extends the input interval to * infinity. * @see net.imglib2.outofbounds.OutOfBoundsMirrorSingleBoundary */ public static < T, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendMirrorSingle( final F source ) { return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsMirrorFactory< T, F >( OutOfBoundsMirrorFactory.Boundary.SINGLE ) ); } /** * Extend a RandomAccessibleInterval with a mirroring out-of-bounds * strategy. Boundary pixels are repeated. * * @param source * the interval to extend. * @return (unbounded) RandomAccessible which extends the input interval to * infinity. * @see net.imglib2.outofbounds.OutOfBoundsMirrorDoubleBoundary */ public static < T, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendMirrorDouble( final F source ) { return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsMirrorFactory< T, F >( OutOfBoundsMirrorFactory.Boundary.DOUBLE ) ); } /** * Extend a RandomAccessibleInterval with a constant-value out-of-bounds * strategy. * * @param source * the interval to extend. * @return (unbounded) RandomAccessible which extends the input interval to * infinity. * @see net.imglib2.outofbounds.OutOfBoundsConstantValue */ public static < T extends Type< T >, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendValue( final F source, final T value ) { return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsConstantValueFactory< T, F >( value ) ); } /** * Extend a RandomAccessibleInterval with a constant-value out-of-bounds * strategy where the constant value is the zero-element of the data type. * * @param source * the interval to extend. * @return (unbounded) RandomAccessible which extends the input interval to * infinity with a constant value of zero. * @see net.imglib2.outofbounds.OutOfBoundsConstantValue */ public static < T extends NumericType< T >, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendZero( final F source ) { final T zero = Util.getTypeFromInterval( source ).createVariable(); zero.setZero(); return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsConstantValueFactory< T, F >( zero ) ); } /** * Extend a RandomAccessibleInterval with a random-value out-of-bounds * strategy. * * @param source * the interval to extend. * @param min * the minimal random value * @param max * the maximal random value * @return (unbounded) RandomAccessible which extends the input interval to * infinity. * @see net.imglib2.outofbounds.OutOfBoundsRandomValue */ public static < T extends RealType< T >, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendRandom( final F source, final double min, final double max ) { return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsRandomValueFactory< T, F >( Util.getTypeFromInterval( source ), min, max ) ); } /** * Extend a RandomAccessibleInterval with a periodic out-of-bounds strategy. * * @param source * the interval to extend. * @return (unbounded) RandomAccessible which extends the input interval to * infinity. * @see net.imglib2.outofbounds.OutOfBoundsPeriodic */ public static < T, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendPeriodic( final F source ) { return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsPeriodicFactory< T, F >() ); } /** * Extend a RandomAccessibleInterval with an out-of-bounds strategy to * repeat border pixels. * * @param source * the interval to extend. * @return (unbounded) RandomAccessible which extends the input interval to * infinity. * @see net.imglib2.outofbounds.OutOfBoundsBorder */ public static < T, F extends RandomAccessibleInterval< T > > ExtendedRandomAccessibleInterval< T, F > extendBorder( final F source ) { return new ExtendedRandomAccessibleInterval< T, F >( source, new OutOfBoundsBorderFactory< T, F >() ); } /** * Define an interval on a RandomAccessible. It is the callers * responsibility to ensure that the source RandomAccessible is defined in * the specified interval. * * @param randomAccessible * the source * @param min * lower bound of interval * @param max * upper bound of interval * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > interval( final RandomAccessible< T > randomAccessible, final long[] min, final long[] max ) { return new IntervalView< T >( randomAccessible, min, max ); } /** * Define an interval on a RandomAccessible. It is the callers * responsibility to ensure that the source RandomAccessible is defined in * the specified interval. * * @param randomAccessible * the source * @param interval * interval boundaries. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > interval( final RandomAccessible< T > randomAccessible, final Interval interval ) { return new IntervalView< T >( randomAccessible, interval ); } /** * Create view that is rotated by 90 degrees. The rotation is specified by * the fromAxis and toAxis arguments. * * If fromAxis=0 and toAxis=1, this means that the X-axis of the source view * is mapped to the Y-Axis of the rotated view. That is, it corresponds to a * 90 degree clock-wise rotation of the source view in the XY plane. * * fromAxis=1 and toAxis=0 corresponds to a counter-clock-wise rotation in * the XY plane. */ public static < T > MixedTransformView< T > rotate( final RandomAccessible< T > randomAccessible, final int fromAxis, final int toAxis ) { final int n = randomAccessible.numDimensions(); final MixedTransform t = new MixedTransform( n, n ); if ( fromAxis != toAxis ) { final int[] component = new int[ n ]; final boolean[] inv = new boolean[ n ]; for ( int e = 0; e < n; ++e ) { if ( e == toAxis ) { component[ e ] = fromAxis; inv[ e ] = true; } else if ( e == fromAxis ) { component[ e ] = toAxis; } else { component[ e ] = e; } } t.setComponentMapping( component ); t.setComponentInversion( inv ); } return new MixedTransformView< T >( randomAccessible, t ); } /** * Create view that is rotated by 90 degrees. The rotation is specified by * the fromAxis and toAxis arguments. * * If fromAxis=0 and toAxis=1, this means that the X-axis of the source view * is mapped to the Y-Axis of the rotated view. That is, it corresponds to a * 90 degree clock-wise rotation of the source view in the XY plane. * * fromAxis=1 and toAxis=0 corresponds to a counter-clock-wise rotation in * the XY plane. */ public static < T > IntervalView< T > rotate( final RandomAccessibleInterval< T > interval, final int fromAxis, final int toAxis ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); if ( fromAxis != toAxis ) { final long fromMinNew = -max[ toAxis ]; final long fromMaxNew = -min[ toAxis ]; min[ toAxis ] = min[ fromAxis ]; max[ toAxis ] = max[ fromAxis ]; min[ fromAxis ] = fromMinNew; max[ fromAxis ] = fromMaxNew; } return Views.interval( Views.rotate( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max ); } /** * Create view with permuted axes. fromAxis and toAxis are swapped. * * If fromAxis=0 and toAxis=2, this means that the X-axis of the source view * is mapped to the Z-Axis of the permuted view and vice versa. For a XYZ * source, a ZYX view would be created. */ public static < T > MixedTransformView< T > permute( final RandomAccessible< T > randomAccessible, final int fromAxis, final int toAxis ) { final int n = randomAccessible.numDimensions(); final int[] component = new int[ n ]; for ( int e = 0; e < n; ++e ) component[ e ] = e; component[ fromAxis ] = toAxis; component[ toAxis ] = fromAxis; final MixedTransform t = new MixedTransform( n, n ); t.setComponentMapping( component ); return new MixedTransformView< T >( randomAccessible, t ); } /** * Create view with permuted axes. fromAxis and toAxis are swapped. * * If fromAxis=0 and toAxis=2, this means that the X-axis of the source view * is mapped to the Z-Axis of the permuted view and vice versa. For a XYZ * source, a ZYX view would be created. */ public static < T > IntervalView< T > permute( final RandomAccessibleInterval< T > interval, final int fromAxis, final int toAxis ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); final long fromMinNew = min[ toAxis ]; final long fromMaxNew = max[ toAxis ]; min[ toAxis ] = min[ fromAxis ]; max[ toAxis ] = max[ fromAxis ]; min[ fromAxis ] = fromMinNew; max[ fromAxis ] = fromMaxNew; return Views.interval( Views.permute( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max ); } /** * Translate the source view by the given translation vector. Pixel * x in the source view has coordinates (x + translation) * in the resulting view. * * @param randomAccessible * the source * @param translation * translation vector of the source view. The pixel at x * in the source view becomes (x + translation) in the * resulting view. */ public static < T > MixedTransformView< T > translate( final RandomAccessible< T > randomAccessible, final long... translation ) { final int n = randomAccessible.numDimensions(); final MixedTransform t = new MixedTransform( n, n ); t.setInverseTranslation( translation ); return new MixedTransformView< T >( randomAccessible, t ); } /** * Translate the source view by the given translation vector. Pixel * x in the source view has coordinates (x + translation) * in the resulting view. * * @param interval * the source * @param translation * translation vector of the source view. The pixel at x * in the source view becomes (x + translation) in the * resulting view. */ public static < T > IntervalView< T > translate( final RandomAccessibleInterval< T > interval, final long... translation ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); for ( int d = 0; d < n; ++d ) { min[ d ] += translation[ d ]; max[ d ] += translation[ d ]; } return Views.interval( Views.translate( ( RandomAccessible< T > ) interval, translation ), min, max ); } /** * Translate such that pixel at offset in randomAccessible is at the origin * in the resulting view. This is equivalent to translating by -offset. * * @param randomAccessible * the source * @param offset * offset of the source view. The pixel at offset becomes the * origin of resulting view. */ public static < T > MixedTransformView< T > offset( final RandomAccessible< T > randomAccessible, final long... offset ) { final int n = randomAccessible.numDimensions(); final MixedTransform t = new MixedTransform( n, n ); t.setTranslation( offset ); return new MixedTransformView< T >( randomAccessible, t ); } /** * Translate such that pixel at offset in interval is at the origin in the * resulting view. This is equivalent to translating by -offset. * * @param interval * the source * @param offset * offset of the source view. The pixel at offset becomes the * origin of resulting view. */ public static < T > IntervalView< T > offset( final RandomAccessibleInterval< T > interval, final long... offset ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); for ( int d = 0; d < n; ++d ) { min[ d ] -= offset[ d ]; max[ d ] -= offset[ d ]; } return Views.interval( Views.offset( ( RandomAccessible< T > ) interval, offset ), min, max ); } /** * Translate the source such that the upper left corner is at the origin * * @param interval * the source. * @return view of the source translated to the origin */ public static < T > IntervalView< T > zeroMin( final RandomAccessibleInterval< T > interval ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; final long[] offset = new long[ n ]; interval.min( offset ); interval.max( max ); for ( int d = 0; d < n; ++d ) max[ d ] -= offset[ d ]; final MixedTransform t = new MixedTransform( n, n ); t.setTranslation( offset ); return Views.interval( new MixedTransformView< T >( interval, t ), min, max ); } /** * take a (n-1)-dimensional slice of a n-dimensional view, fixing * d-component of coordinates to pos. */ public static < T > MixedTransformView< T > hyperSlice( final RandomAccessible< T > view, final int d, final long pos ) { final int m = view.numDimensions(); final int n = m - 1; final MixedTransform t = new MixedTransform( n, m ); final long[] translation = new long[ m ]; translation[ d ] = pos; final boolean[] zero = new boolean[ m ]; final int[] component = new int[ m ]; for ( int e = 0; e < m; ++e ) { if ( e < d ) { zero[ e ] = false; component[ e ] = e; } else if ( e > d ) { zero[ e ] = false; component[ e ] = e - 1; } else { zero[ e ] = true; component[ e ] = 0; } } t.setTranslation( translation ); t.setComponentZero( zero ); t.setComponentMapping( component ); return new MixedTransformView< T >( view, t ); } /** * take a (n-1)-dimensional slice of a n-dimensional view, fixing * d-component of coordinates to pos. */ public static < T > IntervalView< T > hyperSlice( final RandomAccessibleInterval< T > view, final int d, final long pos ) { final int m = view.numDimensions(); final int n = m - 1; final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int e = 0; e < m; ++e ) { if ( e < d ) { min[ e ] = view.min( e ); max[ e ] = view.max( e ); } else if ( e > d ) { min[ e - 1 ] = view.min( e ); max[ e - 1 ] = view.max( e ); } } return Views.interval( Views.hyperSlice( ( RandomAccessible< T > ) view, d, pos ), min, max ); } /** * Create view which adds a dimension to the source {@link RandomAccessible} * . * * The additional dimension is the last dimension. For example, an XYZ view * is created for an XY source. When accessing an XYZ sample in the view, * the final coordinate is discarded and the source XY sample is accessed. * * @param randomAccessible * the source */ public static < T > MixedTransformView< T > addDimension( final RandomAccessible< T > randomAccessible ) { final int m = randomAccessible.numDimensions(); final int n = m + 1; final MixedTransform t = new MixedTransform( n, m ); return new MixedTransformView< T >( randomAccessible, t ); } /** * Create view which adds a dimension to the source * {@link RandomAccessibleInterval}. The {@link Interval} boundaries in the * additional dimension are set to the specified values. * * The additional dimension is the last dimension. For example, an XYZ view * is created for an XY source. When accessing an XYZ sample in the view, * the final coordinate is discarded and the source XY sample is accessed. * * @param interval * the source * @param minOfNewDim * Interval min in the additional dimension. * @param maxOfNewDim * Interval max in the additional dimension. */ public static < T > IntervalView< T > addDimension( final RandomAccessibleInterval< T > interval, final long minOfNewDim, final long maxOfNewDim ) { final int m = interval.numDimensions(); final long[] min = new long[ m + 1 ]; final long[] max = new long[ m + 1 ]; for ( int d = 0; d < m; ++d ) { min[ d ] = interval.min( d ); max[ d ] = interval.max( d ); } min[ m ] = minOfNewDim; max[ m ] = maxOfNewDim; return Views.interval( Views.addDimension( interval ), min, max ); } /** * Invert the d-axis. * * @param randomAccessible * the source * @param d * the axis to invert */ public static < T > MixedTransformView< T > invertAxis( final RandomAccessible< T > randomAccessible, final int d ) { final int n = randomAccessible.numDimensions(); final boolean[] inv = new boolean[ n ]; inv[ d ] = true; final MixedTransform t = new MixedTransform( n, n ); t.setComponentInversion( inv ); return new MixedTransformView< T >( randomAccessible, t ); } /** * Invert the d-axis. * * @param interval * the source * @param d * the axis to invert */ public static < T > IntervalView< T > invertAxis( final RandomAccessibleInterval< T > interval, final int d ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); final long tmp = min[ d ]; min[ d ] = -max[ d ]; max[ d ] = -tmp; return Views.interval( Views.invertAxis( ( RandomAccessible< T > ) interval, d ), min, max ); } /** * Define an interval on a RandomAccessible and translate it such that the * min corner is at the origin. It is the callers responsibility to ensure * that the source RandomAccessible is defined in the specified interval. * * @param randomAccessible * the source * @param offset * offset of min corner. * @param dimension * size of the interval. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final long[] offset, final long[] dimension ) { final int n = randomAccessible.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = dimension[ d ] - 1; return Views.interval( Views.offset( randomAccessible, offset ), min, max ); } /** * Define an interval on a RandomAccessible and translate it such that the * min corner is at the origin. It is the callers responsibility to ensure * that the source RandomAccessible is defined in the specified interval. * * @param randomAccessible * the source * @param interval * the interval on source that should be cut out and translated * to the origin. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final Interval interval ) { final int n = randomAccessible.numDimensions(); final long[] offset = new long[ n ]; final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( offset ); interval.max( max ); for ( int d = 0; d < n; ++d ) max[ d ] -= offset[ d ]; return Views.interval( Views.offset( randomAccessible, offset ), min, max ); } /** * test whether the source interval starts at (0,0,...,0) * * @param interval * - the {@link Interval} to test * @return true if zero-bounded, false otherwise */ public static boolean isZeroMin( final Interval interval ) { for ( int d = 0; d < interval.numDimensions(); ++d ) if ( interval.min( d ) != 0 ) return false; return true; } /** * Return an {@link IterableInterval}. If the passed * {@link RandomAccessibleInterval} is already an {@link IterableInterval} * then it is returned directly (this is the case for {@link Img}). If not, * then an {@link IterableRandomAccessibleInterval} is created. * * @param randomAccessibleInterval * the source * @return an {@link IterableInterval} */ @SuppressWarnings( "unchecked" ) public static < T > IterableInterval< T > iterable( final RandomAccessibleInterval< T > randomAccessibleInterval ) { if ( IterableInterval.class.isInstance( randomAccessibleInterval ) ) { final Class< ? > raiType = Util.getTypeFromInterval( randomAccessibleInterval ).getClass(); final Iterator< ? > iter = ( ( IterableInterval< ? > ) randomAccessibleInterval ).iterator(); final Object o = iter.hasNext() ? iter.next() : null; if ( raiType.isInstance( o ) ) return ( IterableInterval< T > ) randomAccessibleInterval; } return new IterableRandomAccessibleInterval< T >( randomAccessibleInterval ); } /** * Return an {@link IterableInterval} having {@link FlatIterationOrder}. If * the passed {@link RandomAccessibleInterval} is already an * {@link IterableInterval} with {@link FlatIterationOrder} then it is * returned directly (this is the case for {@link ArrayImg}). If not, then * an {@link IterableRandomAccessibleInterval} is created. * * @param randomAccessibleInterval * the source * @return an {@link IterableInterval} with {@link FlatIterationOrder} */ @SuppressWarnings( "unchecked" ) public static < T > IterableInterval< T > flatIterable( final RandomAccessibleInterval< T > randomAccessibleInterval ) { if ( IterableInterval.class.isInstance( randomAccessibleInterval ) && FlatIterationOrder.class.isInstance( ( ( IterableInterval< T > ) randomAccessibleInterval ).iterationOrder() ) ) { final Class< ? > raiType = Util.getTypeFromInterval( randomAccessibleInterval ).getClass(); final Iterator< ? > iter = ( ( IterableInterval< ? > ) randomAccessibleInterval ).iterator(); final Object o = iter.hasNext() ? iter.next() : null; if ( raiType.isInstance( o ) ) return ( IterableInterval< T > ) randomAccessibleInterval; } return new IterableRandomAccessibleInterval< T >( randomAccessibleInterval ); } /** * Collapse the nth dimension of an n * -dimensional {@link RandomAccessibleInterval}<T> into an ( * n-1)-dimensional {@link RandomAccessibleInterval}< * {@link GenericComposite}<T>> * * @param source * the source * @return an (n-1)-dimensional {@link CompositeIntervalView} of * {@link GenericComposite GenericComposites} */ public static < T > CompositeIntervalView< T, ? extends GenericComposite< T > > collapse( final RandomAccessibleInterval< T > source ) { return new CompositeIntervalView< T, GenericComposite< T > >( source, new GenericComposite.Factory< T >() ); } /** * Collapse the nth dimension of an n * -dimensional {@link RandomAccessibleInterval}<T extends * {@link RealType}<T>> into an (n-1)-dimensional * {@link RandomAccessibleInterval}<{@link RealComposite}<T>> * * @param source * the source * @return an (n-1)-dimensional {@link CompositeIntervalView} of * {@link RealComposite RealComposites} */ public static < T extends RealType< T > > CompositeIntervalView< T, RealComposite< T > > collapseReal( final RandomAccessibleInterval< T > source ) { return new CompositeIntervalView< T, RealComposite< T > >( source, new RealComposite.Factory< T >( ( int ) source.dimension( source.numDimensions() - 1 ) ) ); } /** * Collapse the nth dimension of an n * -dimensional {@link RandomAccessibleInterval}<T extends * {@link NumericType}<T>> into an (n-1)-dimensional * {@link RandomAccessibleInterval}<{@link NumericComposite}<T>> * * @param source * the source * @return an (n-1)-dimensional {@link CompositeIntervalView} of * {@link NumericComposite NumericComposites} */ public static < T extends NumericType< T > > CompositeIntervalView< T, NumericComposite< T > > collapseNumeric( final RandomAccessibleInterval< T > source ) { return new CompositeIntervalView< T, NumericComposite< T > >( source, new NumericComposite.Factory< T >( ( int ) source.dimension( source.numDimensions() - 1 ) ) ); } /** * Collapse the nth dimension of an n * -dimensional {@link RandomAccessible}<T> into an (n * -1)-dimensional {@link RandomAccessible}<{@link GenericComposite} * <T>> * * @param source * the source * @return an (n-1)-dimensional {@link CompositeView} of * {@link GenericComposite GenericComposites} */ public static < T > CompositeView< T, ? extends GenericComposite< T > > collapse( final RandomAccessible< T > source ) { return new CompositeView< T, GenericComposite< T > >( source, new GenericComposite.Factory< T >() ); } /** * Collapse the nth dimension of an n * -dimensional {@link RandomAccessible}<T extends {@link RealType} * <T>> into an (n-1)-dimensional {@link RandomAccessible} * <{@link RealComposite}<T>> * * @param source * the source * @param numChannels * the number of channels that the {@link RealComposite} will * consider when performing calculations * @return an (n-1)-dimensional {@link CompositeView} of * {@link RealComposite RealComposites} */ public static < T extends RealType< T > > CompositeView< T, RealComposite< T > > collapseReal( final RandomAccessible< T > source, final int numChannels ) { return new CompositeView< T, RealComposite< T > >( source, new RealComposite.Factory< T >( numChannels ) ); } /** * Collapse the nth dimension of an n * -dimensional {@link RandomAccessible}<T extends {@link NumericType} * <T>> into an (n-1)-dimensional {@link RandomAccessible} * <{@link NumericComposite}<T>> * * @param source * the source * @param numChannels * the number of channels that the {@link NumericComposite} will * consider when performing calculations * @return an (n-1)-dimensional {@link CompositeView} of * {@link NumericComposite NumericComposites} */ public static < T extends NumericType< T > > CompositeView< T, NumericComposite< T > > collapseNumeric( final RandomAccessible< T > source, final int numChannels ) { return new CompositeView< T, NumericComposite< T > >( source, new NumericComposite.Factory< T >( numChannels ) ); } /** * Sample only every stepth value of a source * {@link RandomAccessibleInterval}. This is effectively an integer scaling * and zero offset transformation. * * @param source * the source * @param step * the subsampling step size * @return a subsampled {@link RandomAccessibleInterval} with its origin * coordinates at zero */ public static < T > SubsampleIntervalView< T > subsample( final RandomAccessibleInterval< T > source, final long step ) { return new SubsampleIntervalView< T >( source, step ); } /** * Sample only every stepdth value of a * source {@link RandomAccessibleInterval}. This is effectively an integer * scaling and zero offset transformation. * * @param source * the source * @param steps * the subsampling step sizes * @return a subsampled {@link RandomAccessibleInterval} with its origin * coordinates at zero */ public static < T > SubsampleIntervalView< T > subsample( final RandomAccessibleInterval< T > source, final long... steps ) { assert steps.length >= source.numDimensions(): "Dimensions do not match."; return new SubsampleIntervalView< T >( source, steps ); } /** * Sample only every stepth value of a source * {@link RandomAccessible}. This is effectively an integer scaling * transformation. * * @param source * the source * @param step * the subsampling step size * @return a subsampled {@link RandomAccessible} * */ public static < T > SubsampleView< T > subsample( final RandomAccessible< T > source, final long step ) { return new SubsampleView< T >( source, step ); } /** * Sample only every stepdth value of a * source {@link RandomAccessible}. This is effectively an integer scaling * transformation. * * @param source * the source * @param steps * the subsampling step sizes * @return a subsampled {@link RandomAccessible} * */ public static < T > SubsampleView< T > subsample( final RandomAccessible< T > source, final long... steps ) { assert steps.length >= source.numDimensions(): "Dimensions do not match."; return new SubsampleView< T >( source, steps ); } /** * Removes all unit dimensions (dimensions with size one) from the * RandomAccessibleInterval * * @param source * the source * @return a RandomAccessibleInterval without dimensions of size one */ public static < T > RandomAccessibleInterval< T > dropSingletonDimensions( final RandomAccessibleInterval< T > source ) { RandomAccessibleInterval< T > res = source; for ( int d = source.numDimensions() - 1; d >= 0; --d ) if ( source.dimension( d ) == 1 ) res = Views.hyperSlice( res, d, source.min( d ) ); return res; } /** * Form a (n+1)-dimensional {@link RandomAccessibleInterval} by * stacking n-dimensional {@link RandomAccessibleInterval}s. * * @param hyperslices * a list of n-dimensional * {@link RandomAccessibleInterval} of identical sizes. * @return a (n+1)-dimensional {@link RandomAccessibleInterval} * where the final dimension is the index of the hyperslice. */ public static < T > RandomAccessibleInterval< T > stack( final List< ? extends RandomAccessibleInterval< T > > hyperslices ) { return new StackView<>( hyperslices ); } /** * Form a (n+1)-dimensional {@link RandomAccessibleInterval} by * stacking n-dimensional {@link RandomAccessibleInterval}s. * * @param hyperslices * a list of n-dimensional * {@link RandomAccessibleInterval} of identical sizes. * @return a (n+1)-dimensional {@link RandomAccessibleInterval} * where the final dimension is the index of the hyperslice. */ @SafeVarargs public static < T > RandomAccessibleInterval< T > stack( final RandomAccessibleInterval< T >... hyperslices ) { return new StackView< T >( Arrays.asList( hyperslices ) ); } /** * Form a (n+1)-dimensional {@link RandomAccessibleInterval} by * stacking n-dimensional {@link RandomAccessibleInterval}s. * * @param stackAccessMode * describes how a {@link RandomAccess} on the (n+1) * -dimensional {@link StackView} maps position changes into * position changes of the underlying n-dimensional * {@link RandomAccess}es. * @param hyperslices * a list of n-dimensional * {@link RandomAccessibleInterval} of identical sizes. * @return a (n+1)-dimensional {@link RandomAccessibleInterval} * where the final dimension is the index of the hyperslice. */ public static < T > RandomAccessibleInterval< T > stack( final StackAccessMode stackAccessMode, final List< ? extends RandomAccessibleInterval< T > > hyperslices ) { return new StackView<>( hyperslices, stackAccessMode ); } /** * Form a (n+1)-dimensional {@link RandomAccessibleInterval} by * stacking n-dimensional {@link RandomAccessibleInterval}s. * * @param stackAccessMode * describes how a {@link RandomAccess} on the (n+1) * -dimensional {@link StackView} maps position changes into * position changes of the underlying n-dimensional * {@link RandomAccess}es. * @param hyperslices * a list of n-dimensional * {@link RandomAccessibleInterval} of identical sizes. * @return a (n+1)-dimensional {@link RandomAccessibleInterval} * where the final dimension is the index of the hyperslice. */ public static < T > RandomAccessibleInterval< T > stack( final StackAccessMode stackAccessMode, final RandomAccessibleInterval< T >... hyperslices ) { return new StackView< T >( Arrays.asList( hyperslices ), stackAccessMode ); } /** * Positive shear transform of a RandomAccessible using * {@link ShearTransform}, i.e. c[ shearDimension ] = c[ shearDimension ] + * c[ referenceDimension ] * * @param source * input, e.g. extended {@link RandomAccessibleInterval} * @param shearDimension * dimension to be sheared * @param referenceDimension * reference dimension for shear * * @return {@link TransformView} containing the result. */ public static < T > TransformView< T > shear( final RandomAccessible< T > source, final int shearDimension, final int referenceDimension ) { final ShearTransform transform = new ShearTransform( source.numDimensions(), shearDimension, referenceDimension ); return new TransformView< T >( source, transform.inverse() ); } /** * Negative shear transform of a RandomAccessible using * {@link InverseShearTransform}, i.e. c[ shearDimension ] = c[ * shearDimension ] - c[ referenceDimension ] * * @param source * input, e.g. extended {@link RandomAccessibleInterval} * @param shearDimension * dimension to be sheared * @param referenceDimension * reference dimension for shear * * @return {@link TransformView} containing the result. */ public static < T > TransformView< T > unshear( final RandomAccessible< T > source, final int shearDimension, final int referenceDimension ) { final InverseShearTransform transform = new InverseShearTransform( source.numDimensions(), shearDimension, referenceDimension ); return new TransformView< T >( source, transform.inverse() ); } /** * Positive shear transform of a RandomAccessible using * {@link ShearTransform}, i.e. c[ shearDimension ] = c[ shearDimension ] + * c[ referenceDimension ] * * @param source * input, e.g. extended {@link RandomAccessibleInterval} * @param interval * original interval * @param shearDimension * dimension to be sheared * @param referenceDimension * reference dimension for shear * * @return {@link IntervalView} containing the result. The returned * interval's dimension are determined by applying the * {@link ShearTransform#transform} method on the input interval. */ public static < T > IntervalView< T > shear( final RandomAccessible< T > source, final Interval interval, final int shearDimension, final int referenceDimension ) { final ShearTransform transform = new ShearTransform( source.numDimensions(), shearDimension, referenceDimension ); return Views.interval( Views.shear( source, shearDimension, referenceDimension ), transform.transform( new BoundingBox( interval ) ).getInterval() ); } /** * Negative shear transform of a RandomAccessible using * {@link InverseShearTransform}, i.e. c[ shearDimension ] = c[ * shearDimension ] - c[ referenceDimension ] * * @param source * input, e.g. extended {@link RandomAccessibleInterval} * @param interval * original interval * @param shearDimension * dimension to be sheared * @param referenceDimension * reference dimension for shear * * @return {@link IntervalView} containing the result. The returned * interval's dimension are determined by applying the * {@link ShearTransform#transform} method on the input interval. */ public static < T > IntervalView< T > unshear( final RandomAccessible< T > source, final Interval interval, final int shearDimension, final int referenceDimension ) { final InverseShearTransform transform = new InverseShearTransform( source.numDimensions(), shearDimension, referenceDimension ); return Views.interval( Views.unshear( source, shearDimension, referenceDimension ), transform.transform( new BoundingBox( interval ) ).getInterval() ); } /** * Bijective permutation of the integer coordinates in each dimension of a * {@link RandomAccessibleInterval}. * * @param source * must be an n-dimensional hypercube with each * dimension being of the same size as the permutation array * @param permutation * must be a bijective permutation over its index set, i.e. for a * LUT of length n, the sorted content the array must be * [0,...,n-1] which is the index set of the LUT. * * @return {@link IntervalView} of permuted source. */ public static < T > IntervalView< T > permuteCoordinates( final RandomAccessibleInterval< T > source, final int[] permutation ) { assert AbstractPermutationTransform.checkBijectivity( permutation ): "Non-bijective LUT passed for coordinate permuation."; assert PermutationTransform.checkInterval( source, permutation ): "Source interval boundaries do not match permutation."; final int nDim = source.numDimensions(); final PermutationTransform transform = new PermutationTransform( permutation, nDim, nDim ); return Views.interval( new TransformView< T >( source, transform.inverse() ), source ); } /** * Bijective permutation of the integer coordinates of one dimension of a * {@link RandomAccessibleInterval}. * * @param source * must have dimension(dimension) == permutation.length * @param permutation * must be a bijective permutation over its index set, i.e. for a * lut of length n, the sorted content the array must be * [0,...,n-1] which is the index set of the lut. * @param d * dimension index to be permuted * * @return {@link IntervalView} of permuted source. */ public static < T > IntervalView< T > permuteCoordinates( final RandomAccessibleInterval< T > source, final int[] permutation, final int d ) { assert AbstractPermutationTransform.checkBijectivity( permutation ): "Non-bijective LUT passed for coordinate permuation."; assert source.min( d ) == 0: "Source with min[d] coordinate != 0 passed to coordinate permutation."; assert source.dimension( d ) == permutation.length: "Source with dimension[d] != LUT.length passed to coordinate permutation."; final int nDim = source.numDimensions(); final SingleDimensionPermutationTransform transform = new SingleDimensionPermutationTransform( permutation, nDim, nDim, d ); return Views.interval( new TransformView< T >( source, transform.inverse() ), source ); } /** * Inverse Bijective permutation of the integer coordinates in each * dimension of a {@link RandomAccessibleInterval}. * * @param source * must be an n-dimensional hypercube with each * dimension being of the same size as the permutation array * @param permutation * must be a bijective permutation over its index set, i.e. for a * LUT of length n, the sorted content the array must be * [0,...,n-1] which is the index set of the LUT. * * @return {@link IntervalView} of permuted source. */ public static < T > IntervalView< T > permuteCoordinatesInverse( final RandomAccessibleInterval< T > source, final int[] permutation ) { assert AbstractPermutationTransform.checkBijectivity( permutation ): "Non-bijective LUT passed for coordinate permuation."; assert PermutationTransform.checkInterval( source, permutation ): "Source interval boundaries do not match permutation."; final int nDim = source.numDimensions(); final PermutationTransform transform = new PermutationTransform( permutation, nDim, nDim ).inverse(); return Views.interval( new TransformView< T >( source, transform.inverse() ), source ); } /** * Inverse bijective permutation of the integer coordinates of one dimension * of a {@link RandomAccessibleInterval}. * * @param source * must have dimension(dimension) == permutation.length * @param permutation * must be a bijective permutation over its index set, i.e. for a * lut of length n, the sorted content the array must be * [0,...,n-1] which is the index set of the lut. * @param d * dimension index to be permuted * * @return {@link IntervalView} of permuted source. * * @deprecated use {@link Views#permuteCoordinatesInverse(RandomAccessibleInterval, int[], int)} */ @Deprecated public static < T > IntervalView< T > permuteCoordinateInverse( final RandomAccessibleInterval< T > source, final int[] permutation, final int d ) { return permuteCoordinatesInverse(source, permutation, d); } /** * Inverse bijective permutation of the integer coordinates of one dimension * of a {@link RandomAccessibleInterval}. * * @param source * must have dimension(dimension) == permutation.length * @param permutation * must be a bijective permutation over its index set, i.e. for a * lut of length n, the sorted content the array must be * [0,...,n-1] which is the index set of the lut. * @param d * dimension index to be permuted * * @return {@link IntervalView} of permuted source. */ public static < T > IntervalView< T > permuteCoordinatesInverse( final RandomAccessibleInterval< T > source, final int[] permutation, final int d ) { assert AbstractPermutationTransform.checkBijectivity( permutation ): "Non-bijective LUT passed for coordinate permuation."; assert source.min( d ) == 0: "Source with min[d] coordinate != 0 passed to coordinate permutation."; assert source.dimension( d ) == permutation.length: "Source with dimension[d] != LUT.length passed to coordinate permutation."; final int nDim = source.numDimensions(); final SingleDimensionPermutationTransform transform = new SingleDimensionPermutationTransform( permutation, nDim, nDim, d ).inverse(); return Views.interval( new TransformView< T >( source, transform.inverse() ), source ); } /** * Compose two {@link RandomAccessible} sources into a * {@link RandomAccessible} of {@link Pair}. * * @param sourceA * @param sourceB * @return */ public static < A, B > RandomAccessible< Pair< A, B > > pair( final RandomAccessible< A > sourceA, final RandomAccessible< B > sourceB ) { return new RandomAccessiblePair< A, B >( sourceA, sourceB ); } /** * Provide an (n + m)-dimensional {@link RandomAccessible} of T as * an m-dimensional {@link RandomAccessible} of * n-dimensional {@link RandomAccessible RandomAccessibles} of T. * * @param source * @param axes * the axes to become the inner axes (embedded into the * co-domain) * * @return */ public static < T > RandomAccessible< ? extends RandomAccessible< T > > hyperSlices( final RandomAccessible< T > source, final int... axes ) { return new HyperSlicesView< T >( source, axes ); } /** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled as specified by {@link OutOfBoundsFactory} oob. * * @param source * the interval to expand. * @param oob * the out-of-bounds strategy. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by oob and border. */ public static < T, F extends RandomAccessibleInterval< T > > IntervalView< T > expand( final F source, final OutOfBoundsFactory< T, ? super F > oob, final long... border ) { return Views.interval( Views.extend( source, oob ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled by mirroring source. Boundary pixels are not * repeated. Note that this requires that all dimensions of the source (F * source) must be > 1. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandMirrorSingle( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendMirrorSingle( source ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled by mirroring source. Boundary pixels are repeated. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandMirrorDouble( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendMirrorDouble( source ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with a constant value specified by the caller. * * @param source * the interval to expand. * @param t * Constant extension of source. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by t and border. */ public static < T extends Type< T > > IntervalView< T > expandValue( final RandomAccessibleInterval< T > source, final T t, final long... border ) { return interval( extendValue( source, t ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with the zero-element of that data type. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T extends NumericType< T > > IntervalView< T > expandZero( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendZero( source ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with a random-value out-of-bounds strategy. * * @param source * the interval to expand. * @param min * the minimal random value * @param max * the maximal random value * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by min, max, and border. */ public static < T extends RealType< T > > IntervalView< T > expandRandom( final RandomAccessibleInterval< T > source, final double min, final double max, final long... border ) { return interval( extendRandom( source, min, max ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with a periodic out-of-bounds strategy. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandPeriodic( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendPeriodic( source ), Intervals.expand( source, border ) ); } /** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with the border value. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandBorder( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendBorder( source ), Intervals.expand( source, border ) ); } /** * * Concatenate an array of {@link RandomAccessibleInterval} along the * provided concatenationAxis. The random access behaves as * defined by {@link StackView.StackAccessMode#DEFAULT}. * * @param concatenationAxis * Concatenate along this axis. * @param sources * {@link RandomAccessibleInterval}s to be concatenated. * @return {@link RandomAccessibleInterval} of concatenated sources. */ @SafeVarargs public static < T > RandomAccessibleInterval< T > concatenate( final int concatenationAxis, final RandomAccessibleInterval< T >... sources ) { return concatenate( concatenationAxis, StackView.StackAccessMode.DEFAULT, sources ); } /** * * Concatenate a list of {@link RandomAccessibleInterval} along the provided * concatenationAxis. The random access behaves as defined by * {@link StackView.StackAccessMode#DEFAULT}. * * @param concatenationAxis * Concatenate along this axis. * @param sources * {@link RandomAccessibleInterval}s to be concatenated. * @return {@link RandomAccessibleInterval} of concatenated sources. */ public static < T > RandomAccessibleInterval< T > concatenate( final int concatenationAxis, final List< ? extends RandomAccessibleInterval< T > > sources ) { return concatenate( concatenationAxis, StackView.StackAccessMode.DEFAULT, sources ); } /** * * Concatenate an array of {@link RandomAccessibleInterval} along the * provided concatenationAxis. See * {@link StackView.StackAccessMode} for behaviors of {@link RandomAccess}. * * @param concatenationAxis * Concatenate along this axis. * @param mode * Defines how random accesses are moved. See * {@link StackView.StackAccessMode} for behaviors of * {@link RandomAccess}. * @param sources * {@link RandomAccessibleInterval}s to be concatenated. * @return {@link RandomAccessibleInterval} of concatenated sources. */ @SafeVarargs public static < T > RandomAccessibleInterval< T > concatenate( final int concatenationAxis, final StackView.StackAccessMode mode, final RandomAccessibleInterval< T >... sources ) { return concatenate( concatenationAxis, mode, Arrays.asList( sources ) ); } /** * * Concatenate a list of {@link RandomAccessibleInterval} along the provided * concatenationAxis. See {@link StackView.StackAccessMode} for * behaviors of {@link RandomAccess}. * * @param concatenationAxis * Concatenate along this axis. * @param mode * Defines how random accesses are moved. See * {@link StackView.StackAccessMode} for behaviors of * {@link RandomAccess}. * @param sources * {@link RandomAccessibleInterval}s to be concatenated. * @return {@link RandomAccessibleInterval} of concatenated sources. */ public static < T > RandomAccessibleInterval< T > concatenate( final int concatenationAxis, final StackView.StackAccessMode mode, final List< ? extends RandomAccessibleInterval< T > > sources ) { assert sources.size() > 0; final ArrayList< RandomAccessibleInterval< T > > hyperSlices = new ArrayList<>(); for ( final RandomAccessibleInterval< T > source : sources ) for ( long index = source.min( concatenationAxis ); index <= source.max( concatenationAxis ); ++index ) hyperSlices.add( Views.hyperSlice( source, concatenationAxis, index ) ); return Views.stack( mode, hyperSlices ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/000077500000000000000000000000001316447754700241355ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/AbstractComposite.java000066400000000000000000000045621316447754700304350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.RandomAccess; /** * Abstract implementation of {@link Composite}. * * @author Stephan Saalfeld */ public class AbstractComposite< T > implements Composite< T > { final protected RandomAccess< T > sourceAccess; final protected int d; public AbstractComposite( final RandomAccess< T > sourceAccess ) { this.sourceAccess = sourceAccess; this.d = sourceAccess.numDimensions() - 1; } @Override public T get( final long i ) { sourceAccess.setPosition( i, d ); return sourceAccess.get(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/AbstractNumericComposite.java000066400000000000000000000130171316447754700317530ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import java.util.Iterator; import net.imglib2.RandomAccess; import net.imglib2.type.numeric.NumericType; /** * Abstract base class for a vector of {@link NumericType} scalars. It is a * {@link NumericType} itself, implementing the {@link NumericType} algebra as * element-wise operations. * * @author Stephan Saalfeld */ abstract public class AbstractNumericComposite< T extends NumericType< T >, C extends AbstractNumericComposite< T, C > > extends AbstractComposite< T > implements NumericType< C >, Iterable< T > { final protected int length; final protected Iterator< T > iterator = new Iterator< T >() { @Override public boolean hasNext() { return sourceAccess.getIntPosition( d ) + 1 < length; } @Override public T next() { sourceAccess.fwd( d ); final T t = sourceAccess.get(); return t; } @Override public void remove() { throw new UnsupportedOperationException(); } }; public AbstractNumericComposite( final RandomAccess< T > sourceAccess, final int length ) { super( sourceAccess ); this.length = length; } @Override public void set( final C c ) { sourceAccess.setPosition( 0, d ); c.sourceAccess.setPosition( 0, c.d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().set( c.sourceAccess.get() ); sourceAccess.fwd( d ); c.sourceAccess.fwd( c.d ); } } @Override public void add( final C c ) { sourceAccess.setPosition( 0, d ); c.sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().add( c.sourceAccess.get() ); sourceAccess.fwd( d ); c.sourceAccess.fwd( d ); } } @Override public void sub( final C c ) { sourceAccess.setPosition( 0, d ); c.sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().sub( c.sourceAccess.get() ); sourceAccess.fwd( d ); c.sourceAccess.fwd( d ); } } @Override public void mul( final C c ) { sourceAccess.setPosition( 0, d ); c.sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().mul( c.sourceAccess.get() ); sourceAccess.fwd( d ); c.sourceAccess.fwd( d ); } } @Override public void div( final C c ) { sourceAccess.setPosition( 0, d ); c.sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().div( c.sourceAccess.get() ); sourceAccess.fwd( d ); c.sourceAccess.fwd( d ); } } @Override public void setZero() { sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().setZero(); sourceAccess.fwd( d ); } } @Override public void setOne() { sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().setOne(); sourceAccess.fwd( d ); } } @Override public void mul( final float c ) { sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().mul( c ); sourceAccess.fwd( d ); } } @Override public void mul( final double c ) { sourceAccess.setPosition( 0, d ); while ( sourceAccess.getLongPosition( d ) < length ) { sourceAccess.get().mul( c ); sourceAccess.fwd( d ); } } @Override public Iterator< T > iterator() { sourceAccess.setPosition( -1, d ); return iterator; } @Override public boolean valueEquals( C t ) { if ( t.length == length ) { final Iterator< T > a = iterator(); final Iterator< T > b = t.iterator(); while ( a.hasNext() ) if ( !a.next().valueEquals( b.next() ) ) return false; return true; } else return false; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/Composite.java000066400000000000000000000041571316447754700267510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; /** * A {@link Composite} is a vector of scalars T. * * @author Stephan Saalfeld */ public interface Composite< T > { /** * Get the ith scalar value of the {@link Composite}. * * @param i * @return */ public T get( final long i ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/CompositeFactory.java000066400000000000000000000042111316447754700302700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.RandomAccess; /** * A factory to create a {@link Composite} vector of scalars T given a * {@link RandomAccess}. * * @author Stephan Saalfeld */ public interface CompositeFactory< T, C extends Composite< T > > { public C create( final RandomAccess< T > sourceAccess ); } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/CompositeIntervalView.java000066400000000000000000000102541316447754700313040ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.Interval; import net.imglib2.Positionable; import net.imglib2.RandomAccessibleInterval; import net.imglib2.RealPositionable; import net.imglib2.View; import net.imglib2.view.Views; /** * {@link CompositeView} of a {@link RandomAccessibleInterval}. * * @author Stephan Saalfeld */ public class CompositeIntervalView< T, C extends Composite< T > > extends CompositeView< T, C > implements RandomAccessibleInterval< C >, View { final Interval interval; final static protected < T > RandomAccessibleInterval< T > zeroMinN( final RandomAccessibleInterval< T > source ) { final long[] min = new long[ source.numDimensions() ]; final int n = min.length - 1; min[ n ] = source.min( n ); return Views.offset( source, min ); } public CompositeIntervalView( final RandomAccessibleInterval< T > source, final CompositeFactory< T, C > compositeFactory ) { super( zeroMinN( source ), compositeFactory ); interval = source; } @Override public long min( final int d ) { return interval.min( d ); } @Override public void min( final long[] min ) { for ( int d = 0; d < n; ++d ) min[ d ] = min( d ); } @Override public void min( final Positionable min ) { for ( int d = 0; d < n; ++d ) min.setPosition( min( d ), d ); } @Override public long max( final int d ) { return interval.max( d ); } @Override public void max( final long[] max ) { for ( int d = 0; d < n; ++d ) max[ d ] = max( d ); } @Override public void max( final Positionable max ) { for ( int d = 0; d < n; ++d ) max.setPosition( max( d ), d ); } @Override public double realMin( final int d ) { return min( d ); } @Override public void realMin( final double[] min ) { for ( int d = 0; d < n; ++d ) min[ d ] = min( d ); } @Override public void realMin( final RealPositionable min ) { min( min ); } @Override public double realMax( final int d ) { return max( d ); } @Override public void realMax( final double[] max ) { for ( int d = 0; d < n; ++d ) max[ d ] = max( d ); } @Override public void realMax( final RealPositionable max ) { max( max ); } @Override public void dimensions( final long[] dimensions ) { for ( int d = 0; d < n; ++d ) dimensions[ d ] = interval.dimension( d ); } @Override public long dimension( final int d ) { return interval.dimension( d ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/CompositeView.java000066400000000000000000000145441316447754700276050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.Interval; import net.imglib2.Localizable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessible; import net.imglib2.View; /** * {@link CompositeView} collapses the trailing dimension of a * {@link RandomAccessible} of T into a {@link Composite} of T. The results is * an (n-1)-dimensional {@link RandomAccessible} of {@link Composite} * of T. * * @author Stephan Saalfeld */ public class CompositeView< T, C extends Composite< T > > implements RandomAccessible< C >, View { final protected CompositeFactory< T, C > compositeFactory; final protected RandomAccessible< T > source; final protected int n; public class CompositeRandomAccess implements RandomAccess< C > { final protected RandomAccess< T > sourceAccess; final protected C composite; public CompositeRandomAccess() { sourceAccess = source.randomAccess(); composite = compositeFactory.create( sourceAccess ); } protected CompositeRandomAccess( final CompositeRandomAccess other ) { sourceAccess = other.sourceAccess.copyRandomAccess(); composite = compositeFactory.create( sourceAccess ); } @Override public void localize( final int[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = sourceAccess.getIntPosition( d ); } @Override public void localize( final long[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = sourceAccess.getLongPosition( d ); } @Override public int getIntPosition( final int d ) { return sourceAccess.getIntPosition( d ); } @Override public long getLongPosition( final int d ) { return sourceAccess.getLongPosition( d ); } @Override public void localize( final float[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = sourceAccess.getFloatPosition( d ); } @Override public void localize( final double[] position ) { for ( int d = 0; d < n; ++d ) position[ d ] = sourceAccess.getDoublePosition( d ); } @Override public float getFloatPosition( final int d ) { return sourceAccess.getFloatPosition( d ); } @Override public double getDoublePosition( final int d ) { return sourceAccess.getFloatPosition( d ); } @Override public int numDimensions() { return n; } @Override public void fwd( final int d ) { sourceAccess.fwd( d ); } @Override public void bck( final int d ) { sourceAccess.bck( d ); } @Override public void move( final int distance, final int d ) { sourceAccess.move( distance, d ); } @Override public void move( final long distance, final int d ) { sourceAccess.move( distance, d ); } @Override public void move( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) sourceAccess.move( localizable.getLongPosition( d ), d ); } @Override public void move( final int[] distance ) { for ( int d = 0; d < n; ++d ) sourceAccess.move( distance[ d ], d ); } @Override public void move( final long[] distance ) { for ( int d = 0; d < n; ++d ) sourceAccess.move( distance[ d ], d ); } @Override public void setPosition( final Localizable localizable ) { for ( int d = 0; d < n; ++d ) sourceAccess.setPosition( localizable.getLongPosition( d ), d ); } @Override public void setPosition( final int[] position ) { for ( int d = 0; d < n; ++d ) sourceAccess.setPosition( position[ d ], d ); } @Override public void setPosition( final long[] position ) { for ( int d = 0; d < n; ++d ) sourceAccess.setPosition( position[ d ], d ); } @Override public void setPosition( final int position, final int d ) { sourceAccess.setPosition( position, d ); } @Override public void setPosition( final long position, final int d ) { sourceAccess.setPosition( position, d ); } @Override public C get() { return composite; } @Override public CompositeRandomAccess copy() { return new CompositeRandomAccess( this ); } @Override public CompositeRandomAccess copyRandomAccess() { return copy(); } } public CompositeView( final RandomAccessible< T > source, final CompositeFactory< T, C > compositeFactory ) { this.source = source; this.compositeFactory = compositeFactory; n = source.numDimensions() - 1; } @Override public int numDimensions() { return n; } @Override public CompositeRandomAccess randomAccess() { return new CompositeRandomAccess(); } @Override public CompositeRandomAccess randomAccess( final Interval interval ) { return randomAccess(); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/GenericComposite.java000066400000000000000000000045531316447754700302460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.RandomAccess; /** * A generic vector of scalars T. * * @author Stephan Saalfeld */ public class GenericComposite< T > extends AbstractComposite< T > { static public class Factory< T > implements CompositeFactory< T, GenericComposite< T > > { @Override public GenericComposite< T > create( final RandomAccess< T > sourceAccess ) { return new GenericComposite< T >( sourceAccess ); } } public GenericComposite( final RandomAccess< T > sourceAccess ) { super( sourceAccess ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/NumericComposite.java000066400000000000000000000071231316447754700302700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.list.ListImgFactory; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.NumericType; /** * A vector of {@link NumericType} scalars. It is a {@link NumericType} * itself, implementing the {@link NumericType} algebra as element-wise * operations. * * @author Stephan Saalfeld */ public class NumericComposite< T extends NumericType< T > > extends AbstractNumericComposite< T, NumericComposite< T > > { static public class Factory< T extends NumericType< T > > implements CompositeFactory< T, NumericComposite< T > > { final protected int numChannels; public Factory( final int numChannels ) { this.numChannels = numChannels; } @Override public NumericComposite< T > create( final RandomAccess< T > sourceAccess ) { return new NumericComposite< T >( sourceAccess, numChannels ); } } public NumericComposite( final RandomAccess< T > sourceAccess, final int length ) { super( sourceAccess, length ); } /** * Generates a 1D {@link ArrayImg}<T> */ @Override @SuppressWarnings( { "unchecked", "rawtypes" } ) public NumericComposite< T > createVariable() { final T t = sourceAccess.get(); final Img< T > img; if ( NativeType.class.isInstance( t ) ) img = ( ( NativeType )t ).createSuitableNativeImg( new ArrayImgFactory(), new long[]{ length } ); else img = new ListImgFactory< T >().create( new long[]{ length }, t ); return new NumericComposite< T >( img.randomAccess(), length ); } @Override public NumericComposite< T > copy() { return new NumericComposite< T >( sourceAccess.copyRandomAccess(), length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/composite/RealComposite.java000066400000000000000000000071261316447754700275540ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.composite; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.list.ListImgFactory; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.NumericType; import net.imglib2.type.numeric.RealType; /** * A vector of {@link RealType} scalars. It is a {@link NumericType} * itself, implementing the {@link NumericType} algebra as element-wise * operations. * * @author Stephan Saalfeld */ public class RealComposite< T extends RealType< T > > extends AbstractNumericComposite< T, RealComposite< T > > { static public class Factory< T extends RealType< T > > implements CompositeFactory< T, RealComposite< T > > { final protected int numChannels; public Factory( final int numChannels ) { this.numChannels = numChannels; } @Override public RealComposite< T > create( final RandomAccess< T > sourceAccess ) { return new RealComposite< T >( sourceAccess, numChannels ); } } public RealComposite( final RandomAccess< T > sourceAccess, final int length ) { super( sourceAccess, length ); } /** * Generates a 1D {@link ArrayImg}<T> */ @Override @SuppressWarnings( { "unchecked", "rawtypes" } ) public RealComposite< T > createVariable() { final T t = sourceAccess.get(); final Img< T > img; if ( NativeType.class.isInstance( t ) ) img = ( ( NativeType )t ).createSuitableNativeImg( new ArrayImgFactory(), new long[]{ length } ); else img = new ListImgFactory< T >().create( new long[]{ length }, t ); return new RealComposite< T >( img.randomAccess(), length ); } @Override public RealComposite< T > copy() { return new RealComposite< T >( sourceAccess.copyRandomAccess(), length ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/iteration/000077500000000000000000000000001316447754700241315ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/iteration/IterableTransformBuilder.java000066400000000000000000000225771316447754700317430ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.iteration; import java.util.Arrays; import java.util.Iterator; import net.imglib2.AbstractWrappedInterval; import net.imglib2.Cursor; import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessible; import net.imglib2.transform.integer.BoundingBox; import net.imglib2.transform.integer.SlicingTransform; import net.imglib2.util.Intervals; import net.imglib2.view.IterableRandomAccessibleInterval; import net.imglib2.view.TransformBuilder; import net.imglib2.view.Views; /** * Simplifies View cascades to provide the most efficient {@link Cursor}. * * @see #getEfficientIterableInterval(Interval, RandomAccessible) * * @author Tobias Pietzsch */ public class IterableTransformBuilder< T > extends TransformBuilder< T > { /** * Create an {@link IterableInterval} that iterates an {@link Interval} of a * {@link RandomAccessible}. If possible, this should return an optimized * cursor. If not, falls back to creating an * {@link IterableRandomAccessibleInterval}. * * @param interval * the interval of {@code randomAccessible} which should be * iterated. * @param randomAccessible * the {@link RandomAccessible} that should be iterated. * @return an {@link IterableInterval} that iterates {@code interval} of * {@code randomAccessible}. */ public static < S > IterableInterval< S > getEfficientIterableInterval( final Interval interval, final RandomAccessible< S > randomAccessible ) { return new IterableTransformBuilder< S >( interval, randomAccessible ).buildIterableInterval(); } /** * The interval which should be iterated. * *

* Currently, no transformations are done on this, because the cases where * an optimized {@link IterableInterval} can be returned do not allow for * any transformation except a single slicing. In the future, it may become * necessary, to propagated the interval through the transforms down the * view hierarchy. */ protected Interval interval; /** * Create a new IterableTransformBuilder. This calls the the super * constructor to gather and simplify transformations. * * @param interval * the interval of {@code randomAccessible} which should be * iterated. * @param randomAccessible * the {@link RandomAccessible} that should be iterated. */ public IterableTransformBuilder( final Interval interval, final RandomAccessible< T > randomAccessible ) { super( interval, randomAccessible ); this.interval = interval; } /** * An {@link IterableInterval} on {@link IterableTransformBuilder#interval * interval} of {@link SubIntervalIterable}. */ private class SubInterval extends AbstractWrappedInterval< Interval > implements IterableInterval< T > { final long numElements; final SubIntervalIterable< T > iterableSource; public SubInterval( final SubIntervalIterable< T > iterableSource ) { super( interval ); numElements = Intervals.numElements( interval ); this.iterableSource = iterableSource; } @Override public long size() { return numElements; } @Override public T firstElement() { return cursor().next(); } @Override public Object iterationOrder() { return iterableSource.subIntervalIterationOrder( interval ); } @Override public Iterator< T > iterator() { return cursor(); } @Override public Cursor< T > cursor() { return iterableSource.cursor( interval ); } @Override public Cursor< T > localizingCursor() { return iterableSource.localizingCursor( interval ); } } /** * An {@link IterableInterval} on a slice of a {@link SubIntervalIterable}. */ private class Slice extends AbstractWrappedInterval< Interval > implements IterableInterval< T > { final long numElements; final SubIntervalIterable< T > iterableSource; final Interval sourceInterval; final SlicingTransform transformToSource; final boolean hasFlatIterationOrder; public Slice( final SubIntervalIterable< T > iterableSource, final Interval sourceInterval, final SlicingTransform transformToSource, final boolean hasFlatIterationOrder ) { super( interval ); numElements = Intervals.numElements( interval ); this.iterableSource = iterableSource; this.sourceInterval = sourceInterval; this.transformToSource = transformToSource; this.hasFlatIterationOrder = hasFlatIterationOrder; } @Override public long size() { return numElements; } @Override public T firstElement() { return cursor().next(); } @Override public Object iterationOrder() { return hasFlatIterationOrder ? new FlatIterationOrder( interval ) : this; } @Override public Iterator< T > iterator() { return cursor(); } @Override public Cursor< T > cursor() { return new SlicingCursor< T >( iterableSource.cursor( sourceInterval ), transformToSource ); } @Override public Cursor< T > localizingCursor() { return new SlicingCursor< T >( iterableSource.localizingCursor( sourceInterval ), transformToSource ); } } /** * Create an {@link IterableInterval} on the {@link Interval} specified in * the constructor of the {@link RandomAccessible} specified in the * constructor. */ public IterableInterval< T > buildIterableInterval() { if ( boundingBox != null && SubIntervalIterable.class.isInstance( source ) ) { @SuppressWarnings( "unchecked" ) final SubIntervalIterable< T > iterableSource = ( SubIntervalIterable< T > ) source; if ( transforms.isEmpty() ) { if ( iterableSource.supportsOptimizedCursor( interval ) ) return new SubInterval( iterableSource ); } else if ( transforms.size() == 1 && SlicingTransform.class.isInstance( transforms.get( 0 ) ) ) { final SlicingTransform t = ( SlicingTransform ) transforms.get( 0 ); final int m = t.numTargetDimensions(); final int n = t.numSourceDimensions(); // Check whether the slicing can be potentially optimized. boolean optimizable = true; // 1.) Slice dimensions must be mapped to a contiguous range of // target dimensions starting with dimension 0. int firstZeroDim = 0; for ( ; firstZeroDim < m && !t.getComponentZero( firstZeroDim ); ++firstZeroDim ); for ( int d = firstZeroDim + 1; d < m && optimizable; ++d ) if ( !t.getComponentZero( d ) ) optimizable = false; // 2.) All slice dimensions must be mapped to a target dimension final int[] sourceComponent = new int[ n ]; if ( optimizable ) { Arrays.fill( sourceComponent, -1 ); for ( int d = 0; d < m; ++d ) if ( !t.getComponentZero( d ) ) sourceComponent[ t.getComponentMapping( d ) ] = d; for ( int d = 0; d < n && optimizable; ++d ) if ( sourceComponent[ d ] < 0 ) optimizable = false; } if ( optimizable ) { // System.out.println( "interval = " + Util.printInterval( interval ) ); final Interval sliceInterval = t.transform( new BoundingBox( interval ) ).getInterval(); // System.out.println( "transformed interval = " + Util.printInterval( sliceInterval ) ); if ( iterableSource.supportsOptimizedCursor( sliceInterval ) ) { // check for FlatIterationOrder boolean flat = FlatIterationOrder.class.isInstance( iterableSource.subIntervalIterationOrder( sliceInterval ) ); for ( int d = 0; d < n - 1; ++d ) if ( sourceComponent[ d + 1 ] <= sourceComponent[ d ] ) flat = false; return new Slice( iterableSource, sliceInterval, t, flat ); } } } } return new IterableRandomAccessibleInterval< T >( Views.interval( build(), interval ) ); } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/iteration/SlicingCursor.java000066400000000000000000000141521316447754700275650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.iteration; import net.imglib2.AbstractEuclideanSpace; import net.imglib2.Cursor; import net.imglib2.Localizable; import net.imglib2.transform.integer.Slicing; /** * Wrap a cursor that runs on a hyperslice and apply coordinate transform on * localize calls. * * @author Tobias Pietzsch */ public class SlicingCursor< T > extends AbstractEuclideanSpace implements Cursor< T > { /** * source Cursor. note that this is the target of the * transformToSource. */ private final Cursor< T > s; /** * number of dimensions of source Cursor, respectively numTargetDimensions * of the Slicing transform. */ private final int m; /** * for each component of the source vector: to which target vector component * should it be taken. */ private final int[] sourceComponent; private final long[] tmpPosition; /** * Create a Cursor that forwards all {@link Cursor} methods to * {@code source}, except {@link Localizable} methods. Localize calls are * propagated through {@code transformToSource}. */ SlicingCursor( final Cursor< T > source, final Slicing transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); final boolean[] targetZero = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); sourceComponent = new int[ n ]; for ( int d = 0; d < m; ++d ) if ( !transformToSource.getComponentZero( d ) ) sourceComponent[ transformToSource.getComponentMapping( d ) ] = d; tmpPosition = new long[ m ]; transformToSource.getTranslation( tmpPosition ); } protected SlicingCursor( final SlicingCursor< T > cursor ) { super( cursor.numDimensions() ); s = cursor.s; m = cursor.m; sourceComponent = cursor.sourceComponent.clone(); tmpPosition = cursor.tmpPosition.clone(); } /** * {@inheritDoc} */ @Override public void localize( final int[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getIntPosition( d ); } /** * {@inheritDoc} */ @Override public void localize( final long[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getLongPosition( d ); } /** * {@inheritDoc} */ @Override public int getIntPosition( final int d ) { assert d < n; return s.getIntPosition( sourceComponent[ d ] ); } /** * {@inheritDoc} */ @Override public long getLongPosition( final int d ) { assert d < n; return s.getLongPosition( sourceComponent[ d ] ); } /** * {@inheritDoc} */ @Override public void localize( final float[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getFloatPosition( d ); } /** * {@inheritDoc} */ @Override public void localize( final double[] position ) { assert position.length >= n; for ( int d = 0; d < n; ++d ) position[ d ] = getDoublePosition( d ); } /** * {@inheritDoc} */ @Override public float getFloatPosition( final int d ) { assert d < n; return s.getFloatPosition( sourceComponent[ d ] ); } /** * {@inheritDoc} */ @Override public double getDoublePosition( final int d ) { assert d < n; return s.getDoublePosition( sourceComponent[ d ] ); } /** * {@inheritDoc} */ @Override public T get() { return s.get(); } /** * {@inheritDoc} */ @Override public SlicingCursor< T > copy() { return new SlicingCursor< T >( this ); } /** * {@inheritDoc} */ @Override public SlicingCursor< T > copyCursor() { return copy(); } /** * {@inheritDoc} */ @Override public void jumpFwd( final long steps ) { s.jumpFwd( steps ); } /** * {@inheritDoc} */ @Override public void fwd() { s.fwd(); } /** * {@inheritDoc} */ @Override public void reset() { s.reset(); } /** * {@inheritDoc} */ @Override public boolean hasNext() { return s.hasNext(); } /** * {@inheritDoc} */ @Override public T next() { return s.next(); } /** * {@inheritDoc} */ @Override public void remove() { return; } } imglib2-imglib2-4.5.0/src/main/java/net/imglib2/view/iteration/SubIntervalIterable.java000066400000000000000000000063421316447754700307070ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view.iteration; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.IterableRealInterval; /** * Implementing this interface enables the implementor to return optimized * {@link Cursor}s for certain {@link Interval}s * * @author Tobias Pietzsch */ public interface SubIntervalIterable< T > { /** * Determine whether a {@link Cursor} can be created that iterates the given * {@link Interval}. * * @param interval * to be checked * * @return true if a {@link Cursor} can be optimized given the * {@link Interval} */ public boolean supportsOptimizedCursor( Interval interval ); /** * Returns the iteration order given the interval. * * @param interval * {@link Interval} over which to iterate * * @return the iteration order object @see {@link IterableRealInterval} */ public Object subIntervalIterationOrder( Interval interval ); /** * Create a {@link Cursor} to iterate over the given {@link Interval}. * * @param interval * {@link Interval} over which to iterate * * @return {@link Cursor} */ public Cursor< T > cursor( Interval interval ); /** * Create a {@link Cursor} to iterate over the given {@link Interval}. * * @param interval * {@link Interval} over which to iterate * * @return {@link Cursor} */ public Cursor< T > localizingCursor( Interval interval ); } imglib2-imglib2-4.5.0/src/test/000077500000000000000000000000001316447754700161605ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/000077500000000000000000000000001316447754700171015ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/000077500000000000000000000000001316447754700176675ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/000077500000000000000000000000001316447754700212145ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/BinningTest.java000066400000000000000000000412501316447754700243050ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import net.imglib2.util.Binning; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; /** * * @author Aivar Grislis */ public class BinningTest { private static final double EPSILON_FACTOR = 1000000; private static final boolean TEST_INTERNAL = false; public BinningTest() {} @BeforeClass public static void setUpClass() throws Exception {} @AfterClass public static void tearDownClass() throws Exception {} @Before public void setUp() {} @After public void tearDown() {} @Test public void testInternal() { // avoid lengthy test in build; tests internal method if ( TEST_INTERNAL ) { System.out.println( "testInternal" ); double value; int number; // test going from negative to zero to positive value = -0x0.0000000000010P-1022; number = 1024; testNextDouble( value, number ); // test going from unnormalizable to normalizable value = 0x0.ffffffffffff0P-1022; number = 1024; testNextDouble( value, number ); } } /** * Test looking up some simple values. */ @Test public void testValues() { System.out.println( "testValues" ); testSomeValues( 256 ); testSomeValues( 1000 ); testSomeValues( 32767 ); testSomeValues( 65534 ); } /** * Test edge cases, near min and max. */ @Test public void testEdges() { System.out.println( "testEdges" ); double d = 1.0234; // testing arbitrary values testSomeEdges( 256, d ); testSomeEdges( 1000, d ); testSomeEdges( 32767, d ); testSomeEdges( 65534, d ); d = 9.87654321; testSomeEdges( 256, d ); testSomeEdges( 1000, d ); testSomeEdges( 32767, d ); testSomeEdges( 65534, d ); d = -1.0234; testSomeEdges( 256, d ); testSomeEdges( 1000, d ); testSomeEdges( 32767, d ); testSomeEdges( 65534, d ); d = -9.87654321; testSomeEdges( 256, d ); testSomeEdges( 1000, d ); testSomeEdges( 32767, d ); testSomeEdges( 65534, d ); } /** * Tests bins are evenly distributed. */ @Test public void testDistribution() { System.out.println( "testDistribution" ); int bins = 256; double min = 0.0; double max = 1.0; double inc = 0.0001; testHistogram( min, max, inc, bins ); bins = 1024; min = 0.0; max = 1.0; inc = 0.00001; testHistogram( min, max, inc, bins ); } /** * Tests edge values array. */ @Test public void testEdgeValuesArray() { System.out.println( "testEdgeValuesArray" ); int bins; double min; double max; double[] edgeValues; double[] expectedValues; bins = 256; min = 0.0; max = 1.0; edgeValues = Binning.edgeValuesPerBin( bins, min, max ); expectedValues = new double[] { 0.0, 0.00390625, 0.0078125, 0.01171875, 0.015625, 0.01953125, 0.0234375, 0.02734375, 0.03125, 0.03515625, 0.0390625, 0.04296875, 0.046875, 0.05078125, 0.0546875, 0.05859375, 0.0625, 0.06640625, 0.0703125, 0.07421875, 0.078125, 0.08203125, 0.0859375, 0.08984375, 0.09375, 0.09765625, 0.1015625, 0.10546875, 0.109375, 0.11328125, 0.1171875, 0.12109375, 0.125, 0.12890625, 0.1328125, 0.13671875, 0.140625, 0.14453125, 0.1484375, 0.15234375, 0.15625, 0.16015625, 0.1640625, 0.16796875, 0.171875, 0.17578125, 0.1796875, 0.18359375, 0.1875, 0.19140625, 0.1953125, 0.19921875, 0.203125, 0.20703125, 0.2109375, 0.21484375, 0.21875, 0.22265625, 0.2265625, 0.23046875, 0.234375, 0.23828125, 0.2421875, 0.24609375, 0.25, 0.25390625, 0.2578125, 0.26171875, 0.265625, 0.26953125, 0.2734375, 0.27734375, 0.28125, 0.28515625, 0.2890625, 0.29296875, 0.296875, 0.30078125, 0.3046875, 0.30859375, 0.3125, 0.31640625, 0.3203125, 0.32421875, 0.328125, 0.33203125, 0.3359375, 0.33984375, 0.34375, 0.34765625, 0.3515625, 0.35546875, 0.359375, 0.36328125, 0.3671875, 0.37109375, 0.375, 0.37890625, 0.3828125, 0.38671875, 0.390625, 0.39453125, 0.3984375, 0.40234375, 0.40625, 0.41015625, 0.4140625, 0.41796875, 0.421875, 0.42578125, 0.4296875, 0.43359375, 0.4375, 0.44140625, 0.4453125, 0.44921875, 0.453125, 0.45703125, 0.4609375, 0.46484375, 0.46875, 0.47265625, 0.4765625, 0.48046875, 0.484375, 0.48828125, 0.4921875, 0.49609375, 0.5, 0.50390625, 0.5078125, 0.51171875, 0.515625, 0.51953125, 0.5234375, 0.52734375, 0.53125, 0.53515625, 0.5390625, 0.54296875, 0.546875, 0.55078125, 0.5546875, 0.55859375, 0.5625, 0.56640625, 0.5703125, 0.57421875, 0.578125, 0.58203125, 0.5859375, 0.58984375, 0.59375, 0.59765625, 0.6015625, 0.60546875, 0.609375, 0.61328125, 0.6171875, 0.62109375, 0.625, 0.62890625, 0.6328125, 0.63671875, 0.640625, 0.64453125, 0.6484375, 0.65234375, 0.65625, 0.66015625, 0.6640625, 0.66796875, 0.671875, 0.67578125, 0.6796875, 0.68359375, 0.6875, 0.69140625, 0.6953125, 0.69921875, 0.703125, 0.70703125, 0.7109375, 0.71484375, 0.71875, 0.72265625, 0.7265625, 0.73046875, 0.734375, 0.73828125, 0.7421875, 0.74609375, 0.75, 0.75390625, 0.7578125, 0.76171875, 0.765625, 0.76953125, 0.7734375, 0.77734375, 0.78125, 0.78515625, 0.7890625, 0.79296875, 0.796875, 0.80078125, 0.8046875, 0.80859375, 0.8125, 0.81640625, 0.8203125, 0.82421875, 0.828125, 0.83203125, 0.8359375, 0.83984375, 0.84375, 0.84765625, 0.8515625, 0.85546875, 0.859375, 0.86328125, 0.8671875, 0.87109375, 0.875, 0.87890625, 0.8828125, 0.88671875, 0.890625, 0.89453125, 0.8984375, 0.90234375, 0.90625, 0.91015625, 0.9140625, 0.91796875, 0.921875, 0.92578125, 0.9296875, 0.93359375, 0.9375, 0.94140625, 0.9453125, 0.94921875, 0.953125, 0.95703125, 0.9609375, 0.96484375, 0.96875, 0.97265625, 0.9765625, 0.98046875, 0.984375, 0.98828125, 0.9921875, 0.99609375 }; assertEquals( edgeValues.length, expectedValues.length ); assertEquals( edgeValues.length, bins ); for ( int i = 0; i < bins; ++i ) { assertEquals( edgeValues[ i ], expectedValues[ i ], edgeValues[ i ] / EPSILON_FACTOR ); } // make sure edge value is the first double that maps to that bin // (this won't pass if bins/min/max are too oddball) bins = 256; min = 0.0; max = 1.0; edgeValues = Binning.edgeValuesPerBin( bins, min, max ); for ( int i = 0; i < bins; ++i ) { final int edgeBin = Binning.exclusiveValueToBin( bins, min, max, edgeValues[ i ] ); assertEquals( i, edgeBin ); // previous double should map to previous bin final double prevValue = DoubleUtil.nextDouble( edgeValues[ i ], false ); final int prevBin = Binning.exclusiveValueToBin( bins, min, max, prevValue ); assertEquals( i - 1, prevBin ); } } /** * Tests center values array. */ @Test public void testCenterValuesArray() { System.out.println( "testCenterValuesArray" ); int bins; double min; double max; double[] expectedValues; bins = 256; min = 0.0; max = 1.0; final double[] centerValues = Binning.centerValuesPerBin( bins, min, max ); expectedValues = new double[] { 0.001953125, 0.005859375, 0.009765625, 0.013671875, 0.017578125, 0.021484375, 0.025390625, 0.029296875, 0.033203125, 0.037109375, 0.041015625, 0.044921875, 0.048828125, 0.052734375, 0.056640625, 0.060546875, 0.064453125, 0.068359375, 0.072265625, 0.076171875, 0.080078125, 0.083984375, 0.087890625, 0.091796875, 0.095703125, 0.099609375, 0.103515625, 0.107421875, 0.111328125, 0.115234375, 0.119140625, 0.123046875, 0.126953125, 0.130859375, 0.134765625, 0.138671875, 0.142578125, 0.146484375, 0.150390625, 0.154296875, 0.158203125, 0.162109375, 0.166015625, 0.169921875, 0.173828125, 0.177734375, 0.181640625, 0.185546875, 0.189453125, 0.193359375, 0.197265625, 0.201171875, 0.205078125, 0.208984375, 0.212890625, 0.216796875, 0.220703125, 0.224609375, 0.228515625, 0.232421875, 0.236328125, 0.240234375, 0.244140625, 0.248046875, 0.251953125, 0.255859375, 0.259765625, 0.263671875, 0.267578125, 0.271484375, 0.275390625, 0.279296875, 0.283203125, 0.287109375, 0.291015625, 0.294921875, 0.298828125, 0.302734375, 0.306640625, 0.310546875, 0.314453125, 0.318359375, 0.322265625, 0.326171875, 0.330078125, 0.333984375, 0.337890625, 0.341796875, 0.345703125, 0.349609375, 0.353515625, 0.357421875, 0.361328125, 0.365234375, 0.369140625, 0.373046875, 0.376953125, 0.380859375, 0.384765625, 0.388671875, 0.392578125, 0.396484375, 0.400390625, 0.404296875, 0.408203125, 0.412109375, 0.416015625, 0.419921875, 0.423828125, 0.427734375, 0.431640625, 0.435546875, 0.439453125, 0.443359375, 0.447265625, 0.451171875, 0.455078125, 0.458984375, 0.462890625, 0.466796875, 0.470703125, 0.474609375, 0.478515625, 0.482421875, 0.486328125, 0.490234375, 0.494140625, 0.498046875, 0.501953125, 0.505859375, 0.509765625, 0.513671875, 0.517578125, 0.521484375, 0.525390625, 0.529296875, 0.533203125, 0.537109375, 0.541015625, 0.544921875, 0.548828125, 0.552734375, 0.556640625, 0.560546875, 0.564453125, 0.568359375, 0.572265625, 0.576171875, 0.580078125, 0.583984375, 0.587890625, 0.591796875, 0.595703125, 0.599609375, 0.603515625, 0.607421875, 0.611328125, 0.615234375, 0.619140625, 0.623046875, 0.626953125, 0.630859375, 0.634765625, 0.638671875, 0.642578125, 0.646484375, 0.650390625, 0.654296875, 0.658203125, 0.662109375, 0.666015625, 0.669921875, 0.673828125, 0.677734375, 0.681640625, 0.685546875, 0.689453125, 0.693359375, 0.697265625, 0.701171875, 0.705078125, 0.708984375, 0.712890625, 0.716796875, 0.720703125, 0.724609375, 0.728515625, 0.732421875, 0.736328125, 0.740234375, 0.744140625, 0.748046875, 0.751953125, 0.755859375, 0.759765625, 0.763671875, 0.767578125, 0.771484375, 0.775390625, 0.779296875, 0.783203125, 0.787109375, 0.791015625, 0.794921875, 0.798828125, 0.802734375, 0.806640625, 0.810546875, 0.814453125, 0.818359375, 0.822265625, 0.826171875, 0.830078125, 0.833984375, 0.837890625, 0.841796875, 0.845703125, 0.849609375, 0.853515625, 0.857421875, 0.861328125, 0.865234375, 0.869140625, 0.873046875, 0.876953125, 0.880859375, 0.884765625, 0.888671875, 0.892578125, 0.896484375, 0.900390625, 0.904296875, 0.908203125, 0.912109375, 0.916015625, 0.919921875, 0.923828125, 0.927734375, 0.931640625, 0.935546875, 0.939453125, 0.943359375, 0.947265625, 0.951171875, 0.955078125, 0.958984375, 0.962890625, 0.966796875, 0.970703125, 0.974609375, 0.978515625, 0.982421875, 0.986328125, 0.990234375, 0.994140625, 0.998046875 }; assertEquals( centerValues.length, expectedValues.length ); assertEquals( centerValues.length, bins ); for ( int i = 0; i < bins; ++i ) { assertEquals( centerValues[ i ], expectedValues[ i ], centerValues[ i ] / EPSILON_FACTOR ); } // make sure center value maps to correct bin for ( int i = 0; i < bins; ++i ) { final int centerBin = Binning.exclusiveValueToBin( bins, min, max, centerValues[ i ] ); assertEquals( i, centerBin ); } } /** * Helper function checks values map reasonably. * * @param bins */ private void testSomeValues( final int bins ) { double min; double max; double value; int bin; // check that value min maps to first bin min = 0.0; max = 1.0; value = min; bin = Binning.valueToBin( bins, min, max, value ); assertEquals( 0, bin ); bin = Binning.exclusiveValueToBin( bins, min, max, value ); assertEquals( 0, bin ); // check that value max maps to last bin min = 0.0; max = 1.0; value = max; bin = Binning.valueToBin( bins, min, max, value ); assertEquals( bins - 1, bin ); bin = Binning.exclusiveValueToBin( bins, min, max, value ); assertEquals( bins - 1, bin ); // check that value (max - min) / 2 maps to middle bin min = 0.0; max = 1.0; value = ( max - min ) / 2; bin = Binning.valueToBin( bins, min, max, value ); assertEquals( bins / 2, bin ); bin = Binning.exclusiveValueToBin( bins, min, max, value ); assertEquals( bins / 2, bin ); // check that if max == min == value get middle bin min = 0.0; max = min; value = min; bin = Binning.valueToBin( bins, min, max, value ); assertEquals( bins / 2, bin ); bin = Binning.exclusiveValueToBin( bins, min, max, value ); assertEquals( bins / 2, bin ); } /** * Tests that values less than min or more than max map outside the range of * bins. * * @param bins * @param d1 */ private void testSomeEdges( final int bins, double d1 ) { double min; double max; double value; int bin; // get two adjacent doubles double d2 = DoubleUtil.nextDouble( d1, true ); if ( d2 < d1 ) { // allow for negative numbers final double tmp = d1; d1 = d2; d2 = tmp; } // value is just before min value = d1; min = d2; max = d2 + 1.0; bin = Binning.valueToBin( bins, min, max, value ); // inclusive, get first bin assertEquals( 0, bin ); bin = Binning.exclusiveValueToBin( bins, min, max, value ); // exclusive, get bin - 1 assertEquals( -1, bin ); // value is just after max max = d1; min = d1 - 1.0; value = d2; bin = Binning.valueToBin( bins, min, max, value ); // inclusive, get last bin assertEquals( bins - 1, bin ); bin = Binning.exclusiveValueToBin( bins, min, max, value ); // exclusive, get last bin + 1 assertEquals( bins, bin ); } /** * Tests the uniformity of bin distribution in a histogram situation. * * @param min * @param max * @param inc * @param bins */ private void testHistogram( final double min, final double max, final double inc, final int bins ) { final long[] histogram = new long[ bins ]; // fill up the histogram with uniform values for ( double value = min; value <= max; value += inc ) { final int bin = Binning.valueToBin( bins, min, max, value ); ++histogram[ bin ]; } // make a list of histogram count values final List< Long > values = new ArrayList< Long >(); Arrays.sort( histogram ); long previousCount = -1; for ( final long count : histogram ) { if ( count != previousCount ) { values.add( count ); previousCount = count; } } // should get only two values assertEquals( 2, values.size() ); // values should be off by one final long v1 = values.get( 0 ); final long v2 = values.get( 1 ); assertEquals( v1 + 1, v2 ); } /** * Tests generating next doubles. * * @param value * @param number */ private void testNextDouble( final double value, final int number ) { final double[] values = new double[ number ]; // generate 'number' adjacent double values int i = 0; values[ i ] = value; do { final double prev = values[ i++ ]; final double next = DoubleUtil.nextDouble( prev, true ); values[ i ] = next; } while ( i < number - 1 ); // go down the list backwards do { final double next = values[ i-- ]; final double prev = DoubleUtil.nextDouble( next, false ); assertEquals( values[ i ], prev, prev / EPSILON_FACTOR ); } while ( i > 0 ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/DoubleUtil.java000066400000000000000000000142631316447754700241350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; /** * Utility class for dealing with doubles. * * @author Aivar Grislis */ public class DoubleUtil { private static final double ZERO = 0x0.0p0; private static final double SMALLEST_POSITIVE = 0x0.0000000000001P-1022; private static final double SMALLEST_NEGATIVE = -0x0.0000000000001P-1022; private static final int MAX_PLACES = 13; private static final String MAX_DIGITS = "fffffffffffff"; private static final String MIN_DIGITS = "0000000000000"; private static final int LAST_HEX_DIGIT_INDEX = 12; /** * Given a double value returns the next representable double. */ public static double nextDouble( final double value, final boolean inc ) { double nextValue; // hardcode values around zero if ( ZERO == value ) { if ( inc ) { nextValue = SMALLEST_POSITIVE; } else { nextValue = SMALLEST_NEGATIVE; } } else if ( SMALLEST_NEGATIVE == value && inc ) { nextValue = ZERO; } else if ( SMALLEST_POSITIVE == value && !inc ) { nextValue = ZERO; } else { // increment/decrement hex string value String hexString; final boolean actualInc = ( ( value > 0 && inc ) || ( value < 0 && !inc ) ); hexString = nextDoubleHexString( Double.toHexString( value ), actualInc ); // convert hex string value to double try { nextValue = Double.parseDouble( hexString ); } catch ( final Exception e ) { System.out.println( "Error parsing " + hexString ); nextValue = 0.0; } } return nextValue; } /** * Parses double as hex string and generates next double hex string. */ private static String nextDoubleHexString( String hex, final boolean inc ) { // save & restore negative sign boolean negative = false; if ( '-' == hex.charAt( 0 ) ) { negative = true; hex = hex.substring( 1 ); } // get leading digit, 0 or 1 int leadingDigit = 0; try { leadingDigit = Integer.parseInt( hex.substring( 2, 3 ) ); } catch ( final Exception e ) { System.out.println( "Error parsing " + hex.substring( 2, 3 ) + " " + e ); } // get fractional value in hexadecimal final int pIndex = hex.indexOf( 'p' ); String hexDigits = hex.substring( 4, pIndex ); hexDigits = padWithZeros( hexDigits ); // get exponent int power = 0; try { power = Integer.parseInt( hex.substring( pIndex + 1 ) ); } catch ( final Exception e ) { System.out.println( "Error parsing " + hex.substring( pIndex + 1 ) + " " + e ); } if ( inc ) { // increment hexadecimal numeric value if ( MAX_DIGITS.equals( hexDigits ) ) { if ( 1 == leadingDigit ) { // next after 0x1.fffffffffffffp1 is 0x1.0p2 ++power; } else { // next after 0x0.fffffffffffffp-1022 is 0x1.0p-1022 ++leadingDigit; } hexDigits = MIN_DIGITS; } else { final char[] hexChars = hexDigits.toCharArray(); int i = LAST_HEX_DIGIT_INDEX; boolean carry; do { ++hexChars[ i ]; if ( hexChars[ i ] == 'f' + 1 ) { hexChars[ i ] = '0'; // carry to preceding digit carry = true; --i; } else { // no carry carry = false; // patch hexadecimal if ( hexChars[ i ] == '9' + 1 ) { hexChars[ i ] = 'a'; } } } while ( i >= 0 && carry ); hexDigits = new String( hexChars ); } } else { // decrement hexadecimal numeric value if ( MIN_DIGITS.equals( hexDigits ) ) { // previous before 0x1.0000000000000p1 is 0x1.fffffffffffffp0 --power; hexDigits = MAX_DIGITS; } else { final char[] hexChars = hexDigits.toCharArray(); int i = LAST_HEX_DIGIT_INDEX; boolean borrow; do { --hexChars[ i ]; if ( hexChars[ i ] == '0' - 1 ) { hexChars[ i ] = 'f'; // borrow from preceding digit borrow = true; --i; } else { // no borrow borrow = false; // patch hexadecimal if ( hexChars[ i ] == 'a' - 1 ) { hexChars[ i ] = '9'; } } } while ( i >= 0 && borrow ); hexDigits = new String( hexChars ); } } return ( negative ? "-" : "" ) + "0x" + leadingDigit + "." + hexDigits + "p" + power; } /** * Cheap way to pad with zeros. */ private static String padWithZeros( String hexDigits ) { while ( hexDigits.length() < MAX_PLACES ) { hexDigits += "0"; } return hexDigits; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/PointTest.java000066400000000000000000000244161316447754700240170ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import static org.junit.Assert.assertEquals; import org.junit.Test; /** * TODO * */ public class PointTest { @Test public void testPointInt() { final Point p = new Point( 3 ); assertEquals( p.numDimensions(), 3 ); } @Test public void testPointLongArray() { final Point p = new Point( new long[] { 5, 3 } ); assertEquals( p.numDimensions(), 2 ); assertEquals( p.getLongPosition( 0 ), 5 ); assertEquals( p.getLongPosition( 1 ), 3 ); } @Test public void testPointIntArray() { final Point p = new Point( new int[] { 5, 3 } ); assertEquals( p.numDimensions(), 2 ); assertEquals( p.getLongPosition( 0 ), 5 ); assertEquals( p.getLongPosition( 1 ), 3 ); } @Test public void testPointLocalizable() { final Point p = new Point( new Point( new int[] { 15, 2, 1 } ) ); assertEquals( p.numDimensions(), 3 ); assertEquals( p.getLongPosition( 0 ), 15 ); assertEquals( p.getLongPosition( 1 ), 2 ); assertEquals( p.getLongPosition( 2 ), 1 ); } @Test public void testLocalizeFloatArray() { final long[] initial = new long[] { 532, 632, 987421 }; final float[] result = new float[ 3 ]; final Point p = new Point( initial ); p.localize( result ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( initial[ i ], result[ i ], 0 ); } } @Test public void testLocalizeDoubleArray() { final long[] initial = new long[] { 532, 632, 987421 }; final double[] result = new double[ 3 ]; final Point p = new Point( initial ); p.localize( result ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( initial[ i ], result[ i ], 0 ); } } @Test public void testGetFloatPosition() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( initial[ i ], p.getFloatPosition( i ), 0 ); } } @Test public void testGetDoublePosition() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( initial[ i ], p.getDoublePosition( i ), 0 ); } } @Test public void testNumDimensions() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); assertEquals( p.numDimensions(), 3 ); } @Test public void testFwd() { final long[] initial = new long[] { 532, 632, 987421 }; for ( int j = 0; j < initial.length; j++ ) { final Point p = new Point( initial ); p.fwd( j ); for ( int i = 0; i < initial.length; i++ ) { if ( i == j ) { assertEquals( p.getLongPosition( i ), initial[ i ] + 1 ); } else { assertEquals( initial[ i ], p.getLongPosition( i ), 0 ); } } } } @Test public void testBck() { final long[] initial = new long[] { 532, 632, 987421 }; for ( int j = 0; j < initial.length; j++ ) { final Point p = new Point( initial ); p.bck( j ); for ( int i = 0; i < initial.length; i++ ) { if ( i == j ) { assertEquals( p.getLongPosition( i ), initial[ i ] - 1 ); } else { assertEquals( initial[ i ], p.getLongPosition( i ), 0 ); } } } } @Test public void testMoveIntInt() { final long[] initial = new long[] { 532, 632, 987421 }; final int[] displacement = new int[] { 85, 8643, -973 }; for ( int j = 0; j < initial.length; j++ ) { final Point p = new Point( initial ); p.move( displacement[ j ], j ); for ( int i = 0; i < initial.length; i++ ) { if ( i == j ) { assertEquals( p.getLongPosition( i ), initial[ i ] + displacement[ i ] ); } else { assertEquals( initial[ i ], p.getLongPosition( i ), 0 ); } } } } @Test public void testMoveLongInt() { final long[] initial = new long[] { 532, 632, 987421 }; final long[] displacement = new long[] { 85, 8643, -973 }; for ( int j = 0; j < initial.length; j++ ) { final Point p = new Point( initial ); p.move( displacement[ j ], j ); for ( int i = 0; i < initial.length; i++ ) { if ( i == j ) { assertEquals( p.getLongPosition( i ), initial[ i ] + displacement[ i ] ); } else { assertEquals( initial[ i ], p.getLongPosition( i ), 0 ); } } } } @Test public void testMoveLocalizable() { final long[] initial = new long[] { 532, 632, 987421 }; final long[] displacement = new long[] { 85, 8643, -973 }; final Point p = new Point( initial ); final Point d = new Point( displacement ); p.move( d ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), initial[ i ] + displacement[ i ] ); } } @Test public void testMoveIntArray() { final long[] initial = new long[] { 532, 632, 987421 }; final int[] displacement = new int[] { 85, 8643, -973 }; final Point p = new Point( initial ); p.move( displacement ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), initial[ i ] + displacement[ i ] ); } } @Test public void testMoveLongArray() { final long[] initial = new long[] { 532, 632, 987421 }; final long[] displacement = new long[] { 85, 8643, -973 }; final Point p = new Point( initial ); p.move( displacement ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), initial[ i ] + displacement[ i ] ); } } @Test public void testSetPositionLocalizable() { final long[] initial = new long[] { 532, 632, 987421 }; final long[] displacement = new long[] { 85, 8643, -973 }; final Point p = new Point( initial ); final Point d = new Point( displacement ); p.setPosition( d ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), displacement[ i ] ); } } @Test public void testSetPositionIntArray() { final long[] initial = new long[] { 532, 632, 987421 }; final int[] displacement = new int[] { 85, 8643, -973 }; final Point p = new Point( initial ); p.setPosition( displacement ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), displacement[ i ] ); } } @Test public void testSetPositionLongArray() { final long[] initial = new long[] { 532, 632, 987421 }; final long[] displacement = new long[] { 85, 8643, -973 }; final Point p = new Point( initial ); p.setPosition( displacement ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), displacement[ i ] ); } } @Test public void testSetPositionIntInt() { final long[] initial = new long[] { 532, 632, 987421 }; final int[] displacement = new int[] { 85, 8643, -973 }; for ( int j = 0; j < initial.length; j++ ) { final Point p = new Point( initial ); p.setPosition( displacement[ j ], j ); for ( int i = 0; i < initial.length; i++ ) { if ( i == j ) { assertEquals( p.getLongPosition( i ), displacement[ i ] ); } else { assertEquals( initial[ i ], p.getLongPosition( i ) ); } } } } @Test public void testSetPositionLongInt() { final long[] initial = new long[] { 532, 632, 987421 }; final long[] displacement = new long[] { 85, 8643, -973 }; for ( int j = 0; j < initial.length; j++ ) { final Point p = new Point( initial ); p.setPosition( displacement[ j ], j ); for ( int i = 0; i < initial.length; i++ ) { if ( i == j ) { assertEquals( p.getLongPosition( i ), displacement[ i ] ); } else { assertEquals( initial[ i ], p.getLongPosition( i ) ); } } } } @Test public void testLocalizeIntArray() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); final int[] result = new int[ 3 ]; p.localize( result ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), initial[ i ] ); } } @Test public void testLocalizeLongArray() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); final long[] result = new long[ 3 ]; p.localize( result ); for ( int i = 0; i < initial.length; i++ ) { assertEquals( p.getLongPosition( i ), initial[ i ] ); } } @Test public void testGetIntPosition() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); assertEquals( p.getIntPosition( 1 ), initial[ 1 ] ); } @Test public void testGetLongPosition() { final long[] initial = new long[] { 532, 632, 987421 }; final Point p = new Point( initial ); assertEquals( p.getLongPosition( 1 ), initial[ 1 ] ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/RealPointSampleListTest.java000066400000000000000000000112611316447754700266130ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Iterator; import java.util.Random; import net.imglib2.RealCursor; import net.imglib2.RealLocalizable; import net.imglib2.RealPoint; import net.imglib2.RealPointSampleList; import net.imglib2.type.numeric.real.DoubleType; import org.junit.Before; import org.junit.Test; /** * TODO * */ public class RealPointSampleListTest { final static private int n = 10; final static private int m = 10000; final static private Random rnd = new Random( 123456 ); final static private RealPointSampleList< DoubleType > realPointSampleList = new RealPointSampleList< DoubleType >( n ); final static private ArrayList< RealPoint > realPointList = new ArrayList< RealPoint >(); final static private ArrayList< DoubleType > sampleList = new ArrayList< DoubleType >(); final static private boolean positionEquals( final RealLocalizable a, final RealLocalizable b ) { final int na = a.numDimensions(); if ( na != b.numDimensions() ) return false; for ( int d = 0; d < na; ++d ) { if ( a.getDoublePosition( d ) != b.getDoublePosition( d ) ) return false; } return true; } @Before public void init() { for ( int i = 0; i < m; ++i ) { final double[] position = new double[ n ]; for ( int d = 0; d < n; ++d ) position[ d ] = rnd.nextDouble(); final RealPoint realPoint = new RealPoint( position ); final DoubleType sample = new DoubleType( rnd.nextDouble() ); realPointList.add( realPoint ); sampleList.add( sample ); realPointSampleList.add( realPoint, sample ); } } @Test public void testIteration() { final Iterator< DoubleType > sampleIterator = sampleList.iterator(); for ( final DoubleType t : realPointSampleList ) assertTrue( "Samples differ ", t == sampleIterator.next() ); } @Test public void testPosition() { final Iterator< RealPoint > realPointIterator = realPointList.iterator(); final RealCursor< DoubleType > realPointSampleCursor = realPointSampleList.cursor(); while ( realPointSampleCursor.hasNext() ) { realPointSampleCursor.fwd(); assertTrue( "Positions differ ", positionEquals( realPointIterator.next(), realPointSampleCursor ) ); } } @Test public void testCopy() { final ArrayList< RealCursor< DoubleType > > copies = new ArrayList< RealCursor< DoubleType > >(); final RealCursor< DoubleType > cursor = realPointSampleList.cursor(); while ( cursor.hasNext() ) { cursor.fwd(); copies.add( cursor.copyCursor() ); } cursor.reset(); final Iterator< RealCursor< DoubleType > > copyIterator = copies.iterator(); while ( cursor.hasNext() ) { cursor.fwd(); final RealCursor< DoubleType > copy = copyIterator.next(); assertTrue( "Copy failed at sample ", copy.get() == cursor.get() ); assertTrue( "Copy failed at position ", positionEquals( copy, cursor ) ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/RealPointTest.java000066400000000000000000000362411316447754700246220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import static org.junit.Assert.assertEquals; import org.junit.Test; /** * * @author Lee Kamentsky */ public class RealPointTest { /** * Test method for {@link net.imglib2.RealPoint#RealPoint(int)}. */ @Test public void testRealPointInt() { final RealPoint p = new RealPoint( 3 ); assertEquals( p.numDimensions(), 3 ); for ( int i = 0; i < 3; i++ ) { assertEquals( p.getDoublePosition( i ), 0, 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#RealPoint(double[])}. */ @Test public void testRealPointDoubleArray() { final double[] expected = new double[] { 1.5, 2.5, 4.5, 6.5 }; final RealPoint p = new RealPoint( expected ); assertEquals( p.numDimensions(), 4 ); for ( int i = 0; i < 4; i++ ) { assertEquals( p.getDoublePosition( i ), expected[ i ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#RealPoint(float[])}. */ @Test public void testRealPointFloatArray() { final float[] expected = new float[] { 1.5f, 2.5f, 4.5f, 6.5f }; final RealPoint p = new RealPoint( expected ); assertEquals( p.numDimensions(), 4 ); for ( int i = 0; i < 4; i++ ) { assertEquals( p.getFloatPosition( i ), expected[ i ], 0 ); } } @Test public void testRealPointRealLocalizable() { final RealPoint p = new RealPoint( new RealPoint( new double[] { 15.3, 2.1, 1.2 } ) ); assertEquals( p.numDimensions(), 3 ); assertEquals( p.getDoublePosition( 0 ), 15.3, 0 ); assertEquals( p.getDoublePosition( 1 ), 2.1, 0 ); assertEquals( p.getDoublePosition( 2 ), 1.2, 0 ); } /** * Test method for {@link net.imglib2.RealPoint#fwd(int)}. */ @Test public void testFwd() { for ( int i = 0; i < 3; i++ ) { final double[] expected = new double[] { 1.5, 2.5, 4.5, 6.5 }; final RealPoint p = new RealPoint( expected ); p.fwd( i ); expected[ i ] += 1; for ( int j = 0; j < 4; j++ ) { assertEquals( p.getDoublePosition( j ), expected[ j ], 0 ); } } } /** * Test method for {@link net.imglib2.RealPoint#bck(int)}. */ @Test public void testBck() { for ( int i = 0; i < 3; i++ ) { final double[] expected = new double[] { 1.5, 2.5, 4.5, 6.5 }; final RealPoint p = new RealPoint( expected ); p.bck( i ); expected[ i ] -= 1; for ( int j = 0; j < 4; j++ ) { assertEquals( p.getDoublePosition( j ), expected[ j ], 0 ); } } } /** * Test method for {@link net.imglib2.RealPoint#move(int, int)}. */ @Test public void testMoveIntInt() { final int[] move = { 1, 5, -3, 16 }; for ( int i = 0; i < move.length; i++ ) { final double[] expected = new double[] { 1.5, 2.5, 4.5, 6.5 }; final RealPoint p = new RealPoint( expected ); p.move( move[ i ], i ); expected[ i ] += move[ i ]; for ( int j = 0; j < 4; j++ ) { assertEquals( p.getDoublePosition( j ), expected[ j ], 0 ); } } } /** * Test method for {@link net.imglib2.RealPoint#move(long, int)}. */ @Test public void testMoveLongInt() { final long[] move = { 1, 5, -3, 16 }; for ( int i = 0; i < move.length; i++ ) { final double[] expected = new double[] { 1.5, 2.5, 4.5, 6.5 }; final RealPoint p = new RealPoint( expected ); p.move( move[ i ], i ); expected[ i ] += move[ i ]; for ( int j = 0; j < 4; j++ ) { assertEquals( p.getDoublePosition( j ), expected[ j ], 0 ); } } } /** * Test method for * {@link net.imglib2.RealPoint#move(net.imglib2.Localizable)}. */ @Test public void testMoveLocalizable() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] displacement = { 98.2, -16, 44.2, 0 }; final RealPoint p1 = new RealPoint( initial ); final RealPoint p2 = new RealPoint( displacement ); p1.move( p2 ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ] + displacement[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#move(int[])}. */ @Test public void testMoveIntArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final int[] displacement = { 98, -16, 44, 0 }; final RealPoint p1 = new RealPoint( initial ); p1.move( displacement ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ] + displacement[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#move(long[])}. */ @Test public void testMoveLongArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final long[] displacement = { 98, -16, 44, 0 }; final RealPoint p1 = new RealPoint( initial ); p1.move( displacement ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ] + displacement[ j ], 0 ); } } /** * Test method for * {@link net.imglib2.RealPoint#setPosition(net.imglib2.Localizable)}. */ @Test public void testSetPositionLocalizable() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final long[] fynal = { 98, -16, 44, 0 }; final RealPoint p1 = new RealPoint( initial ); final Point p2 = new Point( fynal ); p1.setPosition( p2 ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(int[])}. */ @Test public void testSetPositionIntArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final int[] fynal = { 98, -16, 44, 0 }; final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(long[])}. */ @Test public void testSetPositionLongArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final long[] fynal = { 98, -16, 44, 0 }; final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(int, int)}. */ @Test public void testSetPositionIntInt() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final int[] fynal = { 98, -16, 44, 0 }; for ( int i = 0; i < initial.length; i++ ) { final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal[ i ], i ); assertEquals( p1.getDoublePosition( i ), fynal[ i ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(long, int)}. */ @Test public void testSetPositionLongInt() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final long[] fynal = { 98, -16, 44, 0 }; for ( int i = 0; i < initial.length; i++ ) { final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal[ i ], i ); assertEquals( p1.getDoublePosition( i ), fynal[ i ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#numDimensions()}. */ @Test public void testNumDimensions() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final RealPoint p1 = new RealPoint( initial ); assertEquals( 4, p1.numDimensions() ); } /** * Test method for {@link net.imglib2.RealPoint#move(float, int)}. */ @Test public void testMoveFloatInt() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final float[] displacement = { 4.2f, 77.1f, -2f, 51.4f }; for ( int i = 0; i < initial.length; i++ ) { final RealPoint p1 = new RealPoint( initial ); p1.move( displacement[ i ], i ); for ( int j = 0; j < 4; j++ ) { double expected = initial[ j ]; if ( i == j ) expected += displacement[ j ]; assertEquals( p1.getDoublePosition( j ), expected, 0 ); } } } /** * Test method for {@link net.imglib2.RealPoint#move(double, int)}. */ @Test public void testMoveDoubleInt() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] displacement = { 4.2, 77.1, -2, 51.4 }; for ( int i = 0; i < initial.length; i++ ) { final RealPoint p1 = new RealPoint( initial ); p1.move( displacement[ i ], i ); for ( int j = 0; j < 4; j++ ) { double expected = initial[ j ]; if ( i == j ) expected += displacement[ j ]; assertEquals( p1.getDoublePosition( j ), expected, 0 ); } } } /** * Test method for * {@link net.imglib2.RealPoint#move(net.imglib2.RealLocalizable)}. */ @Test public void testMoveRealLocalizable() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] displacement = { 4.2, 77.1, -2, 51.4 }; final RealPoint p1 = new RealPoint( initial ); final RealPoint p2 = new RealPoint( displacement ); p1.move( p2 ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ] + displacement[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#move(float[])}. */ @Test public void testMoveFloatArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final float[] displacement = { 4.2f, 77.1f, -2f, 51.4f }; final RealPoint p1 = new RealPoint( initial ); p1.move( displacement ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ] + displacement[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#move(double[])}. */ @Test public void testMoveDoubleArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] displacement = { 4.2, 77.1, -2, 51.4 }; final RealPoint p1 = new RealPoint( initial ); p1.move( displacement ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ] + displacement[ j ], 0 ); } } /** * Test method for * {@link net.imglib2.RealPoint#setPosition(net.imglib2.RealLocalizable)}. */ @Test public void testSetPositionRealLocalizable() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] fynal = { 98.2, -16.1, 44.7, 0 }; final RealPoint p1 = new RealPoint( initial ); final RealPoint p2 = new RealPoint( fynal ); p1.setPosition( p2 ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(float[])}. */ @Test public void testSetPositionFloatArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final float[] fynal = { 98.2f, -16.1f, 44.7f, 0f }; final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(double[])}. */ @Test public void testSetPositionDoubleArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] fynal = { 98.2, -16.1, 44.7, 0 }; final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(float, int)}. */ @Test public void testSetPositionFloatInt() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final float[] fynal = { 98.2f, -16.1f, 44.7f, 0f }; for ( int i = 0; i < initial.length; i++ ) { final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal[ i ], i ); for ( int j = 0; j < 4; j++ ) { if ( i == j ) assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); else assertEquals( p1.getDoublePosition( j ), initial[ j ], 0 ); } } } /** * Test method for {@link net.imglib2.RealPoint#setPosition(double, int)}. */ @Test public void testSetPositionDoubleInt() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] fynal = { 98.2, -16.1, 44.7, 0 }; for ( int i = 0; i < initial.length; i++ ) { final RealPoint p1 = new RealPoint( initial ); p1.setPosition( fynal[ i ], i ); for ( int j = 0; j < 4; j++ ) { if ( i == j ) assertEquals( p1.getDoublePosition( j ), fynal[ j ], 0 ); else assertEquals( p1.getDoublePosition( j ), initial[ j ], 0 ); } } } /** * Test method for {@link net.imglib2.RealPoint#localize(float[])}. */ @Test public void testLocalizeFloatArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final float[] result = new float[ initial.length ]; final RealPoint p1 = new RealPoint( initial ); p1.localize( result ); for ( int j = 0; j < 4; j++ ) { assertEquals( result[ j ], ( float ) ( initial[ j ] ), 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#localize(double[])}. */ @Test public void testLocalizeDoubleArray() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final double[] result = new double[ initial.length ]; final RealPoint p1 = new RealPoint( initial ); p1.localize( result ); for ( int j = 0; j < 4; j++ ) { assertEquals( result[ j ], initial[ j ], 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#getFloatPosition(int)}. */ @Test public void testGetFloatPosition() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final RealPoint p1 = new RealPoint( initial ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getFloatPosition( j ), ( float ) ( initial[ j ] ), 0 ); } } /** * Test method for {@link net.imglib2.RealPoint#getDoublePosition(int)}. */ @Test public void testGetDoublePosition() { final double[] initial = { 5.3, 2.6, 3.1, -852.1 }; final RealPoint p1 = new RealPoint( initial ); for ( int j = 0; j < 4; j++ ) { assertEquals( p1.getDoublePosition( j ), initial[ j ], 0 ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/TestAbstractRealLocalizable.java000066400000000000000000000101331316447754700274260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2; import static org.junit.Assert.assertEquals; import org.junit.Test; /** * * @author Lee Kamentsky */ public class TestAbstractRealLocalizable { static private class AbstractRealLocalizableImpl extends AbstractRealLocalizable { public AbstractRealLocalizableImpl( final int nDimensions ) { super( nDimensions ); } double getPosition( final int d ) { return position[ d ]; } } /** * Test method for * {@link net.imglib2.AbstractRealLocalizable#AbstractRealLocalizableSampler(int)} * . */ @Test public void testAbstractRealLocalizableSampler() { final AbstractRealLocalizableImpl x = new AbstractRealLocalizableImpl( 2 ); assertEquals( x.numDimensions(), 2 ); for ( int i = 0; i < 2; i++ ) { assertEquals( x.getPosition( i ), 0, 0 ); } } /** * Test method for * {@link net.imglib2.AbstractRealLocalizable#localize(float[])}. */ @Test public void testLocalizeFloatArray() { final AbstractRealLocalizableImpl x = new AbstractRealLocalizableImpl( 2 ); final float[] p = { 1.1F, 2.2F }; x.localize( p ); for ( int i = 0; i < 2; i++ ) { assertEquals( ( float ) ( x.getPosition( i ) ), p[ i ], 0 ); } } /** * Test method for * {@link net.imglib2.AbstractRealLocalizable#localize(double[])}. */ @Test public void testLocalizeDoubleArray() { final AbstractRealLocalizableImpl x = new AbstractRealLocalizableImpl( 2 ); final double[] p = { 1.1, 2.2 }; x.localize( p ); for ( int i = 0; i < 2; i++ ) { assertEquals( x.getPosition( i ), p[ i ], 0 ); } } /** * Test method for * {@link net.imglib2.AbstractRealLocalizable#getFloatPosition(int)}. */ @Test public void testGetFloatPosition() { final AbstractRealLocalizableImpl x = new AbstractRealLocalizableImpl( 2 ); final float[] p = { 1.1F, 2.2F }; x.localize( p ); for ( int i = 0; i < 2; i++ ) { assertEquals( x.getFloatPosition( i ), p[ i ], 0 ); } } /** * Test method for * {@link net.imglib2.AbstractRealLocalizable#getDoublePosition(int)}. */ @Test public void testGetDoublePosition() { final AbstractRealLocalizableImpl x = new AbstractRealLocalizableImpl( 2 ); final double[] p = { 1.1, 2.2 }; x.localize( p ); for ( int i = 0; i < 2; i++ ) { assertEquals( x.getDoublePosition( i ), p[ i ], 0 ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/converter/000077500000000000000000000000001316447754700232235ustar00rootroot00000000000000AbstractConvertedRandomAccessibleIntervalTest.java000066400000000000000000000073721316447754700351210ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/converter/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import java.util.Random; import org.junit.Assert; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.util.Pair; import net.imglib2.view.Views; /** * * @author Philipp Hanslovsky * */ public class AbstractConvertedRandomAccessibleIntervalTest { Random rng = new Random(); static final ArrayImg< DoubleType, DoubleArray > data = ArrayImgs.doubles( 10, 20, 30 ); { for ( final DoubleType d : data ) d.set( rng.nextDouble() ); } @Test public void test() { final AbstractConvertedRandomAccessibleInterval< DoubleType, DoubleType > converted = new AbstractConvertedRandomAccessibleInterval< DoubleType, DoubleType >( data ) { @Override public AbstractConvertedRandomAccess< DoubleType, DoubleType > randomAccess() { return new AbstractConvertedRandomAccess< DoubleType, DoubleType >( data.randomAccess() ) { DoubleType t = new DoubleType(); @Override public DoubleType get() { t.set( this.source.get() ); t.mul( this.source.getDoublePosition( this.source.numDimensions() - 1 ) ); return t; } @Override public AbstractConvertedRandomAccess< DoubleType, DoubleType > copy() { return null; } }; } @Override public AbstractConvertedRandomAccess< DoubleType, DoubleType > randomAccess( final Interval interval ) { return randomAccess(); } }; for ( final Cursor< Pair< DoubleType, DoubleType > > c = Views.interval( Views.pair( data, converted ), data ).cursor(); c.hasNext(); ) { final Pair< DoubleType, DoubleType > p = c.next(); final double pos = c.getDoublePosition( c.numDimensions() - 1 ); Assert.assertEquals( pos * p.getA().get(), p.getB().get(), 0.0 ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/converter/ConvertersTest.java000066400000000000000000000115601316447754700270630ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.converter; import java.util.Random; import org.junit.Assert; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.view.Views; /** * * * @author Stephan Saalfeld */ public class ConvertersTest { final Random rnd = new Random(); final static byte[] testValues = new byte[ 20 * 30 * 4 ]; { rnd.nextBytes( testValues ); } final static int[] data = new int[ 20 * 30 ]; { for ( int i = 0; i < data.length; ++i ) data[ i ] = rnd.nextInt(); } @Test public void testArgbChannels() { final ArrayImg< ARGBType, ? > test = ArrayImgs.argbs( data, 20, 30 ); final ArrayImg< ARGBType, ? > source = ArrayImgs.argbs( data.clone(), 20, 30 ); final RandomAccessibleInterval< UnsignedByteType > composite = Converters.argbChannels( source ); final Cursor< UnsignedByteType > compositeCursorA = Views.flatIterable( Views.hyperSlice( composite, 2, 0 ) ).cursor(); final Cursor< UnsignedByteType > compositeCursorR = Views.flatIterable( Views.hyperSlice( composite, 2, 1 ) ).cursor(); final Cursor< UnsignedByteType > compositeCursorG = Views.flatIterable( Views.hyperSlice( composite, 2, 2 ) ).cursor(); final Cursor< UnsignedByteType > compositeCursorB = Views.flatIterable( Views.hyperSlice( composite, 2, 3 ) ).cursor(); final Cursor< ARGBType > testCursor = test.cursor(); final Cursor< ARGBType > sourceCursor = source.cursor(); int i = 0; while ( compositeCursorA.hasNext() ) { final ARGBType argbSource = sourceCursor.next(); final ARGBType argbTest = testCursor.next(); final UnsignedByteType a = compositeCursorA.next(); final UnsignedByteType r = compositeCursorR.next(); final UnsignedByteType g = compositeCursorG.next(); final UnsignedByteType b = compositeCursorB.next(); /* read */ Assert.assertTrue( argbSource.valueEquals( argbTest ) ); Assert.assertEquals( ARGBType.alpha( argbTest.get() ), a.get() ); Assert.assertEquals( ARGBType.red( argbTest.get() ), r.get() ); Assert.assertEquals( ARGBType.green( argbTest.get() ), g.get() ); Assert.assertEquals( ARGBType.blue( argbTest.get() ), b.get() ); /* write */ a.set( testValues[ i ] & 0xff ); Assert.assertEquals( ARGBType.alpha( argbSource.get() ), testValues[ i ] & 0xff ); Assert.assertEquals( a.get(), testValues[ i ] & 0xff ); ++i; r.set( testValues[ i ] & 0xff ); Assert.assertEquals( ARGBType.red( argbSource.get() ), testValues[ i ] & 0xff ); Assert.assertEquals( r.get(), testValues[ i ] & 0xff ); ++i; g.set( testValues[ i ] & 0xff ); Assert.assertEquals( ARGBType.green( argbSource.get() ), testValues[ i ] & 0xff ); Assert.assertEquals( g.get(), testValues[ i ] & 0xff ); ++i; b.set( testValues[ i ] & 0xff ); Assert.assertEquals( ARGBType.blue( argbSource.get() ), testValues[ i ] & 0xff ); Assert.assertEquals( b.get(), testValues[ i ] & 0xff ); ++i; } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/display/000077500000000000000000000000001316447754700226615ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/display/ARGBScreenImageExpectationChecking.java000066400000000000000000000174531316447754700322140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.display; import static org.junit.Assert.assertTrue; import java.awt.AWTException; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; import java.awt.image.PixelGrabber; import java.lang.reflect.InvocationTargetException; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import net.imglib2.display.screenimage.awt.ARGBScreenImage; import org.junit.Test; public class ARGBScreenImageExpectationChecking { static public final void main( final String[] args ) { System.out.println( "Painting on java.awt.Graphics alters original array: " + new ARGBScreenImageExpectationChecking().testFill2() ); System.out.println( "After painting, the image shows a yellow pixel at 0,0: " + new ARGBScreenImageExpectationChecking().testFillAndGrabPixel2() ); try { System.out.println( "After painting onto JPanel and capturing, the imageshows a red pixel at 100,100: " + new ARGBScreenImageExpectationChecking().testFillAndPaintPanelAndGrab2() ); } catch ( final Exception e ) { e.printStackTrace(); } } @Test public void testFill() { assertTrue( "Painting on java.awt.Graphics does not alter original array", testFill2() ); } private boolean testFill2() { // Define an image final int width = 256; final int height = 256; final int[] pixels = new int[ width * height ]; final ARGBScreenImage simg = new ARGBScreenImage( width, height, pixels ); // Paint a yellow rectangle final Graphics g = simg.image().getGraphics(); g.setColor( Color.yellow ); g.fillRect( 0, 0, 100, 100 ); g.dispose(); // Test whether the original array has changed return 0 != pixels[ 0 ]; } private int getPixel( final Image img, final int x, final int y ) { final int[] pix = new int[ 1 ]; final PixelGrabber pg = new PixelGrabber( img, x, y, 1, 1, pix, 0, 1 ); try { pg.grabPixels(); } catch ( final InterruptedException e ) { e.printStackTrace(); } return pix[ 0 ]; } @Test public void testFillAndGrabPixel() { assertTrue( "After painting, the image does not show a yellow pixel at 0,0", testFillAndGrabPixel2() ); } public boolean testFillAndGrabPixel2() { // Define an image final int width = 256; final int height = 256; final int[] pixels = new int[ width * height ]; final ARGBScreenImage simg = new ARGBScreenImage( width, height, pixels ); // Paint a yellow rectangle final Graphics g = simg.image().getGraphics(); g.setColor( Color.yellow ); g.fillRect( 0, 0, 100, 100 ); g.dispose(); // Paint the image, now that it has been altered, onto another image final BufferedImage bi = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB ); final Graphics2D g2 = bi.createGraphics(); g2.drawImage( simg.image(), 0, 0, null ); g2.dispose(); // Test if the first pixel, as seen from the image, is yellow return 0x00ffff00 == ( getPixel( bi, 0, 0 ) & 0x00ffffff ); } @Test public void testFillAndPaintPanelAndGrab() throws InterruptedException, InvocationTargetException { assertTrue( "After painting onto JPanel and capturing, the image does not show a red pixel at 100,100", testFillAndPaintPanelAndGrab2() ); } public boolean testFillAndPaintPanelAndGrab2() throws InterruptedException, InvocationTargetException { // Define an image final int width = 256; final int height = 256; final int[] pixels = new int[ width * height ]; final ARGBScreenImage simg = new ARGBScreenImage( width, height, pixels ); // Paint a yellow rectangle final Graphics g = simg.image().getGraphics(); g.setColor( Color.yellow ); g.fillRect( 0, 0, 100, 100 ); g.dispose(); final BufferedImage[] capture = new BufferedImage[ 1 ]; final JFrame[] frame = new JFrame[ 2 ]; // Show the image in a JFrame SwingUtilities.invokeAndWait( new Runnable() { @Override public void run() { frame[ 0 ] = frame( simg.image(), "Test ARGBScreenImage" ); frame[ 0 ].setVisible( true ); } } ); // Wait for all sorts of asynchronous events Thread.sleep( 2000 ); SwingUtilities.invokeAndWait( new Runnable() { @Override public void run() { // Paint into the image again final Graphics g2 = simg.image().getGraphics(); g2.setColor( Color.red ); g2.fillRect( 100, 100, 100, 100 ); g2.dispose(); final JPanel panel = ( JPanel ) frame[ 0 ].getContentPane().getComponent( 0 ); panel.invalidate(); panel.validate(); panel.repaint(); } } ); // Wait for all sorts of asynchronous events Thread.sleep( 2000 ); // Capture the image with a Robot SwingUtilities.invokeAndWait( new Runnable() { @Override public void run() { final Point panelLocation = frame[ 0 ].getContentPane().getComponent( 0 ).getLocationOnScreen(); final Rectangle panelBounds = new Rectangle( panelLocation.x, panelLocation.y, width, height ); Robot robot; try { robot = new Robot(); capture[ 0 ] = robot.createScreenCapture( panelBounds ); frame[ 1 ] = frame( capture[ 0 ], "Robot capture" ); frame[ 1 ].setVisible( true ); } catch ( final AWTException e ) { e.printStackTrace(); } frame[ 0 ].dispose(); frame[ 1 ].dispose(); } } ); // Is red: return 0x00ff0000 == ( getPixel( capture[ 0 ], 100, 100 ) & 0x00ffffff ); } private JFrame frame( final Image img, final String title ) { final JPanel panel = new JPanel() { /** * */ private static final long serialVersionUID = -1605551958207115402L; @Override public void update( final Graphics g ) { this.paint( g ); } @Override public void paint( final Graphics g ) { g.drawImage( img, 0, 0, null ); } }; panel.setPreferredSize( new Dimension( img.getWidth( null ), img.getHeight( null ) ) ); final JFrame frame = new JFrame( title ); frame.getContentPane().add( panel ); frame.pack(); return frame; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/histogram/000077500000000000000000000000001316447754700232115ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/histogram/Histogram1dTest.java000066400000000000000000000114631316447754700271030ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; import net.imglib2.type.numeric.integer.UnsignedByteType; import org.junit.Test; /** * Test code for Histogram1d. * * @author Barry DeZonia */ public class Histogram1dTest { @Test public void test() { final List< UnsignedByteType > data = getData1(); BinMapper1d< UnsignedByteType > binMapper = new Integer1dBinMapper< UnsignedByteType >( 0, 256, false ); Histogram1d< UnsignedByteType > hist = new Histogram1d< UnsignedByteType >( data, binMapper ); assertEquals( 5, hist.firstDataValue().get() ); assertEquals( 256, hist.getBinCount() ); assertEquals( 11, hist.totalCount() ); assertEquals( 1, hist.frequency( new UnsignedByteType( 3 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 5 ) ) ); assertEquals( 1, hist.frequency( new UnsignedByteType( 7 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 9 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 10 ) ) ); assertEquals( 0, hist.lowerTailCount() ); assertEquals( 0, hist.upperTailCount() ); binMapper = new Integer1dBinMapper< UnsignedByteType >( 4, 8, true ); hist = new Histogram1d< UnsignedByteType >( data, binMapper ); assertEquals( 8, hist.getBinCount() ); assertEquals( 11, hist.distributionCount() ); assertEquals( 1, hist.frequency( new UnsignedByteType( 3 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 5 ) ) ); assertEquals( 1, hist.frequency( new UnsignedByteType( 7 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 9 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 10 ) ) ); assertEquals( 1, hist.lowerTailCount() ); assertEquals( 3, hist.upperTailCount() ); binMapper = new Integer1dBinMapper< UnsignedByteType >( 5, 5, false ); hist = new Histogram1d< UnsignedByteType >( data, binMapper ); assertEquals( 5, hist.getBinCount() ); assertEquals( 7, hist.distributionCount() ); assertEquals( 0, hist.frequency( new UnsignedByteType( 3 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 5 ) ) ); assertEquals( 1, hist.frequency( new UnsignedByteType( 7 ) ) ); assertEquals( 3, hist.frequency( new UnsignedByteType( 9 ) ) ); assertEquals( 0, hist.frequency( new UnsignedByteType( 10 ) ) ); assertEquals( 0, hist.lowerTailCount() ); assertEquals( 0, hist.upperTailCount() ); } private List< UnsignedByteType > getData1() { final List< UnsignedByteType > data = new ArrayList< UnsignedByteType >(); data.add( new UnsignedByteType( 5 ) ); data.add( new UnsignedByteType( 3 ) ); data.add( new UnsignedByteType( 5 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 10 ) ); data.add( new UnsignedByteType( 7 ) ); data.add( new UnsignedByteType( 10 ) ); data.add( new UnsignedByteType( 10 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 5 ) ); return data; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/histogram/HistogramNdTest.java000066400000000000000000000304301316447754700271330ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.imglib2.Cursor; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.UnsignedByteType; import org.junit.Test; /** * Test code for HistogramNd. * * @author Barry DeZonia */ public class HistogramNdTest { @Test public void testUnconstrainedNoTails() { final List< UnsignedByteType > data1 = getData1(); final List< UnsignedByteType > data2 = getData2(); final List< Iterable< UnsignedByteType >> data = new ArrayList< Iterable< UnsignedByteType >>(); data.add( data1 ); data.add( data2 ); final long[] minVals = new long[] { 0, 0 }; final long[] numBins = new long[] { 256, 256 }; final boolean[] tailBins = new boolean[] { false, false }; final HistogramNd< UnsignedByteType > hist = Integer1dBinMapper.histogramNd( minVals, numBins, tailBins ); hist.countData( data ); assertEquals( 256 * 256, hist.getBinCount() ); assertEquals( 11, hist.totalCount() ); assertEquals( 0, hist.lowerTailCount() ); assertEquals( 0, hist.lowerTailCount( 0 ) ); assertEquals( 0, hist.lowerTailCount( 1 ) ); assertEquals( 0, hist.upperTailCount() ); assertEquals( 0, hist.upperTailCount( 0 ) ); assertEquals( 0, hist.upperTailCount( 1 ) ); assertEquals( 0, hist.ignoredCount() ); final List< UnsignedByteType > list = new ArrayList< UnsignedByteType >(); list.add( null ); list.add( null ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 4 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 3 ) ); list.set( 1, new UnsignedByteType( 4 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 7 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 9 ) ); list.set( 1, new UnsignedByteType( 7 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 10 ) ); list.set( 1, new UnsignedByteType( 1 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 7 ) ); list.set( 1, new UnsignedByteType( 1 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 10 ) ); list.set( 1, new UnsignedByteType( 9 ) ); assertEquals( 2, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 9 ) ); list.set( 1, new UnsignedByteType( 12 ) ); assertEquals( 2, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 0 ) ); assertEquals( 1, hist.frequency( list ) ); } @Test public void testConstrainedWithTails() { final List< UnsignedByteType > data1 = getData1(); final List< UnsignedByteType > data2 = getData2(); final List< Iterable< UnsignedByteType >> data = new ArrayList< Iterable< UnsignedByteType >>(); data.add( data1 ); data.add( data2 ); final List< UnsignedByteType > list = new ArrayList< UnsignedByteType >(); list.add( null ); list.add( null ); final long[] minVals = new long[] { 4, 4 }; final long[] numBins = new long[] { 8, 8 }; final boolean[] tailBins = new boolean[] { true, true }; final HistogramNd< UnsignedByteType > hist = Integer1dBinMapper.histogramNd( minVals, numBins, tailBins ); hist.countData( data ); assertEquals( 8 * 8, hist.getBinCount() ); assertEquals( 11, hist.distributionCount() ); assertEquals( 4, hist.lowerTailCount() ); assertEquals( 1, hist.lowerTailCount( 0 ) ); assertEquals( 3, hist.lowerTailCount( 1 ) ); assertEquals( 5, hist.upperTailCount() ); assertEquals( 3, hist.upperTailCount( 0 ) ); assertEquals( 2, hist.upperTailCount( 1 ) ); assertEquals( 0, hist.ignoredCount() ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 4 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 3 ) ); list.set( 1, new UnsignedByteType( 4 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 7 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 9 ) ); list.set( 1, new UnsignedByteType( 7 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 10 ) ); list.set( 1, new UnsignedByteType( 1 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 7 ) ); list.set( 1, new UnsignedByteType( 1 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 10 ) ); list.set( 1, new UnsignedByteType( 9 ) ); assertEquals( 2, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 9 ) ); list.set( 1, new UnsignedByteType( 12 ) ); assertEquals( 2, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 0 ) ); assertEquals( 1, hist.frequency( list ) ); } @Test public void testConstrainedWithNoTails() { final List< UnsignedByteType > data1 = getData1(); final List< UnsignedByteType > data2 = getData2(); final List< Iterable< UnsignedByteType >> data = new ArrayList< Iterable< UnsignedByteType >>(); data.add( data1 ); data.add( data2 ); final List< UnsignedByteType > list = new ArrayList< UnsignedByteType >(); list.add( null ); list.add( null ); final long[] minVals = new long[] { 5, 5 }; final long[] numBins = new long[] { 5, 5 }; final boolean[] tailBins = new boolean[] { false, false }; final HistogramNd< UnsignedByteType > hist = Integer1dBinMapper.histogramNd( minVals, numBins, tailBins ); hist.countData( data ); assertEquals( 5 * 5, hist.getBinCount() ); assertEquals( 2, hist.distributionCount() ); assertEquals( 0, hist.lowerTailCount() ); assertEquals( 0, hist.lowerTailCount( 0 ) ); assertEquals( 0, hist.lowerTailCount( 1 ) ); assertEquals( 0, hist.upperTailCount() ); assertEquals( 0, hist.upperTailCount( 0 ) ); assertEquals( 0, hist.upperTailCount( 1 ) ); assertEquals( 9, hist.ignoredCount() ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 4 ) ); assertEquals( 0, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 3 ) ); list.set( 1, new UnsignedByteType( 4 ) ); assertEquals( 0, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 7 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 9 ) ); list.set( 1, new UnsignedByteType( 7 ) ); assertEquals( 1, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 10 ) ); list.set( 1, new UnsignedByteType( 1 ) ); assertEquals( 0, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 7 ) ); list.set( 1, new UnsignedByteType( 1 ) ); assertEquals( 0, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 10 ) ); list.set( 1, new UnsignedByteType( 9 ) ); assertEquals( 0, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 9 ) ); list.set( 1, new UnsignedByteType( 12 ) ); assertEquals( 0, hist.frequency( list ) ); list.set( 0, new UnsignedByteType( 5 ) ); list.set( 1, new UnsignedByteType( 0 ) ); assertEquals( 0, hist.frequency( list ) ); } @Test public void testRgbHist() { final ArrayImgFactory< ARGBType > factory = new ArrayImgFactory< ARGBType >(); final Img< ARGBType > img = factory.create( new long[] { 100, 200 }, new ARGBType() ); for ( final ARGBType v : img ) { v.set( ( int ) ( Math.random() * Integer.MAX_VALUE ) ); } final RgbIterator data = new RgbIterator( img ); final double[] minVals = new double[] { 0, 0, 0 }; final double[] maxVals = new double[] { 255, 255, 255 }; final long[] numBins = new long[] { 16, 16, 16 }; // 16^3 uses less mem // than 256^3 final boolean[] tailBins = new boolean[] { false, false, false }; final HistogramNd< IntType > hist = Real1dBinMapper.histogramNd( minVals, maxVals, numBins, tailBins ); hist.countData( data ); assertNotNull( hist ); assertEquals( 20000, hist.distributionCount() ); } private List< UnsignedByteType > getData1() { final List< UnsignedByteType > data = new ArrayList< UnsignedByteType >(); data.add( new UnsignedByteType( 5 ) ); data.add( new UnsignedByteType( 3 ) ); data.add( new UnsignedByteType( 5 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 10 ) ); data.add( new UnsignedByteType( 7 ) ); data.add( new UnsignedByteType( 10 ) ); data.add( new UnsignedByteType( 10 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 5 ) ); return data; } private List< UnsignedByteType > getData2() { final List< UnsignedByteType > data = new ArrayList< UnsignedByteType >(); data.add( new UnsignedByteType( 4 ) ); data.add( new UnsignedByteType( 4 ) ); data.add( new UnsignedByteType( 7 ) ); data.add( new UnsignedByteType( 7 ) ); data.add( new UnsignedByteType( 1 ) ); data.add( new UnsignedByteType( 1 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 9 ) ); data.add( new UnsignedByteType( 12 ) ); data.add( new UnsignedByteType( 12 ) ); data.add( new UnsignedByteType( 0 ) ); return data; } private class RgbIterator implements Iterable< List< IntType >> { private final Img< ARGBType > img; public RgbIterator( final Img< ARGBType > img ) { this.img = img; } @Override public Iterator< List< IntType >> iterator() { return new Iterator< List< IntType >>() { private Cursor< ARGBType > cursor; private List< IntType > tuple; @Override public boolean hasNext() { if ( cursor == null ) { cursor = img.cursor(); tuple = new ArrayList< IntType >(); tuple.add( new IntType() ); tuple.add( new IntType() ); tuple.add( new IntType() ); } return cursor.hasNext(); } @Override public List< IntType > next() { final ARGBType argbValue = cursor.next(); tuple.get( 0 ).set( ( argbValue.get() >> 16 ) & 0xff ); tuple.get( 1 ).set( ( argbValue.get() >> 8 ) & 0xff ); tuple.get( 2 ).set( ( argbValue.get() >> 0 ) & 0xff ); return tuple; } @Override public void remove() { // do nothing } }; } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/histogram/HistogramPerformanceTest.java000066400000000000000000000112361316447754700310360ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.IntegerType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.integer.UnsignedShortType; // Adapted by BDZ from the imglib1 HistogramPerformanceTest code by CTR to work // with newer histogram implementations. /** * Performance testing code for the histogram clases. * * @author Curtis Rueden * @author Barry DeZonia */ public class HistogramPerformanceTest< T extends IntegerType< T > & NativeType< T >> { private static final int[] DIMS = { 1024, 1024, 3, 5 }; public static void main( final String[] args ) { System.out.println( "== UNSIGNED 8-BIT ==" ); new HistogramPerformanceTest< UnsignedByteType >().run( new UnsignedByteType(), 256 ); System.out.println( "== UNSIGNED 16-BIT ==" ); new HistogramPerformanceTest< UnsignedShortType >().run( new UnsignedShortType(), 65536 ); } public void run( final T type, final int max ) { long start, end; System.out.print( "Creating image... " ); start = System.currentTimeMillis(); final Img< T > img = createImage( type, max ); end = System.currentTimeMillis(); final long createMillis = end - start; System.out.println( createMillis + " ms" ); // build histogram through manual pixel counting System.out.print( "Counting pixel values manually... " ); start = System.currentTimeMillis(); final long[] bins = new long[ max ]; for ( final T t : img ) { final double v = t.getRealDouble(); bins[ ( int ) v ]++; } end = System.currentTimeMillis(); final long manualMillis = end - start; System.out.println( manualMillis + " ms" ); // build histogram with Histogram implementation System.out.print( "Building histogram... " ); start = System.currentTimeMillis(); final Integer1dBinMapper< T > binMapper = new Integer1dBinMapper< T >( 0, max, false ); final Histogram1d< T > hist = new Histogram1d< T >( img, binMapper ); end = System.currentTimeMillis(); final long histMillis = end - start; System.out.println( histMillis + " ms" ); // check results final T val = img.firstElement(); for ( int i = 0; i < max; i++ ) { val.setReal( i ); final long binPos = hist.map( val ); final long actual = hist.frequency( binPos ); final long expect = bins[ i ]; if ( actual != expect ) { System.out.println( "Error: for bin #" + i + ": expected=" + expect + ", actual=" + actual ); } } } private Img< T > createImage( final T type, final int max ) { final ImgFactory< T > imFactory = new ArrayImgFactory< T >(); final Img< T > img = imFactory.create( DIMS, type ); // populate image with random samples for ( final T t : img ) t.setReal( max * Math.random() ); return img; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/histogram/Integer1dBinMapperTest.java000066400000000000000000000073361316447754700303450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import static org.junit.Assert.assertEquals; import net.imglib2.type.numeric.integer.IntType; import org.junit.Test; /** * Tests the Integer1dBinMapper class. * * @author Barry DeZonia */ public class Integer1dBinMapperTest { @Test public void testNoTail() { long binPos; final IntType tmp = new IntType(); final Integer1dBinMapper< IntType > binMapper = new Integer1dBinMapper< IntType >( 0, 100, false ); assertEquals( 100, binMapper.getBinCount() ); for ( int i = 0; i <= 99; i++ ) { tmp.setInteger( i ); binPos = binMapper.map( tmp ); assertEquals( i, binPos ); binMapper.getLowerBound( binPos, tmp ); assertEquals( i, tmp.getIntegerLong() ); binMapper.getUpperBound( binPos, tmp ); assertEquals( i, tmp.getIntegerLong() ); binMapper.getCenterValue( binPos, tmp ); assertEquals( i, tmp.getIntegerLong() ); } tmp.setReal( -1 ); assertEquals( Long.MIN_VALUE, binMapper.map( tmp ) ); tmp.setReal( 100 ); assertEquals( Long.MAX_VALUE, binMapper.map( tmp ) ); } @Test public void testTail() { long binPos; final IntType tmp = new IntType(); final Integer1dBinMapper< IntType > binMapper = new Integer1dBinMapper< IntType >( 0, 100, true ); assertEquals( 100, binMapper.getBinCount() ); // test the interior areas for ( int i = 0; i < 98; i++ ) { tmp.setInteger( i ); binPos = binMapper.map( tmp ); assertEquals( i + 1, binPos ); binMapper.getLowerBound( binPos, tmp ); assertEquals( i, tmp.getIntegerLong() ); binMapper.getUpperBound( binPos, tmp ); assertEquals( i, tmp.getIntegerLong() ); binMapper.getCenterValue( binPos, tmp ); assertEquals( i, tmp.getIntegerLong() ); } // test the lower tail tmp.setInteger( -1 ); binPos = binMapper.map( tmp ); assertEquals( 0, binPos ); // test the upper tail tmp.setInteger( 100 ); binPos = binMapper.map( tmp ); assertEquals( 99, binPos ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/histogram/Real1dBinMapperTest.java000066400000000000000000000236641316447754700276350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.histogram; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.real.FloatType; import org.junit.Test; /** * Tests the Real1dBinMapper class. * * @author Barry DeZonia */ public class Real1dBinMapperTest { // DONE @Test public void testIntNoTails() { long binPos; final IntType tmp = new IntType(); final Real1dBinMapper< IntType > binMapper = new Real1dBinMapper< IntType >( 0.0, 100.0, 100, false ); assertEquals( 100, binMapper.getBinCount() ); for ( double i = 0; i <= 100; i += 0.125 ) { tmp.setReal( i ); binPos = binMapper.map( tmp ); double expectedBin = Math.round( i ); if ( i >= 99.5 ) expectedBin--; assertEquals( expectedBin, binPos, 0 ); binMapper.getLowerBound( binPos, tmp ); assertEquals( expectedBin, tmp.getRealDouble(), 0.0 ); binMapper.getUpperBound( binPos, tmp ); assertEquals( expectedBin + 1, tmp.getRealDouble(), 0.0 ); // Note - one would hope this would calc easily but due to rounding // errors // one cannot always easily tell what the bin center is when using // an // integral type with a Real1dBinMapper. One should really use an // Integer1dBinMapper in these cases. Disabling test. // binMapper.getCenterValues(binPos, tmpList); // assertEquals(expectedBin + 1, tmp.getRealDouble(), 0.0); } tmp.setReal( -1 ); assertEquals( Long.MIN_VALUE, binMapper.map( tmp ) ); tmp.setReal( 101 ); assertEquals( Long.MAX_VALUE, binMapper.map( tmp ) ); } // DONE @Test public void testIntTails() { long binPos; final IntType tmp = new IntType(); final Real1dBinMapper< IntType > binMapper = new Real1dBinMapper< IntType >( 0.0, 100.0, 102, true ); assertEquals( 102, binMapper.getBinCount() ); for ( double i = 0; i <= 100; i += 0.125 ) { tmp.setReal( i ); binPos = binMapper.map( tmp ); double expectedBin = Math.round( i ) + 1; if ( i >= 99.5 ) expectedBin--; assertEquals( expectedBin, binPos, 0 ); binMapper.getLowerBound( binPos, tmp ); assertEquals( expectedBin - 1, tmp.getRealDouble(), 0.0 ); binMapper.getUpperBound( binPos, tmp ); assertEquals( expectedBin, tmp.getRealDouble(), 0.0 ); // Note - one would hope this would calc easily but due to rounding // errors // one cannot always easily tell what the bin center is when using // an // integral type with a Real1dBinMapper. One should really use an // Integer1dBinMapper in these cases. Disabling test. // binMapper.getCenterValues(binPos, tmpList); // assertEquals(expectedBin + 1, tmp.getRealDouble(), 0.0); } tmp.setReal( -1 ); assertEquals( 0, binMapper.map( tmp ) ); tmp.setReal( 101 ); assertEquals( 101, binMapper.map( tmp ) ); } // DONE @Test public void testFloatNoTails() { long binPos; final FloatType tmp = new FloatType(); final Real1dBinMapper< FloatType > binMapper = new Real1dBinMapper< FloatType >( 0.0, 100.0, 100, false ); assertEquals( 100, binMapper.getBinCount() ); for ( double i = 0; i <= 100; i += 0.125 ) { tmp.setReal( i ); binPos = binMapper.map( tmp ); double expectedBin = Math.floor( i ); if ( i == 100.0 ) expectedBin--; assertEquals( expectedBin, binPos, 0 ); binMapper.getLowerBound( binPos, tmp ); assertEquals( expectedBin, tmp.getRealDouble(), 0.0 ); binMapper.getUpperBound( binPos, tmp ); assertEquals( expectedBin + 1, tmp.getRealDouble(), 0.0 ); binMapper.getCenterValue( binPos, tmp ); assertEquals( expectedBin + 0.5, tmp.getRealDouble(), 0.0 ); } tmp.setReal( -0.0001 ); assertEquals( Long.MIN_VALUE, binMapper.map( tmp ) ); tmp.setReal( 100.0001 ); assertEquals( Long.MAX_VALUE, binMapper.map( tmp ) ); } // DONE @Test public void testFloatTails() { long binPos; final FloatType tmp = new FloatType(); final Real1dBinMapper< FloatType > binMapper = new Real1dBinMapper< FloatType >( 0.0, 100.0, 102, true ); assertEquals( 102, binMapper.getBinCount() ); for ( double i = 0; i <= 100; i += 0.125 ) { tmp.setReal( i ); binPos = binMapper.map( tmp ); double expectedBin = Math.floor( i ) + 1; if ( i == 100.0 ) expectedBin--; assertEquals( expectedBin, binPos, 0 ); binMapper.getLowerBound( binPos, tmp ); assertEquals( expectedBin - 1, tmp.getRealDouble(), 0.0 ); binMapper.getUpperBound( binPos, tmp ); assertEquals( expectedBin, tmp.getRealDouble(), 0.0 ); binMapper.getCenterValue( binPos, tmp ); assertEquals( expectedBin - 0.5, tmp.getRealDouble(), 0.0 ); } tmp.setReal( -0.0001 ); assertEquals( 0, binMapper.map( tmp ) ); tmp.setReal( 100.0001 ); assertEquals( 101, binMapper.map( tmp ) ); } // DONE @Test public void testBinBoundariesTails() { long pos; final FloatType tmp = new FloatType(); Real1dBinMapper< FloatType > binMapper; pos = 0; binMapper = new Real1dBinMapper< FloatType >( 0.0, 4.0, 4, true ); binMapper.getLowerBound( pos, tmp ); assertEquals( Double.NEGATIVE_INFINITY, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 0, tmp.getRealDouble(), 0 ); assertFalse( binMapper.includesUpperBound( pos ) ); pos = 1; binMapper.getLowerBound( pos, tmp ); assertEquals( 0, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 2, tmp.getRealDouble(), 0 ); assertFalse( binMapper.includesUpperBound( pos ) ); pos = 2; binMapper.getLowerBound( pos, tmp ); assertEquals( 2, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 4, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesUpperBound( pos ) ); pos = 3; binMapper.getLowerBound( pos, tmp ); assertEquals( 4, tmp.getRealDouble(), 0 ); assertFalse( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( Double.POSITIVE_INFINITY, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesUpperBound( pos ) ); tmp.setReal( -0.001 ); pos = binMapper.map( tmp ); assertEquals( 0, pos ); tmp.setReal( 4.001 ); pos = binMapper.map( tmp ); assertEquals( 3, pos ); } // DONE @Test public void testBinBoundariesNoTails() { long pos; final FloatType tmp = new FloatType(); Real1dBinMapper< FloatType > binMapper; binMapper = new Real1dBinMapper< FloatType >( 0.0, 4.0, 4, false ); pos = 0; binMapper.getLowerBound( pos, tmp ); assertEquals( 0, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 1, tmp.getRealDouble(), 0 ); assertFalse( binMapper.includesUpperBound( pos ) ); pos = 1; binMapper.getLowerBound( pos, tmp ); assertEquals( 1, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 2, tmp.getRealDouble(), 0 ); assertFalse( binMapper.includesUpperBound( pos ) ); pos = 2; binMapper.getLowerBound( pos, tmp ); assertEquals( 2, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 3, tmp.getRealDouble(), 0 ); assertFalse( binMapper.includesUpperBound( pos ) ); pos = 3; binMapper.getLowerBound( pos, tmp ); assertEquals( 3, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesLowerBound( pos ) ); binMapper.getUpperBound( pos, tmp ); assertEquals( 4, tmp.getRealDouble(), 0 ); assertTrue( binMapper.includesUpperBound( pos ) ); tmp.setReal( -0.001 ); assertEquals( Long.MIN_VALUE, binMapper.map( tmp ) ); tmp.setReal( 4.001 ); assertEquals( Long.MAX_VALUE, binMapper.map( tmp ) ); } @Test public void testEmptyMapper() { long pos; final FloatType tmp = new FloatType(); Real1dBinMapper< FloatType > binMapper; binMapper = new Real1dBinMapper< FloatType >( 0.0, 0.0, 4, false ); assertNotNull( binMapper ); tmp.set( 0 ); pos = binMapper.map( tmp ); assertEquals( 0, pos ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/000077500000000000000000000000001316447754700217705ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/AbstractSubIntervalIterableCursorTest.java000066400000000000000000000142411316447754700322650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; import net.imglib2.view.Views; import net.imglib2.view.iteration.SubIntervalIterable; import org.junit.Test; public abstract class AbstractSubIntervalIterableCursorTest< T extends Img< IntType > & SubIntervalIterable< IntType > > { /** * dimensions of the tested Image. dimension 0 of all should be at least 18 */ protected long[] dimensions; protected int[] intData; /** Img to test on */ protected T img; /** Interval which is optimizable with a special SubIntervalCursor */ protected Interval intervalFast; /** Interval which is not optimizable */ protected Interval intervalShifted; /* * Cursor */ @Test public void testIterationFast() { Cursor< IntType > cursor = Views.interval( img, intervalFast ).cursor(); testCursorIteration( cursor, intervalFast ); } @Test public void testIterationShifted() { Cursor< IntType > cursor = Views.interval( img, intervalShifted ).cursor(); testCursorIteration( cursor, intervalShifted ); } @Test public void testJumpFwdFast() { Cursor< IntType > cursor = Views.interval( img, intervalFast ).cursor(); testCursorJumpFwd( cursor, intervalFast ); } @Test public void testJumpFwdShifted() { Cursor< IntType > cursor = Views.interval( img, intervalShifted ).cursor(); testCursorJumpFwd( cursor, intervalShifted ); } /* * Localizing Cursor */ @Test public void testLocalizingIterationFast() { Cursor< IntType > cursor = Views.interval( img, intervalFast ).localizingCursor(); testCursorIteration( cursor, intervalFast ); } @Test public void testLocalizingIterationShifted() { Cursor< IntType > cursor = Views.interval( img, intervalShifted ).localizingCursor(); testCursorIteration( cursor, intervalShifted ); } @Test public void testLocalizingJumpFwdFast() { Cursor< IntType > cursor = Views.interval( img, intervalFast ).localizingCursor(); testCursorJumpFwd( cursor, intervalFast ); } @Test public void testLocalizingJumpFwdShifted() { Cursor< IntType > cursor = Views.interval( img, intervalShifted ).localizingCursor(); testCursorJumpFwd( cursor, intervalShifted ); } protected void testCursorIteration( Cursor< IntType > cursor, Interval i ) { long[] position = new long[ cursor.numDimensions() ]; long[] min = new long[ cursor.numDimensions() ]; i.min( min ); cursor.fwd(); cursor.localize( position ); cursor.reset(); int ctr = 0; long sum = 0; final RandomAccess< BitType > check = Views.translate( new ArrayImgFactory< BitType >().create( i, new BitType() ), min ).randomAccess(); while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( position ); check.setPosition( position ); assertFalse( check.get().get() ); check.get().set( true ); sum += cursor.get().get(); ctr++; } assertEquals( "wrong number of elements accessed.", getIntervalSize( i ), ctr ); assertEquals( "sum of elements incorrect.", sum, getSum( i ) ); } protected void testCursorJumpFwd( Cursor< IntType > cursor, Interval i ) { long[] position = new long[ cursor.numDimensions() ]; long[] ref = new long[ cursor.numDimensions() ]; i.min( ref ); ref[ 0 ] += 17; cursor.jumpFwd( 18 ); cursor.localize( position ); assertArrayEquals( "jumpFwd position incorrect.", ref, position ); } // HELPER protected final long getSum( Interval interval ) { long[] pos = new long[ interval.numDimensions() ]; long sum = 0; for ( int i = 0; i < intData.length; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); boolean in = true; for ( int j = 0; j < pos.length; j++ ) { if ( pos[ j ] < interval.min( j ) || pos[ j ] > interval.max( j ) ) { in = false; break; } } if ( in ) { sum += intData[ i ]; } } return sum; } protected final long getIntervalSize( Interval interval ) { long size = interval.dimension( 0 ); for ( int i = 1; i < interval.numDimensions(); ++i ) { size *= interval.dimension( i ); } return size; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/ImgFactoryTest.java000066400000000000000000000052041316447754700255400ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import org.junit.Assert; import org.junit.Test; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.type.numeric.integer.UnsignedByteType; /** * * * @author Stephan Saalfeld */ public class ImgFactoryTest { /** * Test method for {@link net.imglib2.img.ImgFactory#create(java.util.function.Supplier, long[])}. */ @Test public final void testCreateSupplierOfTLongArray() { final ArrayImg< UnsignedByteType, ByteArray > img = ArrayImgs.unsignedBytes(1, 2, 3); final Img< UnsignedByteType > copy = img.factory().create( UnsignedByteType::new, 1, 2, 3 ); Assert.assertTrue( ArrayImg.class.isInstance( copy ) ); Assert.assertTrue( UnsignedByteType.class.isInstance( copy.iterator().next() ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/IterableSubIntervalBenchmark.java000066400000000000000000000221101316447754700303500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img; import java.util.ArrayList; import java.util.Collections; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.Interval; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.planar.PlanarImg; import net.imglib2.img.planar.PlanarImgs; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.BenchmarkHelper; import net.imglib2.view.Views; /* * Benchmarked 20.06.2013 Thinkpad i7-2620M CPU @ 2.7 GHz * * Planar Image: the optimized cursor is slower when executed after Array cursors, but faster by ~factor 100 if executed * on its own. This may be due to JIT confusion. * Array Image: the optimized cursor is faster by ~factor 100 */ public class IterableSubIntervalBenchmark { /** * Walk through an Interval on an Img using a LocalizingCursor, localizing * on every step. * * @param img * @param interval */ protected static void localizingWalkThrough( final Img< IntType > img, final Interval interval ) { final Cursor< IntType > c = Views.interval( img, interval ).localizingCursor(); final long[] pos = new long[ interval.numDimensions() ]; int i = 0; while ( c.hasNext() ) { c.fwd(); i += c.get().get(); c.localize( pos ); } j = ( int ) pos[ 0 ] + i; } /** * Walk through an Interval on an Img using a Cursor * * @param img * @param interval */ protected static void walkThrough( final Img< IntType > img, final Interval interval ) { final Cursor< IntType > c = Views.interval( img, interval ).cursor(); int i = 0; while ( c.hasNext() ) { c.fwd(); i += c.get().get(); } j = i; } public static int j; public static void main( final String[] args ) { final int numRuns = 20; final boolean printIndividualTimes = false; final long[] dimensions = new long[] { 5000, 5000, 2, 2 }; // doesn't fit the interval, will force unoptimized cursor final long[] dimensionsUnoptimized = new long[] { 5001, 5000, 2, 2 }; // fits the interval, should be optimized final Interval interval = new FinalInterval( new long[] { 0, 0, 1, 1 }, new long[] { 4999, 4999, 1, 1 } ); // create and fill images final ArrayImg< IntType, ? > arrayImg = ArrayImgs.ints( dimensions ); // fits // the // interval // doesn't fit the interval final ArrayImg< IntType, ? > arrayImgUnOp = ArrayImgs.ints( dimensionsUnoptimized ); // fits the interval final PlanarImg< IntType, ? > planarImg = PlanarImgs.ints( dimensions ); // doesn't fit the interval final PlanarImg< IntType, ? > planarImgUnOp = PlanarImgs.ints( dimensionsUnoptimized ); testArrayImg( numRuns, printIndividualTimes, interval, arrayImg, arrayImgUnOp ); testPlanarImg( numRuns, printIndividualTimes, interval, planarImg, planarImgUnOp ); testArrayImg( numRuns, printIndividualTimes, interval, arrayImg, arrayImgUnOp ); testPlanarImg( numRuns, printIndividualTimes, interval, planarImg, planarImgUnOp ); testArrayImg( numRuns, printIndividualTimes, interval, arrayImg, arrayImgUnOp ); testPlanarImg( numRuns, printIndividualTimes, interval, planarImg, planarImgUnOp ); } /* * the 2nd img is unoptimized with respect to the provided interval i.e. * while optimized cursors can be used for the first image given interval * this is not possible for the 2nd one. */ protected static void testArrayImg( final int numRuns, final boolean printIndividualTimes, final Interval interval, final ArrayImg< IntType, ? > arrayImg, final ArrayImg< IntType, ? > arrayImgUnOp ) { // BLOCK 1 System.out.println( "normal cursor | array img" ); System.out.println( "walk through a subinterval" ); benchmarkAndCompare( numRuns, printIndividualTimes, new Runnable() { @Override public void run() { walkThrough( arrayImgUnOp, interval ); } }, new Runnable() { @Override public void run() { walkThrough( arrayImg, interval ); } } ); // BLOCK 2 System.out.println( "localizing cursor | array img" ); System.out.println( "walk through a subinterval" ); benchmarkAndCompare( numRuns, printIndividualTimes, new Runnable() { @Override public void run() { localizingWalkThrough( arrayImgUnOp, interval ); } }, new Runnable() { @Override public void run() { localizingWalkThrough( arrayImg, interval ); } } ); } /* * the 2nd img is unoptimized with respect to the provided interval i.e. * while optimized cursors can be used for the first image given inter this * is not possible for the 2nd one. */ protected static void testPlanarImg( final int numRuns, final boolean printIndividualTimes, final Interval interval, final PlanarImg< IntType, ? > planarImg, final PlanarImg< IntType, ? > planarImgUnOp ) { // BLOCK 1 System.out.println( "normal cursor | planar img" ); System.out.println( "walk through a subinterval" ); benchmarkAndCompare( numRuns, printIndividualTimes, new Runnable() { @Override public void run() { walkThrough( planarImgUnOp, interval ); } }, new Runnable() { @Override public void run() { walkThrough( planarImg, interval ); } } ); // BLOCK 2 System.out.println( "localizing cursor | planar img" ); System.out.println( "walk through a subinterval" ); benchmarkAndCompare( numRuns, printIndividualTimes, new Runnable() { @Override public void run() { localizingWalkThrough( planarImgUnOp, interval ); } }, new Runnable() { @Override public void run() { localizingWalkThrough( planarImg, interval ); } } ); } // HELPER public static void benchmarkAndCompare( final int numRuns, final boolean individualRuns, final Runnable norm, final Runnable opt ) { final ArrayList< Long > valuesNorm = BenchmarkHelper.benchmark( numRuns, norm ); final ArrayList< Long > valuesOpt = BenchmarkHelper.benchmark( numRuns, opt ); final long[] statsNorm = computeStats( valuesNorm ); final long[] statsOpt = computeStats( valuesOpt ); final long[] statsDiff = new long[] { ( statsNorm[ 0 ] - statsOpt[ 0 ] ), ( statsNorm[ 1 ] - statsOpt[ 1 ] ), ( statsNorm[ 2 ] - statsOpt[ 2 ] ) }; // print System.out.println( "\t| Unoptimized \t| Optimized \t| Speedup Time \t| Speedup % \t|" ); System.out.println( "Median\t|\t" + statsNorm[ 0 ] + "\t|\t" + statsOpt[ 0 ] + "\t| " + statsDiff[ 0 ] + "ms \t| " + ( ( int ) ( 1000.0 / statsNorm[ 0 ] * statsDiff[ 0 ] ) / 10.0 ) + "% \t|" ); System.out.println( "Best\t|\t" + statsNorm[ 1 ] + "\t|\t" + statsOpt[ 1 ] + "\t| " + statsDiff[ 1 ] + "ms \t| " + ( ( int ) ( 1000.0 / statsNorm[ 1 ] * statsDiff[ 1 ] ) / 10.0 ) + "% \t|" ); System.out.println( "Worst\t|\t" + statsNorm[ 2 ] + "\t|\t" + statsOpt[ 2 ] + "\t| " + statsDiff[ 2 ] + "ms \t| " + ( ( int ) ( 1000.0 / statsNorm[ 2 ] * statsDiff[ 2 ] ) / 10.0 ) + "% \t|" ); System.out.println(); } public static long[] computeStats( final ArrayList< Long > values ) { Collections.sort( values ); long median = 0; if ( values.size() % 2 == 1 ) { median = values.get( ( values.size() + 1 ) / 2 - 1 ); } else { final long lower = values.get( values.size() / 2 - 1 ); final long upper = values.get( values.size() / 2 ); median = ( lower + upper ) / 2; } return new long[] { median, values.get( 0 ), values.get( values.size() - 1 ) }; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/array/000077500000000000000000000000001316447754700231065ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/array/ArrayImgTest.java000066400000000000000000000047761316447754700263420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import static org.junit.Assert.assertTrue; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.ImgTestHelper; import net.imglib2.util.Util; import org.junit.Test; /** * Unit tests for {@link ArrayImg}. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Curtis Rueden */ public class ArrayImgTest { @Test public void testArrayImg() { final long[][] dim = ImgTestHelper.dims(); for ( int i = 0; i < dim.length; ++i ) { assertTrue( "ArrayImg failed for: dim=" + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new ArrayImgFactory< FloatType >(), new ArrayImgFactory< FloatType >() ) ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/array/ArrayImgsTest.java000066400000000000000000000272201316447754700265120ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import java.util.Random; import org.junit.Assert; import org.junit.Test; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.type.NativeType; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.IntegerType; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.complex.ComplexDoubleType; import net.imglib2.type.numeric.complex.ComplexFloatType; import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.LongType; import net.imglib2.type.numeric.integer.ShortType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.integer.UnsignedIntType; import net.imglib2.type.numeric.integer.UnsignedLongType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Intervals; /** * * @author Philipp Hanslovsky * */ public class ArrayImgsTest { private final long[] dims = { 4, 5 }; private final int nElements = ( int ) Intervals.numElements( dims ); @Test public void testHelperMethods() { // bytes { final byte[] data = new byte[ nElements ]; for ( int d = 0; d < nElements; ++d ) data[ d ] = ( byte ) d; final ByteArray access = new ByteArray( data ); final ArrayImg< UnsignedByteType, ByteArray > unsignedRef = ArrayImgs.unsignedBytes( data, dims ); final ArrayImg< UnsignedByteType, ByteArray > unsignedComp = ArrayImgs.unsignedBytes( access, dims ); testRange( unsignedComp, unsignedRef, 0, nElements ); final ArrayImg< ByteType, ByteArray > ref = ArrayImgs.bytes( data, dims ); final ArrayImg< ByteType, ByteArray > comp = ArrayImgs.bytes( access, dims ); testRange( comp, ref, 0, nElements ); } // shorts { final short[] data = new short[ nElements ]; for ( int d = 0; d < nElements; ++d ) data[ d ] = ( short ) d; final ShortArray access = new ShortArray( data ); final ArrayImg< UnsignedShortType, ShortArray > unsignedRef = ArrayImgs.unsignedShorts( data, dims ); final ArrayImg< UnsignedShortType, ShortArray > unsignedComp = ArrayImgs.unsignedShorts( access, dims ); testRange( unsignedComp, unsignedRef, 0, nElements ); final ArrayImg< ShortType, ShortArray > ref = ArrayImgs.shorts( data, dims ); final ArrayImg< ShortType, ShortArray > comp = ArrayImgs.shorts( access, dims ); testRange( comp, ref, 0, nElements ); } // ints & arbgs { final int[] data = new int[ nElements ]; for ( int d = 0; d < nElements; ++d ) data[ d ] = d; final IntArray access = new IntArray( data ); final ArrayImg< UnsignedIntType, IntArray > unsignedRef = ArrayImgs.unsignedInts( data, dims ); final ArrayImg< UnsignedIntType, IntArray > unsignedComp = ArrayImgs.unsignedInts( access, dims ); testRange( unsignedComp, unsignedRef, 0, nElements ); final ArrayImg< IntType, IntArray > ref = ArrayImgs.ints( data, dims ); final ArrayImg< IntType, IntArray > comp = ArrayImgs.ints( access, dims ); testRange( comp, ref, 0, nElements ); final ArrayImg< ARGBType, IntArray > argbRef = ArrayImgs.argbs( data, dims ); final ArrayImg< ARGBType, IntArray > argbComp = ArrayImgs.argbs( access, dims ); testEquality( argbComp, argbRef ); } // longs { final long[] data = new long[ nElements ]; for ( int d = 0; d < nElements; ++d ) data[ d ] = d; final LongArray access = new LongArray( data ); final ArrayImg< UnsignedLongType, LongArray > unsignedComp = ArrayImgs.unsignedLongs( access, dims ); final ArrayCursor< UnsignedLongType > u = unsignedComp.cursor(); for ( int i = 0; i < nElements; ++i ) Assert.assertEquals( i, u.next().get() ); final ArrayImg< LongType, LongArray > ref = ArrayImgs.longs( data, dims ); final ArrayImg< LongType, LongArray > comp = ArrayImgs.longs( access, dims ); testRange( comp, ref, 0, nElements ); } // floats { final Random rng = new Random(); final float[] data = new float[ nElements ]; for ( int d = 0; d < data.length; ++d ) data[ d ] = rng.nextFloat(); final FloatArray access = new FloatArray( data ); final ArrayImg< FloatType, FloatArray > comp = ArrayImgs.floats( access, dims ); final ArrayImg< FloatType, FloatArray > ref = ArrayImgs.floats( data, dims ); testEquality( comp, ref ); testEquality( comp, data ); final float[] d0 = new float[ nElements ]; final float[] d1 = new float[ nElements ]; final ArrayCursor< FloatType > c = ArrayImgs.floats( d1, dims ).cursor(); for ( int i = 0; c.hasNext(); ++i ) { final float v = rng.nextFloat(); d0[ i ] = v; c.next().set( v ); } Assert.assertArrayEquals( d0, d1, 0.0f ); testEquality( ArrayImgs.floats( d1, dims ), d0 ); } // complex floats { final Random rng = new Random(); final float[] data = new float[ 2 * nElements ]; for ( int d = 0; d < data.length; ++d ) data[ d ] = rng.nextFloat(); final FloatArray access = new FloatArray( data ); final ArrayImg< ComplexFloatType, FloatArray > complexComp = ArrayImgs.complexFloats( access, dims ); final ArrayImg< ComplexFloatType, FloatArray > complexRef = ArrayImgs.complexFloats( data, dims ); testEquality( complexComp, complexRef ); final float[] d0 = new float[ 2 * nElements ]; final float[] d1 = new float[ 2 * nElements ]; final ArrayCursor< ComplexFloatType > c = ArrayImgs.complexFloats( d1, dims ).cursor(); for ( int i = 0; c.hasNext(); i += 2 ) { final float v1 = rng.nextFloat(); final float v2 = rng.nextFloat(); d0[ i ] = v1; d0[ i + 1 ] = v2; c.next().setReal( v1 ); c.get().setImaginary( v2 ); } Assert.assertArrayEquals( d0, d1, 0.0f ); } // doubles { final Random rng = new Random(); final double[] data = new double[ nElements ]; for ( int d = 0; d < data.length; ++d ) data[ d ] = rng.nextDouble(); final DoubleArray access = new DoubleArray( data ); final ArrayImg< DoubleType, DoubleArray > comp = ArrayImgs.doubles( access, dims ); final ArrayImg< DoubleType, DoubleArray > ref = ArrayImgs.doubles( data, dims ); testEquality( comp, ref ); testEquality( comp, data ); final double[] d0 = new double[ nElements ]; final double[] d1 = new double[ nElements ]; final ArrayCursor< DoubleType > c = ArrayImgs.doubles( d1, dims ).cursor(); for ( int i = 0; c.hasNext(); ++i ) { final double v = rng.nextDouble(); d0[ i ] = v; c.next().set( v ); } Assert.assertArrayEquals( d0, d1, 0.0f ); testEquality( ArrayImgs.doubles( d1, dims ), d0 ); } // complex doubles { final Random rng = new Random(); final double[] data = new double[ 2 * nElements ]; for ( int d = 0; d < data.length; ++d ) data[ d ] = rng.nextDouble(); final DoubleArray access = new DoubleArray( data ); final ArrayImg< ComplexDoubleType, DoubleArray > complexComp = ArrayImgs.complexDoubles( access, dims ); final ArrayImg< ComplexDoubleType, DoubleArray > complexRef = ArrayImgs.complexDoubles( data, dims ); testEquality( complexComp, complexRef ); final double[] d0 = new double[ 2 * nElements ]; final double[] d1 = new double[ 2 * nElements ]; final ArrayCursor< ComplexDoubleType > c = ArrayImgs.complexDoubles( d1, dims ).cursor(); for ( int i = 0; c.hasNext(); i += 2 ) { final double v1 = rng.nextDouble(); final double v2 = rng.nextDouble(); d0[ i ] = v1; d0[ i + 1 ] = v2; c.next().setReal( v1 ); c.get().setImaginary( v2 ); } Assert.assertArrayEquals( d0, d1, 0.0 ); } // bits { final long[] data = new long[] { 0 }; final int step = 3; for ( long start = 0; start < Long.SIZE; start += step ) data[ 0 ] = data[ 0 ] | 1l << start; final ArrayImg< BitType, LongArray > a = ArrayImgs.bits( new LongArray( data ), 8, 4, 2 ); final ArrayCursor< BitType > c = a.cursor(); for ( int i = 0; c.hasNext(); ++i ) Assert.assertEquals( i % 3 == 0, c.next().get() ); } } public static < T extends NativeType< T > & IntegerType< T > > void testRange( final ArrayImg< T, ? > comp, final ArrayImg< T, ? > ref, final int start, final int stop ) { final ArrayCursor< T > c = comp.cursor(); final ArrayCursor< T > r = ref.cursor(); for ( int s = start; s < stop; ++s ) { Assert.assertEquals( c.next().getInteger(), s ); Assert.assertEquals( r.next().getInteger(), s ); } } public static < T extends NativeType< T > > void testEquality( final ArrayImg< T, ? > comp, final ArrayImg< T, ? > ref ) { for ( ArrayCursor< T > c = comp.cursor(), r = ref.cursor(); c.hasNext(); ) Assert.assertTrue( c.next().valueEquals( r.next() ) ); } public static void testEquality( final ArrayImg< ? extends RealType< ? >, ? > img, final float[] array ) { Assert.assertEquals( array.length, Intervals.numElements( img ) ); final ArrayRandomAccess< ? extends RealType< ? > > access = img.randomAccess(); for ( int i = 0; i < array.length; ++i ) { IntervalIndexer.indexToPosition( i, img, access ); Assert.assertEquals( array[ i ], access.get().getRealDouble(), 0.0 ); } } public static void testEquality( final ArrayImg< ? extends RealType< ? >, ? > img, final double[] array ) { Assert.assertEquals( array.length, Intervals.numElements( img ) ); final ArrayRandomAccess< ? extends RealType< ? > > access = img.randomAccess(); for ( int i = 0; i < array.length; ++i ) { IntervalIndexer.indexToPosition( i, img, access ); Assert.assertEquals( array[ i ], access.get().getRealDouble(), 0.0 ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/array/ArrayIterableSubIntervalCursorTest.java000066400000000000000000000110231316447754700327110ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.array; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.Random; import net.imglib2.FinalInterval; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.img.AbstractSubIntervalIterableCursorTest; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; import net.imglib2.view.Views; import org.junit.Before; import org.junit.Test; /** * ArrayIterableSubIntervalCursorTest * * TODO Javadoc * */ public class ArrayIterableSubIntervalCursorTest extends AbstractSubIntervalIterableCursorTest< ArrayImg< IntType, ? >> { int numValues; /* * Interval to ensure optimized cursors are not created when not possible. */ Interval intervalFastPart; long intDataSum; @Before public void createSourceData() { dimensions = new long[] { 23, 31, 11, 7, 3 }; intervalFast = new FinalInterval( new long[] { dimensions[ 0 ], dimensions[ 1 ], 5, 1, 1 } ); intervalFastPart = new FinalInterval( new long[] { dimensions[ 0 ], 2, 3, 1, 1 } ); intervalShifted = new FinalInterval( new long[] { 0, 0, 3, 5, 1 }, new long[] { dimensions[ 0 ] - 1, dimensions[ 1 ] - 1, 4, 5, 1 } ); numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } img = ( ArrayImg< IntType, ? > ) new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); long[] pos = new long[ dimensions.length ]; RandomAccess< IntType > a = img.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } @Test public void testOptimizable() { // Testing Cursor assertTrue( ( Views.interval( img, intervalFast ).cursor() instanceof ArraySubIntervalCursor ) ); // Testing Localizing Cursor assertTrue( ( Views.interval( img, intervalFast ).localizingCursor() instanceof AbstractArrayLocalizingCursor ) ); // Testing Cursor assertFalse( ( Views.interval( img, intervalFastPart ).cursor() instanceof ArraySubIntervalCursor ) ); // Testing Localizing Cursor assertFalse( ( Views.interval( img, intervalFastPart ).localizingCursor() instanceof AbstractArrayLocalizingCursor ) ); // Testing Cursor assertTrue( ( Views.interval( img, intervalShifted ).cursor() instanceof ArraySubIntervalCursor ) ); // Testing Localizing Cursor assertTrue( ( Views.interval( img, intervalShifted ).localizingCursor() instanceof AbstractArrayLocalizingCursor ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/000077500000000000000000000000001316447754700227075ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/ArrayRandomAccessBenchmark.java000066400000000000000000000145001316447754700307260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; /** * TODO * */ public class ArrayRandomAccessBenchmark { long[] dimensions; int numValues; int[] intData; long intDataSum; ArrayImg< IntType, ? > intImg; ArrayImg< IntType, ? > intImgCopy; public void createSourceData() { dimensions = new long[] { 480, 480, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); } /** * Fill intImg (a CellContainer with 40x40x40 cells) with data using flat * array iteration order. */ public void fillImage() { final int[] pos = new int[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); final int[] idim = new int[ dimensions.length ]; for ( int d = 0; d < dimensions.length; ++d ) idim[ d ] = ( int ) dimensions[ d ]; for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, idim, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } public void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final int[] pos = new int[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } } public void copyWithIterationBoth( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final Cursor< IntType > src = srcImg.cursor(); final Cursor< IntType > dst = dstImg.cursor(); while ( src.hasNext() ) { dst.next().set( src.next().get() ); } } public static Long median( final ArrayList< Long > values ) { Collections.sort( values ); if ( values.size() % 2 == 1 ) return values.get( ( values.size() + 1 ) / 2 - 1 ); final long lower = values.get( values.size() / 2 - 1 ); final long upper = values.get( values.size() / 2 ); return ( lower + upper ) / 2; } public interface Benchmark { public void run(); } public static void benchmark( final Benchmark b ) { final ArrayList< Long > times = new ArrayList< Long >( 100 ); final int numRuns = 20; for ( int i = 0; i < numRuns; ++i ) { final long startTime = System.currentTimeMillis(); b.run(); final long endTime = System.currentTimeMillis(); times.add( endTime - startTime ); } for ( int i = 0; i < numRuns; ++i ) { System.out.println( "run " + i + ": " + times.get( i ) + " ms" ); } System.out.println(); System.out.println( "median: " + median( times ) + " ms" ); System.out.println(); } public static void main( final String[] args ) { final ArrayRandomAccessBenchmark randomAccessBenchmark = new ArrayRandomAccessBenchmark(); randomAccessBenchmark.createSourceData(); System.out.println( "benchmarking fill" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.fillImage(); } } ); randomAccessBenchmark.intData = null; randomAccessBenchmark.intImgCopy = new ArrayImgFactory< IntType >().create( randomAccessBenchmark.dimensions, new IntType() ); System.out.println( "benchmarking copy to array" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); System.out.println( "benchmarking copy from array" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImgCopy, randomAccessBenchmark.intImg ); } } ); System.out.println( "benchmarking copy array to array using iteration" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.copyWithIterationBoth( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); randomAccessBenchmark.intImgCopy = null; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CellContainerFactoryTest.java000066400000000000000000000100071316447754700304620ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import static org.junit.Assert.assertArrayEquals; import org.junit.Test; import net.imglib2.type.NativeType; import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.real.FloatType; /** * TODO * */ public class CellContainerFactoryTest { int[][] dim = { { 10, 12 }, { 200, 30, 2, 2384 }, { 12, 3, 4, 1, 9 } }; long[][] offset = { { 0, 0 }, { 0, 912389123123l, 1231238214214367l, 2 }, { 321, 3, 1, 0, 0 } }; int[] expectedLength = { 120, 28608000, 1296 }; private < T extends NativeType< T > > void testDefaultCellSize( final T type ) { final int defaultCellSize = 43; final int[] expectedCellDims = { 43, 43, 43, 43 }; final CellImgFactory< T > factory = new CellImgFactory< T >( defaultCellSize ); final long[] dimension = { 100, 80, 4, 3 }; final CellImg< T, ? > img = factory.create( dimension, type ); final int[] cellDims = new int[ dimension.length ]; img.getCellGrid().cellDimensions( cellDims ); assertArrayEquals( expectedCellDims, cellDims ); } @Test public void testBitDefaultCellSize() { testDefaultCellSize( new BitType() ); } @Test public void testIntDefaultCellSize() { testDefaultCellSize( new IntType() ); } @Test public void testFloatDefaultCellSize() { testDefaultCellSize( new FloatType() ); } private < T extends NativeType< T > > void testDefaultCellDimensions( final T type ) { final int[] defaultCellDims = { 6, 8, 5, 3 }; final int[] expectedCellDims = defaultCellDims.clone(); final CellImgFactory< T > factory = new CellImgFactory< T >( defaultCellDims ); final long[] dimension = { 100, 80, 4, 3 }; final CellImg< T, ? > img = factory.create( dimension, type ); final int[] cellDims = new int[ dimension.length ]; img.getCellGrid().cellDimensions( cellDims ); assertArrayEquals( expectedCellDims, cellDims ); } @Test public void testBitDefaultCellDimensions() { testDefaultCellDimensions( new BitType() ); } @Test public void testIntDefaultCellDimensions() { testDefaultCellDimensions( new IntType() ); } @Test public void testFloatDefaultCellDimensions() { testDefaultCellDimensions( new FloatType() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CellContainerTest.java000066400000000000000000000063451316447754700271440ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.real.FloatType; import org.junit.Before; import org.junit.Test; /** * TODO * */ public class CellContainerTest { int[] cellDimensions; long[] dimensions; Img< FloatType > img; @Before public void setUp() { cellDimensions = new int[] { 8, 16, 5, 2 }; dimensions = new long[] { 20, 37, 12, 33 }; img = new CellImgFactory< FloatType >( cellDimensions ).create( dimensions, new FloatType() ); } @Test public void equalIterationOrder() { final Img< FloatType > img2 = new CellImgFactory< FloatType >( cellDimensions ).create( dimensions, new FloatType() ); assertTrue( img2.iterationOrder().equals( img.iterationOrder() ) ); assertTrue( img.iterationOrder().equals( img2.iterationOrder() ) ); final Img< FloatType > img3 = new CellImgFactory< FloatType >( 9 ).create( dimensions, new FloatType() ); assertFalse( img3.iterationOrder().equals( img.iterationOrder() ) ); assertFalse( img.iterationOrder().equals( img3.iterationOrder() ) ); final Img< FloatType > img4 = new ArrayImgFactory< FloatType >().create( dimensions, new FloatType() ); assertFalse( img4.iterationOrder().equals( img.iterationOrder() ) ); assertFalse( img.iterationOrder().equals( img4.iterationOrder() ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CellCursorTest.java000066400000000000000000000137101316447754700264710ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; import java.util.Random; import org.junit.Before; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; /** * TODO * */ public class CellCursorTest { long[] dimensions; int numValues; int[] intData; long intDataSum; CellImg< IntType, ? > intImg; @Before public void createSourceData() { dimensions = new long[] { 16, 37, 5, 13 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new CellImgFactory< IntType >( 4 ).create( dimensions, new IntType() ); final long[] pos = new long[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } @Test public void testSumWithCursor() { long sum = 0; final Cursor< IntType > cursor = intImg.cursor(); while ( cursor.hasNext() ) { sum += cursor.next().get(); } assertTrue( sum == intDataSum ); } @Test public void testResetWithCursor() { final Cursor< IntType > cursor = intImg.cursor(); final int v1 = cursor.next().get(); final long[] p1 = new long[ dimensions.length ]; cursor.localize( p1 ); cursor.reset(); final int v2 = cursor.next().get(); final long[] p2 = new long[ dimensions.length ]; cursor.localize( p2 ); assertTrue( v1 == v2 ); assertArrayEquals( p1, p2 ); } @Test public void testJmpWithCursor() { final int steps = 43; final Cursor< IntType > cursor1 = intImg.cursor(); for ( int i = 0; i < steps; ++i ) cursor1.fwd(); final int v1 = cursor1.next().get(); final long[] p1 = new long[ dimensions.length ]; cursor1.localize( p1 ); final Cursor< IntType > cursor2 = intImg.cursor(); cursor2.jumpFwd( steps ); final int v2 = cursor2.next().get(); final long[] p2 = new long[ dimensions.length ]; cursor2.localize( p2 ); assertTrue( v1 == v2 ); assertArrayEquals( p1, p2 ); } @Test public void testSumWithLocalizingCursor() { long sum = 0; final Cursor< IntType > cursor = intImg.localizingCursor(); while ( cursor.hasNext() ) { sum += cursor.next().get(); } assertTrue( sum == intDataSum ); } @Test public void testResetWithLocalizingCursor() { final Cursor< IntType > cursor = intImg.localizingCursor(); final int v1 = cursor.next().get(); final long[] p1 = new long[ dimensions.length ]; cursor.localize( p1 ); cursor.reset(); final int v2 = cursor.next().get(); final long[] p2 = new long[ dimensions.length ]; cursor.localize( p2 ); assertTrue( v1 == v2 ); assertArrayEquals( p1, p2 ); } @Test public void testJmpWithLocalizingCursor() { final int steps = 43; final Cursor< IntType > cursor1 = intImg.localizingCursor(); for ( int i = 0; i < steps; ++i ) cursor1.fwd(); final int v1 = cursor1.next().get(); final long[] p1 = new long[ dimensions.length ]; cursor1.localize( p1 ); final Cursor< IntType > cursor2 = intImg.localizingCursor(); cursor2.jumpFwd( steps ); final int v2 = cursor2.next().get(); final long[] p2 = new long[ dimensions.length ]; cursor2.localize( p2 ); assertTrue( v1 == v2 ); assertArrayEquals( p1, p2 ); } @Test public void testSumWithRandomAccess() { long sum = 0; final RandomAccess< IntType > access = intImg.randomAccess(); final long[] position = new long[ dimensions.length ]; for ( int d = 0; d < dimensions.length; ++d ) position[ d ] = 0; for ( int i = 0; i < numValues; ++i ) { access.setPosition( position ); sum += access.get().get(); for ( int d = 0; d < dimensions.length; ++d ) if ( ++position[ d ] >= dimensions[ d ] ) position[ d ] = 0; else break; } assertTrue( sum == intDataSum ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CellImgTest.java000066400000000000000000000060001316447754700257220ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import static org.junit.Assert.assertTrue; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.ImgTestHelper; import net.imglib2.util.Util; import org.junit.Test; /** * Unit tests for {@link CellImg}. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Curtis Rueden */ public class CellImgTest { @Test public void testCellImg() { final long[][] dim = ImgTestHelper.dims(); for ( int i = 0; i < dim.length; ++i ) { if ( dim[ i ].length > 1 ) { assertTrue( "ArrayImg vs CellImg failed for dim = " + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new ArrayImgFactory< FloatType >(), new CellImgFactory< FloatType >( 10 ) ) ); assertTrue( "CellImg vs ArrayImg failed for dim = " + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new CellImgFactory< FloatType >(), new ArrayImgFactory< FloatType >() ) ); assertTrue( "CellImg vs CellImg failed for dim = " + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new CellImgFactory< FloatType >( 5 ), new CellImgFactory< FloatType >() ) ); } } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CellRandomAccessBenchmark.java000066400000000000000000000127601316447754700305350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.BenchmarkHelper; import net.imglib2.util.IntervalIndexer; /** * TODO * */ public class CellRandomAccessBenchmark { long[] dimensions; int numValues; int[] intData; long intDataSum; CellImg< IntType, ? > intImg; CellImg< IntType, ? > intImgCopy; public void createSourceData() { dimensions = new long[] { 480, 480, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new CellImgFactory< IntType >( 40 ).create( dimensions, new IntType() ); } /** * Fill intImg (a CellContainer with 40x40x40 cells) with data using flat * array iteration order. */ public void fillImage() { final int[] pos = new int[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); final int[] idim = new int[ dimensions.length ]; for ( int d = 0; d < dimensions.length; ++d ) idim[ d ] = ( int ) dimensions[ d ]; for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, idim, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } public void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } } public static void main( final String[] args ) { final CellRandomAccessBenchmark randomAccessBenchmark = new CellRandomAccessBenchmark(); randomAccessBenchmark.createSourceData(); System.out.println( "benchmarking fill" ); BenchmarkHelper.benchmarkAndPrint( 50, true, new Runnable() { @Override public void run() { randomAccessBenchmark.fillImage(); } } ); randomAccessBenchmark.intData = null; randomAccessBenchmark.intImgCopy = new CellImgFactory< IntType >( 32 ).create( randomAccessBenchmark.dimensions, new IntType() ); System.out.println( "benchmarking copy to smaller" ); BenchmarkHelper.benchmarkAndPrint( 20, false, new Runnable() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); randomAccessBenchmark.intImgCopy = null; randomAccessBenchmark.intImgCopy = new CellImgFactory< IntType >( 50 ).create( randomAccessBenchmark.dimensions, new IntType() ); System.out.println( "benchmarking copy to larger" ); BenchmarkHelper.benchmarkAndPrint( 20, false, new Runnable() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); randomAccessBenchmark.intImgCopy = null; randomAccessBenchmark.intImgCopy = new CellImgFactory< IntType >( new int[] { 32, 64, 16 } ).create( randomAccessBenchmark.dimensions, new IntType() ); System.out.println( "benchmarking copy to mixed" ); BenchmarkHelper.benchmarkAndPrint( 20, false, new Runnable() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); randomAccessBenchmark.intImgCopy = null; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CellTest.java000066400000000000000000000067701316447754700253030ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; import net.imglib2.img.basictypeaccess.array.FloatArray; /** * TODO * */ public class CellTest { int[][] dim = { { 10, 12 }, { 200, 30, 2, 384 }, { 12, 3, 4, 1, 9 } }; long[][] offset = { { 0, 0 }, { 0, 912389123123l, 1231238214214367l, 2 }, { 321, 3, 1, 0, 0 } }; int[] expectedLength = { 120, 4608000, 1296 }; @Test public void testLocalIndexCalculation() { final long[] min = new long[] { 0, 9876543210l, 222 }; final Cell< FloatArray > cell = new Cell<>( new int[] {20, 8, 10}, min, new FloatArray( 1 ) ); final long[][] position = { {3, 4, 5}, {12, 0, 3}, {3, 2, 0} }; final int[] expectedIndex = { 883, 492, 43 }; for ( int i = 0; i < position.length; ++i ) { for ( int d =0; d cell = new Cell<>( new int[] {20, 8, 10}, new long[] { 0, 9876543210l, 222 }, new FloatArray( 1 ) ); final int[] index = { 883, 492, 43 }; final long[][] expectedPosition = { { 3, 9876543214l, 227 }, { 12, 9876543210l, 225 }, { 3, 9876543212l, 222 } }; for ( int i = 0; i < index.length; ++i ) { final long[] position = new long[ 3 ]; cell.indexToGlobalPosition( index[ i ], position ); assertArrayEquals( expectedPosition[ i ], position ); for ( int d = 0; d < position.length; ++d ) assertTrue( cell.indexToGlobalPosition( index[ i ], d ) == expectedPosition[ i ][ d ] ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/cell/CopyTest.java000066400000000000000000000142651316447754700253340ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.cell; import static org.junit.Assert.assertArrayEquals; import java.util.Random; import org.junit.Before; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; /** * TODO * */ public class CopyTest { long[] dimensions; int numValues; int[] intData; long intDataSum; CellImg< IntType, ? > intImg; @Before public void createSourceData() { dimensions = new long[] { 48, 17, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new CellImgFactory< IntType >( 10 ).create( dimensions, new IntType() ); final long[] pos = new long[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } } void copyWithDestIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dstImg.numDimensions() ]; final Cursor< IntType > dst = dstImg.localizingCursor(); final RandomAccess< IntType > src = srcImg.randomAccess(); while ( dst.hasNext() ) { dst.fwd(); dst.localize( pos ); src.setPosition( pos ); dst.get().set( src.get() ); } } public void copyWithIterationBoth( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final Cursor< IntType > src = srcImg.cursor(); final Cursor< IntType > dst = dstImg.cursor(); while ( src.hasNext() ) { dst.next().set( src.next().get() ); } } int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; } @Test public void testCopyToArrayContainerWithSourceIteration() { final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithSourceIteration( intImg, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } @Test public void testCopyToArrayContainerWithDestIteration() { final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithDestIteration( intImg, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } @Test public void testCopyToCellContainerWithSourceIteration() { final CellImg< IntType, ? > cellImg = new CellImgFactory< IntType >( new int[] { 2, 7, 4 } ).create( dimensions, new IntType() ); copyWithSourceIteration( intImg, cellImg ); assertArrayEquals( intData, getImgAsInts( cellImg ) ); } @Test public void testCopyToCellContainerWithDestIteration() { final CellImg< IntType, ? > cellImg = new CellImgFactory< IntType >( new int[] { 2, 7, 4 } ).create( dimensions, new IntType() ); copyWithDestIteration( intImg, cellImg ); assertArrayEquals( intData, getImgAsInts( cellImg ) ); } @Test public void testCopyArrayToArrayWithIterationBoth() { final ArrayImg< IntType, ? > array2 = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithDestIteration( intImg, array2 ); copyWithIterationBoth( array2, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/list/000077500000000000000000000000001316447754700227435ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/list/CopyTest.java000066400000000000000000000126541316447754700253700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.list; import static org.junit.Assert.assertArrayEquals; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; import org.junit.Before; import org.junit.Test; /** * TODO * */ public class CopyTest { long[] dimensions; int numValues; int[] intData; long intDataSum; ListImg< IntType > intImg; @Before public void createSourceData() { dimensions = new long[] { 48, 17, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new ListImgFactory< IntType >().create( dimensions, new IntType() ); final long[] pos = new long[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } } void copyWithDestIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dstImg.numDimensions() ]; final Cursor< IntType > dst = dstImg.localizingCursor(); final RandomAccess< IntType > src = srcImg.randomAccess(); while ( dst.hasNext() ) { dst.fwd(); dst.localize( pos ); src.setPosition( pos ); dst.get().set( src.get() ); } } int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; } @Test public void testCopyToArrayImgWithSourceIteration() { final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithSourceIteration( intImg, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } @Test public void testCopyToArrayImgWithDestIteration() { final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithDestIteration( intImg, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } @Test public void testCopyToListImgWithSourceIteration() { final ListImg< IntType > listImg = new ListImgFactory< IntType >().create( dimensions, new IntType() ); copyWithSourceIteration( intImg, listImg ); assertArrayEquals( intData, getImgAsInts( listImg ) ); } @Test public void testCopyToPlanarImgWithDestIteration() { final ListImg< IntType > listImg = new ListImgFactory< IntType >().create( dimensions, new IntType() ); copyWithDestIteration( intImg, listImg ); assertArrayEquals( intData, getImgAsInts( listImg ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/planar/000077500000000000000000000000001316447754700232455ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/planar/CopyTest.java000066400000000000000000000127511316447754700256700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import static org.junit.Assert.assertArrayEquals; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; import org.junit.Before; import org.junit.Test; /** * TODO * */ public class CopyTest { long[] dimensions; int numValues; int[] intData; long intDataSum; PlanarImg< IntType, ? > intImg; @Before public void createSourceData() { dimensions = new long[] { 48, 17, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new PlanarImgFactory< IntType >().create( dimensions, new IntType() ); final long[] pos = new long[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } } void copyWithDestIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final long[] pos = new long[ dstImg.numDimensions() ]; final Cursor< IntType > dst = dstImg.localizingCursor(); final RandomAccess< IntType > src = srcImg.randomAccess(); while ( dst.hasNext() ) { dst.fwd(); dst.localize( pos ); src.setPosition( pos ); dst.get().set( src.get() ); } } int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; } @Test public void testCopyToArrayContainerWithSourceIteration() { final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithSourceIteration( intImg, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } @Test public void testCopyToArrayContainerWithDestIteration() { final ArrayImg< IntType, ? > array = new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); copyWithDestIteration( intImg, array ); assertArrayEquals( intData, getImgAsInts( array ) ); } @Test public void testCopyToPlanarContainerWithSourceIteration() { final PlanarImg< IntType, ? > planarImg = new PlanarImgFactory< IntType >().create( dimensions, new IntType() ); copyWithSourceIteration( intImg, planarImg ); assertArrayEquals( intData, getImgAsInts( planarImg ) ); } @Test public void testCopyToPlanarContainerWithDestIteration() { final PlanarImg< IntType, ? > planarImg = new PlanarImgFactory< IntType >().create( dimensions, new IntType() ); copyWithDestIteration( intImg, planarImg ); assertArrayEquals( intData, getImgAsInts( planarImg ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/planar/PlanarImgTest.java000066400000000000000000000057431316447754700266330ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import static org.junit.Assert.assertTrue; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.ImgTestHelper; import net.imglib2.util.Util; import org.junit.Test; /** * Unit tests for {@link PlanarImg}. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Curtis Rueden */ public class PlanarImgTest { @Test public void testPlanarImg() { final long[][] dim = ImgTestHelper.dims(); for ( int i = 0; i < dim.length; ++i ) { assertTrue( "ArrayImg vs PlanarImg failed for dim = " + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new ArrayImgFactory< FloatType >(), new PlanarImgFactory< FloatType >() ) ); assertTrue( "PlanarImg vs ArrayImg failed for dim = " + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new PlanarImgFactory< FloatType >(), new ArrayImgFactory< FloatType >() ) ); assertTrue( "PlanarImg vs PlanarImg failed for dim = " + Util.printCoordinates( dim[ i ] ), ImgTestHelper.testImg( dim[ i ], new PlanarImgFactory< FloatType >(), new PlanarImgFactory< FloatType >() ) ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/planar/PlanarIterableSubIntervalCursorTest.java000066400000000000000000000150561316447754700332210ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.Interval; import net.imglib2.RandomAccess; import net.imglib2.img.AbstractSubIntervalIterableCursorTest; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; import net.imglib2.view.Views; import org.junit.Before; import org.junit.Test; public class PlanarIterableSubIntervalCursorTest extends AbstractSubIntervalIterableCursorTest< PlanarImg< IntType, ? > > { /** Interval for a single plane in img **/ protected Interval intervalSinglePlaneShifted; protected Interval intervalSinglePlaneFull; protected Interval intervalFastPart; int numValues; private FinalInterval intervalLine; @Before public void createSourceData() { dimensions = new long[] { 23, 31, 11, 7, 3 }; intervalLine = new FinalInterval( new long[] { 0, 12, 3, 5, 1 }, new long[] { dimensions[ 0 ] - 1, 13, 3, 5, 1 } ); intervalShifted = new FinalInterval( new long[] { 0, 0, 3, 5, 1 }, new long[] { dimensions[ 0 ] - 1, dimensions[ 1 ] - 1, 4, 5, 1 } ); intervalFast = new FinalInterval( new long[] { dimensions[ 0 ], dimensions[ 1 ], 5, 1, 1 } ); intervalFastPart = new FinalInterval( new long[] { dimensions[ 0 ], 2, 3, 1, 1 } ); intervalSinglePlaneShifted = new FinalInterval( new long[] { 0, 0, 3, 5, 1 }, new long[] { dimensions[ 0 ] - 1, dimensions[ 1 ] - 1, 3, 5, 1 } ); intervalSinglePlaneFull = new FinalInterval( new long[] { 0, 0, 1, 1, 1 }, new long[] { dimensions[ 0 ] - 1, dimensions[ 1 ] - 1, 1, 1, 1 } ); // create random data for all dims and fill the planar img numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); } img = ( PlanarImg< IntType, ? > ) new PlanarImgFactory< IntType >().create( dimensions, new IntType() ); long[] pos = new long[ dimensions.length ]; RandomAccess< IntType > a = img.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } /** * Test whether the correct cursors are created. */ @Test public void testOptimizable() { // Testing Cursor assertTrue( ( Views.interval( img, intervalSinglePlaneShifted ).cursor() instanceof PlanarPlaneSubsetCursor ) ); // Testing Localizing Cursor assertTrue( ( Views.interval( img, intervalSinglePlaneShifted ).localizingCursor() instanceof PlanarPlaneSubsetLocalizingCursor ) ); // Testing Cursor assertTrue( ( Views.interval( img, intervalSinglePlaneFull ).cursor() instanceof PlanarPlaneSubsetCursor ) ); // Testing Localizing Cursor assertTrue( ( Views.interval( img, intervalSinglePlaneFull ).localizingCursor() instanceof PlanarPlaneSubsetLocalizingCursor ) ); // Testing Cursor assertFalse( ( Views.interval( img, intervalFastPart ).cursor() instanceof PlanarPlaneSubsetCursor ) ); // Testing Localizing Cursor assertFalse( ( Views.interval( img, intervalFastPart ).localizingCursor() instanceof PlanarPlaneSubsetLocalizingCursor ) ); } @Test public void testIterationSinglePlane() { Cursor< IntType > cursor = Views.interval( img, intervalSinglePlaneFull ).cursor(); testCursorIteration( cursor, intervalSinglePlaneFull ); } @Test public void testIterationIntervalLine() { Cursor< IntType > cursor = Views.interval( img, intervalLine ).cursor(); testCursorIteration( cursor, intervalLine ); } @Test public void testIterationSinglePlaneShifted() { Cursor< IntType > cursor = Views.interval( img, intervalSinglePlaneShifted ).cursor(); testCursorIteration( cursor, intervalSinglePlaneShifted ); } @Test public void testJumpFwdSinglePlane() { Cursor< IntType > cursor = Views.interval( img, intervalSinglePlaneFull ).localizingCursor(); testCursorJumpFwd( cursor, intervalSinglePlaneFull ); } // Localizing cursor @Test public void testLocalizingtIterationSinglePlaneShifted() { Cursor< IntType > cursor = Views.interval( img, intervalSinglePlaneShifted ).localizingCursor(); testCursorIteration( cursor, intervalSinglePlaneShifted ); } @Test public void testLocalizingJumpFwdSinglePlane() { Cursor< IntType > cursor = Views.interval( img, intervalSinglePlaneFull ).localizingCursor(); testCursorJumpFwd( cursor, intervalSinglePlaneFull ); } @Test public void testLocalizingIterationSinglePlane() { Cursor< IntType > cursor = Views.interval( img, intervalSinglePlaneFull ).localizingCursor(); testCursorIteration( cursor, intervalSinglePlaneFull ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/planar/PlanarRandomAccessBenchmark.java000066400000000000000000000142651316447754700314330ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.planar; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; /** * TODO * */ public class PlanarRandomAccessBenchmark { long[] dimensions; int numValues; int[] intData; long intDataSum; PlanarImg< IntType, ? > intImg; Img< IntType > intImgCopy; public void createSourceData() { dimensions = new long[] { 480, 480, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new PlanarImgFactory< IntType >().create( dimensions, new IntType() ); } /** * Fill intImg (a CellContainer with 40x40x40 cells) with data using flat * array iteration order. */ public void fillImage() { final int[] pos = new int[ dimensions.length ]; final RandomAccess< IntType > a = intImg.randomAccess(); final int[] idim = new int[ dimensions.length ]; for ( int d = 0; d < dimensions.length; ++d ) idim[ d ] = ( int ) dimensions[ d ]; for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, idim, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } public void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final int[] pos = new int[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } } public static Long median( final ArrayList< Long > values ) { Collections.sort( values ); if ( values.size() % 2 == 1 ) return values.get( ( values.size() + 1 ) / 2 - 1 ); final long lower = values.get( values.size() / 2 - 1 ); final long upper = values.get( values.size() / 2 ); return ( lower + upper ) / 2; } public interface Benchmark { public void run(); } public static void benchmark( final Benchmark b ) { final ArrayList< Long > times = new ArrayList< Long >( 100 ); final int numRuns = 20; for ( int i = 0; i < numRuns; ++i ) { final long startTime = System.currentTimeMillis(); b.run(); final long endTime = System.currentTimeMillis(); times.add( endTime - startTime ); } for ( int i = 0; i < numRuns; ++i ) { System.out.println( "run " + i + ": " + times.get( i ) + " ms" ); } System.out.println(); System.out.println( "median: " + median( times ) + " ms" ); System.out.println(); } public static void main( final String[] args ) { final PlanarRandomAccessBenchmark randomAccessBenchmark = new PlanarRandomAccessBenchmark(); randomAccessBenchmark.createSourceData(); System.out.println( "benchmarking fill" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.fillImage(); } } ); randomAccessBenchmark.intData = null; randomAccessBenchmark.intImgCopy = new PlanarImgFactory< IntType >().create( randomAccessBenchmark.dimensions, new IntType() ); System.out.println( "benchmarking copy planar to planar" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); randomAccessBenchmark.intImgCopy = null; randomAccessBenchmark.intImgCopy = new ArrayImgFactory< IntType >().create( randomAccessBenchmark.dimensions, new IntType() ); System.out.println( "benchmarking copy planar to array" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImg, randomAccessBenchmark.intImgCopy ); } } ); System.out.println( "benchmarking copy array to planar" ); benchmark( new Benchmark() { @Override public void run() { randomAccessBenchmark.copyWithSourceIteration( randomAccessBenchmark.intImgCopy, randomAccessBenchmark.intImg ); } } ); randomAccessBenchmark.intImgCopy = null; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/sparse/000077500000000000000000000000001316447754700232655ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/img/sparse/NtreeTest.java000066400000000000000000000064701316447754700260540ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.img.sparse; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; /** * @author Tobias Pietzsch * */ public class NtreeTest { @Test public void test_getNode() { final int v = 10; final Ntree< Integer > t = new Ntree< Integer >( new long[] { 256, 257, 100 }, v ); final long[] pos = new long[] { 27, 38, 99 }; final Ntree.NtreeNode< Integer > n = t.getNode( pos ); assertTrue( n != null ); assertTrue( n.getValue() == v ); } @Test public void test_createNote() { final int v = 10; final Ntree< Integer > t = new Ntree< Integer >( new long[] { 256, 257, 100 }, v ); final long[] pos = new long[] { 27, 38, 99 }; final Ntree.NtreeNode< Integer > n = t.createNode( pos ); assertTrue( n != null ); assertTrue( n.getValue() == v ); n.setValue( v + 1 ); final long[] pos2 = new long[] { 28, 38, 99 }; final Ntree.NtreeNode< Integer > n2 = t.getNode( pos2 ); assertTrue( n2 != null ); assertTrue( n2.getValue() == v ); } @Test public void test_mergeUpwards() { final int v = 10; final Ntree< Integer > t = new Ntree< Integer >( new long[] { 256, 257, 100 }, v ); final long[] pos = new long[] { 27, 38, 99 }; t.createNode( pos ).setValue( v + 1 ); final Ntree.NtreeNode< Integer > n = t.getNode( pos ); assertTrue( n != null ); assertTrue( n.getValue() == v + 1 ); assertTrue( t.root.hasChildren() ); n.setValue( v ); t.mergeUpwards( n ); assertFalse( t.root.hasChildren() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/iterationorder/000077500000000000000000000000001316447754700242465ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/iterationorder/IterationOrderTests.java000066400000000000000000000060051316447754700310670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.iterationorder; import static org.junit.Assert.assertTrue; import net.imglib2.FinalInterval; import net.imglib2.FlatIterationOrder; import org.junit.Test; /** * Tests to check code of iteration orders * * @author Christian Dietz * */ public class IterationOrderTests { // Object to test FlatIterationOrder flatA = new FlatIterationOrder( new FinalInterval( new long[] { 10, 1, 20, 1, 1, 1, 30 } ) ); // Exactly the same FlatIterationOrder flatB = new FlatIterationOrder( new FinalInterval( new long[] { 10, 1, 20, 1, 1, 1, 30 } ) ); // Same if you remove dims of size one FlatIterationOrder flatC = new FlatIterationOrder( new FinalInterval( new long[] { 10, 20, 30 } ) ); // not the same FlatIterationOrder flatD = new FlatIterationOrder( new FinalInterval( new long[] { 10, 1, 10, 1, 1, 1, 10 } ) ); // not the same FlatIterationOrder flatE = new FlatIterationOrder( new FinalInterval( new long[] { 10, 10, 10 } ) ); @Test public void testFlatIterationOrder() { // the same assertTrue( flatA.equals( flatB ) ); assertTrue( flatA.equals( flatC ) ); // not the same assertTrue( !flatA.equals( flatD ) ); assertTrue( !flatA.equals( flatE ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/nearestneighbor/000077500000000000000000000000001316447754700243735ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/nearestneighbor/KDTreeTest.java000066400000000000000000000355721316447754700272300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.nearestneighbor; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Random; import net.imglib2.KDTree; import net.imglib2.RealPoint; import net.imglib2.neighborsearch.KNearestNeighborSearchOnKDTree; import net.imglib2.neighborsearch.NearestNeighborSearchOnKDTree; import net.imglib2.neighborsearch.RadiusNeighborSearchOnKDTree; import net.imglib2.util.ValuePair; import org.junit.Test; /** * TODO * */ public class KDTreeTest { protected static boolean testNearestNeighbor( final int numDimensions, final int numPoints, final int numTests, final float min, final float max ) { final ArrayList< RealPoint > points = new ArrayList< RealPoint >(); final Random rnd = new Random( 435435435 ); final float[] p = new float[ numDimensions ]; final float size = ( max - min ); for ( int i = 0; i < numPoints; ++i ) { for ( int d = 0; d < numDimensions; ++d ) p[ d ] = rnd.nextFloat() * size + min; final RealPoint t = new RealPoint( p ); points.add( t ); } long start = System.currentTimeMillis(); final KDTree< RealPoint > kdTree = new KDTree< RealPoint >( points, points ); final NearestNeighborSearchOnKDTree< RealPoint > kd = new NearestNeighborSearchOnKDTree< RealPoint >( kdTree ); final long kdSetupTime = System.currentTimeMillis() - start; System.out.println( "kdtree setup took: " + ( kdSetupTime ) + " ms." ); start = System.currentTimeMillis(); final ArrayList< RealPoint > testpoints = new ArrayList< RealPoint >(); for ( int i = 0; i < numTests; ++i ) { for ( int d = 0; d < numDimensions; ++d ) p[ d ] = rnd.nextFloat() * 2 * size + min - size / 2; final RealPoint t = new RealPoint( p ); testpoints.add( t ); } for ( final RealPoint t : testpoints ) { kd.search( t ); final RealPoint nnKdtree = kd.getSampler().get(); final RealPoint nnExhaustive = findNearestNeighborExhaustive( points, t ); boolean equal = true; for ( int d = 0; d < numDimensions; ++d ) if ( nnKdtree.getFloatPosition( d ) != nnExhaustive.getFloatPosition( d ) ) equal = false; if ( !equal ) { System.out.println( "Nearest neighbor to: " + t ); System.out.println( "KD-Tree says: " + nnKdtree ); System.out.println( "Exhaustive says: " + nnExhaustive ); return false; } } final long compareTime = System.currentTimeMillis() - start; System.out.println( "comparison (kdtree <-> exhaustive) search took: " + ( compareTime ) + " ms." ); start = System.currentTimeMillis(); for ( final RealPoint t : testpoints ) { kd.search( t ); final RealPoint nnKdtree = kd.getSampler().get(); nnKdtree.getClass(); } final long kdTime = System.currentTimeMillis() - start; System.out.println( "kdtree search took: " + ( kdTime ) + " ms." ); System.out.println( "kdtree all together took: " + ( kdSetupTime + kdTime ) + " ms." ); start = System.currentTimeMillis(); for ( final RealPoint t : testpoints ) { final RealPoint nnExhaustive = findNearestNeighborExhaustive( points, t ); nnExhaustive.getClass(); } final long exhaustiveTime = System.currentTimeMillis() - start; System.out.println( "exhaustive search took: " + ( exhaustiveTime ) + " ms." ); return true; } private static RealPoint findNearestNeighborExhaustive( final ArrayList< RealPoint > points, final RealPoint t ) { float minDistance = Float.MAX_VALUE; RealPoint nearest = null; final int n = t.numDimensions(); final float[] tpos = new float[ n ]; final float[] ppos = new float[ n ]; t.localize( tpos ); for ( final RealPoint p : points ) { p.localize( ppos ); float dist = 0; for ( int i = 0; i < n; ++i ) dist += ( tpos[ i ] - ppos[ i ] ) * ( tpos[ i ] - ppos[ i ] ); if ( dist < minDistance ) { minDistance = dist; nearest = p; } } return nearest; } protected static boolean testKNearestNeighbor( final int neighbors, final int numDimensions, final int numPoints, final int numTests, final float min, final float max ) { final ArrayList< RealPoint > points = new ArrayList< RealPoint >(); final Random rnd = new Random( 435435435 ); final float[] p = new float[ numDimensions ]; final float size = ( max - min ); for ( int i = 0; i < numPoints; ++i ) { for ( int d = 0; d < numDimensions; ++d ) p[ d ] = rnd.nextFloat() * size + min; final RealPoint t = new RealPoint( p ); points.add( t ); } long start = System.currentTimeMillis(); final KDTree< RealPoint > kdTree = new KDTree< RealPoint >( points, points ); final KNearestNeighborSearchOnKDTree< RealPoint > kd = new KNearestNeighborSearchOnKDTree< RealPoint >( kdTree, neighbors ); final long kdSetupTime = System.currentTimeMillis() - start; System.out.println( "kdtree setup took: " + ( kdSetupTime ) + " ms." ); start = System.currentTimeMillis(); final ArrayList< RealPoint > testpoints = new ArrayList< RealPoint >(); for ( int i = 0; i < numTests; ++i ) { for ( int d = 0; d < numDimensions; ++d ) p[ d ] = rnd.nextFloat() * 2 * size + min - size / 2; final RealPoint t = new RealPoint( p ); testpoints.add( t ); } final RealPoint[] nnKdtree = new RealPoint[ neighbors ]; for ( final RealPoint t : testpoints ) { kd.search( t ); for ( int i = 0; i < neighbors; ++i ) { nnKdtree[ i ] = kd.getSampler( i ).get(); } final RealPoint[] nnExhaustive = findKNearestNeighborExhaustive( points, t, neighbors ); for ( int i = 0; i < neighbors; ++i ) { boolean equal = true; for ( int d = 0; d < numDimensions; ++d ) if ( nnKdtree[ i ].getFloatPosition( d ) != nnExhaustive[ i ].getFloatPosition( d ) ) equal = false; if ( !equal ) { System.out.println( ( i + 1 ) + "-nearest neighbor to: " + t ); System.out.println( "KD-Tree says: " + nnKdtree[ i ] ); System.out.println( "Exhaustive says: " + nnExhaustive[ i ] ); return false; } } } final long compareTime = System.currentTimeMillis() - start; System.out.println( "comparison (kdtree <-> exhaustive) search took: " + ( compareTime ) + " ms." ); start = System.currentTimeMillis(); for ( final RealPoint t : testpoints ) { kd.search( t ); for ( int i = 0; i < neighbors; ++i ) { nnKdtree[ i ] = kd.getSampler( i ).get(); nnKdtree[ i ].getClass(); } } final long kdTime = System.currentTimeMillis() - start; System.out.println( "kdtree search took: " + ( kdTime ) + " ms." ); System.out.println( "kdtree all together took: " + ( kdSetupTime + kdTime ) + " ms." ); start = System.currentTimeMillis(); for ( final RealPoint t : testpoints ) { final RealPoint[] nnExhaustive = findKNearestNeighborExhaustive( points, t, neighbors ); nnExhaustive[ 0 ].getClass(); } final long exhaustiveTime = System.currentTimeMillis() - start; System.out.println( "exhaustive search took: " + ( exhaustiveTime ) + " ms." ); return true; } private static RealPoint[] findKNearestNeighborExhaustive( final ArrayList< RealPoint > points, final RealPoint t, final int k ) { final RealPoint[] nearest = new RealPoint[ k ]; final float[] minDistance = new float[ k ]; for ( int i = 0; i < k; ++i ) minDistance[ i ] = Float.MAX_VALUE; final int n = t.numDimensions(); final float[] tpos = new float[ n ]; final float[] ppos = new float[ n ]; t.localize( tpos ); for ( final RealPoint p : points ) { p.localize( ppos ); float dist = 0; for ( int i = 0; i < n; ++i ) dist += ( tpos[ i ] - ppos[ i ] ) * ( tpos[ i ] - ppos[ i ] ); if ( dist < minDistance[ k - 1 ] ) { int i = k - 1; for ( int j = i - 1; i > 0 && dist < minDistance[ j ]; --i, --j ) { minDistance[ i ] = minDistance[ j ]; nearest[ i ] = nearest[ j ]; } minDistance[ i ] = dist; nearest[ i ] = p; } } return nearest; } protected static boolean testRadiusNeighbor( final int numDimensions, final int numPoints, final int numTests, final float min, final float max ) { final ArrayList< RealPoint > points = new ArrayList< RealPoint >(); final Random rnd = new Random( 435435435 ); final float[] p = new float[ numDimensions ]; final float size = ( max - min ); for ( int i = 0; i < numPoints; ++i ) { for ( int d = 0; d < numDimensions; ++d ) p[ d ] = rnd.nextFloat() * size + min; final RealPoint t = new RealPoint( p ); points.add( t ); } final double radius = rnd.nextDouble() * size / 10; long start = System.currentTimeMillis(); final KDTree< RealPoint > kdTree = new KDTree< RealPoint >( points, points ); final RadiusNeighborSearchOnKDTree< RealPoint > kd = new RadiusNeighborSearchOnKDTree< RealPoint >( kdTree ); final long kdSetupTime = System.currentTimeMillis() - start; System.out.println( "kdtree setup took: " + ( kdSetupTime ) + " ms." ); start = System.currentTimeMillis(); final ArrayList< RealPoint > testpoints = new ArrayList< RealPoint >(); for ( int i = 0; i < numTests; ++i ) { for ( int d = 0; d < numDimensions; ++d ) p[ d ] = rnd.nextFloat() * 2 * size + min - size / 2; final RealPoint t = new RealPoint( p ); testpoints.add( t ); } for ( final RealPoint t : testpoints ) { kd.search( t, radius, true ); final int neighbors = kd.numNeighbors(); final ArrayList< ValuePair< RealPoint, Double > > radiusExhaustive = findNeighborsRadiusExhaustive( points, t, radius, true ); if ( neighbors != radiusExhaustive.size() ) return false; for ( int i = 0; i < neighbors; ++i ) { boolean equal = true; for ( int d = 0; d < numDimensions; ++d ) if ( kd.getPosition( i ).getFloatPosition( d ) != radiusExhaustive.get( i ).a.getFloatPosition( d ) ) equal = false; if ( !equal ) { System.out.println( ( i + 1 ) + "-radius neighbor to: " + t ); System.out.println( "KD-Tree says: " + kd.getPosition( i ) ); System.out.println( "Exhaustive says: " + radiusExhaustive.get( i ).a ); if ( kd.getDistance( i ) == radiusExhaustive.get( i ).b ) System.out.println( "different points but same distance" ); else return false; } } } final long compareTime = System.currentTimeMillis() - start; System.out.println( "comparison (kdtree <-> exhaustive) search took: " + ( compareTime ) + " ms." ); start = System.currentTimeMillis(); for ( final RealPoint t : testpoints ) { kd.search( t, radius, true ); final int neighbors = kd.numNeighbors(); for ( int i = 0; i < neighbors; ++i ) { kd.getSampler( i ).get().getClass(); } } final long kdTime = System.currentTimeMillis() - start; System.out.println( "kdtree search took: " + ( kdTime ) + " ms." ); System.out.println( "kdtree all together took: " + ( kdSetupTime + kdTime ) + " ms." ); start = System.currentTimeMillis(); for ( final RealPoint t : testpoints ) { final ArrayList< ValuePair< RealPoint, Double > > radiusExhaustive = findNeighborsRadiusExhaustive( points, t, radius, true ); if ( radiusExhaustive.size() > 0 ) radiusExhaustive.get( 0 ).getClass(); } final long exhaustiveTime = System.currentTimeMillis() - start; System.out.println( "exhaustive search took: " + ( exhaustiveTime ) + " ms." ); return true; } private static ArrayList< ValuePair< RealPoint, Double > > findNeighborsRadiusExhaustive( final ArrayList< RealPoint > points, final RealPoint t, final double radius, final boolean sortResults ) { final ArrayList< ValuePair< RealPoint, Double > > withinRadius = new ArrayList< ValuePair< RealPoint, Double > >(); final int n = t.numDimensions(); final float[] tpos = new float[ n ]; final float[] ppos = new float[ n ]; t.localize( tpos ); for ( final RealPoint p : points ) { p.localize( ppos ); double dist = 0; for ( int i = 0; i < n; ++i ) dist += ( tpos[ i ] - ppos[ i ] ) * ( tpos[ i ] - ppos[ i ] ); dist = Math.sqrt( dist ); if ( dist <= radius ) withinRadius.add( new ValuePair< RealPoint, Double >( p, dist ) ); } if ( sortResults ) { Collections.sort( withinRadius, new Comparator< ValuePair< RealPoint, Double > >() { @Override public int compare( final ValuePair< RealPoint, Double > o1, final ValuePair< RealPoint, Double > o2 ) { return Double.compare( o1.b, o2.b ); } } ); } return withinRadius; } @Test public void testKDTreeKNearestNeighborSearch() { assertTrue( testKNearestNeighbor( 3, 3, 1000, 100, -5, 5 ) ); } @Test public void testKDTreeNearestNeighborSearch() { assertTrue( testNearestNeighbor( 3, 1000, 100, -5, 5 ) ); } @Test public void testKDTreeRadiusNeighborSearch() { assertTrue( testRadiusNeighbor( 3, 1000, 100, -5, 5 ) ); } public static void main( final String[] args ) { for ( int i = 0; i < 5; ++i ) { if ( testKNearestNeighbor( 3, 3, 100000, 1000, -5, 5 ) ) System.out.println( "N-Nearest neighbor test (3) successfull\n" ); } for ( int i = 0; i < 5; ++i ) { if ( testNearestNeighbor( 3, 100000, 1000, -5, 5 ) ) System.out.println( "Nearest neighbor test successfull\n" ); } for ( int i = 0; i < 5; ++i ) { if ( testRadiusNeighbor( 3, 100000, 1000, -5, 5 ) ) System.out.println( "Radius neighbor test successfull\n" ); } } } NearestNeighborSearchOnIterableRealIntervalTest.java000066400000000000000000000076201316447754700365070ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/nearestneighbor/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.nearestneighbor; import static org.junit.Assert.assertTrue; import net.imglib2.RealCursor; import net.imglib2.RealLocalizable; import net.imglib2.RealPoint; import net.imglib2.RealPointSampleList; import net.imglib2.neighborsearch.KNearestNeighborSearchOnIterableRealInterval; import net.imglib2.type.numeric.real.DoubleType; import org.junit.Before; import org.junit.Test; /** * TODO * */ public class NearestNeighborSearchOnIterableRealIntervalTest { final static private RealPointSampleList< DoubleType > realPointSampleList = new RealPointSampleList< DoubleType >( 2 ); final static private double[][] coordinates = new double[][] { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } }; final static private double[] samples = new double[] { 0, 1, 2, 3 }; final static private boolean positionEquals( final RealLocalizable a, final RealLocalizable b ) { final int n = a.numDimensions(); if ( n != b.numDimensions() ) return false; for ( int d = 0; d < n; ++d ) { if ( a.getDoublePosition( d ) != b.getDoublePosition( d ) ) return false; } return true; } @Before public void init() { for ( int i = 0; i < samples.length; ++i ) realPointSampleList.add( new RealPoint( coordinates[ i ] ), new DoubleType( samples[ i ] ) ); } @Test public void testKNearestNeighborSearch() { final RealCursor< DoubleType > cursor = realPointSampleList.cursor(); final KNearestNeighborSearchOnIterableRealInterval< DoubleType > search1 = new KNearestNeighborSearchOnIterableRealInterval< DoubleType >( realPointSampleList, 1 ); search1.search( new RealPoint( new double[] { 0.1, 0.2 } ) ); assertTrue( "Position mismatch ", positionEquals( search1.getPosition( 0 ), new RealPoint( coordinates[ 0 ] ) ) ); assertTrue( "Sample mismatch ", search1.getSampler( 0 ).get() == cursor.next() ); search1.search( new RealPoint( new double[] { -1, 20 } ) ); assertTrue( "Position mismatch ", positionEquals( search1.getPosition( 0 ), new RealPoint( coordinates[ 1 ] ) ) ); assertTrue( "Sample mismatch ", search1.getSampler( 0 ).get() == cursor.next() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/outofbounds/000077500000000000000000000000001316447754700235635ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/outofbounds/OutOfBoundsBorderTest.java000066400000000000000000000326501316447754700306410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import static org.junit.Assert.assertEquals; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.Localizable; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.cell.CellImg; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.img.list.ListImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.view.ExtendedRandomAccessibleInterval; /** * * * @author Stephan Saalfeld * @author Tobias Pietzsch */ public class OutOfBoundsBorderTest { final private long[] dim = new long[] { 5, 4, 3 }; static private ArrayImg< IntType, ? > arrayImage; static private CellImg< IntType, ? > cellImage; static private Img< IntType > listImage; static private OutOfBounds< IntType > cArray; static private OutOfBounds< IntType > cCell; static private OutOfBounds< IntType > cList; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception {} /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception {} /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { arrayImage = new ArrayImgFactory< IntType >().create( dim, new IntType() ); cellImage = new CellImgFactory< IntType >( 2 ).create( dim, new IntType() ); listImage = new ListImgFactory< IntType >().create( dim, new IntType() ); int i = 0; for ( final IntType t : arrayImage ) t.set( i++ ); final int[] position = new int[ dim.length ]; for ( final Cursor< IntType > c = arrayImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } i = 0; for ( final IntType t : listImage ) t.set( i++ ); cArray = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( arrayImage, new OutOfBoundsBorderFactory< IntType, Img< IntType > >() ).randomAccess(); cCell = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( cellImage, new OutOfBoundsBorderFactory< IntType, Img< IntType > >() ).randomAccess(); cList = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( listImage, new OutOfBoundsBorderFactory< IntType, Img< IntType > >() ).randomAccess(); } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception {} final private boolean isOutOfBounds( final Localizable l ) { for ( int i = 0; i < dim.length; ++i ) if ( l.getIntPosition( i ) < 0 || l.getIntPosition( i ) >= dim[ i ] ) return true; return false; } @Test public void fwd() { final int[] expectedX = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; final int[] expectedY = new int[] { 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }; final int[] expectedZ = new int[] { 0, 0, 0, 0, 0, 20, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }; cArray.setPosition( -8, 0 ); cCell.setPosition( -8, 0 ); cList.setPosition( -8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 0 ); cCell.fwd( 0 ); cList.fwd( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( -6, 1 ); cCell.setPosition( -6, 1 ); cList.setPosition( -6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 1 ); cCell.fwd( 1 ); cList.fwd( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( -4, 2 ); cCell.setPosition( -4, 2 ); cList.setPosition( -4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "LinkContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "LinkContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 2 ); cCell.fwd( 2 ); cList.fwd( 2 ); } } @Test public void bck() { final int[] expectedX = new int[] { 4, 4, 4, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; final int[] expectedY = new int[] { 15, 15, 15, 15, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; final int[] expectedZ = new int[] { 40, 40, 40, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; cArray.setPosition( 8, 0 ); cCell.setPosition( 8, 0 ); cList.setPosition( 8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 0 ); cCell.bck( 0 ); cList.bck( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( 6, 1 ); cCell.setPosition( 6, 1 ); cList.setPosition( 6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 1 ); cCell.bck( 1 ); cList.bck( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( 4, 2 ); cCell.setPosition( 4, 2 ); cList.setPosition( 4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 2 ); cCell.bck( 2 ); cList.bck( 2 ); } } @Test public void move() { final int[] distance = new int[] { 0, 10, 6, -12, -5, 13, -5 }; final int[] d = new int[] { 0, 0, 1, 0, 1, 2, 2 }; final int[] v = new int[] { 33, 34, 39, 36, 36, 56, 56 }; final int[] start = new int[] { 3, 2, 1 }; cArray.setPosition( start ); cCell.setPosition( start ); cList.setPosition( start ); for ( int i = 0; i < d.length; ++i ) { cArray.move( distance[ i ], d[ i ] ); cCell.move( distance[ i ], d[ i ] ); cList.move( distance[ i ], d[ i ] ); assertEquals( "ArrayContainer move failed at iteration " + i + ".", v[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer move failed at iteration " + i + ".", v[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer move failed at iteration " + i + ".", v[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); } } @Test public void setPosition() { final int[] x = new int[] { 0, 1, 2, 3, 18, -9, 20 }; final int[] y = new int[] { 0, 0, 2, 3, 11, 12, -40 }; final int[] z = new int[] { 0, 0, 1, 2, 10, -13, -15 }; final int[] t = new int[] { 0, 1, 32, 58, 59, 15, 4 }; for ( int i = 0; i < x.length; ++i ) { cArray.setPosition( x[ i ], 0 ); cArray.setPosition( y[ i ], 1 ); cArray.setPosition( z[ i ], 2 ); cCell.setPosition( x[ i ], 0 ); cCell.setPosition( y[ i ], 1 ); cCell.setPosition( z[ i ], 2 ); cList.setPosition( x[ i ], 0 ); cList.setPosition( y[ i ], 1 ); cList.setPosition( z[ i ], 2 ); assertEquals( "ArrayContainer failed at " + cArray, cArray.get().getInteger(), t[ i ] ); assertEquals( "CellContainer failed at " + cCell, cCell.get().getInteger(), t[ i ] ); assertEquals( "ListContainer failed at " + cList, cList.get().getInteger(), t[ i ] ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/outofbounds/OutOfBoundsMirrorDoubleBoundaryTest.java000066400000000000000000000331561316447754700335370ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import static org.junit.Assert.assertEquals; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.Localizable; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.cell.CellImg; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.img.list.ListImgFactory; import net.imglib2.outofbounds.OutOfBoundsMirrorFactory.Boundary; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.view.ExtendedRandomAccessibleInterval; /** * * * @author Stephan Saalfeld */ public class OutOfBoundsMirrorDoubleBoundaryTest { final private long[] dim = new long[] { 5, 4, 3 }; static private ArrayImg< IntType, ? > arrayImage; static private CellImg< IntType, ? > cellImage; static private Img< IntType > listImage; static private OutOfBounds< IntType > cArray; static private OutOfBounds< IntType > cCell; static private OutOfBounds< IntType > cList; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception {} /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception {} /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { arrayImage = new ArrayImgFactory< IntType >().create( dim, new IntType() ); cellImage = new CellImgFactory< IntType >( 2 ).create( dim, new IntType() ); listImage = new ListImgFactory< IntType >().create( dim, new IntType() ); int i = 0; for ( final IntType t : arrayImage ) t.set( i++ ); final int[] position = new int[ dim.length ]; for ( final Cursor< IntType > c = arrayImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } i = 0; for ( final IntType t : listImage ) t.set( i++ ); cArray = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( arrayImage, new OutOfBoundsMirrorFactory< IntType, Img< IntType > >( Boundary.DOUBLE ) ).randomAccess(); cCell = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( cellImage, new OutOfBoundsMirrorFactory< IntType, Img< IntType > >( Boundary.DOUBLE ) ).randomAccess(); cList = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( listImage, new OutOfBoundsMirrorFactory< IntType, Img< IntType > >( Boundary.DOUBLE ) ).randomAccess(); } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception {} final private boolean isOutOfBounds( final Localizable l ) { for ( int i = 0; i < dim.length; ++i ) if ( l.getIntPosition( i ) < 0 || l.getIntPosition( i ) >= dim[ i ] ) return true; return false; } @Test public void fwd() { final int[] expectedX = new int[] { 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3 }; final int[] expectedY = new int[] { 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5 }; final int[] expectedZ = new int[] { 40, 40, 20, 0, 0, 20, 40, 40, 20, 0, 0, 20, 40, 40, 20, 0, 0, 20, 40, 40, 20, 0, 0, 20, 40, 40, 20 }; cArray.setPosition( -8, 0 ); cCell.setPosition( -8, 0 ); cList.setPosition( -8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 0 ); cCell.fwd( 0 ); cList.fwd( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( -6, 1 ); cCell.setPosition( -6, 1 ); cList.setPosition( -6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 1 ); cCell.fwd( 1 ); cList.fwd( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( -4, 2 ); cCell.setPosition( -4, 2 ); cList.setPosition( -4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "LinkContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "LinkContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 2 ); cCell.fwd( 2 ); cList.fwd( 2 ); } } @Test public void bck() { final int[] expectedX = new int[] { 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3 }; final int[] expectedY = new int[] { 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5 }; final int[] expectedZ = new int[] { 40, 40, 20, 0, 0, 20, 40, 40, 20, 0, 0, 20, 40, 40, 20, 0, 0, 20, 40, 40, 20, 0, 0, 20, 40, 40, 20 }; cArray.setPosition( 7, 0 ); cCell.setPosition( 7, 0 ); cList.setPosition( 7, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 0 ); cCell.bck( 0 ); cList.bck( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( 5, 1 ); cCell.setPosition( 5, 1 ); cList.setPosition( 5, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 1 ); cCell.bck( 1 ); cList.bck( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( 3, 2 ); cCell.setPosition( 3, 2 ); cList.setPosition( 3, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cArray.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 2 ); cCell.bck( 2 ); cList.bck( 2 ); } } @Test public void move() { final int[] distance = new int[] { 0, 10, 6, -12, -5, 13, -5 }; final int[] d = new int[] { 0, 0, 1, 0, 1, 2, 2 }; final int[] v = new int[] { 33, 33, 23, 21, 36, 56, 56 }; final int[] start = new int[] { 3, 2, 1 }; cArray.setPosition( start ); cCell.setPosition( start ); cList.setPosition( start ); for ( int i = 0; i < d.length; ++i ) { cArray.move( distance[ i ], d[ i ] ); cCell.move( distance[ i ], d[ i ] ); cList.move( distance[ i ], d[ i ] ); assertEquals( "ArrayContainer move failed at iteration " + i + ".", v[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer move failed at iteration " + i + ".", v[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer move failed at iteration " + i + ".", v[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); } } @Test public void setPosition() { final int[] x = new int[] { 0, 1, 2, 3, 18, -9, 20 }; final int[] y = new int[] { 0, 0, 2, 3, 11, 12, -40 }; final int[] z = new int[] { 0, 0, 1, 2, 10, -13, -15 }; final int[] t = new int[] { 0, 1, 32, 58, 36, 16, 40 }; for ( int i = 0; i < x.length; ++i ) { cArray.setPosition( x[ i ], 0 ); cArray.setPosition( y[ i ], 1 ); cArray.setPosition( z[ i ], 2 ); cCell.setPosition( x[ i ], 0 ); cCell.setPosition( y[ i ], 1 ); cCell.setPosition( z[ i ], 2 ); cList.setPosition( x[ i ], 0 ); cList.setPosition( y[ i ], 1 ); cList.setPosition( z[ i ], 2 ); assertEquals( "ArrayContainer failed at " + cArray, cArray.get().getInteger(), t[ i ] ); assertEquals( "CellContainer failed at " + cCell, cCell.get().getInteger(), t[ i ] ); assertEquals( "ListContainer failed at " + cList, cList.get().getInteger(), t[ i ] ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/outofbounds/OutOfBoundsMirrorSingleBoundaryTest.java000066400000000000000000000330201316447754700335340ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import static org.junit.Assert.assertEquals; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.Localizable; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.cell.CellImg; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.img.list.ListImgFactory; import net.imglib2.outofbounds.OutOfBoundsMirrorFactory.Boundary; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.view.ExtendedRandomAccessibleInterval; /** * * * @author Stephan Saalfeld */ public class OutOfBoundsMirrorSingleBoundaryTest { final private long[] dim = new long[] { 5, 4, 3 }; static private ArrayImg< IntType, ? > arrayImage; static private CellImg< IntType, ? > cellImage; static private Img< IntType > listImage; static private OutOfBounds< IntType > cArray; static private OutOfBounds< IntType > cCell; static private OutOfBounds< IntType > cList; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception {} /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception {} /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { arrayImage = new ArrayImgFactory< IntType >().create( dim, new IntType() ); cellImage = new CellImgFactory< IntType >( 2 ).create( dim, new IntType() ); listImage = new ListImgFactory< IntType >().create( dim, new IntType() ); int i = 0; for ( final IntType t : arrayImage ) t.set( i++ ); final int[] position = new int[ dim.length ]; for ( final Cursor< IntType > c = arrayImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } i = 0; for ( final IntType t : listImage ) t.set( i++ ); cArray = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( arrayImage, new OutOfBoundsMirrorFactory< IntType, Img< IntType > >( Boundary.SINGLE ) ).randomAccess(); cCell = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( cellImage, new OutOfBoundsMirrorFactory< IntType, Img< IntType > >( Boundary.SINGLE ) ).randomAccess(); cList = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( listImage, new OutOfBoundsMirrorFactory< IntType, Img< IntType > >( Boundary.SINGLE ) ).randomAccess(); } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception {} final private boolean isOutOfBounds( final Localizable l ) { for ( int i = 0; i < dim.length; ++i ) if ( l.getIntPosition( i ) < 0 || l.getIntPosition( i ) >= dim[ i ] ) return true; return false; } @Test public void fwd() { final int[] expectedX = new int[] { 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3 }; final int[] expectedY = new int[] { 0, 5, 10, 15, 10, 5, 0, 5, 10, 15, 10, 5, 0, 5, 10, 15, 10, 5, 0, 5 }; final int[] expectedZ = new int[] { 0, 20, 40, 20, 0, 20, 40, 20, 0, 20, 40, 20, 0, 20, 40, 20, 0, 20, 40, 20 }; cArray.setPosition( -8, 0 ); cCell.setPosition( -8, 0 ); cList.setPosition( -8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 0 ); cCell.fwd( 0 ); cList.fwd( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( -6, 1 ); cCell.setPosition( -6, 1 ); cList.setPosition( -6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 1 ); cCell.fwd( 1 ); cList.fwd( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( -4, 2 ); cCell.setPosition( -4, 2 ); cList.setPosition( -4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "LinkContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "LinkContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 2 ); cCell.fwd( 2 ); cList.fwd( 2 ); } } @Test public void bck() { final int[] expectedX = new int[] { 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3 }; final int[] expectedY = new int[] { 0, 5, 10, 15, 10, 5, 0, 5, 10, 15, 10, 5, 0, 5, 10, 15, 10, 5, 0, 5 }; final int[] expectedZ = new int[] { 0, 20, 40, 20, 0, 20, 40, 20, 0, 20, 40, 20, 0, 20, 40, 20, 0, 20, 40, 20 }; cArray.setPosition( 8, 0 ); cCell.setPosition( 8, 0 ); cList.setPosition( 8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 0 ); cCell.bck( 0 ); cList.bck( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( 6, 1 ); cCell.setPosition( 6, 1 ); cList.setPosition( 6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 1 ); cCell.bck( 1 ); cList.bck( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( 4, 2 ); cCell.setPosition( 4, 2 ); cList.setPosition( 4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 2 ); cCell.bck( 2 ); cList.bck( 2 ); } } @Test public void move() { final int[] distance = new int[] { 0, 10, 6, -12, -5, 13, -5 }; final int[] d = new int[] { 0, 0, 1, 0, 1, 2, 2 }; final int[] v = new int[] { 33, 33, 33, 31, 36, 56, 36 }; final int[] start = new int[] { 3, 2, 1 }; cArray.setPosition( start ); cCell.setPosition( start ); cList.setPosition( start ); for ( int i = 0; i < d.length; ++i ) { cArray.move( distance[ i ], d[ i ] ); cCell.move( distance[ i ], d[ i ] ); cList.move( distance[ i ], d[ i ] ); assertEquals( "ArrayContainer move failed at iteration " + i + ".", v[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer move failed at iteration " + i + ".", v[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer move failed at iteration " + i + ".", v[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); } } @Test public void setPosition() { final int[] x = new int[] { 0, 1, 2, 3, 18, -9, 20 }; final int[] y = new int[] { 0, 0, 2, 3, 11, 12, -40 }; final int[] z = new int[] { 0, 0, 1, 2, 10, -13, -15 }; final int[] t = new int[] { 0, 1, 32, 58, 47, 21, 34 }; for ( int i = 0; i < x.length; ++i ) { cArray.setPosition( x[ i ], 0 ); cArray.setPosition( y[ i ], 1 ); cArray.setPosition( z[ i ], 2 ); cCell.setPosition( x[ i ], 0 ); cCell.setPosition( y[ i ], 1 ); cCell.setPosition( z[ i ], 2 ); cList.setPosition( x[ i ], 0 ); cList.setPosition( y[ i ], 1 ); cList.setPosition( z[ i ], 2 ); assertEquals( "ArrayContainer failed at " + cArray, cArray.get().getInteger(), t[ i ] ); assertEquals( "CellContainer failed at " + cCell, cCell.get().getInteger(), t[ i ] ); assertEquals( "ListContainer failed at " + cList, cList.get().getInteger(), t[ i ] ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/outofbounds/OutOfBoundsPeriodicTest.java000066400000000000000000000326371316447754700311670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.outofbounds; import static org.junit.Assert.assertEquals; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.Localizable; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.cell.CellImg; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.img.list.ListImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.view.ExtendedRandomAccessibleInterval; /** * * * @author Stephan Saalfeld */ public class OutOfBoundsPeriodicTest { final private long[] dim = new long[] { 5, 4, 3 }; static private ArrayImg< IntType, ? > arrayImage; static private CellImg< IntType, ? > cellImage; static private Img< IntType > listImage; static private OutOfBounds< IntType > cArray; static private OutOfBounds< IntType > cCell; static private OutOfBounds< IntType > cList; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception {} /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception {} /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { arrayImage = new ArrayImgFactory< IntType >().create( dim, new IntType() ); cellImage = new CellImgFactory< IntType >( 2 ).create( dim, new IntType() ); listImage = new ListImgFactory< IntType >().create( dim, new IntType() ); int i = 0; for ( final IntType t : arrayImage ) t.set( i++ ); final int[] position = new int[ dim.length ]; for ( final Cursor< IntType > c = arrayImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); ) { c.fwd(); c.localize( position ); i = 0; for ( int d = dim.length - 1; d >= 0; --d ) i = i * ( int ) dim[ d ] + position[ d ]; c.get().setInteger( i ); } i = 0; for ( final IntType t : listImage ) t.set( i++ ); cArray = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( arrayImage, new OutOfBoundsPeriodicFactory< IntType, Img< IntType > >() ).randomAccess(); cCell = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( cellImage, new OutOfBoundsPeriodicFactory< IntType, Img< IntType > >() ).randomAccess(); cList = new ExtendedRandomAccessibleInterval< IntType, Img< IntType > >( listImage, new OutOfBoundsPeriodicFactory< IntType, Img< IntType > >() ).randomAccess(); } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception {} final private boolean isOutOfBounds( final Localizable l ) { for ( int i = 0; i < dim.length; ++i ) if ( l.getIntPosition( i ) < 0 || l.getIntPosition( i ) >= dim[ i ] ) return true; return false; } @Test public void fwd() { final int[] expectedX = new int[] { 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 }; final int[] expectedY = new int[] { 10, 15, 0, 5, 10, 15, 0, 5, 10, 15, 0, 5, 10, 15, 0, 5, 10, 15, 0, 5 }; final int[] expectedZ = new int[] { 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20 }; cArray.setPosition( -8, 0 ); cCell.setPosition( -8, 0 ); cList.setPosition( -8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 0 ); cCell.fwd( 0 ); cList.fwd( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( -6, 1 ); cCell.setPosition( -6, 1 ); cList.setPosition( -6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 1 ); cCell.fwd( 1 ); cList.fwd( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( -4, 2 ); cCell.setPosition( -4, 2 ); cList.setPosition( -4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "LinkContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "LinkContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.fwd( 2 ); cCell.fwd( 2 ); cList.fwd( 2 ); } } @Test public void bck() { final int[] expectedX = new int[] { 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4 }; final int[] expectedY = new int[] { 10, 5, 0, 15, 10, 5, 0, 15, 10, 5, 0, 15, 10, 5, 0, 15, 10, 5, 0, 15 }; final int[] expectedZ = new int[] { 20, 0, 40, 20, 0, 40, 20, 0, 40, 20, 0, 40, 20, 0, 40, 20, 0, 40, 20, 0 }; cArray.setPosition( 8, 0 ); cCell.setPosition( 8, 0 ); cList.setPosition( 8, 0 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer x failed at iteration " + i + ".", expectedX[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer x failed at iteration " + i + ".", expectedX[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer x failed at iteration " + i + ".", expectedX[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer x failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 0 ); cCell.bck( 0 ); cList.bck( 0 ); } cArray.setPosition( 0, 0 ); cCell.setPosition( 0, 0 ); cList.setPosition( 0, 0 ); cArray.setPosition( 6, 1 ); cCell.setPosition( 6, 1 ); cList.setPosition( 6, 1 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer y failed at iteration " + i + ".", expectedY[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer y failed at iteration " + i + ".", expectedY[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer y failed at iteration " + i + ".", expectedY[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer y failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 1 ); cCell.bck( 1 ); cList.bck( 1 ); } cArray.setPosition( 0, 1 ); cCell.setPosition( 0, 1 ); cList.setPosition( 0, 1 ); cArray.setPosition( 4, 2 ); cCell.setPosition( 4, 2 ); cList.setPosition( 4, 2 ); for ( int i = 0; i < 20; ++i ) { assertEquals( "ArrayContainer z failed at iteration " + i + ".", expectedZ[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer z failed at iteration " + i + ".", expectedZ[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer z failed at iteration " + i + ".", expectedZ[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); cArray.bck( 2 ); cCell.bck( 2 ); cList.bck( 2 ); } } @Test public void move() { final int[] distance = new int[] { 0, 10, 6, -12, -5, 13, -5 }; final int[] d = new int[] { 0, 0, 1, 0, 1, 2, 2 }; final int[] v = new int[] { 33, 33, 23, 21, 36, 56, 16 }; final int[] start = new int[] { 3, 2, 1 }; cArray.setPosition( start ); cCell.setPosition( start ); cList.setPosition( start ); for ( int i = 0; i < d.length; ++i ) { cArray.move( distance[ i ], d[ i ] ); cCell.move( distance[ i ], d[ i ] ); cList.move( distance[ i ], d[ i ] ); assertEquals( "ArrayContainer move failed at iteration " + i + ".", v[ i ], cArray.get().getInteger() ); assertEquals( "CellContainer move failed at iteration " + i + ".", v[ i ], cCell.get().getInteger() ); assertEquals( "ListContainer move failed at iteration " + i + ".", v[ i ], cList.get().getInteger() ); assertEquals( "ArrayContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cArray ), cArray.isOutOfBounds() ); assertEquals( "CellContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cCell ), cCell.isOutOfBounds() ); assertEquals( "ListContainer z failed isOutOfBounds() at iteration " + i + ".", isOutOfBounds( cList ), cList.isOutOfBounds() ); } } @Test public void setPosition() { final int[] x = new int[] { 0, 1, 2, 3, 18, -9, 20 }; final int[] y = new int[] { 0, 0, 2, 3, 11, 12, -40 }; final int[] z = new int[] { 0, 0, 1, 2, 10, -13, -15 }; final int[] t = new int[] { 0, 1, 32, 58, 38, 41, 0 }; for ( int i = 0; i < x.length; ++i ) { cArray.setPosition( x[ i ], 0 ); cArray.setPosition( y[ i ], 1 ); cArray.setPosition( z[ i ], 2 ); cCell.setPosition( x[ i ], 0 ); cCell.setPosition( y[ i ], 1 ); cCell.setPosition( z[ i ], 2 ); cList.setPosition( x[ i ], 0 ); cList.setPosition( y[ i ], 1 ); cList.setPosition( z[ i ], 2 ); assertEquals( "ArrayContainer failed at " + cArray, cArray.get().getInteger(), t[ i ] ); assertEquals( "CellContainer failed at " + cCell, cCell.get().getInteger(), t[ i ] ); assertEquals( "ListContainer failed at " + cList, cList.get().getInteger(), t[ i ] ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/position/000077500000000000000000000000001316447754700230605ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/position/transform/000077500000000000000000000000001316447754700250735ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/position/transform/FloorOffsetTest.java000066400000000000000000000423761316447754700310420ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.position.transform; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import net.imglib2.Point; import net.imglib2.RealPoint; import org.junit.Before; import org.junit.Test; /** * * * @author Stephan Saalfeld */ public class FloorOffsetTest { final private double[] singleRealLocations = new double[] { 0.1, 0.7, -0.1, -0.7, 0.2, 0.3, 0.3, 20.1, -13.5, 1, 1, -2.4 }; final private long[] singleLocations = new long[] { 1, 7, -1, -7, 2, 3, 3, 20, -135, 1, -1, -4 }; final private double[][] realLocations = new double[][] { { 0.1, 0.7, -0.1 }, { -0.7, 0.2, 0.3 }, { 0.3, 20.1, -13.5 }, { 1, 1, -2.4 } }; final private long[][] locations = new long[][] { { 1, 7, -1 }, { -7, 2, 3 }, { 3, 20, -135 }, { 1, -1, -4 } }; private double[] r; private RealPoint reference; private long[] t; private Point target; private long[] o; private Point offset; private double[] realLocation; private long[] location; private long[] referenceFloorOffset; private FloorOffset< Point > fo; @Before public void init() { r = new double[] { 1.54, -20.3, 100.4 }; reference = RealPoint.wrap( r ); t = new long[] { 3, 4, 5 }; target = Point.wrap( t ); o = new long[] { 1, -2, 3 }; offset = Point.wrap( o ); realLocation = new double[ 3 ]; location = new long[ 3 ]; referenceFloorOffset = new long[] { 2, -23, 103 }; fo = new FloorOffset< Point >( reference, target, offset ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#FloorOffset(net.imglib2.Localizable, long[])} * . */ @Test public void testFloorOffsetLocalizablePositionableLongArray() { new FloorOffset< Point >( target, o ); target.localize( location ); assertArrayEquals( location, o ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#FloorOffset(net.imglib2.Localizable, net.imglib2.Localizable)} * . */ @Test public void testFloorOffsetLocalizablePositionableLocalizable() { new FloorOffset< Point >( target, offset ); target.localize( location ); assertArrayEquals( location, o ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#FloorOffset(net.imglib2.RealLocalizable, net.imglib2.Localizable, long[])} * . */ @Test public void testFloorOffsetRealLocalizableLocalizablePositionableLongArray() { new FloorOffset< Point >( reference, target, o ); target.localize( location ); assertArrayEquals( location, referenceFloorOffset ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#FloorOffset(net.imglib2.RealLocalizable, net.imglib2.Localizable, net.imglib2.Localizable)} * . */ @Test public void testFloorOffsetRealLocalizableLocalizablePositionableLocalizable() { new FloorOffset< Point >( reference, target, offset ); target.localize( location ); assertArrayEquals( location, referenceFloorOffset ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#f(double, long)}. */ @Test public void testFDoubleLong() { assertEquals( FloorOffset.f( 1.5, 3 ), 4 ); assertEquals( FloorOffset.f( -1.5, 3 ), 1 ); assertEquals( FloorOffset.f( 1.5, -3 ), -2 ); assertEquals( FloorOffset.f( -1.5, -3 ), -5 ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#f(float, long)}. */ @Test public void testFFloatLong() { assertEquals( FloorOffset.f( 1.5f, 3 ), 4 ); assertEquals( FloorOffset.f( -1.5f, 3 ), 1 ); assertEquals( FloorOffset.f( 1.5f, -3 ), -2 ); assertEquals( FloorOffset.f( -1.5f, -3 ), -5 ); } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#move(float, int)}. */ @Test public void testMoveFloatInt() { for ( int d = 0; d < 3; ++d ) { double real = r[ d ]; long discrete = FloorOffset.f( real, o[ d ] ); for ( final double move : singleRealLocations ) { final float f = ( float ) move; real += f; discrete = FloorOffset.f( real, o[ d ] ); fo.move( ( float ) move, d ); assertEquals( fo.getDoublePosition( d ), real, 0.00001 ); assertEquals( target.getLongPosition( d ), discrete ); } } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#move(double, int)}. */ @Test public void testMoveDoubleInt() { for ( int d = 0; d < 3; ++d ) { double real = r[ d ]; long discrete = FloorOffset.f( real, o[ d ] ); for ( final double move : singleRealLocations ) { real += move; discrete = FloorOffset.f( real, o[ d ] ); fo.move( move, d ); assertEquals( fo.getDoublePosition( d ), real, 0.00001 ); assertEquals( target.getLongPosition( d ), discrete ); } } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#move(net.imglib2.RealLocalizable)} * . */ @Test public void testMoveRealLocalizable() { final double[] real = r.clone(); final long[] discrete = referenceFloorOffset.clone(); for ( final double[] move : realLocations ) { for ( int d = 0; d < move.length; ++d ) { real[ d ] += move[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.move( RealPoint.wrap( move ) ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#move(float[])}. */ @Test public void testMoveFloatArray() { final double[] real = r.clone(); final long[] discrete = referenceFloorOffset.clone(); for ( final double[] move : realLocations ) { final float[] f = new float[ move.length ]; for ( int d = 0; d < move.length; ++d ) { f[ d ] = ( float ) move[ d ]; real[ d ] += f[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.move( f ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#move(double[])}. */ @Test public void testMoveDoubleArray() { final double[] real = r.clone(); final long[] discrete = referenceFloorOffset.clone(); for ( final double[] move : realLocations ) { for ( int d = 0; d < move.length; ++d ) { real[ d ] += move[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.move( move ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#setPosition(net.imglib2.RealLocalizable)} * . */ @Test public void testSetPositionRealLocalizable() { final long[] discrete = referenceFloorOffset.clone(); for ( final double[] real : realLocations ) { for ( int d = 0; d < real.length; ++d ) discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); fo.setPosition( RealPoint.wrap( real ) ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#setPosition(float[])}. */ @Test public void testSetPositionFloatArray() { final long[] discrete = referenceFloorOffset.clone(); for ( final double[] real : realLocations ) { final float[] f = new float[ real.length ]; for ( int d = 0; d < real.length; ++d ) { f[ d ] = ( float ) real[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.setPosition( f ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#setPosition(double[])}. */ @Test public void testSetPositionDoubleArray() { final long[] discrete = referenceFloorOffset.clone(); for ( final double[] real : realLocations ) { for ( int d = 0; d < real.length; ++d ) discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); fo.setPosition( real ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#setPosition(float, int)} * . */ @Test public void testSetPositionFloatInt() { for ( int d = 0; d < 3; ++d ) { for ( final double real : singleRealLocations ) { final long discrete = FloorOffset.f( real, o[ d ] ); fo.setPosition( ( float ) real, d ); assertEquals( fo.getDoublePosition( d ), real, 0.00001 ); assertEquals( target.getLongPosition( d ), discrete ); } } } /** * Test method for * {@link net.imglib2.position.transform.FloorOffset#setPosition(double, int)} * . */ @Test public void testSetPositionDoubleInt() { for ( int d = 0; d < 3; ++d ) { for ( final double real : singleRealLocations ) { final long discrete = FloorOffset.f( real, o[ d ] ); fo.setPosition( real, d ); assertEquals( fo.getDoublePosition( d ), real, 0.00001 ); assertEquals( target.getLongPosition( d ), discrete ); } } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#bck(int)} * . */ @Test public void testBck() { for ( int d = 0; d < 3; ++d ) { fo.bck( d ); assertEquals( r[ d ] - 1, fo.getDoublePosition( d ), 0.00001 ); assertEquals( FloorOffset.f( r[ d ], o[ d ] ) - 1, target.getLongPosition( d ) ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#fwd(int)} * . */ @Test public void testFwd() { for ( int d = 0; d < 3; ++d ) { fo.fwd( d ); assertEquals( r[ d ] + 1, fo.getDoublePosition( d ), 0.00001 ); assertEquals( FloorOffset.f( r[ d ], o[ d ] ) + 1, target.getLongPosition( d ) ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#move(int, int)} * . */ @Test public void testMoveIntInt() { for ( int d = 0; d < 3; ++d ) { double real = r[ d ]; long discrete = FloorOffset.f( real, o[ d ] ); for ( final long move : singleLocations ) { final int f = ( int ) move; real += f; discrete = FloorOffset.f( real, o[ d ] ); fo.move( f, d ); assertEquals( fo.getDoublePosition( d ), real, 0.00001 ); assertEquals( target.getLongPosition( d ), discrete ); } } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#move(long, int)} * . */ @Test public void testMoveLongInt() { for ( int d = 0; d < 3; ++d ) { double real = r[ d ]; long discrete = FloorOffset.f( real, o[ d ] ); for ( final long move : singleLocations ) { real += move; discrete = FloorOffset.f( real, o[ d ] ); fo.move( move, d ); assertEquals( fo.getDoublePosition( d ), real, 0.00001 ); assertEquals( target.getLongPosition( d ), discrete ); } } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#move(net.imglib2.Localizable)} * . */ @Test public void testMoveLocalizable() { final double[] real = r.clone(); final long[] discrete = referenceFloorOffset.clone(); for ( final long[] move : locations ) { for ( int d = 0; d < move.length; ++d ) { real[ d ] += move[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.move( Point.wrap( move ) ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#move(int[])} * . */ @Test public void testMoveIntArray() { final double[] real = r.clone(); final long[] discrete = referenceFloorOffset.clone(); for ( final long[] move : locations ) { final int[] f = new int[ move.length ]; for ( int d = 0; d < move.length; ++d ) { f[ d ] = ( int ) move[ d ]; real[ d ] += f[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.move( f ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#move(long[])} * . */ @Test public void testMoveLongArray() { final double[] real = r.clone(); final long[] discrete = referenceFloorOffset.clone(); for ( final long[] move : locations ) { for ( int d = 0; d < move.length; ++d ) { real[ d ] += move[ d ]; discrete[ d ] = FloorOffset.f( real[ d ], o[ d ] ); } fo.move( move ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( discrete, location ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#setPosition(net.imglib2.Localizable)} * . */ @Test public void testSetPositionLocalizable() { final double[] real = r.clone(); for ( final long[] l : locations ) { for ( int d = 0; d < l.length; ++d ) real[ d ] = l[ d ]; fo.setPosition( Point.wrap( l ) ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( l, location ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#setPosition(int[])} * . */ @Test public void testSetPositionIntArray() { final double[] real = r.clone(); for ( final long[] l : locations ) { final int[] li = new int[ l.length ]; for ( int d = 0; d < l.length; ++d ) { real[ d ] = l[ d ]; li[ d ] = ( int ) l[ d ]; } fo.setPosition( li ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( l, location ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#setPosition(long[])} * . */ @Test public void testSetPositionLongArray() { final double[] real = r.clone(); for ( final long[] l : locations ) { for ( int d = 0; d < l.length; ++d ) real[ d ] = l[ d ]; fo.setPosition( l ); fo.localize( realLocation ); target.localize( location ); assertArrayEquals( real, realLocation, 0.00001 ); assertArrayEquals( l, location ); } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#setPosition(int, int)} * . */ @Test public void testSetPositionIntInt() { for ( int d = 0; d < 3; ++d ) { for ( final long l : singleLocations ) { fo.setPosition( ( int ) l, d ); assertEquals( fo.getDoublePosition( d ), l, 0.00001 ); assertEquals( target.getLongPosition( d ), l ); } } } /** * Test method for * {@link net.imglib2.position.transform.AbstractPositionableTransform#setPosition(long, int)} * . */ @Test public void testSetPositionLongInt() { for ( int d = 0; d < 3; ++d ) { for ( final long l : singleLocations ) { fo.setPosition( l, d ); assertEquals( fo.getDoublePosition( d ), l, 0.00001 ); assertEquals( target.getLongPosition( d ), l ); } } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/000077500000000000000000000000001316447754700232275ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/000077500000000000000000000000001316447754700246645ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/permutation/000077500000000000000000000000001316447754700272335ustar00rootroot00000000000000AbstractPermutationTransformTest.java000066400000000000000000000117621316447754700365550ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/permutation/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.permutation; import java.util.ArrayList; import java.util.Collections; import net.imglib2.Localizable; import net.imglib2.Positionable; import org.junit.Assert; import org.junit.Before; import org.junit.Test; /** * @author Philipp Hanslovsky * */ public class AbstractPermutationTransformTest { /** * Wrapper class for AbstractPermutatioTransform to test protected methods. */ public static class MockPermutation extends AbstractPermutationTransform { // test protected methods @Override public int apply( final int x ) { return super.apply( x ); } @Override public long applyChecked( final int x ) { return super.applyChecked( x ); } @Override public int applyInverse( final int y ) { return super.applyInverse( y ); } @Override public long applyInverseChecked( final int y ) { return super.applyInverseChecked( y ); } public MockPermutation( final int[] lut ) { super( lut ); } // ignore unimplemented methods @Override public void applyInverse( final long[] source, final long[] target ) { } @Override public void applyInverse( final int[] source, final int[] target ) { } @Override public void applyInverse( final Positionable source, final Localizable target ) { } @Override public MockPermutation inverse() { return new MockPermutation( this.inverseLut ); } @Override public int numSourceDimensions() { return 0; } @Override public int numTargetDimensions() { return 0; } @Override public void apply( final long[] source, final long[] target ) { } @Override public void apply( final int[] source, final int[] target ) { } @Override public void apply( final Localizable source, final Positionable target ) { } } private final int size = 200; private final int[] lut = new int[ this.size ]; private final int[] inv = new int[ this.size ]; /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { final ArrayList< Integer > al = new ArrayList< Integer >(); for ( int i = 0; i < this.size; ++i ) al.add( i ); Collections.shuffle( al ); for ( int i = 0; i < this.size; ++i ) { this.lut[ i ] = al.get( i ); this.inv[ this.lut[ i ] ] = i; } } @Test public void test() { final MockPermutation transform = new MockPermutation( this.lut ); final MockPermutation inverse = transform.inverse(); int resInt; long resLong; for ( int i = 0; i < this.size; ++i ) { resInt = transform.apply( i ); resLong = transform.applyChecked( i ); Assert.assertEquals( this.lut[ i ], resInt ); Assert.assertEquals( this.lut[ i ], resLong ); resInt = inverse.apply( transform.apply( i ) ); resLong = transform.apply( inverse.apply( i ) ); Assert.assertEquals( i, resInt ); Assert.assertEquals( i, resLong ); resInt = inverse.apply( i ); resLong = inverse.applyChecked( i ); Assert.assertEquals( this.inv[ i ], resInt ); Assert.assertEquals( this.inv[ i ], resLong ); } Assert.assertEquals( -Long.MAX_VALUE, transform.applyChecked( -1 ) ); Assert.assertEquals( Long.MAX_VALUE, transform.applyChecked( this.size + 1 ) ); } } PermutationTransformTest.java000066400000000000000000000132151316447754700350640ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/permutation/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.permutation; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.array.ArrayRandomAccess; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.numeric.integer.LongType; import net.imglib2.view.IntervalView; import net.imglib2.view.TransformView; import net.imglib2.view.Views; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; /** * * * @author Stephan Saalfeld * @author Philipp Hanslovsky */ public class PermutationTransformTest { final static Random rnd = new Random(); static long[] values; static int[] lut; static final int width = 5; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { PermutationTransformTest.values = new long[ PermutationTransformTest.width * PermutationTransformTest.width ]; for ( int i = 0; i < PermutationTransformTest.values.length; ++i ) PermutationTransformTest.values[ i ] = PermutationTransformTest.rnd.nextLong(); PermutationTransformTest.lut = new int[ PermutationTransformTest.width ]; final ArrayList< Integer > indices = new ArrayList< Integer >(); for ( int i = 0; i < PermutationTransformTest.width; ++i ) indices.add( i ); Collections.shuffle( indices ); for ( int i = 0; i < PermutationTransformTest.width; ++i ) PermutationTransformTest.lut[ i ] = indices.get( i ); } @Test public void test() { final ArrayImg< LongType, LongArray > img = ArrayImgs.longs( PermutationTransformTest.values, PermutationTransformTest.width, PermutationTransformTest.width ); final PermutationTransform t = new PermutationTransform( PermutationTransformTest.lut, 2, 2 ); final TransformView< LongType > bijectivePermutation = new TransformView< LongType >( img, t ); final TransformView< LongType > inverseBijectivePermutation = new TransformView< LongType >( bijectivePermutation, t.inverse() ); final IntervalView< LongType > viewTransformed = Views.permuteCoordinatesInverse( img, PermutationTransformTest.lut ); final IntervalView< LongType > identity = Views.permuteCoordinates( viewTransformed, PermutationTransformTest.lut ); final RandomAccess< LongType > reference = img.randomAccess(); final RandomAccess< LongType > result = Views.interval( inverseBijectivePermutation, img ).randomAccess(); for ( int i = 0; i < 1000; ++i ) { final long[] x = new long[] { PermutationTransformTest.rnd.nextInt( PermutationTransformTest.width ), PermutationTransformTest.rnd.nextInt( PermutationTransformTest.width ) }; reference.setPosition( x ); result.setPosition( x ); Assert.assertEquals( reference.get().get(), result.get().get() ); } { final Cursor< LongType > v = Views.flatIterable( viewTransformed ).cursor(); final Cursor< LongType > b = Views.flatIterable( Views.interval( bijectivePermutation, img ) ).cursor(); final Cursor< LongType > i = Views.flatIterable( identity ).cursor(); final ArrayRandomAccess< LongType > r = img.randomAccess(); while ( v.hasNext() ) { b.fwd(); v.fwd(); for ( int d = 0; d < r.numDimensions(); ++d ) r.setPosition( PermutationTransformTest.lut[ b.getIntPosition( d ) ], d ); // manually // permute // source // image // coordinate Assert.assertEquals( r.get().get(), b.get().get() ); Assert.assertEquals( b.get().get(), v.get().get() ); i.fwd(); r.setPosition( i ); Assert.assertEquals( r.get().get(), i.get().get() ); } } { int i = 0; for ( final LongType l : Views.flatIterable( Views.interval( inverseBijectivePermutation, img ) ) ) Assert.assertEquals( PermutationTransformTest.values[ i++ ], l.get() ); } } } SingleDimensionPermutationTransformTest.java000066400000000000000000000150041316447754700400720ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/permutation/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.permutation; import java.util.ArrayList; import java.util.Collections; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.img.array.ArrayCursor; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.array.ArrayRandomAccess; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.view.IntervalView; import net.imglib2.view.TransformView; import net.imglib2.view.Views; import org.junit.Assert; import org.junit.Before; import org.junit.Test; /** * @author Philipp Hanslovsky * */ public class SingleDimensionPermutationTransformTest { private final Random rng = new Random(); private final int width = 100; private final int height = 200; private final long[] dim = new long[] { this.width, this.height }; private final int d = 1; private final int size = ( int ) this.dim[ this.d ]; private final int nDim = this.dim.length; private final int[] lut = new int[ this.size ]; private final int[] inv = new int[ this.size ]; private final int nRandomReps = 1000; private final ArrayImg< IntType, IntArray > img = ArrayImgs.ints( this.dim ); /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { final ArrayList< Integer > al = new ArrayList< Integer >(); for ( int i = 0; i < this.size; ++i ) al.add( i ); Collections.shuffle( al ); for ( int i = 0; i < this.lut.length; ++i ) { this.lut[ i ] = al.get( i ); this.inv[ this.lut[ i ] ] = i; } for ( final IntType l : this.img ) l.set( this.rng.nextInt() ); } @Test public void test() { final SingleDimensionPermutationTransform transform = new SingleDimensionPermutationTransform( this.lut, this.nDim, this.nDim, this.d ); final SingleDimensionPermutationTransform inverse = transform.inverse(); final TransformView< IntType > transformed = new TransformView< IntType >( this.img, transform ); final TransformView< IntType > inversed = new TransformView< IntType >( transformed, inverse ); final IntervalView< IntType > viewTransformed = Views.permuteCoordinateInverse( this.img, this.lut, this.d ); final IntervalView< IntType > identity = Views.permuteCoordinates( viewTransformed, this.lut, this.d ); final ArrayCursor< IntType > ref = this.img.cursor(); final Cursor< IntType > res = Views.flatIterable( Views.interval( inversed, this.img ) ).cursor(); while ( ref.hasNext() ) Assert.assertEquals( ref.next().get(), res.next().get() ); final ArrayRandomAccess< IntType > raFwd = this.img.randomAccess(); final ArrayRandomAccess< IntType > raBck = this.img.randomAccess(); final ArrayRandomAccess< IntType > ra = this.img.randomAccess(); final long[] fwdLong = new long[ this.nDim ]; final long[] bckLong = new long[ this.nDim ]; final int[] fwdInt = new int[ this.nDim ]; final int[] bckInt = new int[ this.nDim ]; for ( int i = 0; i < this.nRandomReps; ++i ) { final int x = this.rng.nextInt( this.width ); final int y = this.rng.nextInt( this.width ); final int[] xyInt = new int[] { x, y }; final long[] xyLong = new long[] { x, y }; ra.setPosition( xyInt ); transform.apply( xyInt, fwdInt ); transform.apply( xyLong, fwdLong ); transform.apply( ra, raFwd ); transform.applyInverse( bckInt, xyInt ); transform.applyInverse( bckLong, xyLong ); transform.applyInverse( raBck, ra ); for ( int d = 0; d < this.nDim; ++d ) { final int fwdVal; final int bckVal; if ( d == this.d ) { fwdVal = this.lut[ xyInt[ d ] ]; bckVal = this.inv[ xyInt[ d ] ]; } else { fwdVal = xyInt[ d ]; bckVal = xyInt[ d ]; } Assert.assertEquals( fwdVal, fwdInt[ d ] ); Assert.assertEquals( bckVal, bckInt[ d ] ); Assert.assertEquals( fwdVal, fwdLong[ d ] ); Assert.assertEquals( bckVal, bckLong[ d ] ); Assert.assertEquals( fwdVal, raFwd.getIntPosition( d ) ); Assert.assertEquals( bckVal, raBck.getIntPosition( d ) ); } } { final Cursor< IntType > v = Views.flatIterable( viewTransformed ).cursor(); final Cursor< IntType > i = Views.flatIterable( identity ).cursor(); final ArrayRandomAccess< IntType > r = this.img.randomAccess(); final Cursor< IntType > t = Views.flatIterable( Views.interval( transformed, this.img ) ).cursor(); while ( t.hasNext() ) { t.fwd(); v.fwd(); r.setPosition( t ); r.setPosition( this.lut[ t.getIntPosition( this.d ) ], this.d ); Assert.assertEquals( r.get().get(), t.get().get() ); Assert.assertEquals( t.get().get(), v.get().get() ); i.fwd(); r.setPosition( i ); Assert.assertEquals( r.get().get(), i.get().get() ); } } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/shear/000077500000000000000000000000001316447754700257665ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/transform/integer/shear/ShearTransformTest.java000066400000000000000000000166741316447754700324450ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.transform.integer.shear; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.img.array.ArrayCursor; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.outofbounds.OutOfBounds; import net.imglib2.transform.integer.BoundingBox; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.view.ExtendedRandomAccessibleInterval; import net.imglib2.view.IntervalView; import net.imglib2.view.TransformView; import net.imglib2.view.Views; import org.junit.Assert; import org.junit.Before; import org.junit.Test; /** * @author Philipp Hanslovsky * */ public class ShearTransformTest { final private long[] dim = new long[] { 5, 6, 7, 8 }; final private int numDimensions = dim.length; final private ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( dim ); final private Random rng = new Random(); final private long[] zero = new long[ numDimensions ]; /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { for ( FloatType i : img ) i.set( rng.nextFloat() ); } @Test public void testIdentity() { for ( int source = 0; source < numDimensions; ++source ) { for ( int target = 0; target < numDimensions; ++ target ) { if ( target == source ) continue; ShearTransform tf = new ShearTransform( numDimensions, target, source ); AbstractShearTransform iv = tf.inverse(); TransformView transformed = new TransformView< FloatType >( new TransformView< FloatType >( img, iv ), tf ); ArrayCursor i = img.cursor(); Cursor t = Views.flatIterable( Views.interval( transformed, img ) ).cursor(); while( t.hasNext() ) { Assert.assertTrue( i.hasNext() ); Assert.assertEquals( i.next().get(), t.next().get(), 0.0f ); } Assert.assertFalse( i.hasNext() ); } } } @Test public void testTransform() { for ( int source = 0; source < numDimensions; ++source ) { for ( int target = 0; target < numDimensions; ++ target ) { if ( target == source ) continue; ShearTransform tf = new ShearTransform( numDimensions, target, source ); AbstractShearTransform iv = tf.inverse(); ExtendedRandomAccessibleInterval> extended = Views.extendValue( img, new FloatType( Float.NaN ) ); TransformView transformed = new TransformView< FloatType >( extended, iv ); BoundingBox boundingBox = new BoundingBox( img ); tf.transform( boundingBox ); IntervalView viewTransformed = Views.shear( extended, img, target, source ); // BoundingBox holds max, and not max + 1; need to account for that by adding 1+1; Assert.assertEquals( dim[ target ] + dim[ source ], boundingBox.corner2[ target ] + 2 ); FinalInterval interval = new FinalInterval( boundingBox.corner1, boundingBox.corner2 ); OutOfBounds i = extended.randomAccess(); Cursor t = Views.flatIterable( Views.interval( transformed, interval ) ).cursor(); Cursor v = Views.flatIterable( viewTransformed ).cursor(); Assert.assertEquals( interval.numDimensions(), viewTransformed.numDimensions() ); for ( int d = 0; d < interval.numDimensions(); ++d ) Assert.assertEquals( interval.dimension( d ), viewTransformed.dimension( d ) ); while( t.hasNext() ) { t.fwd(); v.fwd(); i.setPosition( t ); i.setPosition( i.getLongPosition( target ) - i.getLongPosition( source ), target ); Assert.assertEquals( i.get().get(), t.get().get(), 0.0f ); Assert.assertEquals( t.get().get(), v.get().get(), 0.0f ); } } } } @Test public void testInverseTransform() { for ( int source = 0; source < numDimensions; ++source ) { for ( int target = 0; target < numDimensions; ++ target ) { if ( target == source ) continue; ShearTransform tf = new ShearTransform( numDimensions, target, source ); AbstractShearTransform iv = tf.inverse(); ExtendedRandomAccessibleInterval> extended = Views.extendValue( img, new FloatType( Float.NaN ) ); TransformView transformed = new TransformView< FloatType >( extended, tf ); BoundingBox boundingBox = new BoundingBox( img ); iv.transform( boundingBox ); IntervalView viewTransformed = Views.unshear( extended, img, target, source ); // BoundingBox holds max, and not max + 1; need to account for that by subtracting 1 (zero stays the same); Assert.assertEquals( zero[ target ] - dim[ source ], boundingBox.corner1[ target ] - 1 ); FinalInterval interval = new FinalInterval( boundingBox.corner1, boundingBox.corner2 ); OutOfBounds i = extended.randomAccess(); Cursor t = Views.flatIterable( Views.interval( transformed, interval ) ).cursor(); Cursor v = Views.flatIterable( viewTransformed ).cursor(); Assert.assertEquals( interval.numDimensions(), viewTransformed.numDimensions() ); for ( int d = 0; d < interval.numDimensions(); ++d ) Assert.assertEquals( interval.dimension( d ), viewTransformed.dimension( d ) ); while( t.hasNext() ) { t.fwd(); v.fwd(); i.setPosition( t ); i.setPosition( i.getLongPosition( target ) + i.getLongPosition( source ), target ); Assert.assertEquals( i.get().get(), t.get().get(), 0.0f ); Assert.assertEquals( t.get().get(), v.get().get(), 0.0f ); } } } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/000077500000000000000000000000001316447754700221755ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/logic/000077500000000000000000000000001316447754700232725ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/logic/BitTypeTest.java000066400000000000000000000253351316447754700263650ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ /** * */ package net.imglib2.type.logic; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.math.BigInteger; import java.util.Random; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.basictypeaccess.array.LongArray; import net.imglib2.type.logic.BitType; import org.junit.BeforeClass; import org.junit.Test; /** * @author Stephan Saalfeld * @author Stephan Preibisch * @author Tobias Pietzsch */ public class BitTypeTest { static ArrayImg< BitType, LongArray > img; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { img = ArrayImgs.bits( 10, 20, 30 ); } /** * Test method for {@link net.imglib2.type.logic.BitType#setOne()}. */ @Test public void testSetOne() { for ( final BitType t : img ) t.setOne(); for ( final BitType t : img ) assertTrue( t.get() ); } /** * Test method for {@link net.imglib2.type.logic.BitType#setZero()}. */ @Test public void testSetZero() { for ( final BitType t : img ) t.setZero(); for ( final BitType t : img ) assertTrue( !t.get() ); } /** * Test method for {@link net.imglib2.type.logic.BitType#setOne()}. */ @Test public void testSetOneAndZero() { final Random rnd = new Random( 0 ); for ( final BitType t : img ) { final boolean b = rnd.nextBoolean(); t.set( b ); assertTrue( t.get() == b ); } } /** * Tests that {@link BitType#getBigInteger()} returns the BigInteger * representation of a BitType. */ @Test public void testGetBigInteger() { final BitType l = new BitType(false); assertEquals( BigInteger.ZERO, l.getBigInteger() ); } /** * Tests {@link BitType#setBigInteger(BigInteger)} and ensures that the value * returned is within BitType range. */ @Test public void testSetBigInteger() { final BitType ul = new BitType( false ); assertEquals( ul.get(), false ); final BigInteger bi = new BigInteger( "AAAAAA3141343BBBBBBBBBBB4134", 16 ); ul.setBigInteger( bi ); assertEquals( ul.get(), true ); } // /** // * Test method for {@link net.imglib2.type.logic.BitType#toString()}. // */ // @Test // public void testToString() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#inc()}. // */ // @Test // public void testInc() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#dec()}. // */ // @Test // public void testDec() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#BitType(net.imglib2.img.NativeImg)}. // */ // @Test // public void testBitTypeNativeImgOfBitTypeQextendsLongAccess() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#BitType(boolean)}. // */ // @Test // public void testBitTypeBoolean() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#BitType(net.imglib2.img.basictypeaccess.LongAccess)}. // */ // @Test // public void testBitTypeLongAccess() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#BitType()}. // */ // @Test // public void testBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#createSuitableNativeImg(net.imglib2.img.NativeImgFactory, long[])}. // */ // @Test // public void testCreateSuitableNativeImg() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#updateContainer(java.lang.Object)}. // */ // @Test // public void testUpdateContainer() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#duplicateTypeOnSameNativeImg()}. // */ // @Test // public void testDuplicateTypeOnSameNativeImg() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#get()}. // */ // @Test // public void testGet() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#set(boolean)}. // */ // @Test // public void testSetBoolean() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getInteger()}. // */ // @Test // public void testGetInteger() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getIntegerLong()}. // */ // @Test // public void testGetIntegerLong() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#setInteger(int)}. // */ // @Test // public void testSetIntegerInt() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#setInteger(long)}. // */ // @Test // public void testSetIntegerLong() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getMaxValue()}. // */ // @Test // public void testGetMaxValue() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getMinValue()}. // */ // @Test // public void testGetMinValue() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#set(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testSetBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#and(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testAnd() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#or(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testOr() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#xor(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testXor() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#not()}. // */ // @Test // public void testNot() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#add(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testAddBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#div(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testDivBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#mul(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testMulBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#sub(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testSubBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#compareTo(net.imglib2.type.logic.BitType)}. // */ // @Test // public void testCompareToBitType() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#createVariable()}. // */ // @Test // public void testCreateVariable() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#copy()}. // */ // @Test // public void testCopy() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getEntitiesPerPixel()}. // */ // @Test // public void testGetEntitiesPerPixel() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#updateIndex(int)}. // */ // @Test // public void testUpdateIndex() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getIndex()}. // */ // @Test // public void testGetIndex() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#incIndex()}. // */ // @Test // public void testIncIndex() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#incIndex(int)}. // */ // @Test // public void testIncIndexInt() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#decIndex()}. // */ // @Test // public void testDecIndex() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#decIndex(int)}. // */ // @Test // public void testDecIndexInt() { // fail("Not yet implemented"); // } // // /** // * Test method for {@link net.imglib2.type.logic.BitType#getBitsPerPixel()}. // */ // @Test // public void testGetBitsPerPixel() { // fail("Not yet implemented"); // } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/000077500000000000000000000000001316447754700236375ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/complex/000077500000000000000000000000001316447754700253065ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/complex/ComplexDoubleTypeTest.java000066400000000000000000000061751316447754700324260ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.complex; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; /** * Tests {@link ComplexFloatType}. * * @author Curtis Rueden */ public class ComplexDoubleTypeTest { /** * Tests {@link ComplexDoubleType#equals(Object)}. */ @Test public void testEquals() { final ComplexDoubleType b = new ComplexDoubleType( 1.234, 5.678 ); // non-matching types and values final ComplexFloatType i = new ComplexFloatType( 8.765f, 4.321f ); assertFalse( b.equals( i ) ); assertFalse( i.equals( b ) ); // non-matching types final ComplexFloatType i2 = new ComplexFloatType( 1.234f, 5.678f ); assertFalse( b.equals( i2 ) ); assertFalse( i2.equals( b ) ); // non-matching values final ComplexDoubleType i3 = new ComplexDoubleType( 8.765, 4.321 ); assertFalse( b.equals( i3 ) ); assertFalse( i3.equals( b ) ); // matching type and value final ComplexDoubleType i4 = new ComplexDoubleType( 1.234, 5.678 ); assertTrue( b.equals( i4 ) ); assertTrue( i4.equals( b ) ); } /** Tests {@link ComplexDoubleType#hashCode()}. */ @Test public void testHashCode() { final ComplexDoubleType b = new ComplexDoubleType( 1.234, 5.678 ); assertEquals( 379318760, b.hashCode() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/complex/ComplexFloatTypeTest.java000066400000000000000000000061721316447754700322560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.complex; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; /** * Tests {@link ComplexFloatType}. * * @author Curtis Rueden */ public class ComplexFloatTypeTest { /** * Tests {@link ComplexFloatType#equals(Object)}. */ @Test public void testEquals() { final ComplexFloatType b = new ComplexFloatType( 1.234f, 5.678f ); // non-matching types and values final ComplexDoubleType i = new ComplexDoubleType( 8.765, 4.321 ); assertFalse( b.equals( i ) ); assertFalse( i.equals( b ) ); // non-matching types final ComplexDoubleType i2 = new ComplexDoubleType( 1.234, 5.678 ); assertFalse( b.equals( i2 ) ); assertFalse( i2.equals( b ) ); // non-matching values final ComplexFloatType i3 = new ComplexFloatType( 8.765f, 4.321f ); assertFalse( b.equals( i3 ) ); assertFalse( i3.equals( b ) ); // matching type and value final ComplexFloatType i4 = new ComplexFloatType( 1.234f, 5.678f ); assertTrue( b.equals( i4 ) ); assertTrue( i4.equals( b ) ); } /** Tests {@link ComplexFloatType#hashCode()}. */ @Test public void testHashCode() { final ComplexFloatType b = new ComplexFloatType( 1.234f, 5.678f ); assertEquals( 535103539, b.hashCode() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/000077500000000000000000000000001316447754700252745ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/ByteTypeTest.java000066400000000000000000000054441316447754700305530ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class ByteTypeTest { /** * Test which verifies {@link ByteType#getBigInteger()} returns the * {@code BigInteger} representation of a ByteType. */ @Test public void testGetBigInteger() { final ByteType l = new ByteType( (byte) 124 ); assertEquals( BigInteger.valueOf( 124l ), l.getBigInteger() ); final ByteType l2 = new ByteType( (byte) -18 ); assertEquals( BigInteger.valueOf( -18l ) , l2.getBigInteger() ); } /** * Test which verifies {@link ByteType#setBigInteger(BigInteger)} can set * ByteTypes with a {@code BigInteger} and still return a {@code byte} value. */ @Test public void testSetBigInteger() { final ByteType l = new ByteType( (byte) 93 ); assertEquals( l.get(), (byte) 93 ); final BigInteger bi = BigInteger.valueOf( -71l ); l.setBigInteger( bi ); assertEquals( l.get(), (byte) -71 ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/IntTypeTest.java000066400000000000000000000054211316447754700303750ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class IntTypeTest { /** * Test which verifies {@link IntType#getBigInteger()} returns the * {@code BigInteger} representation of an IntType. */ @Test public void testGetBigInteger() { final IntType l = new IntType( 10948 ); assertEquals( BigInteger.valueOf( 10948l ), l.getBigInteger() ); final IntType l2 = new IntType( -40913824 ); assertEquals( BigInteger.valueOf( -40913824l ) , l2.getBigInteger() ); } /** * Test which verifies {@link IntType#setBigInteger(BigInteger)} * can set IntTypes with a {@code BigInteger} and still return an * {@code int} value. */ @Test public void testSetBigInteger() { final IntType l = new IntType( 0 ); assertEquals( l.get(), 0 ); final BigInteger bi = BigInteger.valueOf( 7987431l ); l.setBigInteger( bi ); assertEquals( l.get(), 7987431 ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/LongTypeTest.java000066400000000000000000000054631316447754700305500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class LongTypeTest { /** * Test which verifies {@link LongType#getBigInteger()} returns the * {@code BigInteger} representation of an LongType. */ @Test public void testGetBigInteger() { final LongType l = new LongType( 901374907l ); assertEquals( BigInteger.valueOf( 901374907l ), l.getBigInteger() ); final LongType l2 = new LongType( -98174938174l ); assertEquals( BigInteger.valueOf( -98174938174l ) , l2.getBigInteger() ); } /** * Test which verifies {@link LongType#setBigInteger(BigInteger)} can set * LongTypes with a {@code BigInteger} and still return a {@code long} value. */ @Test public void testSetBigInteger() { final LongType l = new LongType( 72l ); assertEquals( l.get(), 72l ); final BigInteger bi = BigInteger.valueOf( 1093840120l ); l.setBigInteger( bi ); assertEquals( l.get(), 1093840120l ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/ShortTypeTest.java000066400000000000000000000112201316447754700307340ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; /** * Tests for {@link ShortType} functionality. * * @author Gabe Selzer * */ public class ShortTypeTest { /** * Test which verifies {@link ShortType#getBigInteger()} returns the * {@code BigInteger} representation of a ShortType. */ @Test public void testGetBigInteger() { final ShortType l = new ShortType( ( short ) 31498 ); assertEquals( BigInteger.valueOf( 31498l ), l.getBigInteger() ); final ShortType l2 = new ShortType( ( short ) -24691 ); assertEquals( BigInteger.valueOf( -24691l ), l2.getBigInteger() ); } /** * Test which verifies {@link ShortType#setBigInteger(BigInteger)} can set * ShortTypes with a {@code BigInteger} and still return a {@code short} * value. */ @Test public void testSetBigInteger() { final ShortType l = new ShortType( ( short ) 1082 ); assertEquals( l.get(), ( short ) 1082 ); final BigInteger bi = BigInteger.valueOf( 48906l ); l.setBigInteger( bi ); assertEquals( l.get(), ( short ) -16630 ); } /** * Test which verifies {@link ShortType#add(ShortType)} */ @Test public void testAdd() { final ShortType l = new ShortType( ( short ) 20000 ); l.add( new ShortType( ( short ) 5 ) ); assertEquals( l.get(), ( short ) 20005 ); final ShortType m = new ShortType( Short.MAX_VALUE ); m.add( new ShortType( ( short ) 1 ) ); assertEquals( m.get(), Short.MIN_VALUE ); } /** * Test which verifies {@link ShortType#sub(ShortType)} */ @Test public void testSub() { final ShortType l = new ShortType( ( short ) 20000 ); l.sub( new ShortType( ( short ) 5 ) ); assertEquals( l.get(), ( short ) 19995 ); final ShortType m = new ShortType( Short.MIN_VALUE ); m.sub( new ShortType( ( short ) 1 ) ); assertEquals( m.get(), Short.MAX_VALUE ); } /** * Test which verifies {@link ShortType#mul(ShortType)} */ @Test public void testMul() { final ShortType l = new ShortType( ( short ) 125 ); l.mul( new ShortType( ( short ) 5 ) ); assertEquals( l.get(), ( short ) 625 ); final ShortType m = new ShortType( ( short ) 16384 ); m.mul( new ShortType( ( short ) 2 ) ); assertEquals( m.get(), Short.MIN_VALUE ); } /** * Test which verifies {@link ShortType#div(ShortType)} */ @Test public void testDiv() { final ShortType l = new ShortType( ( short ) 125 ); l.div( new ShortType( ( short ) 5 ) ); assertEquals( l.get(), ( short ) 25 ); final ShortType m = new ShortType( ( short ) 17 ); m.div( new ShortType( ( short ) 2 ) ); assertEquals( m.get(), ( short ) 8 ); } @Test( expected = ArithmeticException.class ) public void testDivByZero() { final ShortType n = new ShortType( ( short ) 17 ); n.div( new ShortType( ( short ) 0 ) ); assertEquals( n.get(), ( short ) 8 ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/Unsigned128BitTypeTest.java000066400000000000000000000124171316447754700323140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.*; import java.math.BigInteger; import java.util.Random; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import org.junit.BeforeClass; import org.junit.Test; public class Unsigned128BitTypeTest { static ArrayImg< Unsigned128BitType, ? > img; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { img = new ArrayImgFactory< Unsigned128BitType >().create( new long[]{ 10, 20, 30 }, new Unsigned128BitType() ); } /** * Tests {@link Unsigned128BitType#set(BigInteger)} with random values. */ @Test public void testSetRandom() { final Random rnd = new Random( 4096 ); for ( final Unsigned128BitType t : img ) { final long v1 = Math.abs( rnd.nextLong() ); final long v2 = Math.abs( rnd.nextLong() ); final BigInteger b = new BigInteger( v1 + "" + v2 ); t.set( b ); assertTrue( t.get().compareTo( b ) == 0 ); } } /** * Regression test that verifies small {@link BigInteger} values work as * expected when passed to * {@link Unsigned128BitType#Unsigned128BitType(BigInteger)}. */ @Test public void testSmallBigIntegerValues() { final BigInteger b = BigInteger.valueOf( 329l ); final Unsigned128BitType u = new Unsigned128BitType( b ); assertEquals( b, u.get() ); } /** * Tests {@link Unsigned128BitType#equals(Object)}. */ @Test public void testEquals() { final Unsigned128BitType b = new Unsigned128BitType( BigInteger.valueOf( 908742l ) ); // non-matching types and values final UnsignedIntType i = new UnsignedIntType( 127l ); assertFalse( b.equals( i ) ); assertFalse( i.equals( b ) ); // non-matching types final UnsignedIntType i2 = new UnsignedIntType( 908742l ); assertFalse( b.equals( i2 ) ); assertFalse( i2.equals( b ) ); // non-matching values final Unsigned128BitType i3 = new Unsigned128BitType( BigInteger.valueOf( 127l ) ); assertFalse( b.equals( i3 ) ); assertFalse( i3.equals( b ) ); // matching type and value final Unsigned128BitType i4 = new Unsigned128BitType( BigInteger.valueOf( 908742l ) ); assertTrue( b.equals( i4 ) ); assertTrue( i4.equals( b ) ); } /** Tests {@link Unsigned128BitType#hashCode()}. */ @Test public void testHashCode() { final Unsigned128BitType b = new Unsigned128BitType( BigInteger.valueOf( 908742l ) ); assertEquals( 908742, b.hashCode() ); } /** * Test which verifies {@link Unsigned128BitType#getBigInteger()} returns the * {@code BigInteger} representation of an Unsigned128BitType. */ @Test public void testGetBigInteger() { final BigInteger bi = new BigInteger("CAFE123498230498CAFE", 16); final Unsigned128BitType l = new Unsigned128BitType( bi ); assertEquals( bi, l.getBigInteger() ); final BigInteger bi2 = BigInteger.valueOf( -279l ); final Unsigned128BitType l2 = new Unsigned128BitType( bi2 ); assertEquals( BigInteger.valueOf( 65257l ), l2.getBigInteger() ); } /** * Test which verifies {@link Unsigned128BitType#setBigInteger(BigInteger)} * can set Unsigned128BitTypes with a {@code BigInteger} and still return an * {@code int} value. */ @Test public void testSetBigInteger() { final BigInteger b = new BigInteger("BABE09481BEEF", 16); final Unsigned128BitType l = new Unsigned128BitType( b ); assertEquals( l.get(), b ); final BigInteger bi = BigInteger.valueOf( 7987431l ); l.setBigInteger( bi ); assertEquals( l.get(), bi ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/Unsigned12BitTypeTest.java000066400000000000000000000112211316447754700322140ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.math.BigInteger; import java.util.Random; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import org.junit.BeforeClass; import org.junit.Test; public class Unsigned12BitTypeTest { static ArrayImg< Unsigned12BitType, ? > img; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { img = new ArrayImgFactory< Unsigned12BitType >().create( new long[]{ 10, 20, 30 }, new Unsigned12BitType() ); } /** * Test method for {@link net.imglib2.type.numeric.integer.Unsigned12BitType}. */ @Test public void testSetRandom() { final Random rnd = new Random( 4096 ); for ( final Unsigned12BitType t : img ) { final int v = rnd.nextInt( 16 ); t.set( v ); assertTrue( t.get() == v ); } } /** * Test which verifies {@link Unsigned12BitType#getBigInteger()} returns the * {@code BigInteger} representation of an Unsigned12BitType. */ @Test public void testGetBigInteger() { final Unsigned12BitType l = new Unsigned12BitType( 300l ); assertEquals( BigInteger.valueOf( 300l ), l.getBigInteger() ); final Unsigned12BitType l2 = new Unsigned12BitType( 5700l ); assertEquals( BigInteger.valueOf( 1604l ) , l2.getBigInteger() ); } /** * Test which verifies {@link Unsigned12BitType#setBigInteger(BigInteger)} * can set Unsigned12BitTypes with a {@code BigInteger} and still return an * {@code int} value that is in the proper range. */ @Test public void testSetBigInteger() { final Unsigned12BitType l = new Unsigned12BitType( 1029l ); assertEquals( l.get(), 1029l ); final BigInteger bi = BigInteger.valueOf( -122l ); l.setBigInteger( bi ); assertEquals( l.get(), 3974l ); } /** * Tests {@link Unsigned12BitType#equals(Object)}. */ @Test public void testEquals() { final Unsigned12BitType b = new Unsigned12BitType( 3526l ); // non-matching types and values final UnsignedIntType i = new UnsignedIntType( 127l ); assertFalse( b.equals( i ) ); assertFalse( i.equals( b ) ); // non-matching types final UnsignedIntType i2 = new UnsignedIntType( 3526l ); assertFalse( b.equals( i2 ) ); assertFalse( i2.equals( b ) ); // non-matching values final Unsigned12BitType i3 = new Unsigned12BitType( 127l ); assertFalse( b.equals( i3 ) ); assertFalse( i3.equals( b ) ); // matching type and value final Unsigned12BitType i4 = new Unsigned12BitType( 3526l ); assertTrue( b.equals( i4 ) ); assertTrue( i4.equals( b ) ); } /** Tests {@link Unsigned12BitType#hashCode()}. */ @Test public void testHashCode() { final Unsigned12BitType b = new Unsigned12BitType( 3526l ); assertEquals( 3526, b.hashCode() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/Unsigned2BitTypeTest.java000066400000000000000000000111511316447754700321350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.math.BigInteger; import java.util.Random; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import org.junit.BeforeClass; import org.junit.Test; public class Unsigned2BitTypeTest { static ArrayImg< Unsigned2BitType, ? > img; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { img = new ArrayImgFactory< Unsigned2BitType >().create( new long[]{ 10, 20, 30 }, new Unsigned2BitType() ); } /** * Test method for {@link net.imglib2.type.numeric.integer.Unsigned2BitType}. */ @Test public void testSetRandom() { final Random rnd = new Random( 0 ); for ( final Unsigned2BitType t : img ) { final int v = rnd.nextInt( 4 ); t.set( v ); assertTrue( t.get() == v ); } } /** * Test which verifies {@link Unsigned2BitType#getBigInteger()} returns the * {@code BigInteger} representation of an Unsigned2BitType. */ @Test public void testGetBigInteger() { final Unsigned2BitType l = new Unsigned2BitType( 2 ); assertEquals( BigInteger.valueOf( 2l ), l.getBigInteger() ); final Unsigned2BitType l2 = new Unsigned2BitType( 0l ); assertEquals( BigInteger.ZERO , l2.getBigInteger() ); } /** * Test which verifies {@link Unsigned2BitType#setBigInteger(BigInteger)} * can set Unsigned2BitTypes with a {@code BigInteger} and still return an * {@code int} value that is in the proper range. */ @Test public void testSetBigInteger() { final Unsigned2BitType l = new Unsigned2BitType( 10l ); assertEquals( l.get(), 2l ); final BigInteger bi = BigInteger.valueOf( -122l ); l.setBigInteger( bi ); assertEquals( l.get(), 2l ); } /** * Tests {@link Unsigned2BitType#equals(Object)}. */ @Test public void testEquals() { final Unsigned2BitType b = new Unsigned2BitType( 3l ); // non-matching types and values final UnsignedIntType i = new UnsignedIntType( 1l ); assertFalse( b.equals( i ) ); assertFalse( i.equals( b ) ); // non-matching types final UnsignedIntType i2 = new UnsignedIntType( 3l ); assertFalse( b.equals( i2 ) ); assertFalse( i2.equals( b ) ); // non-matching values final Unsigned2BitType i3 = new Unsigned2BitType( 1l ); assertFalse( b.equals( i3 ) ); assertFalse( i3.equals( b ) ); // matching type and value final Unsigned2BitType i4 = new Unsigned2BitType( 3l ); assertTrue( b.equals( i4 ) ); assertTrue( i4.equals( b ) ); } /** Tests {@link Unsigned2BitType#hashCode()}. */ @Test public void testHashCode() { for (int i = 0; i < 4; i++) { final Unsigned2BitType b = new Unsigned2BitType( i ); assertEquals( i, b.hashCode() ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/Unsigned4BitTypeTest.java000066400000000000000000000111671316447754700321460ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.math.BigInteger; import java.util.Random; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import org.junit.BeforeClass; import org.junit.Test; public class Unsigned4BitTypeTest { static ArrayImg< Unsigned4BitType, ? > img; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { img = new ArrayImgFactory< Unsigned4BitType >().create( new long[]{ 10, 20, 30 }, new Unsigned4BitType() ); } /** * Test method for {@link net.imglib2.type.numeric.integer.Unsigned4BitType}. */ @Test public void testSetRandom() { final Random rnd = new Random( 0 ); for ( final Unsigned4BitType t : img ) { final int v = rnd.nextInt( 16 ); t.set( v ); assertTrue( t.get() == v ); } } /** * Test which verifies {@link Unsigned4BitType#getBigInteger()} returns the * {@code BigInteger} representation of an Unsigned4BitType. */ @Test public void testGetBigInteger() { final Unsigned4BitType l = new Unsigned4BitType( 14l ); assertEquals( BigInteger.valueOf( 14l ), l.getBigInteger() ); final Unsigned4BitType l2 = new Unsigned4BitType( -7l ); assertEquals( BigInteger.valueOf( 9l ) , l2.getBigInteger() ); } /** * Test which verifies {@link Unsigned4BitType#setBigInteger(BigInteger)} * can set Unsigned4BitType with a {@code BigInteger} and still return an * {@code int} value that is in the proper range. */ @Test public void testSetBigInteger() { final Unsigned4BitType l = new Unsigned4BitType( 4l ); assertEquals( l.get(), 4l ); final BigInteger bi = BigInteger.valueOf( 163l ); l.setBigInteger( bi ); assertEquals( l.get(), 3l ); } /** * Tests {@link Unsigned4BitType#equals(Object)}. */ @Test public void testEquals() { final Unsigned4BitType b = new Unsigned4BitType( 13l ); // non-matching types and values final UnsignedIntType i = new UnsignedIntType( 2l ); assertFalse( b.equals( i ) ); assertFalse( i.equals( b ) ); // non-matching types final UnsignedIntType i2 = new UnsignedIntType( 13l ); assertFalse( b.equals( i2 ) ); assertFalse( i2.equals( b ) ); // non-matching values final Unsigned4BitType i3 = new Unsigned4BitType( 2l ); assertFalse( b.equals( i3 ) ); assertFalse( i3.equals( b ) ); // matching type and value final Unsigned4BitType i4 = new Unsigned4BitType( 13l ); assertTrue( b.equals( i4 ) ); assertTrue( i4.equals( b ) ); } /** Tests {@link Unsigned4BitType#hashCode()}. */ @Test public void testHashCode() { for (int i = 0; i < 16; i++) { final Unsigned4BitType b = new Unsigned4BitType( i ); assertEquals( i, b.hashCode() ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/UnsignedByteTypeTest.java000066400000000000000000000075751316447754700322570ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class UnsignedByteTypeTest { /** * Regression test that verifies in range int values work as expected when * passed to {@link UnsignedByteType#UnsignedByteType(int)}. */ @Test public void testInRangeValues() { final int i = 126; final UnsignedByteType u = new UnsignedByteType( i ); assertEquals( i, u.get() ); u.set( 0 ); assertEquals( 0, u.get() ); u.set( 5 ); assertEquals( 5, u.get() ); } /** * Regression test that verifies that an int which is greater than 256 works * as expected when passed to {@link UnsignedByteType#UnsignedByteType(int)}. */ @Test public void testPositiveOutOfRangeValue() { final int i = 1027; final UnsignedByteType u = new UnsignedByteType( i ); assertEquals( 3, u.get() ); } /** * Regression test that verifies that a negative value works as * expected when passed to {@link UnsignedByteType#UnsignedByteType(int)}. */ @Test public void testNegativeOutOfRangeValue() { final int i = -212; final UnsignedByteType u = new UnsignedByteType( i ); assertEquals( 44, u.get() ); } /** * Test which verifies {@link UnsignedByteType#getBigInteger()} returns the * {@code BigInteger} representation of an UnsignedByteType. */ @Test public void testGetBigInteger() { final UnsignedByteType l = new UnsignedByteType( 255 ); assertEquals( BigInteger.valueOf( 255l ), l.getBigInteger() ); final UnsignedByteType l2 = new UnsignedByteType( -127 ); assertEquals( BigInteger.valueOf( 129l ) , l2.getBigInteger() ); } /** * Test which verifies {@link UnsignedByteType#setBigInteger(BigInteger)} can * set UnsignedByteTypes with a {@code BigInteger} and still return an the * proper {@code int} value. */ @Test public void testSetBigInteger() { final UnsignedByteType l = new UnsignedByteType( 255 ); assertEquals( l.get(), 255 ); final BigInteger bi = BigInteger.valueOf( 400l ); l.setBigInteger( bi ); assertEquals( l.get(), 144 ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/UnsignedIntTypeTest.java000066400000000000000000000077161316447754700321030ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class UnsignedIntTypeTest { /** * Regression test that verifies in range long values work as expected when * passed to {@link UnsignedIntType#UnsignedIntType(long)}. */ @Test public void testInRangeValues() { final long l = 9823409L; final UnsignedIntType u = new UnsignedIntType( l ); assertEquals( l, u.get() ); u.set( 0L ); assertEquals( 0L, u.get() ); u.set( 120L ); assertEquals( 120L, u.get() ); } /** * Regression test that verifies that an long which is greater than * 0xffffffffL works as expected when passed to * {@link UnsignedIntType#UnsignedIntType(long)}. */ @Test public void testPositiveOutOfRangeValue() { final long l = 4294967299L; final UnsignedIntType u = new UnsignedIntType( l ); assertEquals( 3L, u.get() ); } /** * Regression test that verifies that a negative value works as * expected when passed to {@link UnsignedIntType#UnsignedIntType(long)}. */ @Test public void testNegativeOutOfRangeValue() { final long l = -2038L; final UnsignedIntType u = new UnsignedIntType( l ); assertEquals( 4294965258L, u.get() ); } /** * Test which verifies {@link UnsignedIntType#getBigInteger()} returns the * {@code BigInteger} representation of an UnsignedIntType. */ @Test public void testGetBigInteger() { final UnsignedIntType l = new UnsignedIntType( 120345l ); assertEquals( BigInteger.valueOf( 120345l ), l.getBigInteger() ); final UnsignedIntType l2 = new UnsignedIntType( -1209843l ); assertEquals( BigInteger.valueOf( 4293757453l ) , l2.getBigInteger() ); } /** * Test which verifies {@link UnsignedIntType#setBigInteger(BigInteger)} * can set UnsignedIntTypes with a {@code BigInteger} and still return a * {@code long} value within the proper range. */ @Test public void testSetBigInteger() { final UnsignedIntType l = new UnsignedIntType( 6943 ); assertEquals( l.get(), 6943 ); final BigInteger bi = BigInteger.valueOf( 400984314908l ); l.setBigInteger( bi ); assertEquals( l.get(), 1552356380l ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/UnsignedLongTypeTest.java000066400000000000000000000123131316447754700322350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.junit.Test; public class UnsignedLongTypeTest { private UnsignedLongType u = new UnsignedLongType(); private UnsignedLongType t = new UnsignedLongType(); /** Tests that {@link UnsignedLongType#compareTo(UnsignedLongType)} works for * comparing a positive number to a negative number and vice versa. */ @Test public void testComparePosNeg(){ u.set( -1L ); t.set( 1L ); assertTrue( u.compareTo( t ) >= 1 ); u.set( 9223372036854775807L ); t.set( -9223372036854775808L ); assertTrue( u.compareTo( t ) <= -1 ); u.set( -109817491384701984L ); t.set( 12L ); assertTrue( u.compareTo( t ) >= 1 ); } /** Tests that {@link UnsignedLongType#compareTo(UnsignedLongType)} works for * comparing two negative numbers. */ @Test public void testCompareNegatives(){ u.set( -9000L ); t.set( -9000L ); assertEquals( u.compareTo( t ), 0 ); u.set( -16L ); t.set( -10984012840123984L ); assertTrue( u.compareTo( t ) >= 1 ); u.set( -500L ); t.set( -219L ); assertTrue( u.compareTo( t ) <= -1 ); } /** Tests that {@link UnsignedLongType#compareTo(UnsignedLongType)} works for * comparing two positive numbers. */ @Test public void testComparePositives(){ u.set( 100L ); t.set( 100L ); assertEquals( u.compareTo( t ), 0); u.set( 3098080948019L ); t.set( 1L ); assertTrue( u.compareTo( t ) >= 1 ); u.set( 199L ); t.set( 299L ); assertTrue( u.compareTo( t ) <= -1 ); } /** Tests that {@link UnsignedLongType#compareTo(UnsignedLongType)} works * when comparing values to zero. */ @Test public void testCompareZero() { u.set( 0L ); t.set( 0L ); assertEquals( u.compareTo( t ), 0 ); u.set( -17112921L ); t.set( 0L ); assertTrue( u.compareTo( t ) >= 1 ); u.set( 0L ); t.set( 698L ); assertTrue( u.compareTo( t ) <= -1 ); } /** * Tests {@link UnsignedLongType#UnsignedLongType(BigInteger)} works for out * of range values. */ @Test public void testBIConstructor() { final BigInteger bi = new BigInteger( "ABCD14984904EFEFEFE4324904294D17A", 16 ); final UnsignedLongType l = new UnsignedLongType( bi ); assertEquals( bi.longValue(), l.get() ); } /** * Tests that {@link UnsignedLongType#getBigInteger()} returns the unsigned * representation of an {@link UnsignedLongType} regardless of if it was * constructed with a {@code long} or a {@code BigInteger}. */ @Test public void testGetBigInteger() { final BigInteger mask = new BigInteger( "FFFFFFFFFFFFFFFF", 16 ); final BigInteger bi = new BigInteger( "DEAD12345678BEEF", 16 ); final UnsignedLongType l = new UnsignedLongType( bi ); assertEquals( bi.and( mask ), l.getBigInteger() ); final UnsignedLongType l2 = new UnsignedLongType( -473194873871904l ); assertEquals(BigInteger.valueOf( -473194873871904l ).and( mask ), l2.getBigInteger() ); } /** * Tests that {@link UnsignedLongType#setBigInteger(BigInteger)} works and * can still return the proper long value. */ @Test public void testSetBigInteger() { final long l = -184713894790123847l; final UnsignedLongType ul = new UnsignedLongType( l ); assertEquals( ul.get(), l ); final BigInteger bi = new BigInteger( "AAAAAA3141343BBBBBBBBBBB4134", 16 ); ul.setBigInteger( bi ); assertEquals( ul.get(), bi.longValue() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/UnsignedShortTypeTest.java000066400000000000000000000076531316447754700324500ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class UnsignedShortTypeTest { /** * Regression test that verifies in range int values work as expected when * passed to {@link UnsignedShortType#UnsignedShortType(int)}. */ @Test public void testInRangeValues() { final int i = 6004; final UnsignedShortType u = new UnsignedShortType( i ); assertEquals( i, u.get() ); u.set( 0 ); assertEquals( 0, u.get() ); u.set( 34 ); assertEquals( 34, u.get() ); } /** * Regression test that verifies that an int which is greater than 65535 works * as expected when passed to {@link UnsignedShortType#UnsignedShortType(int)}. */ @Test public void testPositiveOutOfRangeValue() { final int i = 78098; final UnsignedShortType u = new UnsignedShortType( i ); assertEquals( 12562, u.get() ); } /** * Regression test that verifies that a negative value works as * expected when passed to {@link UnsignedShortType#UnsignedShortType(int)}. */ @Test public void testNegativeOutOfRangeValue() { final int i = -597; final UnsignedShortType u = new UnsignedShortType( i ); assertEquals( 64939, u.get() ); } /** * Test which verifies {@link UnsignedShortType#getBigInteger()} returns the * {@code BigInteger} representation of an UnsignedShortType. */ @Test public void testGetBigInteger() { final UnsignedShortType l = new UnsignedShortType( 1000 ); assertEquals( BigInteger.valueOf( 1000l ), l.getBigInteger() ); final UnsignedShortType l2 = new UnsignedShortType( 32001 ); assertEquals( BigInteger.valueOf( 32001l ) , l2.getBigInteger() ); } /** * Test which verifies {@link UnsignedShortType#setBigInteger(BigInteger)} * can set UnsignedShortTypes with a {@code BigInteger} and still return an * {@code int} value within range. */ @Test public void testSetBigInteger() { final UnsignedShortType l = new UnsignedShortType( 93 ); assertEquals( l.get(), 93 ); final BigInteger bi = BigInteger.valueOf( -33125l ); l.setBigInteger( bi ); assertEquals( l.get(), 32411 ); } } UnsignedVariableBitLengthTypeTest.java000066400000000000000000000065461316447754700346200ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/type/numeric/integer/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.type.numeric.integer; import static org.junit.Assert.assertEquals; import java.math.BigInteger; import org.junit.Test; public class UnsignedVariableBitLengthTypeTest { /** * Test which verifies {@link UnsignedVariableBitLengthType#getBigInteger()} * returns the {@code BigInteger} representation of an * UnsignedVariableBitLengthType. */ @Test public void testGetBigInteger() { final UnsignedVariableBitLengthType l = new UnsignedVariableBitLengthType( 1234l, 16 ); assertEquals( BigInteger.valueOf( 1234l ), l.getBigInteger() ); final UnsignedVariableBitLengthType l2 = new UnsignedVariableBitLengthType( -196, 8); assertEquals( BigInteger.valueOf( 60l ), l2.getBigInteger() ); final UnsignedVariableBitLengthType l3 = new UnsignedVariableBitLengthType( -9223372036854775807l, 64 ); assertEquals( BigInteger.valueOf( -9223372036854775807l ).and( new BigInteger("FFFFFFFFFFFFFFFF", 16) ), l3.getBigInteger() ); } /** * Test which verifies * {@link UnsignedVariableBitLengthType#setBigInteger(BigInteger)} can set * UnsignedVariableBitLengthTypes with a {@code BigInteger} and still return * a {@code long} value that is in the correct range. */ @Test public void testSetBigInteger() { final UnsignedVariableBitLengthType ul = new UnsignedVariableBitLengthType( 6347, 14 ); assertEquals( ul.get(), 6347 ); ul.setBigInteger( BigInteger.valueOf( 15004l ) ); assertEquals( ul.get(), 15004l ); ul.setBigInteger( BigInteger.valueOf( 25625l ) ); assertEquals( ul.get(), 9241l ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/000077500000000000000000000000001316447754700221715ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/ImgTestHelper.java000066400000000000000000000151051316447754700255520ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.outofbounds.OutOfBoundsPeriodicFactory; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.view.ExtendedRandomAccessibleInterval; /** * Helper class for {@link Img} subclass unit tests. * * @author Stephan Preibisch * @author Stephan Saalfeld * @author Curtis Rueden */ public class ImgTestHelper { // which dimensions to test private static final long[][] DIM = new long[][] { { 127 }, { 288 }, { 135, 111 }, { 172, 131 }, { 15, 13, 33 }, { 110, 38, 30 }, { 109, 34, 111 }, { 12, 43, 92, 10 }, { 21, 34, 29, 13 }, { 5, 12, 30, 4, 21 }, { 14, 21, 13, 9, 12 } }; public static long[][] dims() { return DIM.clone(); } public static boolean testImg( final long[] size, final ImgFactory< FloatType > factory1, final ImgFactory< FloatType > factory2 ) { // create the image final Img< FloatType > img1 = factory1.create( size, new FloatType() ); final Img< FloatType > img2 = factory2.create( size, new FloatType() ); final int numDimensions = img1.numDimensions(); // get a reference to compare to final float[] reference = createReference( img1 ); // copy into a second image using simple cursors final Cursor< FloatType > cursor1 = img1.cursor(); final Cursor< FloatType > cursor2 = img2.cursor(); while ( cursor1.hasNext() ) { cursor1.fwd(); cursor2.fwd(); cursor2.get().set( cursor1.get() ); } cursor1.reset(); cursor2.reset(); // and copy right back while ( cursor2.hasNext() ) { cursor1.fwd(); cursor2.fwd(); cursor1.get().set( cursor2.get() ); } // copy back into a second image using localizable and positionable // cursors final Cursor< FloatType > localizableCursor1 = img1.localizingCursor(); final RandomAccess< FloatType > positionable2 = img2.randomAccess(); int i = 0; while ( localizableCursor1.hasNext() ) { localizableCursor1.fwd(); ++i; if ( i % 2 == 0 ) positionable2.setPosition( localizableCursor1 ); else positionable2.setPosition( localizableCursor1 ); final FloatType t2 = positionable2.get(); final FloatType t1 = localizableCursor1.get(); // float f1 = t1.getRealFloat(); // float f2 = t2.getRealFloat(); t2.set( t1 ); // positionable2.get().set( localizableCursor1.get() ); } // copy again to the first image using a LocalizableByDimOutsideCursor // and a LocalizableByDimCursor final ExtendedRandomAccessibleInterval< FloatType, Img< FloatType > > extendedImg2 = new ExtendedRandomAccessibleInterval< FloatType, Img< FloatType > >( img2, new OutOfBoundsPeriodicFactory< FloatType, Img< FloatType > >() ); final RandomAccess< FloatType > outsideCursor2 = extendedImg2.randomAccess(); localizableCursor1.reset(); final int[] pos = new int[ numDimensions ]; i = 0; int direction = 1; try { while ( localizableCursor1.hasNext() ) { localizableCursor1.fwd(); localizableCursor1.localize( pos ); ++i; // how many times far away from the original image do we grab // the pixel final int distance = i % 5; direction *= -1; pos[ i % numDimensions ] += img1.dimension( i % numDimensions ) * distance * direction; if ( i % 7 == 0 ) outsideCursor2.setPosition( pos ); else outsideCursor2.setPosition( pos ); final FloatType t1 = localizableCursor1.get(); final FloatType t2 = outsideCursor2.get(); // final float f1 = t1.getRealFloat(); // final float f2 = t2.getRealFloat(); t1.set( t2 ); } } catch ( final ArrayIndexOutOfBoundsException e ) { System.err.println( ( i % 7 == 0 ? "setPosition() " : "moveTo() " ) + Util.printCoordinates( pos ) ); e.printStackTrace(); System.exit( 1 ); } final boolean success = test( img1, reference ); return success; } private static float[] createReference( final Img< FloatType > img ) { // use a random number generator final Random rnd = new Random( 1241234 ); // create reference array final float[] reference = new float[ ( int ) img.size() ]; // iterate over image and reference array and fill with data final Cursor< FloatType > cursor = img.cursor(); int i = 0; while ( cursor.hasNext() ) { cursor.fwd(); final float value = rnd.nextFloat(); reference[ i++ ] = value; cursor.get().set( value ); } return reference; } private static boolean test( final Img< FloatType > img, final float[] reference ) { boolean allEqual = true; final Cursor< FloatType > cursor = img.cursor(); int i = 0; while ( cursor.hasNext() ) { cursor.fwd(); allEqual &= cursor.get().get() == reference[ i++ ]; } return allEqual; } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/ImgUtilTest.java000066400000000000000000000237061316447754700252560ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.LongType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; import org.junit.Test; /** * TODO * */ public class ImgUtilTest { @Test public void testCopyDoubleArrayIntIntArrayImgOfT() { final double[] input = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final double[][][] expected = { { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }, { { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 } }, { { 8, 7, 6 }, { 5, 4, 3 }, { 2, 1, 0 } } }; for ( int i = 0; i < offsets.length; i++ ) { final Img< DoubleType > img = new ArrayImgFactory< DoubleType >().create( new long[] { 3, 3 }, new DoubleType() ); ImgUtil.copy( input, offsets[ i ], strides[ i ], img ); final RandomAccess< DoubleType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); assertEquals( expected[ i ][ y ][ x ], ra.get().get(), 0 ); } } } } @Test public void testCopyFloatArrayIntIntArrayImgOfT() { final float[] input = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final float[][][] expected = { { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }, { { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 } }, { { 8, 7, 6 }, { 5, 4, 3 }, { 2, 1, 0 } } }; for ( int i = 0; i < offsets.length; i++ ) { final Img< FloatType > img = new ArrayImgFactory< FloatType >().create( new long[] { 3, 3 }, new FloatType() ); ImgUtil.copy( input, offsets[ i ], strides[ i ], img ); final RandomAccess< FloatType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); assertEquals( expected[ i ][ y ][ x ], ra.get().get(), 0 ); } } } } @Test public void testCopyLongArrayIntIntArrayImgOfT() { final long[] input = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final long[][][] expected = { { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }, { { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 } }, { { 8, 7, 6 }, { 5, 4, 3 }, { 2, 1, 0 } } }; for ( int i = 0; i < offsets.length; i++ ) { final Img< LongType > img = new ArrayImgFactory< LongType >().create( new long[] { 3, 3 }, new LongType() ); ImgUtil.copy( input, offsets[ i ], strides[ i ], img ); final RandomAccess< LongType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); assertEquals( expected[ i ][ y ][ x ], ra.get().get(), 0 ); } } } } @Test public void testCopyIntArrayIntIntArrayImgOfT() { final int[] input = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final int[][][] expected = { { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }, { { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 } }, { { 8, 7, 6 }, { 5, 4, 3 }, { 2, 1, 0 } } }; for ( int i = 0; i < offsets.length; i++ ) { final Img< IntType > img = new ArrayImgFactory< IntType >().create( new long[] { 3, 3 }, new IntType() ); ImgUtil.copy( input, offsets[ i ], strides[ i ], img ); final RandomAccess< IntType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); assertEquals( expected[ i ][ y ][ x ], ra.get().get(), 0 ); } } } } @Test public void testCopyImgOfTDoubleArrayIntIntArray() { final double[][] input = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final double[][] expected = { { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, { 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; final double[] output = new double[ 9 ]; final Img< DoubleType > img = new ArrayImgFactory< DoubleType >().create( new long[] { 3, 3 }, new DoubleType() ); final RandomAccess< DoubleType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); ra.get().set( input[ y ][ x ] ); } } for ( int i = 0; i < offsets.length; i++ ) { ImgUtil.copy( img, output, offsets[ i ], strides[ i ] ); assertArrayEquals( expected[ i ], output, 0 ); } } @Test public void testCopyImgOfTFloatArrayIntIntArray() { final float[][] input = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final float[][] expected = { { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, { 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; final float[] output = new float[ 9 ]; final Img< FloatType > img = new ArrayImgFactory< FloatType >().create( new long[] { 3, 3 }, new FloatType() ); final RandomAccess< FloatType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); ra.get().set( input[ y ][ x ] ); } } for ( int i = 0; i < offsets.length; i++ ) { ImgUtil.copy( img, output, offsets[ i ], strides[ i ] ); assertArrayEquals( expected[ i ], output, 0 ); } } @Test public void testCopyImgOfTLongArrayIntIntArray() { final long[][] input = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final long[][] expected = { { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, { 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; final long[] output = new long[ 9 ]; final Img< LongType > img = new ArrayImgFactory< LongType >().create( new long[] { 3, 3 }, new LongType() ); final RandomAccess< LongType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); ra.get().set( input[ y ][ x ] ); } } for ( int i = 0; i < offsets.length; i++ ) { ImgUtil.copy( img, output, offsets[ i ], strides[ i ] ); assertArrayEquals( expected[ i ], output ); } } @Test public void testCopyImgOfTIntArrayIntIntArray() { final int[][] input = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } }; final int[] offsets = { 0, 0, 8 }; final int[][] strides = { { 1, 3 }, { 3, 1 }, { -1, -3 } }; final int[][] expected = { { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, { 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; final int[] output = new int[ 9 ]; final Img< LongType > img = new ArrayImgFactory< LongType >().create( new long[] { 3, 3 }, new LongType() ); final RandomAccess< LongType > ra = img.randomAccess(); final long[] location = new long[ 2 ]; for ( int x = 0; x < 3; x++ ) { location[ 0 ] = x; for ( int y = 0; y < 3; y++ ) { location[ 1 ] = y; ra.setPosition( location ); ra.get().set( input[ y ][ x ] ); } } for ( int i = 0; i < offsets.length; i++ ) { ImgUtil.copy( img, output, offsets[ i ], strides[ i ] ); assertArrayEquals( expected[ i ], output ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/IterablePairTest.java000066400000000000000000000111361316447754700262410ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import org.junit.Test; /** * Tests {@link IterablePair}. * * @author Curtis Rueden * @author Ellen T Arena */ public class IterablePairTest { /** * Tests {@link IterablePair#iterator()}. */ @Test public void testIterator() { final List< Integer > iter1 = Arrays.asList( 3, 5, 6, 1, 2, 3 ); final List< String > iter2 = Arrays.asList( "dog", "cat", "mouse", "fox" ); final IterablePair< Integer, String > pair = new IterablePair< >( iter1, iter2 ); final Iterator< Pair< Integer, String > > iterPair = pair.iterator(); assertNotNull( iterPair ); assertNextItems( iterPair, 3, "dog" ); assertNextItems( iterPair, 5, "cat" ); assertNextItems( iterPair, 6, "mouse" ); assertNextItems( iterPair, 1, "fox" ); assertFalse( iterPair.hasNext() ); try { final Pair< Integer, String > next = iterPair.next(); fail( "Next element not expected: " + next ); } catch ( final NoSuchElementException exc ) { // expected behavior } } /** * Tests iteration with null inputs. */ @Test( expected = NullPointerException.class ) public void testNulls() { final IterablePair< Integer, Integer > pair = new IterablePair< >( null, null ); pair.iterator().next(); } /** * Tests iteration with empty inputs. */ @Test( expected = NoSuchElementException.class ) public void testEmpty() { final List< Integer > iter1 = Collections.emptyList(); final List< Integer > iter2 = Collections.emptyList(); final IterablePair< Integer, Integer > pair = new IterablePair< >( iter1, iter2 ); pair.iterator().next(); } /** * Tests iteration when two inputs are the same reference. */ @Test public void testSameIterable() { final List< Integer > iter = Arrays.asList( 3, 5, 6, 1, 2, 3 ); final IterablePair< Integer, Integer > pair = new IterablePair< >( iter, iter ); final Iterator< Pair< Integer, Integer > > iterPair = pair.iterator(); assertNotNull( iterPair ); int count = 0; for ( final Integer i : iter ) { final Pair< Integer, Integer > p = iterPair.next(); assertEquals( i, p.getA() ); assertEquals( i, p.getB() ); count++; } assertEquals( iter.size(), count ); } // -- Helper methods -- private void assertNextItems( final Iterator< Pair< Integer, String > > iter, final Integer i, final String s ) { assertTrue( iter.hasNext() ); final Pair< Integer, String > pair1 = iter.next(); assertEquals( i, pair1.getA() ); assertEquals( s, pair1.getB() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/KthElementTest.java000066400000000000000000000527211316447754700257430ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.ListIterator; import org.junit.Test; /** * TODO * */ public class KthElementTest { @Test public void testMedianByte() { final byte[] values = new byte[] { 2, -1, 1, 100, 123, 12 }; final byte[] sortedValues = values.clone(); final int i = 1; final int j = 3; final int k = i + ( j - i ) / 2; KthElement.kthElement( i, j, k, values ); Arrays.sort( sortedValues, i, j + 1 ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values, i, j + 1 ); assertArrayEquals( sortedValues, values ); } @Test public void testMedianByteFull() { final byte[] values = new byte[] { 2, -1, 1, 100, 123, 12 }; final byte[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testMinByteFull() { final byte[] values = new byte[] { 2, -1, 1, 100, 123, 12 }; final byte[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = 0; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testMaxByteFull() { final byte[] values = new byte[] { 2, -1, 1, 100, 123, 12 }; final byte[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = j; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testMedianShortFull() { final short[] values = new short[] { 2, -1, 1, 100, 123, 12, 19, 12183, 123, 12, 6453, 233 }; final short[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testMedianIntFull() { final int[] values = new int[] { 2, 233 }; final int[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testMedianLongFull() { final long[] values = new long[] { 2, -123890123, 12, 6453, 233, 1, 1, 1, 1, 1 }; final long[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ] ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testMedianFloatFull() { final float[] values = new float[] { 2, -123890123, 12, 6453, 233, 1, 1, 1, 1, 1 }; final float[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ], 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values ); assertArrayEquals( sortedValues, values, 0 ); } @Test public void testMedianDoubleFull() { final double[] values = new double[] { 2, 453, 233, 1, 1, 1, 1, 1, 0.7 }; final double[] sortedValues = values.clone(); final int i = 0; final int j = values.length - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Arrays.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values[ k ], sortedValues[ k ], 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values[ p ] <= values[ k ] ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values[ p ] >= values[ k ] ); // all elements should be contained in list, i.e., after sorting lists // should be identical Arrays.sort( values, i, j + 1 ); assertArrayEquals( sortedValues, values, 0 ); } @Test public void testMedianFloatObject() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); final int i = 4; final int j = 9; final int k = i + ( j - i ) / 2; KthElement.kthElement( i, j, k, values ); Collections.sort( sortedValues.subList( i, j + 1 ) ); // the elements at the k-th positions should be equal assertEquals( values.get( k ), sortedValues.get( k ), 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); // all elements should be contained in list, i.e., after sorting lists // should be identical Collections.sort( values.subList( i, j + 1 ) ); for ( int p = i; p <= j; ++p ) assertTrue( values.get( p ).equals( sortedValues.get( p ) ) ); } @Test public void testMedianFloatObjectFull() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); final int i = 0; final int j = values.size() - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values ); Collections.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values.get( k ), sortedValues.get( k ), 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); // all elements should be contained in list, i.e., after sorting lists // should be identical Collections.sort( values ); for ( int p = i; p <= j; ++p ) assertTrue( values.get( p ).equals( sortedValues.get( p ) ) ); } public static class ComparableComparator< T extends Comparable< T > > implements Comparator< T > { @Override public int compare( final T o1, final T o2 ) { return o1.compareTo( o2 ); } } @Test public void testMedianFloatObjectFullComparator() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); final int i = 0; final int j = values.size() - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values, new ComparableComparator< Float >() ); Collections.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values.get( k ), sortedValues.get( k ), 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); // all elements should be contained in list, i.e., after sorting lists // should be identical Collections.sort( values ); for ( int p = i; p <= j; ++p ) assertTrue( values.get( p ).equals( sortedValues.get( p ) ) ); } @Test public void testMedianFloatObjectIterator() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); final int i = 4; final int j = 9; final ListIterator< Float > iIterator = values.listIterator( i ); final ListIterator< Float > jIterator = values.listIterator( j + 1 ); final int k = i + ( j - i ) / 2; KthElement.kthElement( iIterator, jIterator, k ); Collections.sort( sortedValues.subList( i, j + 1 ) ); // iIterator should be at k assertEquals( iIterator.nextIndex() - 1, k ); // the elements at the k-th positions should be equal assertEquals( values.get( k ), sortedValues.get( k ), 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); // all elements should be contained in list, i.e., after sorting lists // should be identical Collections.sort( values.subList( i, j + 1 ) ); for ( int p = i; p <= j; ++p ) assertTrue( values.get( p ).equals( sortedValues.get( p ) ) ); } @Test public void testMedianFloatObjectFullIteratorComparator() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); final int i = 0; final int j = values.size() - 1; final ListIterator< Float > iIterator = values.listIterator( i ); final ListIterator< Float > jIterator = values.listIterator( j + 1 ); final int k = i + ( j - i ) / 2; KthElement.kthElement( iIterator, jIterator, k, new ComparableComparator< Float >() ); Collections.sort( sortedValues ); // the elements at the k-th positions should be equal assertEquals( values.get( k ), sortedValues.get( k ), 0 ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); // all elements should be contained in list, i.e., after sorting lists // should be identical Collections.sort( values ); for ( int p = i; p <= j; ++p ) assertTrue( values.get( p ).equals( sortedValues.get( p ) ) ); } @Test public void testMedianFloatObjectFullPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final int i = 0; final int j = values.size() - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values, permutation ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); for ( int p = 0; p < permutation.length; ++p ) assertTrue( values.get( p ).equals( origvalues.get( permutation[ p ] ) ) ); } @Test public void testMedianFloatObjectFullComparatorPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final int i = 0; final int j = values.size() - 1; final int k = i + ( j - i ) / 2; KthElement.kthElement( k, values, permutation, new ComparableComparator< Float >() ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); for ( int p = 0; p < permutation.length; ++p ) assertTrue( values.get( p ).equals( origvalues.get( permutation[ p ] ) ) ); } @Test public void testMedianFloatObjectFullIteratorComparatorPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final int i = 0; final int j = values.size() - 1; final ListIterator< Float > iIterator = values.listIterator( i ); final ListIterator< Float > jIterator = values.listIterator( j + 1 ); final int k = i + ( j - i ) / 2; KthElement.kthElement( iIterator, jIterator, k, permutation, new ComparableComparator< Float >() ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); for ( int p = 0; p < permutation.length; ++p ) assertTrue( values.get( p ).equals( origvalues.get( permutation[ p ] ) ) ); } @Test public void testMedianFloatObjectFullIteratorPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final int i = 0; final int j = values.size() - 1; final ListIterator< Float > iIterator = values.listIterator( i ); final ListIterator< Float > jIterator = values.listIterator( j + 1 ); final int k = i + ( j - i ) / 2; KthElement.kthElement( iIterator, jIterator, k, permutation ); // the elements before the k-th should be equal or smaller than the k-th for ( int p = i; p < k; ++p ) assertTrue( values.get( p ) <= values.get( k ) ); // the elements after the k-th should be equal or greater than the k-th for ( int p = k + 1; p <= j; ++p ) assertTrue( values.get( p ) >= values.get( k ) ); for ( int p = 0; p < permutation.length; ++p ) assertTrue( values.get( p ).equals( origvalues.get( permutation[ p ] ) ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/LinAlgHelpersTest.java000066400000000000000000000156341316447754700263760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import org.junit.Test; public class LinAlgHelpersTest { public double[][] getXRot( final double theta ) { final double s = Math.sin( theta ); final double c = Math.cos( theta ); final double[][] R = new double[][] { { 1, 0, 0 }, { 0, c, -s }, { 0, s, c } }; return R; } public double[][] getYRot( final double theta ) { final double s = Math.sin( theta ); final double c = Math.cos( theta ); final double[][] R = new double[][] { { c, 0, s }, { 0, 1, 0 }, { -s, 0, c } }; return R; } public double[][] getZRot( final double theta ) { final double s = Math.sin( theta ); final double c = Math.cos( theta ); final double[][] R = new double[][] { { c, -s, 0 }, { s, c, 0 }, { 0, 0, 1 } }; return R; } final static double delta = 1e-10; @Test public void testAngleFromR() { assertEquals( 0.2, LinAlgHelpers.angleFromR( getXRot( 0.2 ) ), delta ); assertEquals( 0.5, LinAlgHelpers.angleFromR( getYRot( 0.5 ) ), delta ); assertEquals( 0.135, LinAlgHelpers.angleFromR( getZRot( 0.135 ) ), delta ); assertEquals( 3.14, LinAlgHelpers.angleFromR( getZRot( 3.14 ) ), delta ); } @Test public void testAxisFromR() { final double[] X = new double[] { 1, 0, 0 }; final double[] Y = new double[] { 0, 1, 0 }; final double[] Z = new double[] { 0, 0, 1 }; final double[] a = new double[ 3 ]; LinAlgHelpers.axisFromR( getXRot( 0.2 ), a ); assertArrayEquals( X, a, delta ); LinAlgHelpers.axisFromR( getXRot( 3.1 ), a ); assertArrayEquals( X, a, delta ); LinAlgHelpers.axisFromR( getYRot( 0.2 ), a ); assertArrayEquals( Y, a, delta ); LinAlgHelpers.axisFromR( getYRot( 3.1 ), a ); assertArrayEquals( Y, a, delta ); LinAlgHelpers.axisFromR( getZRot( 0.2 ), a ); assertArrayEquals( Z, a, delta ); LinAlgHelpers.axisFromR( getZRot( 0.9 ), a ); assertArrayEquals( Z, a, delta ); } @Test public void testR2Q2R() { double[][] expectedR; final double[][] R = new double[ 3 ][ 3 ]; final double[] q = new double[ 4 ]; expectedR = getXRot( 0.2 ); LinAlgHelpers.quaternionFromR( expectedR, q ); LinAlgHelpers.quaternionToR( q, R ); for ( int i = 0; i < 3; ++i ) assertArrayEquals( expectedR[ i ], R[ i ], delta ); expectedR = getXRot( 3.1 ); LinAlgHelpers.quaternionFromR( expectedR, q ); LinAlgHelpers.quaternionToR( q, R ); for ( int i = 0; i < 3; ++i ) assertArrayEquals( expectedR[ i ], R[ i ], delta ); expectedR = getYRot( 0.2 ); LinAlgHelpers.quaternionFromR( expectedR, q ); LinAlgHelpers.quaternionToR( q, R ); for ( int i = 0; i < 3; ++i ) assertArrayEquals( expectedR[ i ], R[ i ], delta ); expectedR = getYRot( 3.1 ); LinAlgHelpers.quaternionFromR( expectedR, q ); LinAlgHelpers.quaternionToR( q, R ); for ( int i = 0; i < 3; ++i ) assertArrayEquals( expectedR[ i ], R[ i ], delta ); expectedR = getZRot( 0.2 ); LinAlgHelpers.quaternionFromR( expectedR, q ); LinAlgHelpers.quaternionToR( q, R ); for ( int i = 0; i < 3; ++i ) assertArrayEquals( expectedR[ i ], R[ i ], delta ); expectedR = getZRot( 0.9 ); LinAlgHelpers.quaternionFromR( expectedR, q ); LinAlgHelpers.quaternionToR( q, R ); for ( int i = 0; i < 3; ++i ) assertArrayEquals( expectedR[ i ], R[ i ], delta ); } @Test public void testQuaternionToR() { final double[] q = new double[] { 1, 0, 0, 0 }; final double[][] expectedR = new double[][] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; final double[][] R = new double[ 3 ][ 3 ]; LinAlgHelpers.quaternionToR( q, R ); assertArrayEquals( expectedR[ 0 ], R[ 0 ], delta ); assertArrayEquals( expectedR[ 1 ], R[ 1 ], delta ); assertArrayEquals( expectedR[ 2 ], R[ 2 ], delta ); } @Test public void testQuaternionFromR() { final double[][] R = new double[][] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; final double[] expectedQ = new double[] { 1, 0, 0, 0 }; final double[] q = new double[ 4 ]; LinAlgHelpers.quaternionFromR( R, q ); assertArrayEquals( expectedQ, q, delta ); } @Test public void testQuaternionMultiply() { final double[][] Rp = getZRot( 0.2 ); final double[][] Rq = getXRot( 4.1 ); final double[][] Rpq = new double[ 3 ][ 3 ]; LinAlgHelpers.mult( Rp, Rq, Rpq ); final double[] p = new double[ 4 ]; final double[] q = new double[ 4 ]; final double[] pq = new double[ 4 ]; final double[] expectedPq = new double[ 4 ]; LinAlgHelpers.quaternionFromR( Rp, p ); LinAlgHelpers.quaternionFromR( Rq, q ); LinAlgHelpers.quaternionFromR( Rpq, expectedPq ); LinAlgHelpers.quaternionMultiply( p, q, pq ); assertArrayEquals( expectedPq, pq, delta ); } @Test public void testQuaternionApply() { final double[][] R = getXRot( 4.1 ); final double[] q = new double[ 4 ]; LinAlgHelpers.quaternionFromR( R, q ); final double[] p = new double[] { 100, 0.7, -31 }; final double[] qp = new double[ 3 ]; final double[] expectedQp = new double[ 3 ]; LinAlgHelpers.mult( R, p, expectedQp ); LinAlgHelpers.quaternionApply( q, p, qp ); assertArrayEquals( expectedQp, qp, delta ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/PartitionTest.java000066400000000000000000000351411316447754700256510ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.ListIterator; import org.junit.Test; /** * TODO * */ public class PartitionTest { @Test public void testPartitionByte() { final byte[] values = new byte[] { 2, -1, 1 }; final byte[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testPartitionShort() { final short[] values = new short[] { 2, 2138, 29, 123, 23, 23134, -123, 23134 }; final short[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testPartitionInt() { final int[] values = new int[] { 1, 3, 9, 100, 10, 10, 10, 9, 25, 4, 10 }; final int[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testPartitionLong() { final long[] values = new long[] { 112312738 }; final long[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testPartitionFloat() { final float[] values = new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 }; final float[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values, 0 ); } @Test public void testPartitionDouble() { final double[] values = new double[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 }; final double[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values, 0 ); } @Test public void testPartitionChar() { final char[] values = new char[] { 'b', 'a', 'x', 'c', 'c' }; final char[] sortedValues = values.clone(); Arrays.sort( sortedValues ); final int i = 0; final int j = values.length - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values[ k ] < values[ p ] ); for ( int k = p + 1; k < j; ++k ) assertTrue( values[ k ] >= values[ p ] ); Arrays.sort( values ); assertArrayEquals( sortedValues, values ); } @Test public void testPartitionFloatObject() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); Collections.sort( sortedValues ); final int i = 0; final int j = values.size() - 1; final int p = Partition.partitionSubList( i, j, values ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); Collections.sort( values ); for ( int k = i; k <= j; ++k ) assertTrue( values.get( k ).equals( sortedValues.get( k ) ) ); } public static class ComparableComparator< T extends Comparable< T > > implements Comparator< T > { @Override public int compare( final T o1, final T o2 ) { return o1.compareTo( o2 ); } } @Test public void testPartitionFloatObjectComparator() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); Collections.sort( sortedValues ); final int i = 0; final int j = values.size() - 1; final int p = Partition.partitionSubList( i, j, values, new ComparableComparator< Float >() ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); Collections.sort( values ); for ( int k = i; k <= j; ++k ) assertTrue( values.get( k ).equals( sortedValues.get( k ) ) ); } @Test public void testPartitionFloatObjectIterator() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); Collections.sort( sortedValues ); final ListIterator< Float > iIterator = values.listIterator(); final ListIterator< Float > jIterator = values.listIterator( values.size() ); final int i = 0; final int j = values.size() - 1; Partition.partitionSubList( iIterator, jIterator ); final int p = iIterator.nextIndex() - 1; assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); Collections.sort( values ); for ( int k = i; k <= j; ++k ) assertTrue( values.get( k ).equals( sortedValues.get( k ) ) ); } @Test public void testPartitionFloatObjectIteratorComparator() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > sortedValues = ( ArrayList< Float > ) values.clone(); Collections.sort( sortedValues ); final ListIterator< Float > iIterator = values.listIterator(); final ListIterator< Float > jIterator = values.listIterator( values.size() ); final int i = 0; final int j = values.size() - 1; Partition.partitionSubList( iIterator, jIterator, new ComparableComparator< Float >() ); final int p = iIterator.nextIndex() - 1; assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); Collections.sort( values ); for ( int k = i; k <= j; ++k ) assertTrue( values.get( k ).equals( sortedValues.get( k ) ) ); } @Test public void testPartitionFloatObjectPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329, 1, 1, 1, 100 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final int i = 0; final int j = values.size() - 1; final int p = Partition.partitionSubList( i, j, values, permutation ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); for ( int k = 0; k < permutation.length; ++k ) assertTrue( values.get( k ).equals( origvalues.get( permutation[ k ] ) ) ); } @Test public void testPartitionFloatObjectComparatorPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final int i = 0; final int j = values.size() - 1; final int p = Partition.partitionSubList( i, j, values, permutation, new ComparableComparator< Float >() ); assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); for ( int k = 0; k < permutation.length; ++k ) assertTrue( values.get( k ).equals( origvalues.get( permutation[ k ] ) ) ); } @Test public void testPartitionFloatObjectIteratorPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final ListIterator< Float > iIterator = values.listIterator(); final ListIterator< Float > jIterator = values.listIterator( values.size() ); final int i = 0; final int j = values.size() - 1; Partition.partitionSubList( iIterator, jIterator, permutation ); final int p = iIterator.nextIndex() - 1; assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); for ( int k = 0; k < permutation.length; ++k ) assertTrue( values.get( k ).equals( origvalues.get( permutation[ k ] ) ) ); } @Test public void testPartitionFloatObjectIteratorComparatorPermutation() { final ArrayList< Float > values = new ArrayList< Float >(); for ( final float f : new float[] { 123, 21, 12912, 321, 32, 12345, 249, 5823, 834, 10, 23, 329 } ) { values.add( f ); } @SuppressWarnings( "unchecked" ) final ArrayList< Float > origvalues = ( ArrayList< Float > ) values.clone(); final int[] permutation = new int[ values.size() ]; for ( int k = 0; k < permutation.length; ++k ) permutation[ k ] = k; final ListIterator< Float > iIterator = values.listIterator(); final ListIterator< Float > jIterator = values.listIterator( values.size() ); final int i = 0; final int j = values.size() - 1; Partition.partitionSubList( iIterator, jIterator, permutation, new ComparableComparator< Float >() ); final int p = iIterator.nextIndex() - 1; assertTrue( p >= i && p <= j ); for ( int k = i; k < p; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) < 0 ); for ( int k = p + 1; k < j; ++k ) assertTrue( values.get( k ).compareTo( values.get( p ) ) >= 0 ); for ( int k = 0; k < permutation.length; ++k ) assertTrue( values.get( k ).equals( origvalues.get( permutation[ k ] ) ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/util/RealSumTest.java000066400000000000000000000077451316447754700252610ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.util; import java.math.BigDecimal; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; /** * * * @author Stephan Saalfeld */ public class RealSumTest { final static protected double[] stream = new double[ 1000000 ]; static protected BigDecimal referenceSum = new BigDecimal( 0.0 ); final static Random rnd = new Random( 12345 ); @BeforeClass public static void init() { for ( int i = 0; i < stream.length; ++i ) { stream[ i ] = rnd.nextDouble() * 1000000; referenceSum = referenceSum.add( new BigDecimal( stream[ i ] ) ); } } /** * Test method for {@link net.imglib2.util.RealSum#RealSum()}. */ @Test public void testRealSum() { final RealSum sum = new RealSum(); Assert.assertEquals( sum.getSum(), 0.0, 0.001 ); } /** * Test method for {@link net.imglib2.util.RealSum#RealSum(int)}. */ @Test public void testRealSumInt() { final RealSum sum = new RealSum( 10 ); Assert.assertEquals( sum.getSum(), 0.0, 0.001 ); } /** * Test method for {@link net.imglib2.util.RealSum#getSum()}. */ @Test public void testGetSum() { final RealSum sum = new RealSum(); for ( int i = 0; i < stream.length; ++i ) sum.add( stream[ i ] ); Assert.assertEquals( sum.getSum(), referenceSum.doubleValue(), 0.0001 ); } /** * Test method for {@link net.imglib2.util.RealSum#getSum()}. */ @Test public void testDoubleSum() { double sum = 0; for ( int i = 0; i < stream.length; ++i ) sum += stream[ i ]; Assert.assertEquals( sum, referenceSum.doubleValue(), 0.01 ); } /** * Test method for {@link net.imglib2.util.RealSum#add(double)}. */ @Test public void testAdd() { for ( int t = 0; t < 20; ++t ) { final RealSum sum = new RealSum(); for ( int i = 0; i < stream.length; ++i ) sum.add( 1 ); Assert.assertEquals( sum.getSum(), stream.length, 0.0001 ); } } /** * Test method for {@link net.imglib2.util.RealSum#add(double)}. */ @Test public void testDoubleAdd() { for ( int t = 0; t < 20; ++t ) { double sum = 0; for ( int i = 0; i < stream.length; ++i ) sum += 1; Assert.assertEquals( sum, stream.length, 0.0001 ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/000077500000000000000000000000001316447754700221665ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/ConcatenateViewTest.java000066400000000000000000000066751316447754700267660ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.Random; import org.junit.Assert; import org.junit.Test; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.basictypeaccess.array.ByteArray; import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.util.Intervals; import net.imglib2.util.Pair; /** * * @author Philipp Hanslovsky * */ public class ConcatenateViewTest { private final long[] dim = new long[] { 3, 4, 5, 6 }; private final long divider = 3; private final int axis = 3; @Test public void testConcatenate() { final long numElements = Intervals.numElements( dim ); final Random rng = new Random(); final byte[] data = new byte[ ( int ) numElements ]; rng.nextBytes( data ); final ArrayImg< ByteType, ByteArray > img = ArrayImgs.bytes( data, dim ); final long[] min = Intervals.minAsLongArray( img ); final long[] max = Intervals.maxAsLongArray( img ); final long[] min1 = min.clone(); final long[] min2 = min.clone(); final long[] max1 = max.clone(); final long[] max2 = max.clone(); max1[ axis ] = divider; min2[ axis ] = divider + 1; final IntervalView< ByteType > interval1 = Views.interval( img, min1, max1 ); final IntervalView< ByteType > interval2 = Views.interval( img, min2, max2 ); final RandomAccessibleInterval< ByteType > concatenated = Views.concatenate( axis, interval1, interval2 ); for ( final Pair< ByteType, ByteType > p : Views.flatIterable( Views.interval( Views.pair( img, concatenated ), img ) ) ) Assert.assertEquals( p.getA().getInteger(), p.getB().getInteger() ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/HyperSlicesViewTest.java000066400000000000000000000057051316447754700267650ustar00rootroot00000000000000package net.imglib2.view; import java.util.Arrays; import java.util.stream.LongStream; import org.junit.Assert; import org.junit.Test; import net.imglib2.FinalInterval; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.array.ArrayImgs; import net.imglib2.type.numeric.integer.LongType; public class HyperSlicesViewTest { final static long[] sizes = new long[]{ 2, 3, 4, 5, 6 }; final static private long[] hyperSlice2Array( final RandomAccess< HyperSlice< LongType > > hyperSlicesAccess, final int... axes ) { final long[] max = new long[ axes.length ]; for ( int d = 0; d < axes.length; ++d ) max[ d ] = sizes[ axes[ d ] ] - 1; final RandomAccessibleInterval< LongType > hyperSlice = Views.interval( hyperSlicesAccess.get(), new FinalInterval( new long[ axes.length ], max ) ); long n = 1; for ( final long s : max ) n *= s + 1; final long[] list = new long[ ( int )n ]; int i = 0; for ( final LongType t : Views.iterable( hyperSlice ) ) list[ i++ ] = t.get(); return list; } final static private String printHyperSlice( final RandomAccess< HyperSlice< LongType > > hyperSlicesAccess, final int... axes ) { final long[] max = new long[ axes.length ]; for ( int d = 0; d < axes.length; ++d ) max[ d ] = sizes[ axes[ d ] ] - 1; final RandomAccessibleInterval< LongType > hyperSlice = Views.interval( hyperSlicesAccess.get(), new FinalInterval( new long[ axes.length ], max ) ); long n = 1; for ( final long s : max ) n *= s + 1; final long[] list = new long[ ( int )n ]; int i = 0; for ( final LongType t : Views.iterable( hyperSlice ) ) list[ i++ ] = t.get(); return Arrays.toString( list ); } @Test public void test() { final long n = LongStream.of( sizes ).reduce( 1, ( x, y ) -> x * y ); final long[] data = new long[ ( int )n ]; for ( int d = 0; d < n ; ++d ) data[ d ] = d; final RandomAccessibleInterval< LongType > source = ArrayImgs.longs( data, sizes ); RandomAccessibleInterval< LongType > slice = source; while ( slice.numDimensions() > 2 ) slice = Views.hyperSlice( slice, slice.numDimensions() - 1, 0 ); final HyperSlicesView< LongType > hyperSlices = new HyperSlicesView< LongType >( source, 2, 3 ); final RandomAccess< HyperSlice< LongType > > hyperSlicesAccess = hyperSlices.randomAccess(); final long[][] expecteds = new long[][]{ {0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114}, {1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115}, {2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, 104, 110, 116}, {3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99, 105, 111, 117} }; for ( int d = 0; hyperSlicesAccess.getLongPosition( 0 ) < sizes[ 2 ]; hyperSlicesAccess.fwd( 0 ), ++d ) { Assert.assertArrayEquals( expecteds[ d ], hyperSlice2Array(hyperSlicesAccess, 2, 3 ) ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/MixedTransformConcatenateTest.java000066400000000000000000000253431316447754700310070ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertTrue; import net.imglib2.transform.integer.Mixed; import net.imglib2.transform.integer.MixedTransform; import net.imglib2.transform.integer.SlicingTransform; import net.imglib2.transform.integer.TranslationTransform; import org.junit.Before; import org.junit.Test; import Jama.Matrix; /** * TODO * */ public class MixedTransformConcatenateTest { public static boolean testConcatenation( final MixedTransform t1, final Mixed t2 ) { if ( t1.numSourceDimensions() != t2.numTargetDimensions() ) { System.out.println( "incompatible dimensions" ); return false; } final MixedTransform t1t2 = t1.concatenate( t2 ); final Matrix mt1 = new Matrix( t1.getMatrix() ); final Matrix mt2 = new Matrix( t2.getMatrix() ); final Matrix mt1t2 = new Matrix( t1t2.getMatrix() ); if ( mt1.times( mt2 ).minus( mt1t2 ).normF() > 0.1 ) { System.out.println( "=======================" ); System.out.println( "t1: " + t1.numSourceDimensions() + " -> " + t1.numTargetDimensions() + " (n -> m)" ); System.out.println( "t2: " + t2.numSourceDimensions() + " -> " + t2.numTargetDimensions() + " (n -> m)" ); System.out.println( "t1t2: " + t1t2.numSourceDimensions() + " -> " + t1t2.numTargetDimensions() + " (n -> m)" ); System.out.print( "t1 = " ); mt1.print( 1, 0 ); System.out.print( "t2 = " ); mt2.print( 1, 0 ); System.out.print( "t1t2 = " ); mt1t2.print( 1, 0 ); System.out.print( "t1 x t2 = " ); mt1.times( mt2 ).print( 1, 0 ); System.out.println( "wrong result" ); System.out.println( "=======================" ); return false; } return true; } public static boolean testPreConcatenation( final Mixed t1, final MixedTransform t2 ) { if ( t1.numSourceDimensions() != t2.numTargetDimensions() ) { System.out.println( "incompatible dimensions" ); return false; } final MixedTransform t1t2 = t2.preConcatenate( t1 ); final Matrix mt1 = new Matrix( t1.getMatrix() ); final Matrix mt2 = new Matrix( t2.getMatrix() ); final Matrix mt1t2 = new Matrix( t1t2.getMatrix() ); if ( mt1.times( mt2 ).minus( mt1t2 ).normF() > 0.1 ) { System.out.println( "=======================" ); System.out.println( "t1: " + t1.numSourceDimensions() + " -> " + t1.numTargetDimensions() + " (n -> m)" ); System.out.println( "t2: " + t2.numSourceDimensions() + " -> " + t2.numTargetDimensions() + " (n -> m)" ); System.out.println( "t1t2: " + t1t2.numSourceDimensions() + " -> " + t1t2.numTargetDimensions() + " (n -> m)" ); System.out.print( "t1 = " ); mt1.print( 1, 0 ); System.out.print( "t2 = " ); mt2.print( 1, 0 ); System.out.print( "t1t2 = " ); mt1t2.print( 1, 0 ); System.out.print( "t1 x t2 = " ); mt1.times( mt2 ).print( 1, 0 ); System.out.println( "wrong result" ); System.out.println( "=======================" ); return false; } return true; } MixedTransform tr1; MixedTransform tr2; MixedTransform tr3; MixedTransform perm1; MixedTransform rot1; MixedTransform proj1; MixedTransform proj2; MixedTransform comp1; MixedTransform slice1; TranslationTransform translation1; SlicingTransform slicing1; @Before public void setUp() { tr1 = new MixedTransform( 3, 3 ); long[] translation = new long[] { 3, 4, 5 }; tr1.setTranslation( translation ); tr2 = new MixedTransform( 3, 3 ); translation = new long[] { 7, 8, 9 }; tr2.setTranslation( translation ); perm1 = new MixedTransform( 3, 3 ); boolean[] zero = new boolean[] { false, false, false }; boolean[] inv = new boolean[] { false, false, false }; int[] component = new int[] { 0, 2, 1 }; perm1.setComponentZero( zero ); perm1.setComponentMapping( component ); perm1.setComponentInversion( inv ); rot1 = new MixedTransform( 3, 3 ); zero = new boolean[] { false, false, false }; inv = new boolean[] { false, true, false }; component = new int[] { 1, 0, 2 }; rot1.setComponentZero( zero ); rot1.setComponentMapping( component ); rot1.setComponentInversion( inv ); proj1 = new MixedTransform( 3, 2 ); proj2 = new MixedTransform( 2, 3 ); slice1 = new MixedTransform( 2, 3 ); slice1.setTranslation( new long[] { 233, 0, 0 } ); slice1.setComponentMapping( new int[] { 0, 0, 1 } ); slice1.setComponentZero( new boolean[] { true, false, false } ); tr3 = new MixedTransform( 2, 2 ); tr3.setTranslation( new long[] { 10, 10 } ); comp1 = rot1.concatenate( tr2 ); translation1 = new TranslationTransform( new long[] { 2011, 3, 24 } ); slicing1 = new SlicingTransform( 2, 3 ); slicing1.setComponentMapping( new int[] { 0, 1, 0 } ); slicing1.setComponentZero( new boolean[] { false, false, true } ); slicing1.setTranslation( new long[] { 0, 0, 100 } ); } @Test public void concatenateSlice1Tr3() { assertTrue( testConcatenation( slice1, tr3 ) ); } @Test public void preconcatenateSlice1Tr3() { assertTrue( testPreConcatenation( slice1, tr3 ) ); } @Test public void concatenateProj1Tr1() { assertTrue( testConcatenation( proj1, tr1 ) ); } @Test public void preconcatenateProj1Tr1() { assertTrue( testPreConcatenation( proj1, tr1 ) ); } @Test public void concatenateTr11Tr2() { assertTrue( testConcatenation( tr1, tr2 ) ); } @Test public void preconcatenateTr1Tr2() { assertTrue( testPreConcatenation( tr1, tr2 ) ); } @Test public void concatenateTr1Perm1() { assertTrue( testConcatenation( tr1, perm1 ) ); } @Test public void preconcatenateTr1Perm1() { assertTrue( testPreConcatenation( tr1, perm1 ) ); } @Test public void concatenateTr1Rot1() { assertTrue( testConcatenation( tr1, rot1 ) ); } @Test public void preconcatenateTr1Rot1() { assertTrue( testPreConcatenation( tr1, rot1 ) ); } @Test public void concatenateRot1Tr1() { assertTrue( testConcatenation( rot1, tr1 ) ); } @Test public void preconcatenateRot1Tr1() { assertTrue( testPreConcatenation( rot1, tr1 ) ); } @Test public void concatenateProj1Proj2() { assertTrue( testConcatenation( proj1, proj2 ) ); } @Test public void preconcatenateProj1Proj2() { assertTrue( testPreConcatenation( proj1, proj2 ) ); } @Test public void concatenateProj2Proj1() { assertTrue( testConcatenation( proj2, proj1 ) ); } @Test public void preconcatenateProj2Proj1() { assertTrue( testPreConcatenation( proj2, proj1 ) ); } @Test public void concatenateComp1Tr1() { assertTrue( testConcatenation( comp1, tr1 ) ); } @Test public void preconcatenateComp1Tr1() { assertTrue( testPreConcatenation( comp1, tr1 ) ); } @Test public void concatenateTr1Comp1() { assertTrue( testConcatenation( tr1, comp1 ) ); } @Test public void preconcatenateTr1Comp1() { assertTrue( testPreConcatenation( tr1, comp1 ) ); } @Test public void concatenateComp1Rot1() { assertTrue( testConcatenation( comp1, rot1 ) ); } @Test public void preconcatenateComp1Rot1() { assertTrue( testPreConcatenation( comp1, rot1 ) ); } @Test public void concatenateRot1Comp1() { assertTrue( testConcatenation( rot1, comp1 ) ); } @Test public void preconcatenateRot1Comp1() { assertTrue( testPreConcatenation( rot1, comp1 ) ); } @Test public void concatenateProj1Comp1() { assertTrue( testConcatenation( proj1, comp1 ) ); } @Test public void preconcatenateProj1Comp1() { assertTrue( testPreConcatenation( proj1, comp1 ) ); } @Test public void concatenateComp1Proj2() { assertTrue( testConcatenation( comp1, proj2 ) ); } @Test public void preconcatenateComp1Proj2() { assertTrue( testPreConcatenation( comp1, proj2 ) ); } @Test public void concatenateComp1Translation1() { assertTrue( testConcatenation( comp1, translation1 ) ); } @Test public void preconcatenateTranslation1Comp1() { assertTrue( testPreConcatenation( translation1, comp1 ) ); } @Test public void concatenateComp1Slicing1() { assertTrue( testConcatenation( comp1, slicing1 ) ); } public static void main( final String[] args ) { final MixedTransformConcatenateTest test = new MixedTransformConcatenateTest(); test.setUp(); final Matrix m_tr1 = new Matrix( test.tr1.getMatrix() ); final Matrix m_tr2 = new Matrix( test.tr2.getMatrix() ); final Matrix m_perm1 = new Matrix( test.perm1.getMatrix() ); final Matrix m_rot1 = new Matrix( test.rot1.getMatrix() ); final Matrix m_proj1 = new Matrix( test.proj1.getMatrix() ); final Matrix m_proj2 = new Matrix( test.proj2.getMatrix() ); final Matrix m_comp1 = new Matrix( test.comp1.getMatrix() ); final Matrix m_slicing1 = new Matrix( test.slicing1.getMatrix() ); System.out.print( "tr1 = " ); m_tr1.print( 1, 0 ); System.out.print( "tr2 = " ); m_tr2.print( 1, 0 ); System.out.print( "perm1 = " ); m_perm1.print( 1, 0 ); System.out.print( "rot1 = " ); m_rot1.print( 1, 0 ); System.out.print( "proj1 = " ); m_proj1.print( 1, 0 ); System.out.print( "proj2 = " ); m_proj2.print( 1, 0 ); System.out.print( "comp1 = " ); m_comp1.print( 1, 0 ); System.out.print( "m_slicing1 = " ); m_slicing1.print( 1, 0 ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/RandomAccessTest.java000066400000000000000000000132101316447754700262300ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertTrue; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.UnsignedByteType; import org.junit.Assert; import org.junit.Before; import org.junit.Test; /** * TODO * */ public class RandomAccessTest { Img< UnsignedByteType > img; @Before public void setUp() { final long[] dimension = new long[] { 100, 60, 10, 30, 50 }; img = new ArrayImgFactory< UnsignedByteType >().create( dimension, new UnsignedByteType() ); } @Test public void testRandomAccess() { final RandomAccess< UnsignedByteType > a = img.randomAccess(); final long[] pos = new long[] { 28, 30, 5, 5, 12 }; final long[] dist = new long[] { 2, 3, 4, 2, 1 }; testlocalize( a, pos ); testfwd( a, pos ); testbck( a, pos ); testmove( a, pos, 3 ); testmove( a, pos, dist ); } @Test public void testFullSourceMapMixedAccess() { final long[] offset = new long[] { 1, 10, 0, -5 }; final long[] dim = new long[] { 10, 10, 10, 10 }; final RandomAccess< UnsignedByteType > a = Views.offsetInterval( Views.invertAxis( Views.hyperSlice( img, 2, 2 ), 3 ), offset, dim ).randomAccess(); assertTrue( FullSourceMapMixedRandomAccess.class.isInstance( a ) ); final long[] pos = new long[] { 28, 30, 2, 15 }; final long[] dist = new long[] { 2, 3, 4, 1 }; testlocalize( a, pos ); testfwd( a, pos ); testbck( a, pos ); testmove( a, pos, 3 ); testmove( a, pos, -2 ); testmove( a, pos, dist ); } public < T > void testlocalize( final RandomAccess< T > a, final long[] pos ) { final long[] loc = new long[ pos.length ]; final long[] expected = pos.clone(); a.setPosition( pos ); a.localize( loc ); Assert.assertArrayEquals( expected, loc ); for ( int d = 0; d < a.numDimensions(); ++d ) { Assert.assertTrue( expected[ d ] == a.getLongPosition( d ) ); Assert.assertTrue( expected[ d ] == a.getIntPosition( d ) ); Assert.assertTrue( expected[ d ] == ( long ) a.getFloatPosition( d ) ); Assert.assertTrue( expected[ d ] == ( long ) a.getDoublePosition( d ) ); } } public < T > void testfwd( final RandomAccess< T > a, final long[] pos ) { final long[] loc = new long[ pos.length ]; final long[] expected = new long[ pos.length ]; for ( int d = 0; d < a.numDimensions(); ++d ) { a.setPosition( pos ); a.fwd( d ); a.localize( loc ); for ( int i = 0; i < pos.length; ++i ) expected[ i ] = pos[ i ]; expected[ d ] += 1; Assert.assertArrayEquals( expected, loc ); } } public < T > void testbck( final RandomAccess< T > a, final long[] pos ) { final long[] loc = new long[ pos.length ]; final long[] expected = new long[ pos.length ]; for ( int d = 0; d < a.numDimensions(); ++d ) { a.setPosition( pos ); a.bck( d ); a.localize( loc ); for ( int i = 0; i < pos.length; ++i ) expected[ i ] = pos[ i ]; expected[ d ] -= 1; Assert.assertArrayEquals( expected, loc ); } } public < T > void testmove( final RandomAccess< T > a, final long[] pos, final long distance ) { final long[] loc = new long[ pos.length ]; final long[] expected = new long[ pos.length ]; for ( int d = 0; d < a.numDimensions(); ++d ) { a.setPosition( pos ); a.move( distance, d ); a.localize( loc ); for ( int i = 0; i < pos.length; ++i ) expected[ i ] = pos[ i ]; expected[ d ] += distance; Assert.assertArrayEquals( expected, loc ); } } public < T > void testmove( final RandomAccess< T > a, final long[] pos, final long[] distance ) { final long[] loc = new long[ pos.length ]; final long[] expected = new long[ pos.length ]; for ( int d = 0; d < pos.length; ++d ) expected[ d ] = pos[ d ] + distance[ d ]; a.setPosition( pos ); a.move( distance ); a.localize( loc ); Assert.assertArrayEquals( expected, loc ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/RandomAccessibleIntervalCursorBenchmark.java000066400000000000000000000113521316447754700327470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import java.util.Random; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.cell.CellImg; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.BenchmarkHelper; import net.imglib2.util.IntervalIndexer; /** * * @author Tobias Pietzsch */ public class RandomAccessibleIntervalCursorBenchmark { long[] dimensions; int numValues; int[] intData; ArrayImg< IntType, IntArray > array1; ArrayImg< IntType, IntArray > array2; CellImg< IntType, IntArray > cell; @SuppressWarnings( "unchecked" ) public void setUp() { dimensions = new long[] { 207, 103, 1021 }; array1 = ( ArrayImg< IntType, IntArray > ) new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); array2 = ( ArrayImg< IntType, IntArray > ) new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); cell = ( CellImg< IntType, IntArray > ) new CellImgFactory< IntType >().create( dimensions, new IntType() ); // fill intData with random values numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) intData[ i ] = random.nextInt(); // copy intData to array1 final long[] pos = new long[ dimensions.length ]; final RandomAccess< IntType > a = array1.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } static < C extends Cursor< IntType >, D extends Cursor< IntType > > void copy( final C src, final D dst ) { while ( src.hasNext() ) dst.next().set( src.next().get() ); } static int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; } public static void main( final String[] args ) { final RandomAccessibleIntervalCursorBenchmark b = new RandomAccessibleIntervalCursorBenchmark(); b.setUp(); for ( int iteration = 0; iteration < 10; ++iteration ) { System.out.println( "array to RandomAccessibleIntervalCursor( array ) copy" ); BenchmarkHelper.benchmarkAndPrint( 20, false, new Runnable() { @Override public void run() { copy( b.array1.cursor(), new RandomAccessibleIntervalCursor< IntType >( b.array2 ) ); } } ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/RandomAccessibleIntervalCursorTest.java000066400000000000000000000124101316447754700317700ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import java.util.Random; import org.junit.Before; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.img.cell.CellImg; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.util.IntervalIndexer; /** * * @author Tobias Pietzsch */ public class RandomAccessibleIntervalCursorTest { long[] dimensions; int numValues; int[] intData; ArrayImg< IntType, IntArray > array1; ArrayImg< IntType, IntArray > array2; CellImg< IntType, IntArray > cell; @SuppressWarnings( "unchecked" ) @Before public void setUp() { dimensions = new long[] { 207, 103 }; array1 = ( ArrayImg< IntType, IntArray > ) new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); array2 = ( ArrayImg< IntType, IntArray > ) new ArrayImgFactory< IntType >().create( dimensions, new IntType() ); cell = ( CellImg< IntType, IntArray > ) new CellImgFactory< IntType >().create( dimensions, new IntType() ); // fill intData with random values numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) intData[ i ] = random.nextInt(); // copy intData to array1 final long[] pos = new long[ dimensions.length ]; final RandomAccess< IntType > a = array1.randomAccess(); for ( int i = 0; i < numValues; ++i ) { IntervalIndexer.indexToPosition( i, dimensions, pos ); a.setPosition( pos ); a.get().set( intData[ i ] ); } } public void copy( final Cursor< IntType > src, final Cursor< IntType > dst ) { while ( src.hasNext() ) dst.next().set( src.next().get() ); } int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; } @Test public void testJumpFwd() { final Cursor< IntType > c1 = array1.cursor(); final Cursor< IntType > c2 = new RandomAccessibleIntervalCursor< IntType >( array1 ); c1.fwd(); c2.fwd(); assertEquals( c1.get().get(), c2.get().get() ); for ( int i = 0; i < 10; ++i ) c1.fwd(); c2.jumpFwd( 10 ); assertEquals( c1.get().get(), c2.get().get() ); c1.jumpFwd( 713 ); c2.jumpFwd( 713 ); assertEquals( c1.get().get(), c2.get().get() ); } @Test public void testArrayCopy() { copy( array1.cursor(), new RandomAccessibleIntervalCursor< IntType >( array2 ) ); assertArrayEquals( intData, getImgAsInts( array2 ) ); } @Test public void testArrayCopy2() { copy( new RandomAccessibleIntervalCursor< IntType >( array1 ), array2.cursor() ); assertArrayEquals( intData, getImgAsInts( array2 ) ); } @Test public void testCellCopy() { copy( array1.cursor(), new RandomAccessibleIntervalCursor< IntType >( cell ) ); assertArrayEquals( intData, getImgAsInts( cell ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/RotationViewTest.java000066400000000000000000000065741316447754700263370ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertEquals; import java.util.stream.LongStream; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.array.ArrayImgs; import net.imglib2.type.numeric.integer.LongType; import org.junit.Test; /** * Tests for {@link Views#rotate(RandomAccessibleInterval, int, int)} * functionality. * * @author Gabe Selzer * */ public class RotationViewTest { @Test public void test() { final long[] sizes = { 3, 4 }; final long n = LongStream.of( sizes ).reduce( 1, ( x, y ) -> x * y ); final long[] data = new long[ ( int ) n ]; for ( int i = 0; i < n; i++ ) { data[ i ] = i; } final RandomAccessibleInterval< LongType > source = ArrayImgs.longs( data, sizes ); final RandomAccess< LongType > sourceRA = source.randomAccess(); final RandomAccessibleInterval< LongType > actual = Views.rotate( source, 0, 1 ); final RandomAccess< LongType > actualRA = actual.randomAccess(); // check each value matches with their rotated counterparts for ( int i = 0; i < sizes[ 0 ]; i++ ) { for ( int j = 0; j < sizes[ 1 ]; j++ ) { sourceRA.setPosition( new long[] { i, j } ); actualRA.setPosition( new long[] { -j, i } ); assertEquals( sourceRA.get().get(), actualRA.get().get() ); } } // check to make sure the bounds are the same assertEquals( source.min( 0 ), actual.min( 1 ) ); assertEquals( source.max( 0 ), actual.max( 1 ) ); assertEquals( source.min( 1 ), -actual.max( 0 ) ); assertEquals( source.max( 1 ), -actual.min( 0 ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/SequentializeTransformTest.java000066400000000000000000000135131316447754700304120ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertArrayEquals; import net.imglib2.transform.integer.SequentializeTransform; import org.junit.Test; /** * TODO * */ public class SequentializeTransformTest { @Test public void test2Dto1D() { final long[] dim = new long[] { 10, 20 }; final SequentializeTransform t = new SequentializeTransform( dim, 1 ); final long[] source = new long[ 2 ]; final long[] target = new long[ 1 ]; final long[] expectedTarget = new long[ 1 ]; source[ 0 ] = 0; source[ 1 ] = 0; expectedTarget[ 0 ] = 0; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 5; source[ 1 ] = 0; expectedTarget[ 0 ] = 5; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 5; source[ 1 ] = 1; expectedTarget[ 0 ] = 15; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); } @Test public void test3Dto1D() { final long[] dim = new long[] { 10, 20, 30 }; final SequentializeTransform t = new SequentializeTransform( dim, 1 ); final int[] source = new int[ 3 ]; final int[] target = new int[ 1 ]; final int[] expectedTarget = new int[ 1 ]; source[ 0 ] = 0; source[ 1 ] = 0; source[ 2 ] = 0; expectedTarget[ 0 ] = 0; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 5; source[ 1 ] = 0; source[ 2 ] = 0; expectedTarget[ 0 ] = 5; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 5; source[ 1 ] = 1; source[ 2 ] = 0; expectedTarget[ 0 ] = 15; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 5; source[ 1 ] = 4; source[ 2 ] = 3; expectedTarget[ 0 ] = 5 + 4 * 10 + 3 * 20 * 10; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); } @Test public void test4Dto3D() { final long[] dim = new long[] { 10, 20, 30, 40 }; final SequentializeTransform t = new SequentializeTransform( dim, 3 ); final long[] source = new long[ 4 ]; final long[] target = new long[ 3 ]; final long[] expectedTarget = new long[ 3 ]; source[ 0 ] = 0; source[ 1 ] = 0; source[ 2 ] = 0; source[ 3 ] = 0; expectedTarget[ 0 ] = source[ 0 ]; expectedTarget[ 1 ] = source[ 1 ]; expectedTarget[ 2 ] = 0; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 0; source[ 1 ] = 0; source[ 2 ] = 0; source[ 3 ] = 1; expectedTarget[ 0 ] = source[ 0 ]; expectedTarget[ 1 ] = source[ 1 ]; expectedTarget[ 2 ] = 30; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); source[ 0 ] = 9; source[ 1 ] = 4; source[ 2 ] = 2; source[ 3 ] = 3; expectedTarget[ 0 ] = source[ 0 ]; expectedTarget[ 1 ] = source[ 1 ]; expectedTarget[ 2 ] = 2 + 3 * 30; t.apply( source, target ); assertArrayEquals( expectedTarget, target ); } @Test public void test4Dto3DInverse() { final long[] dim = new long[] { 10, 20, 30, 40 }; final SequentializeTransform t = new SequentializeTransform( dim, 3 ); final long[] source = new long[ 4 ]; final long[] target = new long[ 3 ]; final long[] expectedSource = new long[ 4 ]; source[ 0 ] = 0; source[ 1 ] = 0; source[ 2 ] = 0; source[ 3 ] = 0; t.apply( source, target ); for ( int d = 0; d < 4; ++d ) { expectedSource[ d ] = source[ d ]; source[ d ] = -1; } t.applyInverse( source, target ); assertArrayEquals( expectedSource, source ); source[ 0 ] = 0; source[ 1 ] = 0; source[ 2 ] = 0; source[ 3 ] = 1; t.apply( source, target ); for ( int d = 0; d < 4; ++d ) { expectedSource[ d ] = source[ d ]; source[ d ] = -1; } t.applyInverse( source, target ); assertArrayEquals( expectedSource, source ); source[ 0 ] = 9; source[ 1 ] = 4; source[ 2 ] = 2; source[ 3 ] = 3; t.apply( source, target ); for ( int d = 0; d < 4; ++d ) { expectedSource[ d ] = source[ d ]; source[ d ] = -1; } t.applyInverse( source, target ); assertArrayEquals( expectedSource, source ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/SlicingTransformConcatenateTest.java000066400000000000000000000124321316447754700313240ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertTrue; import net.imglib2.transform.integer.Slicing; import net.imglib2.transform.integer.SlicingTransform; import org.junit.Before; import org.junit.Test; import Jama.Matrix; /** * TODO * */ public class SlicingTransformConcatenateTest { public static boolean testConcatenation( final SlicingTransform t1, final Slicing t2 ) { if ( t1.numSourceDimensions() != t2.numTargetDimensions() ) { System.out.println( "incompatible dimensions" ); return false; } final SlicingTransform t1t2 = t1.concatenate( t2 ); final Matrix mt1 = new Matrix( t1.getMatrix() ); final Matrix mt2 = new Matrix( t2.getMatrix() ); final Matrix mt1t2 = new Matrix( t1t2.getMatrix() ); if ( mt1.times( mt2 ).minus( mt1t2 ).normF() > 0.1 ) { System.out.println( "=======================" ); System.out.println( "t1: " + t1.numSourceDimensions() + " -> " + t1.numTargetDimensions() + " (n -> m)" ); System.out.println( "t2: " + t2.numSourceDimensions() + " -> " + t2.numTargetDimensions() + " (n -> m)" ); System.out.println( "t1t2: " + t1t2.numSourceDimensions() + " -> " + t1t2.numTargetDimensions() + " (n -> m)" ); System.out.print( "t1 = " ); mt1.print( 1, 0 ); System.out.print( "t2 = " ); mt2.print( 1, 0 ); System.out.print( "t1t2 = " ); mt1t2.print( 1, 0 ); System.out.print( "t1 x t2 = " ); mt1.times( mt2 ).print( 1, 0 ); System.out.println( "wrong result" ); System.out.println( "=======================" ); return false; } return true; } public static boolean testPreConcatenation( final Slicing t1, final SlicingTransform t2 ) { if ( t1.numSourceDimensions() != t2.numTargetDimensions() ) { System.out.println( "incompatible dimensions" ); return false; } final SlicingTransform t1t2 = t2.preConcatenate( t1 ); final Matrix mt1 = new Matrix( t1.getMatrix() ); final Matrix mt2 = new Matrix( t2.getMatrix() ); final Matrix mt1t2 = new Matrix( t1t2.getMatrix() ); if ( mt1.times( mt2 ).minus( mt1t2 ).normF() > 0.1 ) { System.out.println( "=======================" ); System.out.println( "t1: " + t1.numSourceDimensions() + " -> " + t1.numTargetDimensions() + " (n -> m)" ); System.out.println( "t2: " + t2.numSourceDimensions() + " -> " + t2.numTargetDimensions() + " (n -> m)" ); System.out.println( "t1t2: " + t1t2.numSourceDimensions() + " -> " + t1t2.numTargetDimensions() + " (n -> m)" ); System.out.print( "t1 = " ); mt1.print( 1, 0 ); System.out.print( "t2 = " ); mt2.print( 1, 0 ); System.out.print( "t1t2 = " ); mt1t2.print( 1, 0 ); System.out.print( "t1 x t2 = " ); mt1.times( mt2 ).print( 1, 0 ); System.out.println( "wrong result" ); System.out.println( "=======================" ); return false; } return true; } SlicingTransform sl1; SlicingTransform sl2; @Before public void setUp() { sl1 = new SlicingTransform( 2, 3 ); sl1.setComponentMapping( new int[] { 0, 1, -9 } ); sl1.setComponentZero( new boolean[] { false, false, true } ); sl1.setTranslation( new long[] { 0, 0, 100 } ); sl2 = new SlicingTransform( 3, 4 ); sl2.setComponentMapping( new int[] { -9, 0, 1, 2 } ); sl2.setComponentZero( new boolean[] { true, false, false, false } ); sl2.setTranslation( new long[] { 1287, 0, 0, 0 } ); } @Test public void concatenateTr1Tr2() { assertTrue( testConcatenation( sl2, sl1 ) ); } @Test public void preconcatenateTr1Tr2() { assertTrue( testPreConcatenation( sl2, sl1 ) ); } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/StackRandomAccessibleIntervalsTest.java000066400000000000000000000072301316447754700317470ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.numeric.integer.UnsignedByteType; import org.junit.Before; import org.junit.Test; /** * Simple test to test Views.stack(...) * * @author Christian Dietz * */ public class StackRandomAccessibleIntervalsTest { private ArrayImg< UnsignedByteType, ? > img; @Before public void setUp() { final long[] dimension = new long[] { 10, 10, 10 }; img = new ArrayImgFactory< UnsignedByteType >().create( dimension, new UnsignedByteType() ); final Cursor< UnsignedByteType > inCursor = img.localizingCursor(); while ( inCursor.hasNext() ) { // set with plane position inCursor.next().set( inCursor.getIntPosition( 2 ) ); } } @Test public void testStacking() { // lets create a stack with every second plane of the input image, // works! final List< RandomAccessibleInterval< UnsignedByteType >> intervals = new ArrayList< RandomAccessibleInterval< UnsignedByteType > >(); for ( int d = 0; d < img.dimension( 2 ); d++ ) { if ( d % 2 == 0 ) intervals.add( Views.dropSingletonDimensions( Views.interval( img, new FinalInterval( new long[] { img.min( 0 ), img.min( 1 ), d }, new long[] { img.max( 0 ), img.max( 1 ), d } ) ) ) ); } // stack it! final RandomAccessibleInterval< UnsignedByteType > stack = Views.stack( intervals ); assertTrue( stack.numDimensions() == 3 ); assertTrue( intervals.size() == stack.dimension( 2 ) ); final Cursor< UnsignedByteType > stackC = Views.iterable( stack ).cursor(); while ( stackC.hasNext() ) { assertTrue( stackC.next().get() % 2 == 0 ); } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/SubsampleIntervalViewTest.java000066400000000000000000000122531316447754700301670ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import org.junit.Assert; import org.junit.Test; import net.imglib2.Cursor; import net.imglib2.FinalInterval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgs; import net.imglib2.img.basictypeaccess.array.IntArray; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.ConstantUtils; public class SubsampleIntervalViewTest { @Test public void test1DSubsampling() { // Tests single dimensional (array) subsampling final int[] testData = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; final int[][] expectedSubsamples = new int[][] { {}, {}, // not testing a subsampling size of 0 or 1 { 0, 2, 4, 6, 8, 10 }, // sample size 2 { 0, 3, 6, 9 }, { 0, 4, 8 }, { 0, 5, 10 }, { 0, 6 }, { 0, 7 }, { 0, 8 } // sample size 8 }; final int[] testShifts = new int[] { -17, -8, 2, 0, 5, 8, 9, 10 }; final ArrayImg< IntType, IntArray > interval = ArrayImgs.ints( testData, testData.length ); IntervalView< IntType > shiftedInterval; SubsampleIntervalView< IntType > subInterval; for ( int shift : testShifts ) { shiftedInterval = Views.translate( interval, shift ); // subsampling should be shift-invariant for ( int subsamplesize = 2; subsamplesize <= 8; subsamplesize++ ) { subInterval = Views.subsample( shiftedInterval, subsamplesize ); // try subsample sizes between 2 and 8, compare to the expected // subsamples Cursor< IntType > subIntCursor = Views.flatIterable( subInterval ).cursor(); for ( int i = 0; i < expectedSubsamples[ subsamplesize ].length || subIntCursor.hasNext(); i++ ) { Assert.assertEquals( expectedSubsamples[ subsamplesize ][ i ], subIntCursor.next().get() ); } } } } @Test public void testDimSubsampling() { final long[] minValues = new long[] { 0, 30, -10, 303, -302 }; final long[] maxValues = new long[] { 100, 53, 7, 305, 1431 }; final int dimension = minValues.length; final FinalInterval interval = new FinalInterval( minValues, maxValues ); final long[][] expectedDimensionSizes = new long[][] { {}, {}, // not testing a subsampling size of 0 or 1 { 51, 12, 9, 2, 867 }, { 34, 8, 6, 1, 578 }, { 26, 6, 5, 1, 434 }, { 21, 5, 4, 1, 347 }, { 17, 4, 3, 1, 289 }, { 15, 4, 3, 1, 248 }, { 13, 3, 3, 1, 217 }, }; // tests a bunch of random shifts in each dimension final long[][] testShifts = new long[][] { { -56, 11, 82, -83, -33 }, { 4, 18, 10, 8, 13 }, { 4, -85, 0, -58, -73 }, { -7, 3, -75, -23, 31 }, { 79, -7, 54, 44, 1 }, { 0, -802, 968, 185, 1072 } }; IntervalView< FloatType > shiftedInterval; SubsampleIntervalView< FloatType > subInterval; RandomAccessibleInterval< FloatType > randAccessInterval = ConstantUtils.constantRandomAccessibleInterval( new FloatType( 1f ), 5, interval ); for ( long[] shift : testShifts ) { shiftedInterval = Views.translate( randAccessInterval, shift ); for ( int subsamplesize = 2; subsamplesize <= 8; subsamplesize++ ) { subInterval = Views.subsample( shiftedInterval, subsamplesize ); // checks that size of each dimension is what it should be after // subsampling Assert.assertArrayEquals( expectedDimensionSizes[ subsamplesize ], subInterval.dimensions ); } } } } imglib2-imglib2-4.5.0/src/test/java/net/imglib2/view/TranslationTransformConcatenateTest.java000066400000000000000000000124351316447754700322350ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package net.imglib2.view; import static org.junit.Assert.assertTrue; import net.imglib2.transform.integer.Translation; import net.imglib2.transform.integer.TranslationTransform; import org.junit.Before; import org.junit.Test; import Jama.Matrix; /** * TODO * */ public class TranslationTransformConcatenateTest { public static boolean testConcatenation( final TranslationTransform t1, final Translation t2 ) { if ( t1.numSourceDimensions() != t2.numTargetDimensions() ) { System.out.println( "incompatible dimensions" ); return false; } final TranslationTransform t1t2 = t1.concatenate( t2 ); final Matrix mt1 = new Matrix( t1.getMatrix() ); final Matrix mt2 = new Matrix( t2.getMatrix() ); final Matrix mt1t2 = new Matrix( t1t2.getMatrix() ); if ( mt1.times( mt2 ).minus( mt1t2 ).normF() > 0.1 ) { System.out.println( "=======================" ); System.out.println( "t1: " + t1.numSourceDimensions() + " -> " + t1.numTargetDimensions() + " (n -> m)" ); System.out.println( "t2: " + t2.numSourceDimensions() + " -> " + t2.numTargetDimensions() + " (n -> m)" ); System.out.println( "t1t2: " + t1t2.numSourceDimensions() + " -> " + t1t2.numTargetDimensions() + " (n -> m)" ); System.out.print( "t1 = " ); mt1.print( 1, 0 ); System.out.print( "t2 = " ); mt2.print( 1, 0 ); System.out.print( "t1t2 = " ); mt1t2.print( 1, 0 ); System.out.print( "t1 x t2 = " ); mt1.times( mt2 ).print( 1, 0 ); System.out.println( "wrong result" ); System.out.println( "=======================" ); return false; } return true; } public static boolean testPreConcatenation( final Translation t1, final TranslationTransform t2 ) { if ( t1.numSourceDimensions() != t2.numTargetDimensions() ) { System.out.println( "incompatible dimensions" ); return false; } final TranslationTransform t1t2 = t2.preConcatenate( t1 ); final Matrix mt1 = new Matrix( t1.getMatrix() ); final Matrix mt2 = new Matrix( t2.getMatrix() ); final Matrix mt1t2 = new Matrix( t1t2.getMatrix() ); if ( mt1.times( mt2 ).minus( mt1t2 ).normF() > 0.1 ) { System.out.println( "=======================" ); System.out.println( "t1: " + t1.numSourceDimensions() + " -> " + t1.numTargetDimensions() + " (n -> m)" ); System.out.println( "t2: " + t2.numSourceDimensions() + " -> " + t2.numTargetDimensions() + " (n -> m)" ); System.out.println( "t1t2: " + t1t2.numSourceDimensions() + " -> " + t1t2.numTargetDimensions() + " (n -> m)" ); System.out.print( "t1 = " ); mt1.print( 1, 0 ); System.out.print( "t2 = " ); mt2.print( 1, 0 ); System.out.print( "t1t2 = " ); mt1t2.print( 1, 0 ); System.out.print( "t1 x t2 = " ); mt1.times( mt2 ).print( 1, 0 ); System.out.println( "wrong result" ); System.out.println( "=======================" ); return false; } return true; } TranslationTransform tr1; TranslationTransform tr2; @Before public void setUp() { tr1 = new TranslationTransform( 3 ); final long[] translation = new long[] { 3, 4, 5 }; tr1.setTranslation( translation ); tr2 = new TranslationTransform( new long[] { 7, 8, 9 } ); } @Test public void concatenateTr1Tr2() { assertTrue( testConcatenation( tr1, tr2 ) ); } @Test public void preconcatenateTr1Tr2() { assertTrue( testPreConcatenation( tr1, tr2 ) ); } @Test public void concatenateTr2Tr1() { assertTrue( testConcatenation( tr2, tr1 ) ); } @Test public void preconcatenateTr2Tr1() { assertTrue( testPreConcatenation( tr2, tr1 ) ); } } imglib2-imglib2-4.5.0/src/test/java/tests/000077500000000000000000000000001316447754700202435ustar00rootroot00000000000000imglib2-imglib2-4.5.0/src/test/java/tests/BasicTest.java000066400000000000000000000075051316447754700227760ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package tests; import static org.junit.Assert.assertTrue; import net.imglib2.Cursor; import net.imglib2.img.Img; import net.imglib2.type.numeric.real.FloatType; import org.junit.Test; /** * Basic tests * * If these tests fail, the world is about to end. * * * @author Johannes Schindelin */ public class BasicTest extends JUnitTestBase { /** * A very simple test image: 3x3x3, with the pixel (1, 0, 2) set to 1, * otherwise 0 */ protected Img< FloatType > singlePixel = makeSinglePixel3D( 3, 1, 0, 2 ); protected float[] singlePixelSignature = { 0.037037037f, 1.0f, 0.0f, 2.0f, 0.18885258f, 0.0f, 0.0f, 0.0f }; /** * The second test image */ protected Img< FloatType > testImage = makeTestImage3D( 3 ); protected float[] testImageSignature = { 11.0f, 1.1818181f, 1.2424242f, 1.3636364f, 6.6666665f, 0.7959956f, 0.7796777f, 0.77138925f }; /** * Test the value of the single "bright" pixel */ @Test public void testOnePixel() { assertTrue( get3D( singlePixel, 1, 0, 2 ) == 1 ); } /** * Test the value of a "dark" pixel */ @Test public void testAnotherPixel() { assertTrue( get3D( singlePixel, 2, 0, 1 ) == 0 ); } /** * Verify that the pixels were stored correctly */ @Test public void testDefinition() { assertTrue( match( testImage, new TestGenerator( 3 ) ) ); } /** * Verify the known (and hand-generated) image signatures */ @Test public void testSignature() { assertTrue( matchSignature( singlePixel, singlePixelSignature ) ); assertTrue( matchSignature( testImage, testImageSignature ) ); } /** * Ensure that all pixels are iterated over */ @Test public void testCursorCoverage() { final Cursor< FloatType > cursor = testImage.cursor(); long count = 0; while ( cursor.hasNext() ) { cursor.fwd(); count++; } assertTrue( count == 27 ); final Cursor< FloatType > localizingCursor = testImage.localizingCursor(); count = 0; while ( localizingCursor.hasNext() ) { localizingCursor.fwd(); count++; } assertTrue( count == 27 ); } } imglib2-imglib2-4.5.0/src/test/java/tests/BasicTests.java000066400000000000000000000075171316447754700231640ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package tests; import static org.junit.Assert.assertTrue; import net.imglib2.Cursor; import net.imglib2.img.Img; import net.imglib2.type.numeric.real.FloatType; import org.junit.Test; /** * Basic tests * * If these tests fail, the world is about to end. * * * @author Johannes Schindelin */ public class BasicTests extends JUnitTestBase { /** * A very simple test image: 3x3x3, with the pixel (1, 0, 2) set to 1, * otherwise 0 */ protected Img< FloatType > singlePixel = makeSinglePixel3D( 3, 1, 0, 2 ); protected float[] singlePixelSignature = { 0.037037037f, 1.0f, 0.0f, 2.0f, 0.18885258f, 0.0f, 0.0f, 0.0f }; /** * The second test image */ protected Img< FloatType > testImage = makeTestImage3D( 3 ); protected float[] testImageSignature = { 11.0f, 1.1818181f, 1.2424242f, 1.3636364f, 6.6666665f, 0.7959956f, 0.7796777f, 0.77138925f }; /** * Test the value of the single "bright" pixel */ @Test public void testOnePixel() { assertTrue( get3D( singlePixel, 1, 0, 2 ) == 1 ); } /** * Test the value of a "dark" pixel */ @Test public void testAnotherPixel() { assertTrue( get3D( singlePixel, 2, 0, 1 ) == 0 ); } /** * Verify that the pixels were stored correctly */ @Test public void testDefinition() { assertTrue( match( testImage, new TestGenerator( 3 ) ) ); } /** * Verify the known (and hand-generated) image signatures */ @Test public void testSignature() { assertTrue( matchSignature( singlePixel, singlePixelSignature ) ); assertTrue( matchSignature( testImage, testImageSignature ) ); } /** * Ensure that all pixels are iterated over */ @Test public void testCursorCoverage() { final Cursor< FloatType > cursor = testImage.localizingCursor(); int count = 0; while ( cursor.hasNext() ) { cursor.fwd(); count++; } assertTrue( count == 27 ); final Cursor< FloatType > localizingCursor = testImage.localizingCursor(); count = 0; while ( localizingCursor.hasNext() ) { localizingCursor.fwd(); count++; } assertTrue( count == 27 ); } } imglib2-imglib2-4.5.0/src/test/java/tests/JUnitTestBase.java000066400000000000000000000222541316447754700235770ustar00rootroot00000000000000/* * #%L * ImgLib2: a general-purpose, multidimensional image processing library. * %% * Copyright (C) 2009 - 2016 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld, * John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke, * Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner, * Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert, * Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin, * Jean-Yves Tinevez and Michael Zinsmaier. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * #L% */ package tests; import java.util.Arrays; import net.imglib2.Cursor; import net.imglib2.RandomAccess; import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.Intervals; /** * The base class for JUnit tests * * This class provides several methods to verify that a result of an operation * is as expected. * * The simplest method verifies that a given image agrees with a function that * maps coordinates to values. * * Sometimes, it is not possible to calculate easily what the result image * should be, in which case you can use a signature for verification: the 1st * and 2nd order moments of the intensity, and the moments of intensity * pos[i] * for i = 0, .., dim-1 * * * @author Johannes Schindelin */ public class JUnitTestBase { /** * An interface for image generators */ protected interface Function { public float calculate( long[] pos ); } /** * Check whether an image is identical to a generated image */ protected < T extends RealType< T >> boolean match( final Img< T > image, final Function function ) { final Cursor< T > cursor = image.localizingCursor(); final long[] pos = new long[ cursor.numDimensions() ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); if ( function.calculate( pos ) != cursor.get().getRealFloat() ) return false; } return true; } /** * Check whether an image is identical to a generated image, with fuzz */ protected < T extends RealType< T >> boolean match( final Img< T > image, final Function function, final float tolerance ) { final Cursor< T > cursor = image.localizingCursor(); final long[] pos = new long[ cursor.numDimensions() ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); if ( Math.abs( function.calculate( pos ) - cursor.get().getRealFloat() ) > tolerance ) return false; } return true; } /** * Calculate an image signature * * The image signature are 1st and 2nd order moments of the intensity and * the coordinates. */ protected < T extends RealType< T >> float[] signature( final Img< T > image ) { final float[] result = new float[ ( image.numDimensions() + 1 ) * 2 ]; signature( image, result ); return result; } /** * Calculate an image signature * * The image signature are 1st and 2nd order moments of the intensity and * the coordinates. */ protected < T extends RealType< T >> void signature( final Img< T > image, final float[] result ) { Arrays.fill( result, 0 ); final Cursor< T > cursor = image.localizingCursor(); final int dim = cursor.numDimensions(); final int[] pos = new int[ dim ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); final float value = cursor.get().getRealFloat(); result[ 0 ] += value; result[ dim + 1 ] += value * value; for ( int i = 0; i < dim; i++ ) { result[ i + 1 ] += value * pos[ i ]; result[ i + 1 + dim + 1 ] += value * pos[ i ] * pos[ i ]; } } for ( int i = 1; i < dim + 1; i++ ) { result[ i ] /= result[ 0 ]; result[ i + dim + 1 ] = ( float ) Math.sqrt( result[ i + dim + 1 ] / result[ 0 ] - result[ i ] * result[ i ] ); } final long[] dims = Intervals.dimensionsAsLongArray( image ); float total = dims[ 0 ]; for ( int i = 1; i < dim; i++ ) total *= dims[ i ]; result[ 0 ] /= total; result[ dim + 1 ] = ( float ) Math.sqrt( result[ dim + 1 ] / total - result[ 0 ] * result[ 0 ] ); } /** * Verify that an image has a certain image signature * * When it is hard/computationally expensive to calculate the values of the * expected image, we need a quick test like this one. */ protected < T extends RealType< T >> boolean matchSignature( final Img< T > image, final float[] signature ) { final float[] result = signature( image ); return Arrays.equals( result, signature ); } /** * Verify that an image has a certain image signature, with fuzz * * When it is hard/computationally expensive to calculate the values of the * expected image, we need a quick test like this one. */ protected < T extends RealType< T >> boolean matchSignature( final Img< T > image, final float[] signature, final float tolerance ) { final float[] result = signature( image ); for ( int i = 0; i < signature.length; i++ ) if ( Math.abs( result[ i ] - signature[ i ] ) > tolerance ) return false; return true; } /** * Convenience helper to access single pixels */ protected < T extends RealType< T >> float get( final Img< T > image, final int[] pos ) { final RandomAccess< T > cursor = image.randomAccess(); cursor.setPosition( pos ); final float result = cursor.get().getRealFloat(); return result; } /** * Convenience helper to access single pixels */ protected < T extends RealType< T >> float get3D( final Img< T > image, final int x, final int y, final int z ) { return get( image, new int[] { x, y, z } ); } /** * Generate an image */ protected < T extends RealType< T > & NativeType< T >> Img< T > makeImage( final T type, final Function function, final long[] dims ) { final ImgFactory< T > factory = new ArrayImgFactory< T >(); final Img< T > result = factory.create( dims, type ); final Cursor< T > cursor = result.cursor(); final long[] pos = new long[ cursor.numDimensions() ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); final float value = function.calculate( pos ); cursor.get().setReal( value ); } return result; } /** * Test image generator (of a hopefully complex-enough image) */ protected class TestGenerator implements Function { float factor; protected TestGenerator( final float factor ) { this.factor = factor; } @Override public float calculate( final long[] pos ) { return 1 + pos[ 0 ] + 2 * ( pos[ 0 ] + 1 ) * pos[ 1 ] + factor * pos[ 2 ] * pos[ 2 ]; } } /** * Test image generator * * This test image is 0 everywhere, except at the given coordinate, where it * is 1. */ protected class SinglePixel3D implements Function { long x, y, z; protected SinglePixel3D( final long x, final long y, final long z ) { this.x = x; this.y = y; this.z = z; } @Override public float calculate( final long[] pos ) { return pos[ 0 ] == x && pos[ 1 ] == y && pos[ 2 ] == z ? 1 : 0; } } /** * Generate a test image */ protected Img< FloatType > makeTestImage3D( final long cubeLength ) { return makeImage( new FloatType(), new TestGenerator( cubeLength ), new long[] { cubeLength, cubeLength, cubeLength } ); } /** * Generate a test image */ protected Img< FloatType > makeSinglePixel3D( final long cubeLength, final long x, final long y, final long z ) { return makeImage( new FloatType(), new SinglePixel3D( x, y, z ), new long[] { cubeLength, cubeLength, cubeLength } ); } /** * Convenience method to display a tuple of floats, such as the image * signature */ public String toString( final float[] array ) { if ( array == null ) return "(null)"; if ( array.length == 0 ) return "()"; final StringBuffer buffer = new StringBuffer(); buffer.append( "( " + array[ 0 ] ); for ( int i = 1; i < array.length; i++ ) buffer.append( "f, " + array[ i ] ); buffer.append( "f )" ); return buffer.toString(); } }