BioGTK  5.1.1
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images.
Loading...
Searching...
No Matches
Bio.SlideBase Class Reference
Inheritance diagram for Bio.SlideBase:
Bio.SlideSourceBase Bio.ISlideSource Bio.ISliceProvider Bio.ISlideExternInfo

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

readonly SlideImage SlideImage
 
- Public Attributes inherited from Bio.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 Bio.SlideSourceBase
static Extent destExtent
 
static Extent sourceExtent
 
static double curUnitsPerPixel = 1
 
static bool UseVips = true
 
- Properties inherited from Bio.SlideSourceBase
static bool UseRealResolution = true [get, set]
 
double MinUnitsPerPixel [get, protected set]
 um/pixel
 
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.
 
string Source [get, protected set]
 File path.
 
- Properties inherited from Bio.ISliceProvider
double MinUnitsPerPixel [get]
 um/pixel
 
- Properties inherited from Bio.ISlideExternInfo
string Source [get]
 File path.
 
IReadOnlyDictionary< string, object > ExternInfo [get]
 Extern info.
 

Constructor & Destructor Documentation

◆ SlideBase()

Bio.SlideBase.SlideBase ( BioImage  source,
SlideImage  im,
bool  enableCache = true 
)
inline
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 }
SixLabors.ImageSharp.Image Image
Definition ISlideSource.cs:11
readonly SlideImage SlideImage
Definition SlideBase.cs:16
void InitResolutions(IDictionary< int, BruTile.Resolution > resolutions, int tileWidth, int tileHeight)
Definition SlideBase.cs:113
ImageDimension Dimensions
Get the dimensions of level 0 (the largest level). Exactly equivalent to calling GetLevelDimensions(0...
Definition SlideImage.cs:108
static bool UseRealResolution
Definition ISlideSource.cs:138
double MinUnitsPerPixel
um/pixel
Definition ISlideSource.cs:175
ITileSchema Schema
Definition ISlideSource.cs:291
string Source
File path.
Definition ISlideSource.cs:299
string file
Definition Bio.cs:2721
double PhysicalSizeX
Definition Bio.cs:2362
double PhysicalSizeY
Definition Bio.cs:2366

Member Function Documentation

◆ ConvertRgbaToRgb()

static byte[] Bio.SlideBase.ConvertRgbaToRgb ( byte[]  rgbaArray)
inlinestatic
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 Bio.SlideBase.DetectVendor ( string  source)
inlinestatic
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 Bio.SlideBase.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented from Bio.SlideSourceBase.

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

◆ GetExternImages()

override IReadOnlyDictionary< string, byte[]> Bio.SlideBase.GetExternImages ( )
inlinevirtual

Extern image.

Returns

Implements Bio.SlideSourceBase.

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[] Bio.SlideBase.GetTile ( TileInfo  tileInfo)
inline
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 }
static byte[] ConvertRgbaToRgb(byte[] rgbaArray)
Definition SlideBase.cs:97
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 Bio.SlideBase.InitResolutions ( IDictionary< int, BruTile::Resolution >  resolutions,
int  tileWidth,
int  tileHeight 
)
inlineprotected
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 }
int LevelCount
Get the number of levels in the whole slide image.
Definition SlideImage.cs:87
BioImage BioImage
Definition SlideImage.cs:21
double GetUnitPerPixel(int level)
Get Unit Per Pixel for pyramidal images.
Definition Bio.cs:2345

Member Data Documentation

◆ SlideImage

readonly SlideImage Bio.SlideBase.SlideImage

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