15 {
17
18
19
21 {
23 image = reader.AsMultiscaleImage();
25
26
27 long[] shape = level.Shape;
28 string dtype = level.DataType;
29 int rank = level.Rank;
30 double[] pixelSize = level.GetPixelSize();
31
32
33 var axes = level.Multiscale.Axes;
34 var yIndex = Array.FindIndex(axes, a => a.Name.Equals("y", StringComparison.OrdinalIgnoreCase));
35 var xIndex = Array.FindIndex(axes, a => a.Name.Equals("x", StringComparison.OrdinalIgnoreCase));
36 long arrayHeight = level.Shape[yIndex];
37 long arrayWidth = level.Shape[xIndex];
38
39
40
41
42
43
44
45
46
47 var plane = await level.ReadPlaneAsync(t: 0, c: 0, z: 0);
48
49
50 int width = plane.Width;
51 int height = plane.Height;
52
53
54
55
56
57 ushort[,] pixels2D = plane.As2DArray<ushort>();
58 ushort[] pixels1D = plane.As1DArray<ushort>();
60
61
62
63
64
66 origin: [0, 0, 0, 0, 0],
67 size: [5, 4, 10, 100, 100]
68 );
69 var result = await level.ReadRegionAsync(roi);
70
71
72 var data = result.Data;
73 shape = result.Shape;
74 dtype = result.DataType;
75 rank = result.Rank;
76 var elementCount = result.ElementCount;
77
78
79
80
81 }
82
83
84
85
86
87 public static async Task GetArrayDimensions()
88 {
90
91
92 var axes = level.Multiscale.Axes;
93 for (int i = 0; i < axes.Length; i++)
94 {
95 Console.WriteLine($"{axes[i].Name}: {level.Shape[i]}");
96 }
97
98
99
100 if (level.Rank == 5)
101 {
102 long t = level.Shape[0];
103 long c = level.Shape[1];
104 long z = level.Shape[2];
105 long y = level.Shape[3];
106 long x = level.Shape[4];
107 Console.WriteLine($"Array: {t}t x {c}c x {z}z x {y}y x {x}x");
108 }
109 }
110
111
112 public static async Task GetPlaneDimensions()
113 {
115 var plane = await level.ReadPlaneAsync(t: 0, c: 0, z: 0);
116
117
118 Console.WriteLine($"Plane: {plane.Width} x {plane.Height}");
119
120
121 Console.WriteLine($"Shape: [{string.Join(", ", plane.Shape)}]");
122 }
123
124
125 public async static Task ValidateDimensions()
126 {
128
129
130 if (level.Rank != 5)
131 {
132 throw new InvalidOperationException(
133 $"Expected 5D data (t,c,z,y,x), got {level.Rank}D");
134 }
135
136
137 var yIndex = Array.FindIndex(level.Multiscale.Axes,
138 a => a.Name.Equals("y", StringComparison.OrdinalIgnoreCase));
139 var xIndex = Array.FindIndex(level.Multiscale.Axes,
140 a => a.Name.Equals("x", StringComparison.OrdinalIgnoreCase));
141
142 long height = level.Shape[yIndex];
143 long width = level.Shape[xIndex];
144
145 Console.WriteLine($"Spatial dimensions: {width} x {height}");
146 }
147
148
149 public async static Task ProcessPlane()
150 {
152 var plane = await level.ReadPlaneAsync(t: 0, c: 0, z: 0);
153
154
155 int w = plane.Width;
156 int h = plane.Height;
157
158
159 var pixels = plane.As2DArray<ushort>();
160 for (int y = 0; y < h; y++)
161 {
162 for (int x = 0; x < w; x++)
163 {
164 ushort value = pixels[y, x];
165
166 }
167 }
168 }
169 }
Represents a multiscale image group. Contains one or more resolution levels and optionally a labels s...
Definition OmeZarrNodes.cs:40
async Task< ResolutionLevelNode > OpenResolutionLevelAsync(int multiscaleIndex=0, int datasetIndex=0, CancellationToken ct=default)
Opens a specific resolution level by index (0 = full resolution).
Definition OmeZarrNodes.cs:56
A region of interest expressed in physical units (e.g. micrometers). Axis order matches the multiscal...
Definition PhysicalROI.cs:9
Entry point for reading OME-Zarr datasets.
Definition OmeZarrReader.cs:31
static async Task< OmeZarrReader > OpenAsync(string pathOrUrl, CancellationToken ct=default)
Opens a Zarr store at the given path or URL and detects the OME-Zarr node type at the root.
Definition OmeZarrReader.cs:99
Definition PlaneReader.cs:5
Definition ChunkLruCache.cs:3
Definition BloscCodec.cs:6