openslide wrapper
More...
|
| | SlideImage () |
| |
| ImageDimension | GetLevelDimension (int level) |
| | Get the dimensions of a level. More...
|
| |
| IEnumerable< ImageDimension > | GetLevelDimensions () |
| | Get all level dimensions. More...
|
| |
| unsafe byte[] | ReadRegion (int level, long x, long y, long width, long height) |
| | Copy pre-multiplied BGRA data from a whole slide image. More...
|
| |
| unsafe bool | TryReadRegion (int level, long x, long y, long width, long height, ZCT coord, out byte[] data) |
| | Copy pre-multiplied BGRA data from a whole slide image. More...
|
| |
| void | Close () |
| |
| void | Dispose () |
| |
| async Task< byte[]> | ReadRegionAsync (int level, long curLevelOffsetXPixel, long curLevelOffsetYPixel, int curTileWidth, int curTileHeight, ZCT coord) |
| |
|
| BioImage | BioImage [get, set] |
| |
| int | LevelCount [get] |
| | Get the number of levels in the whole slide image. More...
|
| |
| ImageDimension | Dimensions [get] |
| | Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0). More...
|
| |
openslide wrapper
Definition at line 19 of file SlideImage.cs.
◆ SlideImage()
| BioImager.SlideImage.SlideImage |
( |
| ) |
|
◆ CalculateBaseFactor()
| static double BioImager.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 151 of file SlideImage.cs.
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 BioImager.SlideImage.Close |
( |
| ) |
|
◆ DetectVendor()
| static string BioImager.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 39 of file SlideImage.cs.
40 {
41 return filename;
42 }
◆ Dispose() [1/2]
| void BioImager.SlideImage.Dispose |
( |
| ) |
|
◆ Dispose() [2/2]
| virtual void BioImager.SlideImage.Dispose |
( |
bool |
disposing | ) |
|
|
protectedvirtual |
Dispose
- Parameters
-
Definition at line 278 of file SlideImage.cs.
279 {
280 if (!disposedValue)
281 {
282 if (disposing)
283 {
284 }
285
286 Close();
287 disposedValue = true;
288 }
289 }
◆ GetLevelDimension()
| ImageDimension BioImager.SlideImage.GetLevelDimension |
( |
int |
level | ) |
|
◆ GetLevelDimensions()
| IEnumerable< ImageDimension > BioImager.SlideImage.GetLevelDimensions |
( |
| ) |
|
◆ GetLevelDownsamples()
| static List< double > BioImager.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 173 of file SlideImage.cs.
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 BioImager.SlideImage.Initialize |
( |
string |
path = null | ) |
|
|
static |
Add .dll directory to PATH
- Parameters
-
- Exceptions
-
Definition at line 59 of file SlideImage.cs.
◆ Open()
◆ ReadRegion()
| unsafe byte[] BioImager.SlideImage.ReadRegion |
( |
int |
level, |
|
|
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 225 of file SlideImage.cs.
226 {
227 return BioImage.
GetTile(BioImage, App.viewer.GetCoordinate(), level, (
int)x, (
int)y, (
int)width, (
int)height).RGBBytes;
228 }
static Bitmap GetTile(BioImage b, ZCT coord, int serie, int tilex, int tiley, int tileSizeX, int tileSizeY)
References BioImager.ImageView.GetCoordinate(), and BioImager.BioImage.GetTile().
◆ ReadRegionAsync()
| async Task< byte[]> BioImager.SlideImage.ReadRegionAsync |
( |
int |
level, |
|
|
long |
curLevelOffsetXPixel, |
|
|
long |
curLevelOffsetYPixel, |
|
|
int |
curTileWidth, |
|
|
int |
curTileHeight, |
|
|
ZCT |
coord |
|
) |
| |
Definition at line 306 of file SlideImage.cs.
307 {
308 try
309 {
310 byte[] bts;
311 TryReadRegion(level, curLevelOffsetXPixel, curLevelOffsetYPixel, curTileWidth, curTileHeight, coord,out bts);
312 return bts;
313 }
314 catch (Exception e)
315 {
316 return null;
317 }
318 }
unsafe bool TryReadRegion(int level, long x, long y, long width, long height, ZCT coord, out byte[] data)
Copy pre-multiplied BGRA data from a whole slide image.
◆ TryReadRegion()
| unsafe bool BioImager.SlideImage.TryReadRegion |
( |
int |
level, |
|
|
long |
x, |
|
|
long |
y, |
|
|
long |
width, |
|
|
long |
height, |
|
|
ZCT |
coord, |
|
|
out byte[] |
data |
|
) |
| |
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 240 of file SlideImage.cs.
References BioImager.BioImage.GetTile().
◆ BioImage
◆ Dimensions
| ImageDimension BioImager.SlideImage.Dimensions |
|
get |
Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0).
- Exceptions
-
Definition at line 107 of file SlideImage.cs.
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 BioImager.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 86 of file SlideImage.cs.
87 {
88 get
89 {
90 if (BioImage.MacroResolution.HasValue)
91 {
92 return BioImage.Resolutions.Count - 2;
93 }
94 else
95 return BioImage.Resolutions.Count;
96 }
97 }
Referenced by BioImager.SlideImage.GetLevelDimensions().
The documentation for this class was generated from the following file: