openslide wrapper
More...
|
| | SlideImage () |
| |
| ImageDimension | GetLevelDimension (int level) |
| | Get the dimensions of a level.
|
| |
| IEnumerable< ImageDimension > | GetLevelDimensions () |
| | Get all level dimensions.
|
| |
| unsafe byte[] | ReadRegion (int level, ZCT zct, long x, long y, long width, long height) |
| | Copy pre-multiplied BGRA data from a whole slide image.
|
| |
| unsafe bool | TryReadRegion (int level, long x, long y, long width, long height, out byte[] data, ZCT zct) |
| | Copy pre-multiplied BGRA data from a whole slide image.
|
| |
| void | Close () |
| |
| void | Dispose () |
| |
| async Task< byte[]> | ReadRegionAsync (int level, long curLevelOffsetXPixel, long curLevelOffsetYPixel, int curTileWidth, int curTileHeight, ZCT coord) |
| |
|
| static string | DetectVendor (string filename) |
| | Quickly determine whether a whole slide image is recognized.
|
| |
| static void | Initialize (string path=null) |
| | Add .dll directory to PATH.
|
| |
| static SlideImage | Open (BioImage b) |
| | Open.
|
| |
| static double | CalculateBaseFactor (int originalResolution, int lastLevelResolution, int totalLevels) |
| | Calculates the base downsampling factor between two levels of a slide.
|
| |
| static List< double > | GetLevelDownsamples (double baseDownsampleFactor, int totalLevels) |
| | Calculates the downsample factors for each level of a slide.
|
| |
|
| virtual void | Dispose (bool disposing) |
| | Dispose.
|
| |
|
| BioImage | BioImage [get, set] |
| |
| int | LevelCount [get] |
| | Get the number of levels in the whole slide image.
|
| |
| ImageDimension | Dimensions [get] |
| | Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0).
|
| |
openslide wrapper
Definition at line 18 of file SlideImage.cs.
◆ SlideImage()
| BioLib.SlideImage.SlideImage |
( |
| ) |
|
- Parameters
-
| handle | |
| isOwner | close handle when disposed |
- Exceptions
-
Definition at line 48 of file SlideImage.cs.
◆ CalculateBaseFactor()
| static double BioLib.SlideImage.CalculateBaseFactor |
( |
int | originalResolution, |
|
|
int | lastLevelResolution, |
|
|
int | totalLevels ) |
|
static |
Calculates the base downsampling factor between two levels of a slide.
- Parameters
-
| originalDimension | The dimension (width or height) of the original level. |
| nextLevelDimension | The dimension (width or height) of the next level. |
- Returns
- The base downsampling factor.
Definition at line 150 of file SlideImage.cs.
151 {
152 if (totalLevels <= 1)
153 {
154 throw new ArgumentException("Total levels must be greater than 1 to calculate a base factor.");
155 }
156 if (lastLevelResolution <= 0 || originalResolution <= 0)
157 {
158 throw new ArgumentException("Resolutions must be greater than 0.");
159 }
160
161
162 double baseFactor = Math.Pow((double)originalResolution / lastLevelResolution, 1.0 / (totalLevels - 1));
163 return baseFactor;
164 }
◆ Close()
| void BioLib.SlideImage.Close |
( |
| ) |
|
◆ DetectVendor()
| static string BioLib.SlideImage.DetectVendor |
( |
string | filename | ) |
|
|
static |
Quickly determine whether a whole slide image is recognized.
If OpenSlide recognizes the file referenced by filename , return a string identifying the slide format vendor.This is equivalent to the value of the NativeMethods.VENDOR property. Calling Open(string) on this file will return a valid OpenSlide object or an OpenSlide object in error state.
Otherwise, return null.Calling
Open(string) on this file will also return null.
- Parameters
-
| filename | The filename to check. On Windows, this must be in UTF-8. |
- Returns
- An identification of the format vendor for this file, or NULL.
Definition at line 38 of file SlideImage.cs.
39 {
40 return filename;
41 }
◆ Dispose() [1/2]
| void BioLib.SlideImage.Dispose |
( |
| ) |
|
Definition at line 290 of file SlideImage.cs.
291 {
293 GC.SuppressFinalize(this);
294 }
virtual void Dispose(bool disposing)
Dispose.
◆ Dispose() [2/2]
| virtual void BioLib.SlideImage.Dispose |
( |
bool | disposing | ) |
|
|
protectedvirtual |
Dispose.
- Parameters
-
Definition at line 268 of file SlideImage.cs.
269 {
270 if (!disposedValue)
271 {
272 if (disposing)
273 {
274 }
275
276 Close();
277 disposedValue = true;
278 }
279 }
◆ GetLevelDimension()
| ImageDimension BioLib.SlideImage.GetLevelDimension |
( |
int | level | ) |
|
Get the dimensions of a level.
- Parameters
-
- Exceptions
-
Definition at line 126 of file SlideImage.cs.
127 {
128 return new ImageDimension(BioImage.Resolutions[level].SizeX, BioImage.Resolutions[level].SizeY);
129 }
◆ GetLevelDimensions()
| IEnumerable< ImageDimension > BioLib.SlideImage.GetLevelDimensions |
( |
| ) |
|
Get all level dimensions.
- Returns
- Exceptions
-
Definition at line 136 of file SlideImage.cs.
137 {
139 for (int i = 0; i < count; i++)
140 {
142 }
143 }
int LevelCount
Get the number of levels in the whole slide image.
ImageDimension GetLevelDimension(int level)
Get the dimensions of a level.
◆ GetLevelDownsamples()
| static List< double > BioLib.SlideImage.GetLevelDownsamples |
( |
double | baseDownsampleFactor, |
|
|
int | totalLevels ) |
|
static |
Calculates the downsample factors for each level of a slide.
- Parameters
-
| baseDownsampleFactor | The downsample factor between each level. |
| totalLevels | Total number of levels in the slide. |
- Returns
- A list of downsample factors for each level.
Definition at line 172 of file SlideImage.cs.
173 {
174 var levelDownsamples = new List<double>();
175
176 for (int level = 0; level < totalLevels; level++)
177 {
178
179
180 double downsampleFactorAtLevel = Math.Pow(baseDownsampleFactor, level);
181 levelDownsamples.Add(downsampleFactorAtLevel);
182 }
183
184 return levelDownsamples;
185 }
◆ Initialize()
| static void BioLib.SlideImage.Initialize |
( |
string | path = null | ) |
|
|
static |
Add .dll directory to PATH.
- Parameters
-
- Exceptions
-
Definition at line 58 of file SlideImage.cs.
◆ Open()
Open.
- Parameters
-
- Returns
- Exceptions
-
Definition at line 73 of file SlideImage.cs.
74 {
76 im.BioImage = b;
77 return im;
78 }
◆ ReadRegion()
| unsafe byte[] BioLib.SlideImage.ReadRegion |
( |
int | level, |
|
|
ZCT | zct, |
|
|
long | x, |
|
|
long | y, |
|
|
long | width, |
|
|
long | height ) |
Copy pre-multiplied BGRA data from a whole slide image.
- Parameters
-
| level | The desired level. |
| x | The top left x-coordinate, in the level 0 reference frame. |
| y | The top left y-coordinate, in the level 0 reference frame. |
| width | The width of the region. Must be non-negative. |
| height | The height of the region. Must be non-negative. |
- Returns
- The pixel data of this region.
- Exceptions
-
| ArgumentOutOfRangeException | - Exceptions
-
|
Definition at line 224 of file SlideImage.cs.
225 {
226 return BioImage.
GetTile(BioImage, BioImage.GetFrameIndex(zct.Z, zct.C, zct.T), level, (
int)x, (
int)y, (
int)width, (
int)height).Bytes;
227 }
static Bitmap GetTile(BioImage b, int index, int level, int tilex, int tiley, int tileSizeX, int tileSizeY)
It reads a tile from a file, and returns a bitmap.
◆ ReadRegionAsync()
| async Task< byte[]> BioLib.SlideImage.ReadRegionAsync |
( |
int | level, |
|
|
long | curLevelOffsetXPixel, |
|
|
long | curLevelOffsetYPixel, |
|
|
int | curTileWidth, |
|
|
int | curTileHeight, |
|
|
ZCT | coord ) |
Definition at line 296 of file SlideImage.cs.
297 {
298 try
299 {
300 byte[] bts;
301 TryReadRegion(level, curLevelOffsetXPixel, curLevelOffsetYPixel, curTileWidth, curTileHeight,out bts,coord);
302 return bts;
303 }
304 catch (Exception e)
305 {
306 return null;
307 }
308 }
unsafe bool TryReadRegion(int level, long x, long y, long width, long height, out byte[] data, ZCT zct)
Copy pre-multiplied BGRA data from a whole slide image.
◆ TryReadRegion()
| unsafe bool BioLib.SlideImage.TryReadRegion |
( |
int | level, |
|
|
long | x, |
|
|
long | y, |
|
|
long | width, |
|
|
long | height, |
|
|
out byte[] | data, |
|
|
ZCT | zct ) |
Copy pre-multiplied BGRA data from a whole slide image.
- Parameters
-
| level | The desired level. |
| x | The top left x-coordinate, in the level 0 reference frame. |
| y | The top left y-coordinate, in the level 0 reference frame. |
| width | The width of the region. Must be non-negative. |
| height | The height of the region. Must be non-negative. |
| data | The BGRA pixel data of this region. |
- Returns
summary> Close an OpenSlide object. /summary> remarks> No other threads may be using the object. After this call returns, the object cannot be used anymore. /remarks>
Definition at line 239 of file SlideImage.cs.
◆ BioImage
◆ Dimensions
| ImageDimension BioLib.SlideImage.Dimensions |
|
get |
Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0).
- Exceptions
-
Definition at line 106 of file SlideImage.cs.
107 {
108 get
109 {
110 if (_dimensionsRef == null)
111 {
112 lock (_dimensionsSynclock)
113 {
114 if (_dimensionsRef == null)
116 }
117 }
118 return _dimensionsRef.Value;
119 }
120 }
◆ LevelCount
| int BioLib.SlideImage.LevelCount |
|
get |
Get the number of levels in the whole slide image.
<return>The number of levels, or -1 if an error occurred.</return>
- Exceptions
-
Definition at line 85 of file SlideImage.cs.
86 {
87 get
88 {
89 if (BioImage.MacroResolution.HasValue)
90 {
91 return BioImage.Resolutions.Count - 2;
92 }
93 else
94 return BioImage.Resolutions.Count;
95 }
96 }
The documentation for this class was generated from the following file: