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, 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).
|
| |
◆ SlideImage()
| Bio.SlideImage.SlideImage |
( |
| ) |
|
|
inline |
- Parameters
-
| handle | |
| isOwner | close handle when disposed |
- Exceptions
-
◆ CalculateBaseFactor()
| static double Bio.SlideImage.CalculateBaseFactor |
( |
int |
originalResolution, |
|
|
int |
lastLevelResolution, |
|
|
int |
totalLevels |
|
) |
| |
|
inlinestatic |
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.
152 {
153 if (totalLevels <= 1)
154 {
155 throw new ArgumentException("Total levels must be greater than 1 to calculate a base factor.");
156 }
157 if (lastLevelResolution <= 0 || originalResolution <= 0)
158 {
159 throw new ArgumentException("Resolutions must be greater than 0.");
160 }
161
162
163 double baseFactor = Math.Pow((double)originalResolution / lastLevelResolution, 1.0 / (totalLevels - 1));
164 return baseFactor;
165 }
◆ Close()
| void Bio.SlideImage.Close |
( |
| ) |
|
|
inline |
◆ DetectVendor()
| static string Bio.SlideImage.DetectVendor |
( |
string |
filename | ) |
|
|
inlinestatic |
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.
40 {
41 return filename;
42 }
◆ Dispose() [1/2]
| void Bio.SlideImage.Dispose |
( |
| ) |
|
|
inline |
292 {
294 GC.SuppressFinalize(this);
295 }
void Dispose()
Definition SlideImage.cs:291
◆ Dispose() [2/2]
| virtual void Bio.SlideImage.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprotectedvirtual |
Dispose.
- Parameters
-
270 {
271 if (!disposedValue)
272 {
273 if (disposing)
274 {
275 }
276
278 disposedValue = true;
279 }
280 }
void Close()
Definition SlideImage.cs:256
◆ GetLevelDimension()
| ImageDimension Bio.SlideImage.GetLevelDimension |
( |
int |
level | ) |
|
|
inline |
Get the dimensions of a level.
- Parameters
-
- Exceptions
-
128 {
130 }
List< Resolution > Resolutions
Definition Bio.cs:2101
◆ GetLevelDimensions()
| IEnumerable< ImageDimension > Bio.SlideImage.GetLevelDimensions |
( |
| ) |
|
|
inline |
Get all level dimensions.
- Returns
- Exceptions
-
138 {
140 for (int i = 0; i < count; i++)
141 {
143 }
144 }
ImageDimension GetLevelDimension(int level)
Get the dimensions of a level.
Definition SlideImage.cs:127
int LevelCount
Get the number of levels in the whole slide image.
Definition SlideImage.cs:87
◆ GetLevelDownsamples()
| static List< double > Bio.SlideImage.GetLevelDownsamples |
( |
double |
baseDownsampleFactor, |
|
|
int |
totalLevels |
|
) |
| |
|
inlinestatic |
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.
174 {
175 var levelDownsamples = new List<double>();
176
177 for (int level = 0; level < totalLevels; level++)
178 {
179
180
181 double downsampleFactorAtLevel = Math.Pow(baseDownsampleFactor, level);
182 levelDownsamples.Add(downsampleFactorAtLevel);
183 }
184
185 return levelDownsamples;
186 }
◆ Initialize()
| static void Bio.SlideImage.Initialize |
( |
string |
path = null | ) |
|
|
inlinestatic |
Add .dll directory to PATH.
- Parameters
-
- Exceptions
-
◆ Open()
Open.
- Parameters
-
- Returns
- Exceptions
-
75 {
77 im.BioImage = b;
78 return im;
79 }
SlideImage()
Definition SlideImage.cs:49
◆ ReadRegion()
| unsafe byte[] Bio.SlideImage.ReadRegion |
( |
int |
level, |
|
|
long |
x, |
|
|
long |
y, |
|
|
long |
width, |
|
|
long |
height |
|
) |
| |
|
inline |
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
-
|
226 {
227 return BioImage.
GetTile(
BioImage, App.viewer.GetCoordinate(), level, (
int)x, (
int)y, (
int)width, (
int)height).Bytes;
228 }
static Bitmap GetTile(BioImage b, ZCT coord, int serie, int tilex, int tiley, int tileSizeX, int tileSizeY)
Definition Bio.cs:6976
◆ ReadRegionAsync()
| async Task< byte[]> Bio.SlideImage.ReadRegionAsync |
( |
int |
level, |
|
|
long |
curLevelOffsetXPixel, |
|
|
long |
curLevelOffsetYPixel, |
|
|
int |
curTileWidth, |
|
|
int |
curTileHeight, |
|
|
ZCT |
coord |
|
) |
| |
|
inline |
298 {
299 try
300 {
301 byte[] bts;
302 TryReadRegion(level, curLevelOffsetXPixel, curLevelOffsetYPixel, curTileWidth, curTileHeight,out bts,coord);
303 return bts;
304 }
305 catch (Exception e)
306 {
307 return null;
308 }
309 }
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.
Definition SlideImage.cs:240
◆ TryReadRegion()
| unsafe bool Bio.SlideImage.TryReadRegion |
( |
int |
level, |
|
|
long |
x, |
|
|
long |
y, |
|
|
long |
width, |
|
|
long |
height, |
|
|
out byte[] |
data, |
|
|
ZCT |
zct |
|
) |
| |
|
inline |
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>
◆ BioImage
◆ Dimensions
| ImageDimension Bio.SlideImage.Dimensions |
|
get |
Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0).
- Exceptions
-
108 {
109 get
110 {
111 if (_dimensionsRef == null)
112 {
113 lock (_dimensionsSynclock)
114 {
115 if (_dimensionsRef == null)
117 }
118 }
119 return _dimensionsRef.Value;
120 }
121 }
◆ LevelCount
| int Bio.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
-
87 {
88 get
89 {
91 {
92 return BioImage.Resolutions.Count - 2;
93 }
94 else
96 }
97 }
int? MacroResolution
Definition Bio.cs:3174
The documentation for this class was generated from the following file: