Package qupath.opencv.tools
Class NumpyTools
java.lang.Object
qupath.opencv.tools.NumpyTools
Read .npy and .npz files from NumPy.
Note that only a subset of files are supported. Specifically, each .npy file should contain a single (possibly multidimensional) array with a type supported by OpenCV.
Structured, complex and object arrays are not supported.
See https://numpy.org/devdocs/reference/generated/numpy.lib.format.html for more information about the format.
- Since:
- v0.4.0
- Author:
- Pete Bankhead
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreadAllMats(String path) Read a all Mats from an .npy or .npz file.readAllMats(String path, boolean squeezeDimensions) Read a all Mats from an .npy or .npz file, optionally squeezing singleton dimensions.readAllMats(Path path) Read a all Mats from an .npy or .npz path.readAllMats(Path path, boolean squeezeDimensions) Read a all Mats from an .npy or .npz path, optionally squeezing singleton dimensions This will be a single Mat for .npy but may be multiple for .npz.static MatreadMat(InputStream stream, boolean squeezeDimensions) Read a single Mat from an input stream, which should follow the .npy file format specification.static MatRead a single Mat from an .npy or .npz file.static MatRead a single Mat from an .npy or .npz file, optionally squeezing singleton dimensions.static MatRead an OpenCV Mat from a Numpy .npy file.static MatRead an OpenCV Mat from a Numpy .npy file, optionally squeezing singleton dimensions.
-
Constructor Details
-
NumpyTools
public NumpyTools()
-
-
Method Details
-
readMat
Read a single Mat from an .npy or .npz file.- Parameters:
path-- Returns:
- Throws:
IOException
-
readMat
Read a single Mat from an .npy or .npz file, optionally squeezing singleton dimensions.- Parameters:
path- path to the .npy filesqueezeDimensions- if true, squeeze singleton dimensions- Returns:
- Throws:
IOException
-
readAllMats
Read a all Mats from an .npy or .npz file. This will be a single Mat for .npy but may be multiple for .npz.- Parameters:
path- path to the file- Returns:
- a map with mat names (from file/entry names) and their corresponding Mats
- Throws:
IOException
-
readAllMats
public static Map<String,Mat> readAllMats(String path, boolean squeezeDimensions) throws IOException Read a all Mats from an .npy or .npz file, optionally squeezing singleton dimensions. This will be a single Mat for .npy but may be multiple for .npz.- Parameters:
path- path to the filesqueezeDimensions- if true, squeeze singleton dimensions- Returns:
- a map with mat names (from file/entry names) and their corresponding Mats
- Throws:
IOException
-
readAllMats
Read a all Mats from an .npy or .npz path. This will be a single Mat for .npy but may be multiple for .npz.- Parameters:
path- path to the file- Returns:
- a map with mat names (from file/entry names) and their corresponding Mats
- Throws:
IOException
-
readAllMats
Read a all Mats from an .npy or .npz path, optionally squeezing singleton dimensions This will be a single Mat for .npy but may be multiple for .npz.- Parameters:
path- path to the filesqueezeDimensions- if true, squeeze singleton dimensions- Returns:
- a map with mat names (from file/entry names) and their corresponding Mats
- Throws:
IOException
-
readMat
Read an OpenCV Mat from a Numpy .npy file.- Parameters:
path- path to the .npy file- Returns:
- Throws:
IOException- if a Mat could not be read from the given path
-
readMat
Read an OpenCV Mat from a Numpy .npy file, optionally squeezing singleton dimensions.- Parameters:
path- path to the .npy filesqueezeDimensions- if true, squeeze singleton dimensions- Returns:
- Throws:
IOException- if a Mat could not be read from the given path
-
readMat
Read a single Mat from an input stream, which should follow the .npy file format specification.- Parameters:
stream-squeezeDimensions-- Returns:
- Throws:
IOException
-