BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
BioImager.SlideBase Class Reference
Inheritance diagram for BioImager.SlideBase:
BioImager.SlideSourceBase BioImager.ISlideSource BioImager.ISliceProvider BioImager.ISlideExternInfo

Public Member Functions

 SlideBase (BioImage source, SlideImage im, bool enableCache=true)
 
override IReadOnlyDictionary< string, byte[]> GetExternImages ()
 Extern image. More...
 
byte[] GetTile (TileInfo tileInfo)
 
- Public Member Functions inherited from BioImager.SlideSourceBase
async Task< byte[]> GetSlice (SliceInfo sliceInfo)
 Get slice. More...
 
byte[] GetRgb24Bytes (Image< Rgb24 > image)
 
abstract IReadOnlyDictionary< string, byte[]> GetExternImages ()
 Extern image. More...
 
void Dispose ()
 
async Task< byte[]> GetTileAsync (TileInformation tileInfo)
 
async Task< byte[]> GetTileAsync (BruTile.TileInfo tileInfo)
 
Task< byte[]> GetSlice (SliceInfo sliceInfo)
 Get slice. More...
 
IReadOnlyDictionary< string, byte[]> GetExternImages ()
 Extern image. More...
 

Static Public Member Functions

static string DetectVendor (string source)
 
static byte[] ConvertRgbaToRgb (byte[] rgbaArray)
 
- Static Public Member Functions inherited from BioImager.SlideSourceBase
static void Resister (string extensionUpper, Func< string, bool, ISlideSource > factory)
 resister decode for Specific format More...
 
static ISlideSource Create (BioImage source, SlideImage im, bool enableCache=true)
 
static byte[] ConvertRgbaToRgb (byte[] rgbaArray)
 

Public Attributes

readonly SlideImage SlideImage
 
- Public Attributes inherited from BioImager.SlideSourceBase
TileCache cache = null
 

Protected Member Functions

void InitResolutions (IDictionary< int, BruTile.Resolution > resolutions, int tileWidth, int tileHeight)
 
override void Dispose (bool disposing)
 
virtual void Dispose (bool disposing)
 

Additional Inherited Members

- Static Public Attributes inherited from BioImager.SlideSourceBase
static byte[] LastSlice
 
static Extent destExtent
 
static Extent sourceExtent
 
static double curUnitsPerPixel = 1
 
static bool UseVips = true
 
- Properties inherited from BioImager.SlideSourceBase
static bool UseRealResolution = true [get, set]
 
double MinUnitsPerPixel [get, protected set]
 um/pixel More...
 
SlideImage Image [get, set]
 
ITileSchema Schema [get, protected set]
 
string Name [get, protected set]
 
Attribution Attribution [get, protected set]
 
IReadOnlyDictionary< string, object > ExternInfo [get, protected set]
 Extern info. More...
 
string Source [get, protected set]
 File path. More...
 
- Properties inherited from BioImager.ISliceProvider
double MinUnitsPerPixel [get]
 um/pixel More...
 
- Properties inherited from BioImager.ISlideExternInfo
string Source [get]
 File path. More...
 
IReadOnlyDictionary< string, object > ExternInfo [get]
 Extern info. More...
 

Detailed Description

Definition at line 14 of file SlideBase.cs.

Constructor & Destructor Documentation

◆ SlideBase()

BioImager.SlideBase.SlideBase ( BioImage  source,
SlideImage  im,
bool  enableCache = true 
)

Definition at line 17 of file SlideBase.cs.

18 {
19 Source = source.file;
20 SlideImage = im;
21 Image = im;
22 double minUnitsPerPixel;
23 if (source.PhysicalSizeX < source.PhysicalSizeY) minUnitsPerPixel = source.PhysicalSizeX; else minUnitsPerPixel = source.PhysicalSizeY;
24 MinUnitsPerPixel = UseRealResolution ? minUnitsPerPixel : 1;
26 var height = SlideImage.Dimensions.Height;
27 var width = SlideImage.Dimensions.Width;
28 //ExternInfo = GetInfo();
29 Schema = new TileSchema
30 {
31 YAxis = YAxis.OSM,
32 Format = "jpg",
33 Extent = new Extent(0, -height, width, 0),
34 OriginX = 0,
35 OriginY = 0,
36 };
37 InitResolutions(Schema.Resolutions, 256, 256);
38 }
ImageDimension Dimensions
Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0...
Definition: SlideImage.cs:108
string Source
File path.
double MinUnitsPerPixel
um/pixel

Member Function Documentation

◆ ConvertRgbaToRgb()

static byte[] BioImager.SlideBase.ConvertRgbaToRgb ( byte[]  rgbaArray)
static

Definition at line 97 of file SlideBase.cs.

98 {
99 // Initialize a new byte array for RGB24 format
100 byte[] rgbArray = new byte[(rgbaArray.Length / 4) * 3];
101
102 for (int i = 0, j = 0; i < rgbaArray.Length; i += 4, j += 3)
103 {
104 // Copy the R, G, B values, skip the A value
105 rgbArray[j] = rgbaArray[i]; // B
106 rgbArray[j + 1] = rgbaArray[i + 1]; // G
107 rgbArray[j + 2] = rgbaArray[i + 2]; // R
108 }
109
110 return rgbArray;
111 }

◆ DetectVendor()

static string BioImager.SlideBase.DetectVendor ( string  source)
static

Definition at line 40 of file SlideBase.cs.

41 {
42 return SlideImage.DetectVendor(source);
43 }
static string DetectVendor(string filename)
Quickly determine whether a whole slide image is recognized.
Definition: SlideImage.cs:39

◆ Dispose()

override void BioImager.SlideBase.Dispose ( bool  disposing)
protectedvirtual

Reimplemented from BioImager.SlideSourceBase.

Definition at line 132 of file SlideBase.cs.

133 {
134 if (!disposedValue)
135 {
136 if (disposing)
137 {
138 SlideImage.Dispose();
139 }
140 disposedValue = true;
141 }
142 base.Dispose(disposing);
143 }
virtual void Dispose(bool disposing)
Dispose
Definition: SlideImage.cs:278

◆ GetExternImages()

override IReadOnlyDictionary< string, byte[]> BioImager.SlideBase.GetExternImages ( )
virtual

Extern image.

Returns

Implements BioImager.SlideSourceBase.

Definition at line 46 of file SlideBase.cs.

47 {
48 throw new NotImplementedException();
49 /*
50 Dictionary<string, byte[]> images = new Dictionary<string, byte[]>();
51 var r = Math.Max(Schema.Extent.Height, Schema.Extent.Width) / 512;
52 images.Add("preview", GetSlice(new SliceInfo { Extent = Schema.Extent, Resolution = r }));
53 foreach (var item in SlideImage.GetAssociatedImages())
54 {
55 var dim = item.Value.Dimensions;
56 images.Add(item.Key, ImageUtil.GetJpeg(item.Value.Data, 4, 4 * (int)dim.Width, (int)dim.Width, (int)dim.Height));
57 }
58 return images;
59 */
60 }

◆ GetTile()

byte[] BioImager.SlideBase.GetTile ( TileInfo  tileInfo)

Definition at line 81 of file SlideBase.cs.

82 {
83 var r = Schema.Resolutions[tileInfo.Index.Level].UnitsPerPixel;
84 var tileWidth = Schema.Resolutions[tileInfo.Index.Level].TileWidth;
85 var tileHeight = Schema.Resolutions[tileInfo.Index.Level].TileHeight;
86 var curLevelOffsetXPixel = tileInfo.Extent.MinX / MinUnitsPerPixel;
87 var curLevelOffsetYPixel = -tileInfo.Extent.MaxY / MinUnitsPerPixel;
88 var curTileWidth = (int)(tileInfo.Extent.MaxX > Schema.Extent.Width ? tileWidth - (tileInfo.Extent.MaxX - Schema.Extent.Width) / r : tileWidth);
89 var curTileHeight = (int)(-tileInfo.Extent.MinY > Schema.Extent.Height ? tileHeight - (-tileInfo.Extent.MinY - Schema.Extent.Height) / r : tileHeight);
90 var bgraData = SlideImage.ReadRegion(tileInfo.Index.Level, (long)curLevelOffsetXPixel, (long)curLevelOffsetYPixel, curTileWidth, curTileHeight);
91 //We check to see if the data is valid.
92 if (bgraData.Length != curTileWidth * curTileHeight * 4)
93 return null;
94 byte[] bm = ConvertRgbaToRgb(bgraData);
95 return bm;
96 }
unsafe byte[] ReadRegion(int level, long x, long y, long width, long height)
Copy pre-multiplied BGRA data from a whole slide image.
Definition: SlideImage.cs:225

◆ InitResolutions()

void BioImager.SlideBase.InitResolutions ( IDictionary< int, BruTile.Resolution >  resolutions,
int  tileWidth,
int  tileHeight 
)
protected

Definition at line 113 of file SlideBase.cs.

114 {
115 for (int i = 0; i < SlideImage.LevelCount; i++)
116 {
117 /*
118 bool useInternalWidth = int.TryParse(ExternInfo.TryGetValue($"openslide.level[{i}].tile-width", out var _w) ? (string)_w : null, out var w) && w >= tileWidth;
119 bool useInternalHeight = int.TryParse(ExternInfo.TryGetValue($"openslide.level[{i}].tile-height", out var _h) ? (string)_h : null, out var h) && h >= tileHeight;
120
121 bool useInternalSize = useInternalHeight && useInternalWidth;
122 var tw = useInternalSize ? w : tileWidth;
123 var th = useInternalSize ? h : tileHeight;
124 resolutions.Add(i, new Resolution(i, MinUnitsPerPixel * SlideImage.GetLevelDownsample(i), tw, th));
125 */
126 resolutions.Add(i, new BruTile.Resolution(i, SlideImage.BioImage.GetUnitPerPixel(i), tileWidth, tileHeight));
127 }
128 }
double GetUnitPerPixel(int level)
Get Unit Per Pixel for pyramidal images.
Definition: Bio.cs:2617
int LevelCount
Get the number of levels in the whole slide image.
Definition: SlideImage.cs:87

Member Data Documentation

◆ SlideImage

readonly SlideImage BioImager.SlideBase.SlideImage

Definition at line 16 of file SlideBase.cs.


The documentation for this class was generated from the following file: