Created
December 8, 2023 18:16
-
-
Save bogovicj/cb5ddfbc31a3ec1ad2e1aebf6452a6b7 to your computer and use it in GitHub Desktop.
Create example n5 array datasets for a variety of compression methods.
This file contains hidden or 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
package org.janelia.saalfeldlab.n5.generateExamples; | |
import org.janelia.saalfeldlab.n5.Bzip2Compression; | |
import org.janelia.saalfeldlab.n5.Compression; | |
import org.janelia.saalfeldlab.n5.GzipCompression; | |
import org.janelia.saalfeldlab.n5.Lz4Compression; | |
import org.janelia.saalfeldlab.n5.N5Writer; | |
import org.janelia.saalfeldlab.n5.RawCompression; | |
import org.janelia.saalfeldlab.n5.XzCompression; | |
import org.janelia.saalfeldlab.n5.blosc.BloscCompression; | |
import org.janelia.saalfeldlab.n5.imglib2.N5Utils; | |
import org.janelia.saalfeldlab.n5.universe.N5Factory; | |
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; | |
public class CompressionExamples { | |
public static void main(String[] args) { | |
final String rootPath = args[0]; | |
final N5Writer n5 = new N5Factory().openWriter( rootPath ); | |
final ArrayImg<UnsignedByteType, ByteArray> img = ArrayImgs.unsignedBytes(3, 2); | |
final int[] blockSize = new int[]{3, 2}; | |
for( Compression c : getCompressions() ) | |
{ | |
final String dset = c.getClass().getName().replaceAll(".*\\.", ""); | |
System.out.println( dset ); | |
N5Utils.save(img, n5, dset, blockSize, c); | |
} | |
} | |
protected static Compression[] getCompressions() { | |
return new Compression[]{ | |
new RawCompression(), | |
new Bzip2Compression(), | |
new BloscCompression(), | |
new GzipCompression(), | |
new Lz4Compression(), | |
new XzCompression() | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment