|
11 | 11 | * %%
|
12 | 12 | * Redistribution and use in source and binary forms, with or without
|
13 | 13 | * modification, are permitted provided that the following conditions are met:
|
14 |
| - * |
| 14 | + * |
15 | 15 | * 1. Redistributions of source code must retain the above copyright notice,
|
16 | 16 | * this list of conditions and the following disclaimer.
|
17 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
18 | 18 | * this list of conditions and the following disclaimer in the documentation
|
19 | 19 | * and/or other materials provided with the distribution.
|
20 |
| - * |
| 20 | + * |
21 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22 | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23 | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
34 | 34 | package net.imglib2.labeling;
|
35 | 35 |
|
36 | 36 | import net.imagej.ImageJService;
|
37 |
| -import net.imglib2.labeling.codecs.LabelingMappingCodec; |
38 | 37 | import net.imglib2.labeling.data.Container;
|
39 | 38 | import net.imglib2.roi.labeling.ImgLabeling;
|
40 | 39 | import net.imglib2.type.numeric.IntegerType;
|
41 |
| -import org.bson.codecs.Codec; |
42 | 40 |
|
43 | 41 | import java.io.IOException;
|
44 | 42 | import java.util.function.LongFunction;
|
|
48 | 46 | * A service to easily access a load/save functionality for BSON-based labeling data files.
|
49 | 47 | * Basic support for primitive types and BSON standard types is already included. For non-primitive types,
|
50 | 48 | * a codec must be set and the class must be given as an argument to the methods.
|
51 |
| - * Examples for Codecs can be found at {@link LabelingMappingCodec}. |
52 | 49 | *
|
53 | 50 | * @author Tom Burke
|
54 | 51 | */
|
55 | 52 | public interface LabelingIOService extends ImageJService {
|
56 | 53 |
|
57 |
| - <T, I extends IntegerType<I>> ImgLabeling<T,I> load(String file) throws IOException; |
58 |
| - |
59 |
| - <T, I extends IntegerType<I>> ImgLabeling<T,I> load(String file, Class<T> clazz, Codec<T>... codecs) throws IOException; |
60 |
| - |
61 |
| - <T, I extends IntegerType<I>> void save(ImgLabeling<T,I> imgLabeling, String file) throws IOException; |
62 |
| - |
63 |
| - <T, I extends IntegerType<I>> void save(ImgLabeling<T,I> imgLabeling, String file, Class<T> clazz, Codec<T>... codecs) throws IOException; |
| 54 | + <T, I extends IntegerType<I>> ImgLabeling<T, I> load(String file, Class<T> labelType, Class<I> backingType) throws IOException; |
64 | 55 |
|
| 56 | + <T, I extends IntegerType<I>> void save(ImgLabeling<T, I> imgLabeling, String file) throws IOException; |
65 | 57 |
|
66 | 58 | /**
|
67 | 59 | * Load a labeling container from the given file path as string.
|
68 | 60 | * The file path must point to the bson file containing the labeling data.
|
69 | 61 | *
|
70 |
| - * @param file The path to the file |
71 |
| - * @param codecs One or more codecs necessary to convert the data to clazz. |
72 |
| - * @param metadataClazz the metadata class |
73 |
| - * @param <T> the label value |
74 |
| - * @param <I> IntegerType for the pixel value |
75 |
| - * @param <S> Class of the meta data |
76 |
| - * @throws IOException on file read fail |
| 62 | + * @param file The path to the file |
| 63 | + * @param metadataType the metadata class |
| 64 | + * @param <T> the label value |
| 65 | + * @param <I> IntegerType for the pixel value |
| 66 | + * @param <S> Class of the meta data |
77 | 67 | * @return a container object holding the ImgLabeling (as well as an optional source mapping)
|
78 |
| - */ |
79 |
| - <S, T, I extends IntegerType<I>> Container<S, T, I> loadWithMetadata(String file, Class<S> metadataClazz, Codec<?>... codecs) throws IOException; |
80 |
| - |
81 |
| - |
82 |
| - /** |
83 |
| - * Load a labeling container from the given file path as string. |
84 |
| - * The file path must point to the bson file containing the labeling data. |
85 |
| - * |
86 |
| - * @param file The path to the file |
87 |
| - * @param clazz The class to convert the contains of the file to |
88 |
| - * @param metadataClazz the metadata class |
89 |
| - * @param codecs One or more codecs necessary to convert the data to clazz. |
90 |
| - * @param <T> the label value |
91 |
| - * @param <I> IntegerType for the pixel value |
92 |
| - * @param <S> Class of the meta data |
93 | 68 | * @throws IOException on file read fail
|
94 |
| - * @return a container object holding the ImgLabeling (as well as an optional source mapping) |
95 | 69 | */
|
96 |
| - <S, T, I extends IntegerType<I>> Container<S, T, I> loadWithMetadata(String file, Class<T> clazz, Class<S> metadataClazz, Codec<?>... codecs) throws IOException; |
| 70 | + <S, T, I extends IntegerType<I>> Container<S, T, I> loadWithMetadata(String file, Class<S> metadataType, Class<T> labelType, Class<I> backingType) throws IOException; |
97 | 71 |
|
98 | 72 | /**
|
99 | 73 | * Load a labeling container from the given file path as string.
|
100 | 74 | * The file path must point to the bson file containing the labeling data.
|
101 | 75 | *
|
102 |
| - * @param file The path to the file |
103 |
| - * @param idToLabel a function transforming the label of type T into something else |
| 76 | + * @param file The path to the file |
| 77 | + * @param idToLabel a function transforming the label of type T into something else |
104 | 78 | * @param metadataClazz the metadata class
|
105 |
| - * @param codecs One or more codecs necessary to convert the data to clazz. |
106 |
| - * @param <T> the label value |
107 |
| - * @param <I> IntegerType for the pixel value |
108 |
| - * @param <S> Class of the meta data |
109 |
| - * @throws IOException on file read fail |
| 79 | + * @param <T> the label value |
| 80 | + * @param <I> IntegerType for the pixel value |
| 81 | + * @param <S> Class of the meta data |
110 | 82 | * @return a container object holding the ImgLabeling (as well as an optional source mapping)
|
| 83 | + * @throws IOException on file read fail |
111 | 84 | */
|
112 |
| - <S, T, I extends IntegerType<I>> Container<S, T, I> loadWithMetadata(String file, LongFunction<T> idToLabel, Class<S> metadataClazz, Codec<?>... codecs) throws IOException; |
113 |
| - |
114 |
| - /** |
115 |
| - * Save an ImgLabelingContainer in the file-path, transforming it into a bson file and an image. |
116 |
| - * The path must contain the filename (ending does not matter). |
117 |
| - * |
118 |
| - * @param codecs one or more codecs to convert clazz into something bsonifyable |
119 |
| - * @param container the container with the ImgLabeling and a metadata object |
120 |
| - * @param file the path pointing to the file, including the filename |
121 |
| - * @param metadataClazz the metadata class |
122 |
| - * @param <T> the label value |
123 |
| - * @param <I> IntegerType for the pixel value |
124 |
| - * @param <S> Class of the meta data |
125 |
| - */ |
126 |
| - <S, T, I extends IntegerType<I>> void saveWithMetaData(Container<S, T, I> container, String file, Class<S> metadataClazz, Codec<?>... codecs); |
| 85 | + <S, T, I extends IntegerType<I>> Container<S, T, I> loadWithMetadata(String file, LongFunction<T> idToLabel, Class<S> metadataClazz) throws IOException; |
127 | 86 |
|
128 | 87 | /**
|
129 | 88 | * Save an ImgLabelingContainer in the file-path, transforming it into a bson file and an image.
|
130 | 89 | * The path must contain the filename (ending does not matter).
|
131 | 90 | *
|
132 |
| - * @param clazz the class of the type T that is contained in the labeling |
133 |
| - * @param codecs one or more codecs to convert clazz into something bsonifyable |
134 |
| - * @param container the container with the ImgLabeling and a metadata object |
135 |
| - * @param file the path pointing to the file, including the filename |
136 |
| - * @param metadataClazz the metadata class |
137 |
| - * @param <T> the label value |
138 |
| - * @param <I> IntegerType for the pixel value |
139 |
| - * @param <S> Class of the meta data |
| 91 | + * @param imgLabeling the imglabeling object that needs to be serialized |
| 92 | + * @param file the path pointing to the file, including the filename |
| 93 | + * @param <T> the label value |
| 94 | + * @param <I> IntegerType for the pixel value |
| 95 | + * @param <S> Class of the meta data |
140 | 96 | */
|
141 |
| - <S, T, I extends IntegerType<I>> void saveWithMetaData(Container<S, T, I> container, String file, Class<T> clazz, Class<S> metadataClazz, Codec<?>... codecs); |
| 97 | + <S, T, I extends IntegerType<I>> void saveWithMetaData(ImgLabeling<T, I> imgLabeling, String file, S metadata) throws IOException; |
142 | 98 |
|
143 | 99 | /**
|
144 | 100 | * Save an ImgLabelingContainer in the file-path, transforming it into a bson file and an image.
|
145 | 101 | * The path must contain the filename (ending does not matter).
|
146 | 102 | *
|
147 |
| - * @param labelToId a function to convert the type T to a long value. |
148 |
| - * @param container the container with the ImgLabeling and a metadata object |
149 |
| - * @param codecs one or more codecs to convert clazz into something bsonifyable |
150 |
| - * @param file the path pointing to the file, including the filename |
151 |
| - * @param metadataClazz the metadata class |
152 |
| - * @param <T> the label value |
153 |
| - * @param <I> IntegerType for the pixel value |
154 |
| - * @param <S> Class of the meta data |
| 103 | + * @param imgLabeling the imglabeling object that needs to be serialized |
| 104 | + * @param labelToId a function to convert the type T to a long value. |
| 105 | + * @param file the path pointing to the file, including the filename |
| 106 | + * @param <T> the label value |
| 107 | + * @param <I> IntegerType for the pixel value |
| 108 | + * @param <S> Class of the meta data |
155 | 109 | */
|
156 |
| - <S, T, I extends IntegerType<I>> void saveWithMetaData(Container<S, T, I> container, String file, ToLongFunction<T> labelToId, Class<S> metadataClazz, Codec<?>... codecs); |
| 110 | + <S, T, I extends IntegerType<I>> void saveWithMetaData(ImgLabeling<T, I> imgLabeling, String file, ToLongFunction<T> labelToId, S metadata) throws IOException; |
157 | 111 |
|
158 | 112 | }
|
0 commit comments