-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package develop; | ||
|
||
import ij.IJ; | ||
import ij.ImagePlus; | ||
import net.imglib2.RandomAccessibleInterval; | ||
import net.imglib2.converter.Converters; | ||
import net.imglib2.img.display.imagej.ImageJFunctions; | ||
import net.imglib2.type.numeric.integer.UnsignedShortType; | ||
import net.imglib2.type.numeric.real.FloatType; | ||
import org.embl.mobie.io.OMEZarrWriter; | ||
|
||
public class LazyConvertAndSaveOMEZarr | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
// Open | ||
ImagePlus floatImp = IJ.openVirtual("/Users/tischer/Desktop/blobs-float.tif"); | ||
|
||
// Lazy convert from float to short | ||
float min = 0.0F; | ||
float max = 255.0F; | ||
float scale = 65535 / ( max - min); | ||
RandomAccessibleInterval< FloatType > floatTypes = ImageJFunctions.wrapFloat( floatImp ); | ||
RandomAccessibleInterval< UnsignedShortType > shortTypes = | ||
Converters.convert( floatTypes, ( floatType, shortType ) | ||
-> shortType.setReal( scale * ( floatType.get() - min ) ), new UnsignedShortType() ); | ||
ImagePlus shortImp = ImageJFunctions.wrap( shortTypes, "converted image" ); | ||
|
||
// Save | ||
OMEZarrWriter.write( shortImp, "/Users/tischer/Desktop/test.zarr", OMEZarrWriter.ImageType.Intensities, true ); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/java/develop/OpenOMEZarrFromS3WithCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package develop; | ||
|
||
import bdv.cache.SharedQueue; | ||
import org.embl.mobie.io.ImageDataFormat; | ||
import org.embl.mobie.io.ImageDataOpener; | ||
import org.embl.mobie.io.imagedata.ImageData; | ||
|
||
import java.util.Arrays; | ||
|
||
public class OpenOMEZarrFromS3WithCredentials | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
ImageDataFormat omeZarr = ImageDataFormat.OmeZarr; | ||
// If the below is commented it will look in ~/.aws/credentials | ||
//omeZarr.setS3SecretAndAccessKey( new String[]{"tr4UedW5", "XfECV2scqKkpAM"} ); | ||
ImageData< ? > imageData = ImageDataOpener.open( | ||
"https://s3.embl.de/wsi-unihd/mitosis-5D.ome.zarr", | ||
omeZarr, | ||
new SharedQueue( 4 ) ); | ||
long[] dimensions = imageData.getSourcePair( 0 ).getA().getSource( 0, 0 ).dimensionsAsLongArray(); | ||
System.out.println( Arrays.toString( dimensions )); | ||
} | ||
} |