BioLib  4.1.1
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.BioImage Class Reference
Inheritance diagram for BioLib.BioImage:

Classes

class  ImageJDesc
 
class  WellPlate
 

Public Types

enum  ImageType { stack , pyramidal , well }
 
enum  Order { ZCT , CZT , TCZ }
 

Public Member Functions

BioImage Copy (bool rois)
 
BioImage Copy ()
 
double GetLevelDownsample (int level)
 Get the downsampling factor of a given level.
 
double[] GetLevelDownsamples ()
 
int LevelFromResolution (double Resolution)
 Returns the level of a given resolution.
 
double GetUnitPerPixel (int level)
 Get Unit Per Pixel for pyramidal images.
 
void InvalidateTileCache ()
 Clears the pyramidal tile cache so the next render fetches fresh tiles for the current ZCT coordinate instead of returning stale ones.
 
void To8Bit ()
 Converts a 16-bit image to an 8-bit image.
 
void To16Bit ()
 Converts the image to 16 bit.
 
void To24Bit ()
 Converts the image to 24 bit.
 
void To32Bit ()
 Converts the image to 32 bit.
 
void To48Bit ()
 
void ToShort ()
 
void ToFloat ()
 
void RotateFlip (AForge.RotateFlipType rot)
 
void Bake (int rmin, int rmax, int gmin, int gmax, int bmin, int bmax)
 Bake(int rmin, int rmax, int gmin, int gmax, int bmin, int bmax)
 
void Bake (IntRange rf, IntRange gf, IntRange bf)
 It takes a range of values for each channel, and creates a new image with the filtered values.
 
void UpdateCoords ()
 It takes a list of images and assigns them to a 3D array of coordinates.
 
void UpdateCoords (int sz, int sc, int st)
 It takes the number of Z, C, and T planes in the image and then assigns each image buffer a coordinate in the ZCT space.
 
void UpdateCoords (int sz, int sc, int st, Order order)
 It takes a list of images and assigns them to a 3D array of coordinates.
 
double ToImageSizeX (double d)
 Convert a physical size to an image size.
 
double ToImageSizeY (double d)
 Convert a physical size in Y direction to an image size in Y direction.
 
double ToImageSpaceX (double x)
 
double ToImageSpaceY (double y)
 
PointD ToImageSpace (PointD p)
 Convert a point in the stage coordinate system to a point in the image coordinate system.
 
PointD[] ToImageSpace (List< PointD > p)
 Convert a list of points from stage space to image space.
 
PointF[] ToImageSpace (PointF[] p)
 
RectangleF ToImageSpace (RectangleD p)
 
PointD ToStageSpace (PointD p)
 
PointD ToStageSpace (PointD p, int resolution)
 Convert a point in the image space to a point in the stage space.
 
RectangleD ToStageSpace (RectangleD p)
 
PointD[] ToStageSpace (PointD[] p)
 
 BioImage (string file)
 
BioImage[] SplitChannels ()
 It takes a single image and splits it into three images, one for each channel.
 
Bitmap GetImageByCoord (int z, int c, int t)
 
Bitmap GetBitmap (int z, int c, int t)
 "Given a z, c, t coordinate, return the bitmap at that coordinate."
 
int GetIndex (int ix, int iy)
 
int GetIndexRGB (int ix, int iy, int index)
 
ushort GetValue (ZCTXY coord)
 If the coordinate is within the bounds of the image, then return the value of the pixel at that coordinate.
 
ushort GetValueRGB (ZCTXY coord, int index)
 It takes a coordinate and an index and returns the value of the pixel at that coordinate.
 
ushort GetValue (ZCT coord, int x, int y)
 
ushort GetValue (int z, int c, int t, int x, int y)
 
float GetValueRGB (ZCT coord, int x, int y, int RGBindex)
 
float GetValueRGB (int z, int c, int t, int x, int y, int RGBindex)
 This function returns the value of the pixel at the specified coordinates in the specified channel, frame, and RGB index.
 
void SetValue (ZCTXY coord, ushort value)
 It takes a coordinate and a value, and sets the value at that coordinate.
 
void SetValue (int x, int y, int ind, ushort value)
 It sets the value of a pixel in a buffer.
 
void SetValue (int x, int y, ZCT coord, ushort value)
 This function sets the value of a pixel at a given x,y coordinate in a given image plane.
 
void SetValueRGB (ZCTXY coord, int RGBindex, ushort value)
 It takes a coordinate, an RGB index, and a value, and sets the value of the pixel at that coordinate to the value.
 
Bitmap GetBitmap (ZCT coord)
 
Bitmap GetFiltered (ZCT coord, IntRange r, IntRange g, IntRange b)
 
Bitmap GetFiltered (int ind, IntRange r, IntRange g, IntRange b)
 It takes an image, and returns a filtered version of that image.
 
UnmanagedImage GetChannelImage (int ind, short s)
 It takes an image, and returns a channel of that image.
 
Bitmap GetEmission (ZCT coord, IntRange rf, IntRange gf, IntRange bf)
 
Bitmap GetRGBBitmap (ZCT coord, IntRange rf, IntRange gf, IntRange bf)
 
List< ROIGetAnnotations (ZCT coord)
 
List< ROIGetAnnotations (int Z, int C, int T)
 This function returns a list of ROI objects that are associated with the specified Z, C, and T coordinates.
 

Static Public Member Functions

static BioImage Copy (BioImage b, bool rois)
 
static BioImage Copy (BioImage b)
 
static BioImage CopyInfo (BioImage b, bool copyAnnotations, bool copyChannels)
 
static PointD ToStageSpace (PointD p, double physicalSizeX, double physicalSizeY, double volumeX, double volumeY)
 
static RectangleD ToStageSpace (RectangleD p, double physicalSizeX, double physicalSizeY, double volumeX, double volumeY)
 
static PointD[] ToStageSpace (PointD[] p, double physicalSizeX, double physicalSizeY, double volumeX, double volumeY)
 It takes a list of points, and converts them from a coordinate system where the origin is in the center of the image, to a coordinate system where the origin is in the top left corner of the image.
 
static BioImage Substack (BioImage orig, int ser, int zs, int ze, int cs, int ce, int ts, int te)
 It takes a BioImage object, and returns a new BioImage object that is a subset of the original.
 
static BioImage MergeChannels (BioImage b2, BioImage b)
 This function takes two images and merges them together.
 
static BioImage MergeChannels (string bname, string b2name)
 MergeChannels(b, b2) takes two images, b and b2, and merges the channels of b2 into b.
 
static BioImage MergeZ (BioImage b)
 It takes a 3D image and merges the Z-stack into a single 2D image.
 
static BioImage MergeT (BioImage b)
 It takes a 3D image and merges the time dimension into a single image.
 
static BioImage[] SplitChannels (BioImage bb)
 
static BioImage[] SplitChannels (string name)
 This function takes an image and splits it into its individual channels.
 
static IntRange MapIntRangeToByteRange (IntRange ushortRange)
 
static unsafe Bitmap GetBitmapRGB (int w, int h, PixelFormat px, byte[] bts)
 It takes a byte array of RGB or RGBA data and converts it to a Bitmap.
 
static void Initialize (string imageJPath)
 Initializes ImageJ/Fiji with the given path.
 
static void SaveFile (string file, string ID)
 This function takes a string array of file names and a string ID and saves the files to the database.
 
static void SaveSeries (string[] IDs, string file)
 It takes a list of image IDs, and saves them as a single multi-page TIFF file.
 

Public Attributes

WellPlate Plate = null
 
int[,,] Coords
 
List< Channel > Channels = new List<Channel>()
 
List< ResolutionResolutions = new List<Resolution>()
 
List< AForge.Bitmap > Buffers = new List<AForge.Bitmap>()
 
List< NetVips.Image > vipPages = new List<NetVips.Image>()
 
VolumeD Volume
 
List< ROIAnnotations = new List<ROI>()
 
string filename = ""
 
string script = ""
 
int[] rgbChannels = new int[3] { 0, 1, 2 }
 
int imagesPerSeries = 0
 
int seriesCount = 1
 
double frameInterval = 0
 
bool littleEndian = false
 
bool isGroup = false
 
long loadTimeMS = 0
 
long loadTimeTicks = 0
 
bool selected = false
 
Stopwatch watch = new Stopwatch()
 
string file
 
bool Loading = false
 

Static Public Attributes

static GLContext Context
 
static float Progress = 0
 
static bool Planes = false
 
static string progFile
 
static LevelsLinear filter8 = new LevelsLinear()
 
static LevelsLinear16bpp filter16 = new LevelsLinear16bpp()
 
static Stopwatch swatch = new Stopwatch()
 

Properties

ZCT Coordinate [get, set]
 
ImageType Type [get]
 
int PyramidNativeLevelCount = 0 [get, set]
 
int Level [get, set]
 
string Filename [get, set]
 
string SourceFile [get]
 
bool IsZarrSource [get]
 
int RGBChannelCount [get]
 
int bitsPerPixel [get]
 
Statistics Statistics [get, set]
 
double Resolution [get, set]
 
string ID [get, set]
 
int ImageCount [get]
 
double PhysicalSizeX [get]
 
double PhysicalSizeY [get]
 
double PhysicalSizeZ [get]
 
double StageSizeX [get]
 
double StageSizeY [get]
 
double StageSizeZ [get]
 
AForge.Size PyramidalSize [get, set]
 
bool UseOSMNegativeY = true [get, set]
 
PointD PyramidalOrigin [get, set]
 
int series [get, set]
 
OpenSlideBase OpenSlideBase [get]
 
SlideBase SlideBase [get, set]
 
Channel RChannel [get]
 
Channel GChannel [get]
 
Channel BChannel [get]
 
List< ROIAnnotationsR [get]
 
List< ROIAnnotationsG [get]
 
List< ROIAnnotationsB [get]
 
int SizeX [get]
 
int SizeY [get]
 
int SizeZ [get]
 
int SizeC [get]
 
int SizeT [get]
 
double Magnification [get, set]
 
Order StackOrder [get, set]
 
object Tag [get, set]
 
IntRange RRange [get]
 
IntRange GRange [get]
 
IntRange BRange [get]
 
Bitmap SelectedBuffer [get]
 
bool isRGB [get]
 
bool isTime [get]
 
bool isSeries [get]
 
bool isPyramidal [get]
 
static string Status [get, set]
 
static bool Initialized [get]
 
int? MacroResolution [get, set]
 
int? LabelResolution [get, set]
 

Member Enumeration Documentation

◆ ImageType

enum BioLib.BioImage.ImageType
1961 {
1962 stack,
1963 pyramidal,
1964 well,
1965 }

◆ Order

enum BioLib.BioImage.Order
2898 {
2899 ZCT,
2900 CZT,
2901 TCZ
2902 }

Constructor & Destructor Documentation

◆ BioImage()

BioLib.BioImage.BioImage ( string file)
3809 {
3810 if (file == null || file=="")
3811 file = System.IO.Path.GetRandomFileName() + ".ome.tif";
3812 id = file;
3813 this.file = file;
3814 filename = Images.GetImageName(id);
3815 Coordinate = new ZCT();
3816 rgbChannels[0] = 0;
3817 rgbChannels[1] = 0;
3818 rgbChannels[2] = 0;
3819 }

Member Function Documentation

◆ Bake() [1/2]

void BioLib.BioImage.Bake ( int rmin,
int rmax,
int gmin,
int gmax,
int bmin,
int bmax )

Bake(int rmin, int rmax, int gmin, int gmax, int bmin, int bmax)

Parameters
rminThe minimum value of the red channel.
rmaxThe maximum value of the red channel.
gminThe minimum value of the green channel.
gmaxThe maximum value of the green channel.
bminThe minimum value of the blue channel.
bmaxThe maximum value of the blue channel.
3410 {
3411 Bake(new IntRange(rmin, rmax), new IntRange(gmin, gmax), new IntRange(bmin, bmax));
3412 }
void Bake(int rmin, int rmax, int gmin, int gmax, int bmin, int bmax)
Bake(int rmin, int rmax, int gmin, int gmax, int bmin, int bmax)
Definition Bio.cs:3409

◆ Bake() [2/2]

void BioLib.BioImage.Bake ( IntRange rf,
IntRange gf,
IntRange bf )

It takes a range of values for each channel, and creates a new image with the filtered values.

Parameters
IntRange
IntRange
IntRange
3420 {
3421 BioImage bm = new BioImage(Images.GetImageName(ID));
3422 bm = CopyInfo(this, true, true);
3423 for (int i = 0; i < Buffers.Count; i++)
3424 {
3425 ZCT co = Buffers[i].Coordinate;
3426 UnmanagedImage b = GetFiltered(i, rf, gf, bf);
3427 Bitmap inf = new Bitmap(bm.ID, b, co, i);
3428 bm.SetFrameIndex(co.Z, co.C, co.T, i);
3429 bm.Buffers.Add(inf);
3430 }
3431 foreach (Channel item in bm.Channels)
3432 {
3433 for (int i = 0; i < item.range.Length; i++)
3434 {
3435 item.range[i].Min = 0;
3436 if (bm.bitsPerPixel > 8)
3437 item.range[i].Max = ushort.MaxValue;
3438 else
3439 item.range[i].Max = 255;
3440 }
3441 }
3442 AutoThreshold(bm, true);
3443 Images.AddImage(bm);
3444 }
Definition Bio.cs:1872
Bitmap GetFiltered(ZCT coord, IntRange r, IntRange g, IntRange b)
Definition Bio.cs:4377
static BioImage CopyInfo(BioImage b, bool copyAnnotations, bool copyChannels)
Definition Bio.cs:2220

◆ Copy() [1/4]

BioImage BioLib.BioImage.Copy ( )

‍This function copies the current BioImage object and returns a new BioImage object

Returns
A copy of the BioImage object.
2210 {
2211 return BioImage.Copy(this, true);
2212 }
static BioImage Copy(BioImage b, bool rois)
Definition Bio.cs:2133

◆ Copy() [2/4]

static BioImage BioLib.BioImage.Copy ( BioImage b)
static

Copy a BioImage object.

Parameters
BioImageThe image to copy
Returns
A copy of the BioImage object.
2194 {
2195 return Copy(b, true);
2196 }
BioImage Copy()
Definition Bio.cs:2209

◆ Copy() [3/4]

static BioImage BioLib.BioImage.Copy ( BioImage b,
bool rois )
static

It copies the BioImage b and returns a new BioImage object.

Parameters
BioImageThe BioImage object to copy
roisIf true, the ROIs will be copied. If false, the ROIs will be ignored.
2134 {
2135 BioImage bi = new BioImage(b.ID);
2136 if (rois)
2137 foreach (ROI an in b.Annotations)
2138 {
2139 bi.Annotations.Add(an);
2140 }
2141 foreach (Bitmap bf in b.Buffers)
2142 {
2143 bi.Buffers.Add(bf.Copy());
2144 }
2145 foreach (Channel c in b.Channels)
2146 {
2147 bi.Channels.Add(c);
2148 }
2149 bi.Volume = b.Volume;
2150 bi.Coords = b.Coords;
2151 bi.sizeZ = b.sizeZ;
2152 bi.sizeC = b.sizeC;
2153 bi.sizeT = b.sizeT;
2154 bi.series = b.series;
2155 bi.seriesCount = b.seriesCount;
2156 bi.frameInterval = b.frameInterval;
2157 bi.littleEndian = b.littleEndian;
2158 bi.isGroup = b.isGroup;
2159 bi.imageInfo = b.imageInfo;
2160 bi.file = b.file;
2161 bi.filename = b.filename;
2162 foreach (var item in b.Resolutions)
2163 {
2164 bi.Resolutions.Add(item);
2165 }
2166 bi.statistics = b.statistics;
2167 bi.MacroResolution = b.MacroResolution;
2168 bi.LabelResolution = b.LabelResolution;
2169 bi.Resolution = b.Resolution;
2170 bi.imagesPerSeries = b.imagesPerSeries;
2171 bi.imRead = b.imRead;
2172 bi.tifRead = b.tifRead;
2173 if (b.OpenSlideBase != null)
2174 {
2175 bi.openslideBase = b.openslideBase;
2176 bi.openSlideImage = b.openSlideImage;
2177 }
2178 else
2179 {
2180 bi.slideBase = b.slideBase;
2181 }
2182 bi.PyramidalOrigin = b.PyramidalOrigin;
2183 bi.PyramidalSize = b.PyramidalSize;
2184 bi.Plate = b.Plate;
2185 Recorder.Record($"BioImage.Copy({b}, {rois.ToString().ToLowerInvariant()});");
2186 return bi;
2187 }
Definition ROI.cs:27

◆ Copy() [4/4]

BioImage BioLib.BioImage.Copy ( bool rois)

Copy the image and optionally the ROIs

Parameters
roisBoolean value indicating whether to copy the ROIs or not.
Returns
A copy of the BioImage object.
2203 {
2204 return BioImage.Copy(this, rois);
2205 }

◆ CopyInfo()

static BioImage BioLib.BioImage.CopyInfo ( BioImage b,
bool copyAnnotations,
bool copyChannels )
static

CopyInfo() copies the information from one BioImage to another

Parameters
BioImagethe image to copy
copyAnnotationstrue
copyChannelstrue
Returns
A new BioImage object.
2221 {
2222 BioImage bi = new BioImage(b.ID);
2223 if (copyAnnotations)
2224 foreach (ROI an in b.Annotations)
2225 {
2226 bi.Annotations.Add(an);
2227 }
2228 if (copyChannels)
2229 foreach (Channel c in b.Channels)
2230 {
2231 bi.Channels.Add(c.Copy());
2232 }
2233 foreach (var item in b.Resolutions)
2234 {
2235 bi.Resolutions.Add(item);
2236 }
2237 bi.Coords = b.Coords;
2238 bi.Volume = b.Volume;
2239 bi.sizeZ = b.sizeZ;
2240 bi.sizeC = b.sizeC;
2241 bi.sizeT = b.sizeT;
2242 bi.series = b.series;
2243 bi.seriesCount = b.seriesCount;
2244 bi.frameInterval = b.frameInterval;
2245 bi.littleEndian = b.littleEndian;
2246 bi.isGroup = b.isGroup;
2247 bi.imageInfo = b.imageInfo;
2248 bi.Coordinate = b.Coordinate;
2249 bi.file = b.file;
2250 bi.Filename = b.Filename;
2251 bi.ID = Images.GetImageName(b.file);
2252 bi.statistics = b.statistics;
2253 bi.MacroResolution = b.MacroResolution;
2254 bi.LabelResolution = b.LabelResolution;
2255 bi.Resolution = b.Resolution;
2256 bi.imagesPerSeries = b.imagesPerSeries;
2257 bi.imRead = b.imRead;
2258 bi.tifRead = b.tifRead;
2259 bi.PyramidalOrigin = b.PyramidalOrigin;
2260 bi.PyramidalSize = b.PyramidalSize;
2261 if (b.OpenSlideBase != null)
2262 {
2263 bi.openslideBase = b.openslideBase;
2264 bi.openSlideImage = b.openSlideImage;
2265 }
2266 else
2267 {
2268 bi.slideBase = b.slideBase;
2269 }
2270 bi.Plate = b.Plate;
2271 return bi;
2272 }

◆ GetAnnotations() [1/2]

List< ROI > BioLib.BioImage.GetAnnotations ( int Z,
int C,
int T )

This function returns a list of ROI objects that are associated with the specified Z, C, and T coordinates.

Parameters
ZThe Z-stack index
CChannel
TTime
Returns
A list of ROI objects.
4740 {
4741 List<ROI> annotations = new List<ROI>();
4742 foreach (ROI an in Annotations)
4743 {
4744 if (an.coord.Z == Z && an.coord.Z == Z && an.coord.C == C && an.coord.T == T)
4745 annotations.Add(an);
4746 }
4747 return annotations;
4748 }

◆ GetAnnotations() [2/2]

List< ROI > BioLib.BioImage.GetAnnotations ( ZCT coord)

GetAnnotations() returns a list of ROI objects that are associated with the ZCT coordinate passed in as a parameter

Parameters
ZCTa 3D coordinate (Z, C, T)
Returns
A list of ROI objects.
4720 {
4721 List<ROI> annotations = new List<ROI>();
4722 foreach (ROI an in Annotations)
4723 {
4724 if (an == null)
4725 continue;
4726 if (an.coord == coord)
4727 annotations.Add(an);
4728 }
4729 return annotations;
4730 }

◆ GetBitmap() [1/2]

Bitmap BioLib.BioImage.GetBitmap ( int z,
int c,
int t )

"Given a z, c, t coordinate, return the bitmap at that coordinate."

The function is called by the following code:

Parameters
zthe z-stack index
cchannel
ttime
Returns
A bitmap.
4189 {
4190 return Buffers[GetFrameIndex(z, c, t)];
4191 }

◆ GetBitmap() [2/2]

Bitmap BioLib.BioImage.GetBitmap ( ZCT coord)

‍This function returns a Bitmap object from the image data stored in the OME-TIFF file

Parameters
ZCTZ = Z-stack, C = channel, T = timepoint
Returns
A Bitmap object.
4366 {
4367 return (Bitmap)GetImageByCoord(coord.Z, coord.C, coord.T);
4368 }
Bitmap GetImageByCoord(int z, int c, int t)
Definition Bio.cs:4175

◆ GetBitmapRGB()

static unsafe Bitmap BioLib.BioImage.GetBitmapRGB ( int w,
int h,
PixelFormat px,
byte[] bts )
static

It takes a byte array of RGB or RGBA data and converts it to a Bitmap.

Parameters
wwidth of the image
hheight of the image
PixelFormatThe pixel format of the image.
btsthe byte array of the image
Returns
A Bitmap object.
4542 {
4543 static int GetSourceRowStride(byte[] data, int height, int expectedRowBytes)
4544 {
4545 if (height > 0 && data != null && data.Length % height == 0)
4546 {
4547 int stride = data.Length / height;
4548 if (stride >= expectedRowBytes)
4549 return stride;
4550 }
4551 return expectedRowBytes;
4552 }
4553
4554 if (px == PixelFormat.Format32bppArgb)
4555 {
4556 //opening a 8 bit per pixel jpg image
4557 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
4558 //creating the bitmapdata and lock bits
4559 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
4560 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
4561 //iterating through all the pixels in y direction
4562 for (int y = 0; y < h; y++)
4563 {
4564 //getting the pixels of current row
4565 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
4566 int rowRGB = y * w * 4;
4567 //iterating through all the pixels in x direction
4568 for (int x = 0; x < w; x++)
4569 {
4570 int indexRGB = x * 4;
4571 int indexRGBA = x * 4;
4572 row[indexRGBA + 3] = bts[rowRGB + indexRGB + 3];//byte A
4573 row[indexRGBA + 2] = bts[rowRGB + indexRGB + 2];//byte R
4574 row[indexRGBA + 1] = bts[rowRGB + indexRGB + 1];//byte G
4575 row[indexRGBA] = bts[rowRGB + indexRGB];//byte B
4576 }
4577 }
4578 //unlocking bits and disposing image
4579 bmp.UnlockBits(bmd);
4580 return bmp;
4581 }
4582 else if (px == PixelFormat.Format24bppRgb)
4583 {
4584 //opening a 8 bit per pixel jpg image
4585 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
4586 //creating the bitmapdata and lock bits
4587 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
4588 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
4589 //iterating through all the pixels in y direction
4590 for (int y = 0; y < h; y++)
4591 {
4592 //getting the pixels of current row
4593 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
4594 int rowRGB = y * w * 3;
4595 //iterating through all the pixels in x direction
4596 for (int x = 0; x < w; x++)
4597 {
4598 int indexRGB = x * 3;
4599 int indexRGBA = x * 4;
4600 row[indexRGBA + 3] = byte.MaxValue;//byte A
4601 row[indexRGBA + 2] = bts[rowRGB + indexRGB + 2];//byte R
4602 row[indexRGBA + 1] = bts[rowRGB + indexRGB + 1];//byte G
4603 row[indexRGBA] = bts[rowRGB + indexRGB];//byte B
4604 }
4605 }
4606 //unlocking bits and disposing image
4607 bmp.UnlockBits(bmd);
4608 return bmp;
4609 }
4610 else
4611 if (px == PixelFormat.Format48bppRgb)
4612 {
4613 //opening a 8 bit per pixel jpg image
4614 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
4615 //creating the bitmapdata and lock bits
4616 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
4617 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
4618 unsafe
4619 {
4620 int rowStride = GetSourceRowStride(bts, h, w * 6);
4621 //iterating through all the pixels in y direction
4622 for (int y = 0; y < h; y++)
4623 {
4624 //getting the pixels of current row
4625 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
4626 int rowRGB = y * rowStride;
4627 //iterating through all the pixels in x direction
4628 for (int x = 0; x < w; x++)
4629 {
4630 int indexRGB = x * 6;
4631 int indexRGBA = x * 4;
4632 int b = (int)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB) * byte.MaxValue / ushort.MaxValue);
4633 int g = (int)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB + 2) * byte.MaxValue / ushort.MaxValue);
4634 int r = (int)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB + 4) * byte.MaxValue / ushort.MaxValue);
4635 row[indexRGBA + 3] = 255;//byte A
4636 row[indexRGBA + 2] = (byte)(b);//byte R
4637 row[indexRGBA + 1] = (byte)(g);//byte G
4638 row[indexRGBA] = (byte)(r);//byte B
4639 }
4640 }
4641 }
4642 bmp.UnlockBits(bmd);
4643 return bmp;
4644 }
4645 else
4646 if (px == PixelFormat.Format8bppIndexed)
4647 {
4648 //opening a 8 bit per pixel jpg image
4649 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
4650 //creating the bitmapdata and lock bits
4651 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
4652 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
4653 unsafe
4654 {
4655 //iterating through all the pixels in y direction
4656 for (int y = 0; y < h; y++)
4657 {
4658 //getting the pixels of current row
4659 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
4660 int rowRGB = y * w;
4661 //iterating through all the pixels in x direction
4662 for (int x = 0; x < w; x++)
4663 {
4664 int indexRGB = x;
4665 int indexRGBA = x * 4;
4666 byte b = bts[rowRGB + indexRGB];
4667 row[indexRGBA + 3] = 255;//byte A
4668 row[indexRGBA + 2] = (byte)(b);//byte R
4669 row[indexRGBA + 1] = (byte)(b);//byte G
4670 row[indexRGBA] = (byte)(b);//byte B
4671 }
4672 }
4673 }
4674 bmp.UnlockBits(bmd);
4675 return bmp;
4676 }
4677 else
4678 if (px == PixelFormat.Format16bppGrayScale)
4679 {
4680 //opening a 8 bit per pixel jpg image
4681 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
4682 //creating the bitmapdata and lock bits
4683 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
4684 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
4685 unsafe
4686 {
4687 //iterating through all the pixels in y direction
4688 for (int y = 0; y < h; y++)
4689 {
4690 //getting the pixels of current row
4691 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
4692 int rowRGB = y * w * 2;
4693 //iterating through all the pixels in x direction
4694 for (int x = 0; x < w; x++)
4695 {
4696 int indexRGB = x * 2;
4697 int indexRGBA = x * 4;
4698 ushort b = (ushort)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB) / 255);
4699 row[indexRGBA + 3] = 255;//byte A
4700 row[indexRGBA + 2] = (byte)(b);//byte R
4701 row[indexRGBA + 1] = (byte)(b);//byte G
4702 row[indexRGBA] = (byte)(b);//byte B
4703 }
4704 }
4705 }
4706 bmp.UnlockBits(bmd);
4707 return bmp;
4708 }
4709
4710 throw new NotSupportedException("Pixelformat " + px + " is not supported.");
4711 }

◆ GetChannelImage()

UnmanagedImage BioLib.BioImage.GetChannelImage ( int ind,
short s )

It takes an image, and returns a channel of that image.

Parameters
indthe index of the buffer
s0, 1, 2
4448 {
4449 Bitmap bf = Buffers[ind];
4450 if (bf.isRGB)
4451 {
4452 if (s == 0)
4453 return extractR.Apply(Buffers[ind].Image);
4454 else
4455 if (s == 1)
4456 return extractG.Apply(Buffers[ind].Image);
4457 else
4458 return extractB.Apply(Buffers[ind].Image);
4459 }
4460 else
4461 throw new InvalidOperationException();
4462 }

◆ GetEmission()

Bitmap BioLib.BioImage.GetEmission ( ZCT coord,
IntRange rf,
IntRange gf,
IntRange bf )

GetEmission() returns an UnmanagedImage object that is a composite of the emission channels

Parameters
ZCTZ, C, T coordinates
IntRange
IntRange
IntRange
Returns
A Bitmap or an UnmanagedImage.
4473 {
4474 if (RGBChannelCount == 1)
4475 {
4476 Bitmap[] bs = new Bitmap[Channels.Count];
4477 List<Channel> chs = new List<Channel>();
4478 for (int c = 0; c < Channels.Count; c++)
4479 {
4480 int index = GetFrameIndex(coord.Z, c, coord.T);
4481 bs[c] = Buffers[index];
4482 chs.Add(Channels[c]);
4483 }
4484 Bitmap bm = (Bitmap)Bitmap.GetEmissionBitmap(bs, chs.ToArray());
4485 return bm;
4486 }
4487 else
4488 {
4489 int index = GetFrameIndex(coord.Z, coord.C, coord.T);
4490 return Buffers[index];
4491 }
4492 }

◆ GetFiltered() [1/2]

Bitmap BioLib.BioImage.GetFiltered ( int ind,
IntRange r,
IntRange g,
IntRange b )

It takes an image, and returns a filtered version of that image.

Parameters
indthe index of the buffer to be filtered
IntRange
IntRange
IntRange
Returns
A filtered image.
4403 {
4404 if (Buffers.Count > 0)
4405 {
4406 if (Buffers[ind].PixelFormat == PixelFormat.Float)
4407 {
4408 if (Statistics.StackMax <= 1)
4409 {
4410 Bitmap bm = Buffers[ind].GetImageRGBA(true);
4411 return bm;
4412 }
4413 else
4414 {
4415 BioImage.filter8.InRed = MapIntRangeToByteRange(r);
4416 BioImage.filter8.InGreen = MapIntRangeToByteRange(g);
4417 BioImage.filter8.InBlue = MapIntRangeToByteRange(b);
4418 Bitmap bm = BioImage.filter8.Apply(Buffers[ind].GetImageRGBA(false));
4419 return bm;
4420 }
4421 }
4422 else
4423 if (Buffers[ind].BitsPerPixel > 8)
4424 {
4425 BioImage.filter16.InRed = r;
4426 BioImage.filter16.InGreen = g;
4427 BioImage.filter16.InBlue = b;
4428 Bitmap bm = BioImage.filter16.Apply(Buffers[ind]);
4429 return bm;
4430 }
4431 else
4432 {
4433 // set ranges
4434 BioImage.filter8.InRed = r;
4435 BioImage.filter8.InGreen = g;
4436 BioImage.filter8.InBlue = b;
4437 return BioImage.filter8.Apply(Buffers[ind]);
4438 }
4439 }
4440 else
4441 return null;
4442 }

◆ GetFiltered() [2/2]

Bitmap BioLib.BioImage.GetFiltered ( ZCT coord,
IntRange r,
IntRange g,
IntRange b )

‍Get the image at the specified ZCT coordinate, and return a filtered version of it

Parameters
ZCTa 3-tuple of integers (z, c, t)
IntRange
IntRange
IntRange
Returns
An UnmanagedImage object.
4378 {
4379 int index = GetFrameIndex(coord.Z, coord.C, coord.T);
4380 return GetFiltered(index, r, g, b);
4381 }

◆ GetImageByCoord()

Bitmap BioLib.BioImage.GetImageByCoord ( int z,
int c,
int t )

‍Get the image at the specified coordinates

Parameters
zthe z-stack index
cchannel
ttime
Returns
A Bitmap object.
4176 {
4177 return Buffers[GetFrameIndex(z, c, t)];
4178 }

◆ GetIndex()

int BioLib.BioImage.GetIndex ( int ix,
int iy )

‍GetIndex(x,y) = (y * stridex + x) * 2

The stridex is the width of the image in bytes.

The stridey is the height of the image in bytes.

Parameters
ixx coordinate of the pixel
iyThe y coordinate of the pixel
Returns
The index of the pixel in the array.
4203 {
4204 if (ix > SizeX || iy > SizeY || ix < 0 || iy < 0)
4205 return 0;
4206 int stridex = SizeX;
4207 int x = ix;
4208 int y = iy;
4209 if (bitsPerPixel > 8)
4210 {
4211 return (y * stridex + x) * 2;
4212 }
4213 else
4214 {
4215 return (y * stridex + x);
4216 }
4217 }

◆ GetIndexRGB()

int BioLib.BioImage.GetIndexRGB ( int ix,
int iy,
int index )

‍The function returns the index of the pixel in the buffer

Parameters
ixx coordinate of the pixel
iyThe y coordinate of the pixel
index0 = Red, 1 = Green, 2 = Blue
Returns
The index of the pixel in the buffer.
4226 {
4227 int stridex = SizeX;
4228 //For 16bit (2*8bit) images we multiply buffer index by 2
4229 int x = ix;
4230 int y = iy;
4231 if (bitsPerPixel > 8)
4232 {
4233 return (y * stridex + x) * 2 * index;
4234 }
4235 else
4236 {
4237 return (y * stridex + x) * index;
4238 }
4239 }

◆ GetLevelDownsample()

double BioLib.BioImage.GetLevelDownsample ( int level)

Get the downsampling factor of a given level.

Parameters
levelThe desired level.

<return> The downsampling factor for this level. </return>

Exceptions
OpenSlideException
2282 {
2283 int originalWidth = Resolutions[0].SizeX; // Width of the original level
2284 int nextLevelWidth = Resolutions[level].SizeX; // Width of the next level (downsampled)
2285 return (double)originalWidth / (double)nextLevelWidth;
2286 }

◆ GetLevelDownsamples()

double[] BioLib.BioImage.GetLevelDownsamples ( )
2288 {
2289 double[] ds = new double[Resolutions.Count];
2290 for (int i = 0; i < Resolutions.Count; i++)
2291 {
2292 ds[i] = Resolutions[0].PhysicalSizeX * GetLevelDownsample(i);
2293 }
2294 return ds;
2295 }
double GetLevelDownsample(int level)
Get the downsampling factor of a given level.
Definition Bio.cs:2281

◆ GetRGBBitmap()

Bitmap BioLib.BioImage.GetRGBBitmap ( ZCT coord,
IntRange rf,
IntRange gf,
IntRange bf )

‍Get the RGB bitmap for the specified ZCT coordinate

Parameters
ZCTZ, C, T coordinates
IntRange
IntRange
IntRange
Returns
A Bitmap object.
4502 {
4503 int index = GetFrameIndex(coord.Z, 0, coord.T);
4504 if (Buffers[0].RGBChannelsCount == 1)
4505 {
4506 if (Channels.Count >= 3)
4507 {
4508 Bitmap[] bs = new Bitmap[3];
4509 bs[2] = Buffers[index + RChannel.Index];
4510 bs[1] = Buffers[index + GChannel.Index];
4511 bs[0] = Buffers[index + BChannel.Index];
4512 return Bitmap.GetRGBBitmap(bs, rf, gf, bf);
4513 }
4514 else
4515 {
4516 Bitmap[] bs = new Bitmap[3];
4517 bs[2] = Buffers[index + RChannel.Index];
4518 bs[1] = Buffers[index + RChannel.Index + 1];
4519 bs[0] = Buffers[index + RChannel.Index + 2];
4520 return Bitmap.GetRGBBitmap(bs, rf, gf, bf);
4521 }
4522 }
4523 else
4524 {
4525 if (Buffers[0].PixelFormat == PixelFormat.Float || Buffers[0].PixelFormat == PixelFormat.Short)
4526 {
4527 return Buffers[index].GetImageRGBA(littleEndian);
4528 }
4529 else
4530 return Buffers[index];
4531 }
4532 }

◆ GetUnitPerPixel()

double BioLib.BioImage.GetUnitPerPixel ( int level)

Get Unit Per Pixel for pyramidal images.

Parameters
level
Returns
2329 {
2330 return Resolutions[0].PhysicalSizeX * GetLevelDownsample(level);
2331 }

◆ GetValue() [1/3]

ushort BioLib.BioImage.GetValue ( int z,
int c,
int t,
int x,
int y )

‍This function returns the value of the pixel at the specified ZCTXY coordinates

Parameters
zThe Z-plane of the image.
cchannel
ttime
xx coordinate of the pixel
ythe y coordinate of the pixel
Returns
The value of the pixel at the given coordinates.
4287 {
4288 return GetValueRGB(new ZCTXY(z, c, t, x, y), 0);
4289 }
ushort GetValueRGB(ZCTXY coord, int index)
It takes a coordinate and an index and returns the value of the pixel at that coordinate.
Definition Bio.cs:4256

◆ GetValue() [2/3]

ushort BioLib.BioImage.GetValue ( ZCT coord,
int x,
int y )

‍Get the value of the pixel at the given coordinates

Parameters
ZCTZ is the Z-plane, C is the channel, T is the timepoint
xx coordinate of the pixel
yThe y coordinate of the pixel
Returns
The value of the pixel at the given coordinates.
4274 {
4275 return GetValueRGB(new ZCTXY(coord.Z, coord.C, coord.T, x, y), 0);
4276 }

◆ GetValue() [3/3]

ushort BioLib.BioImage.GetValue ( ZCTXY coord)

If the coordinate is within the bounds of the image, then return the value of the pixel at that coordinate.

Parameters
ZCTXYa struct that contains the X, Y, Z, C, and T coordinates of the pixel.
Returns
The value of the pixel at the given coordinate.
4247 {
4248 return GetValueRGB(coord, 0);
4249 }

◆ GetValueRGB() [1/3]

float BioLib.BioImage.GetValueRGB ( int z,
int c,
int t,
int x,
int y,
int RGBindex )

This function returns the value of the pixel at the specified coordinates in the specified channel, frame, and RGB index.

Parameters
zThe Z-plane index
cchannel
ttime index
xx coordinate of the pixel
yThe y coordinate of the pixel
RGBindex0 = Red, 1 = Green, 2 = Blue
Returns
The value of the pixel at the given coordinates.
4317 {
4318 return GetValueRGB(new ZCT(z, c, t), x, y, RGBindex);
4319 }

◆ GetValueRGB() [2/3]

float BioLib.BioImage.GetValueRGB ( ZCT coord,
int x,
int y,
int RGBindex )

‍Get the value of a pixel at a given coordinate, x, y, and RGB index

Parameters
ZCTThe ZCT coordinate of the image.
xx coordinate of the pixel
ythe y coordinate of the pixel
RGBindex0 = Red, 1 = Green, 2 = Blue
Returns
The value of the pixel at the given coordinates.
4299 {
4300 int i = GetFrameIndex(coord.Z, coord.C, coord.T);
4301 if (x >= SizeX && y >= SizeY)
4302 return 0;
4303 return Buffers[i].GetValue(x, y, RGBindex);
4304 }

◆ GetValueRGB() [3/3]

ushort BioLib.BioImage.GetValueRGB ( ZCTXY coord,
int index )

It takes a coordinate and an index and returns the value of the pixel at that coordinate.

Parameters
ZCTXYa struct that contains the Z, C, T, X, and Y coordinates of the pixel.
index0, 1, 2
Returns
A ushort value.
4257 {
4258 int ind = 0;
4259 if (coord.C >= SizeC)
4260 {
4261 coord.C = 0;
4262 }
4263 ind = GetFrameIndex(coord.Z, coord.C, coord.T);
4264 return (ushort)Buffers[ind].GetValue(coord.X, coord.Y, index);
4265 }

◆ Initialize()

static void BioLib.BioImage.Initialize ( string imageJPath)
static

Initializes ImageJ/Fiji with the given path.

Parameters
imageJPath
4755 {
4756 //We initialize OME on a seperate thread so the user doesn't have to wait for initialization to
4757 //view images.
4758 InitFactory();
4759 InitReader();
4760 InitWriter();
4761 if (OperatingSystem.IsMacOS())
4762 return;
4763 if (imageJPath.Contains("Fiji"))
4764 {
4765 Fiji.Initialize(imageJPath);
4766 }
4767 else
4768 ImageJ.Initialize(imageJPath);
4769
4770 }

◆ InvalidateTileCache()

void BioLib.BioImage.InvalidateTileCache ( )

Clears the pyramidal tile cache so the next render fetches fresh tiles for the current ZCT coordinate instead of returning stale ones.

2681 {
2682 slideBase?.cache?.Clear();
2683 openslideBase?.cache?.Clear();
2684 }

◆ LevelFromResolution()

int BioLib.BioImage.LevelFromResolution ( double Resolution)

Returns the level of a given resolution.

Parameters
Resolution
Returns
2302 {
2303 int l = 0;
2304 double[] ds = GetLevelDownsamples();
2305 if (MacroResolution.HasValue)
2306 {
2307 for (int i = 0; i < MacroResolution.Value; i++)
2308 {
2309 if (ds[i] < Resolution)
2310 l = i;
2311 }
2312 }
2313 else
2314 {
2315 for (int i = 0; i < Resolutions.Count; i++)
2316 {
2317 if (ds[i] < Resolution)
2318 l = i;
2319 }
2320 }
2321 return l;
2322 }
Definition Bio.cs:203

◆ MapIntRangeToByteRange()

static IntRange BioLib.BioImage.MapIntRangeToByteRange ( IntRange ushortRange)
static
4383 {
4384 // Ensure the range is valid
4385 if (ushortRange.Min < 0 || ushortRange.Max > ushort.MaxValue)
4386 throw new ArgumentOutOfRangeException(nameof(ushortRange), "Range must be within 0 to ushort.MaxValue.");
4387
4388 // Map each value in the range
4389 int mappedMin = (int)((ushortRange.Min / (float)ushort.MaxValue) * byte.MaxValue);
4390 int mappedMax = (int)((ushortRange.Max / (float)ushort.MaxValue) * byte.MaxValue);
4391
4392 return new IntRange(mappedMin, mappedMax);
4393 }

◆ MergeChannels() [1/2]

static BioImage BioLib.BioImage.MergeChannels ( BioImage b2,
BioImage b )
static

This function takes two images and merges them together.

Parameters
BioImageThe image to be merged
BioImageThe image to be merged
Returns
A new BioImage object.
3877 {
3878 BioImage res = new BioImage(b2.ID);
3879 res.ID = Images.GetImageName(b2.ID);
3880 res.series = b2.series;
3881 res.sizeZ = b2.SizeZ;
3882 int cOrig = b2.SizeC;
3883 res.sizeC = b2.SizeC + b.SizeC;
3884 res.sizeT = b2.SizeT;
3885 res.imageInfo = b2.imageInfo;
3886 res.littleEndian = b2.littleEndian;
3887 res.seriesCount = b2.seriesCount;
3888 res.imagesPerSeries = res.ImageCount / res.seriesCount;
3889 res.Coords = new int[res.SizeZ, res.SizeC, res.SizeT];
3890 res.Resolutions.Add(b2.Resolutions[0]);
3891 res.Volume = new VolumeD(new Point3D(res.StageSizeX, res.StageSizeY, res.StageSizeZ), new Point3D(b2.SizeX, b2.SizeY, b2.SizeZ));
3892 int i = 0;
3893 for (int ci = 0; ci < res.SizeC; ci++)
3894 {
3895 for (int ti = 0; ti < res.SizeT; ti++)
3896 {
3897 for (int zi = 0; zi < res.SizeZ; zi++)
3898 {
3899 if (i < b.ImageCount)
3900 {
3901 ZCT co = new ZCT(zi, ci, ti);
3902 int ind = b.GetFrameIndex(zi, 0, ti);
3903 //This plane is not part of b1 so we add the planes from b2 channels.
3904 Bitmap copy = new Bitmap(b.id, b.SizeX, b.SizeY, b.Buffers[0].PixelFormat, b.Buffers[ind].Bytes, co, ind);
3905 res.SetFrameIndex(zi, ci, ti, ind);
3906 res.Buffers.Add(copy);
3907 //Lets copy the ROI's from the original image.
3908 List<ROI> anns = b.GetAnnotations(zi, ci, ti);
3909 if (anns.Count > 0)
3910 res.Annotations.AddRange(anns);
3911 }
3912 else
3913 {
3914 ZCT co = new ZCT(zi, ci, ti);
3915 int ind = b2.GetFrameIndex(zi, 0, ti);
3916 //This plane is not part of b1 so we add the planes from b2 channels.
3917 Bitmap copy = new Bitmap(b2.id, b2.SizeX, b2.SizeY, b2.Buffers[0].PixelFormat, b2.Buffers[ind].Bytes, co, ind);
3918 res.SetFrameIndex(zi, ci, ti, b.ImageCount + ind);
3919 res.Buffers.Add(copy);
3920 //Lets copy the ROI's from the original image.
3921 List<ROI> anns = b2.GetAnnotations(zi, ci, ti);
3922 if (anns.Count > 0)
3923 res.Annotations.AddRange(anns);
3924 }
3925 i++;
3926 }
3927 }
3928 }
3929 for (int ci = 0; ci < b.SizeC; ci++)
3930 {
3931 res.Channels.Add(b.Channels[ci].Copy());
3932 }
3933 for (int ci = 0; ci < b2.SizeC; ci++)
3934 {
3935 res.Channels.Add(b2.Channels[ci].Copy());
3936 }
3937 res.rgbChannels[0] = 0;
3938 if (res.Channels.Count > 1)
3939 res.rgbChannels[1] = 1;
3940 if (res.Channels.Count > 2)
3941 res.rgbChannels[2] = 2;
3942 Images.AddImage(res);
3943 res.imagesPerSeries = res.Buffers.Count;
3944 //We wait for threshold image statistics calculation
3945 do
3946 {
3947 Thread.Sleep(100);
3948 } while (res.Buffers[res.Buffers.Count - 1].Stats == null);
3949 AutoThreshold(res, false);
3950 if (res.bitsPerPixel > 8)
3951 res.StackThreshold(true);
3952 else
3953 res.StackThreshold(false);
3954 return res;
3955 }
List< ROI > GetAnnotations(ZCT coord)
Definition Bio.cs:4719

◆ MergeChannels() [2/2]

static BioImage BioLib.BioImage.MergeChannels ( string bname,
string b2name )
static

MergeChannels(b, b2) takes two images, b and b2, and merges the channels of b2 into b.

Parameters
bnameThe name of the first image
b2nameThe name of the image to merge with the first image.
Returns
A BioImage object.
3963 {
3964 BioImage b = Images.GetImage(bname);
3965 BioImage b2 = Images.GetImage(b2name);
3966 return MergeChannels(b, b2);
3967 }
static BioImage MergeChannels(BioImage b2, BioImage b)
This function takes two images and merges them together.
Definition Bio.cs:3876

◆ MergeT()

static BioImage BioLib.BioImage.MergeT ( BioImage b)
static

It takes a 3D image and merges the time dimension into a single image.

Parameters
BioImageThe image to be processed
Returns
A new BioImage object.
4012 {
4013 BioImage bi = BioImage.CopyInfo(b, true, true);
4014 int ind = 0;
4015 for (int c = 0; c < b.SizeC; c++)
4016 {
4017 for (int z = 0; z < b.sizeZ; z++)
4018 {
4019 Merge m = new Merge(b.Buffers[b.GetFrameIndex(z, c, 0)]);
4020 Bitmap bm = new Bitmap(b.SizeX, b.SizeY, b.Buffers[0].PixelFormat);
4021 for (int i = 1; i < b.sizeT; i++)
4022 {
4023 m.OverlayImage = bm;
4024 bm = m.Apply(b.Buffers[b.GetFrameIndex(z, c, i)]);
4025 }
4026 Bitmap bf = new Bitmap(b.file, bm, new ZCT(z, c, 0), ind);
4027 bi.Buffers.Add(bf);
4028 bf.Stats = Statistics.FromBytes(bf);
4029 ind++;
4030 }
4031 }
4032 Images.AddImage(bi);
4033 bi.UpdateCoords(1, b.SizeC, b.SizeT);
4034 bi.Coordinate = new ZCT(0, 0, 0);
4035 bi.Resolutions.Add(new Resolution(b.Buffers[0].SizeX, b.Buffers[0].SizeY, b.Buffers[0].PixelFormat, b.PhysicalSizeX, b.PhysicalSizeY, b.PhysicalSizeZ, b.StageSizeX, b.StageSizeY, b.StageSizeZ));
4036 AutoThreshold(bi, false);
4037 if (bi.bitsPerPixel > 8)
4038 bi.StackThreshold(true);
4039 else
4040 bi.StackThreshold(false);
4041 return bi;
4042 }
void UpdateCoords()
It takes a list of images and assigns them to a 3D array of coordinates.
Definition Bio.cs:3446

◆ MergeZ()

static BioImage BioLib.BioImage.MergeZ ( BioImage b)
static

It takes a 3D image and merges the Z-stack into a single 2D image.

Parameters
BioImageThe image to be merged
Returns
A new BioImage object.
3974 {
3975 BioImage bi = BioImage.CopyInfo(b, true, true);
3976 int ind = 0;
3977 for (int c = 0; c < b.SizeC; c++)
3978 {
3979 for (int t = 0; t < b.sizeT; t++)
3980 {
3981 Merge m = new Merge(b.Buffers[b.GetFrameIndex(0, c, t)]);
3982 Bitmap bm = new Bitmap(b.SizeX, b.SizeY, b.Buffers[0].PixelFormat);
3983 for (int i = 1; i < b.sizeZ; i++)
3984 {
3985 m.OverlayImage = bm;
3986 bm = m.Apply(b.Buffers[b.GetFrameIndex(i, c, t)]);
3987 }
3988 Bitmap bf = new Bitmap(b.file, bm, new ZCT(0, c, t), ind);
3989 bi.Buffers.Add(bf);
3990 bf.Stats = Statistics.FromBytes(bf);
3991 ind++;
3992 }
3993 }
3994 Images.AddImage(bi);
3995 bi.UpdateCoords(1, b.SizeC, b.SizeT);
3996 bi.Coordinate = new ZCT(0, 0, 0);
3997 bi.Resolutions.Add(new Resolution(b.Buffers[0].SizeX, b.Buffers[0].SizeY, b.Buffers[0].PixelFormat, b.PhysicalSizeX, b.PhysicalSizeY, b.PhysicalSizeZ, b.StageSizeX, b.StageSizeY, b.StageSizeZ));
3998
3999 AutoThreshold(bi, false);
4000 if (bi.bitsPerPixel > 8)
4001 bi.StackThreshold(true);
4002 else
4003 bi.StackThreshold(false);
4004 return bi;
4005 }

◆ RotateFlip()

void BioLib.BioImage.RotateFlip ( AForge.RotateFlipType rot)
3394 {
3395 for (int i = 0; i < Buffers.Count; i++)
3396 {
3397 Buffers[i].RotateFlip(rot);
3398 }
3399 Volume = new VolumeD(new Point3D(StageSizeX, StageSizeY, StageSizeZ), new Point3D(PhysicalSizeX * SizeX, PhysicalSizeY * SizeY, PhysicalSizeZ * SizeZ));
3400 }

◆ SaveFile()

static void BioLib.BioImage.SaveFile ( string file,
string ID )
static

This function takes a string array of file names and a string ID and saves the files to the database.

Parameters
fileThe file path to the file you want to save.
IDThe ID of the series you want to save.
4999 {
5000 string[] sts = new string[1];
5001 sts[0] = ID;
5002 SaveSeries(sts, file);
5003 Recorder.Record($"BioImage.SaveFile(\"{file}\", \"{ID}\");");
5004 }
static void SaveSeries(string[] IDs, string file)
It takes a list of image IDs, and saves them as a single multi-page TIFF file.
Definition Bio.cs:5009

◆ SaveSeries()

static void BioLib.BioImage.SaveSeries ( string[] IDs,
string file )
static

It takes a list of image IDs, and saves them as a single multi-page TIFF file.

Parameters
Anarray of IDs of the images to save
Thepath to the file to save to.
5010 {
5011 string desc = "";
5012 int stride = 0;
5013 ImageJDesc j = new ImageJDesc();
5014 BioImage bi = Images.GetImage(IDs[0]);
5015 j.FromImage(bi);
5016 desc = j.GetString();
5017 for (int fi = 0; fi < IDs.Length; fi++)
5018 {
5019 string id = IDs[fi];
5020 BioImage b = Images.GetImage(id);
5021 string fn = Path.GetFileNameWithoutExtension(id);
5022 string dir = Path.GetDirectoryName(file);
5023 stride = b.Buffers[0].Stride;
5024
5025 //Save ROIs to CSV file.
5026 if (b.Annotations.Count > 0)
5027 {
5028 string f = dir + "//" + fn + ".csv";
5029 ExportROIsCSV(f, b.Annotations);
5030 }
5031
5032 //Embed ROI's to image description.
5033 for (int i = 0; i < b.Annotations.Count; i++)
5034 {
5035 desc += "-ROI:" + b.series + ":" + ROIToString(b.Annotations[i]) + NewLine;
5036 }
5037 foreach (Channel c in b.Channels)
5038 {
5039 string cj = JsonConvert.SerializeObject(c.info, Formatting.None);
5040 desc += "-Channel:" + fi + ":" + cj + NewLine;
5041 }
5042 string json = JsonConvert.SerializeObject(b.imageInfo, Formatting.None);
5043 desc += "-ImageInfo:" + fi + ":" + json + NewLine;
5044 }
5045
5046 Tiff image = Tiff.Open(file, "w");
5047 for (int fi = 0; fi < IDs.Length; fi++)
5048 {
5049 int im = 0;
5050 string id = IDs[fi];
5051 BioImage b = Images.GetImage(id);
5052 int sizec = 1;
5053 if (!b.isRGB)
5054 {
5055 sizec = b.SizeC;
5056 }
5057 byte[] buffer;
5058 for (int c = 0; c < sizec; c++)
5059 {
5060 for (int z = 0; z < b.SizeZ; z++)
5061 {
5062 for (int t = 0; t < b.SizeT; t++)
5063 {
5064 image.SetDirectory((short)(im + (b.Buffers.Count * fi)));
5065 image.SetField(TiffTag.IMAGEWIDTH, b.SizeX);
5066 image.SetField(TiffTag.IMAGEDESCRIPTION, desc);
5067 image.SetField(TiffTag.IMAGELENGTH, b.SizeY);
5068 image.SetField(TiffTag.BITSPERSAMPLE, b.bitsPerPixel);
5069 image.SetField(TiffTag.SAMPLESPERPIXEL, b.RGBChannelCount);
5070 image.SetField(TiffTag.ROWSPERSTRIP, b.SizeY);
5071 image.SetField(TiffTag.ORIENTATION, BitMiracle.LibTiff.Classic.Orientation.TOPLEFT);
5072 image.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
5073 image.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);
5074 image.SetField(TiffTag.ROWSPERSTRIP, image.DefaultStripSize(0));
5075 if (b.PhysicalSizeX != -1 && b.PhysicalSizeY != -1)
5076 {
5077 image.SetField(TiffTag.XRESOLUTION, (b.PhysicalSizeX * b.SizeX) / ((b.PhysicalSizeX * b.SizeX) * b.PhysicalSizeX));
5078 image.SetField(TiffTag.YRESOLUTION, (b.PhysicalSizeY * b.SizeY) / ((b.PhysicalSizeY * b.SizeY) * b.PhysicalSizeY));
5079 image.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.NONE);
5080 }
5081 else
5082 {
5083 image.SetField(TiffTag.XRESOLUTION, 100.0);
5084 image.SetField(TiffTag.YRESOLUTION, 100.0);
5085 image.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.INCH);
5086 }
5087 // specify that it's a page within the multipage file
5088 image.SetField(TiffTag.SUBFILETYPE, FileType.PAGE);
5089 // specify the page number
5090 buffer = b.Buffers[im].GetSaveBytes(true);
5091 image.SetField(TiffTag.PAGENUMBER, im + (b.Buffers.Count * fi), b.Buffers.Count * IDs.Length);
5092 for (int i = 0, offset = 0; i < b.SizeY; i++)
5093 {
5094 image.WriteScanline(buffer, offset, i, 0);
5095 offset += stride;
5096 }
5097 image.WriteDirectory();
5098 im++;
5099 }
5100 }
5101 }
5102 }
5103 image.Dispose();
5104 Recorder.Record($"BioImage.SaveSeries(new string[] {{ {string.Join(", ", IDs.Select(id => $"\"{id}\""))} }}, \"{file}\");");

◆ SetValue() [1/3]

void BioLib.BioImage.SetValue ( int x,
int y,
int ind,
ushort value )

It sets the value of a pixel in a buffer.

Parameters
xThe x coordinate of the pixel to set.
yThe y coordinate of the pixel to set.
indThe index of the buffer to set the value in.
valueThe value to set the pixel to.
4336 {
4337 Buffers[ind].SetValue(x, y, value);
4338 }

◆ SetValue() [2/3]

void BioLib.BioImage.SetValue ( int x,
int y,
ZCT coord,
ushort value )

This function sets the value of a pixel at a given x,y coordinate in a given image plane.

Parameters
xx coordinate of the pixel
yThe y coordinate of the pixel to set.
ZCTa struct that contains the Z, C, and T coordinates of the pixel
valuethe value to set
4346 {
4347 SetValue(x, y, GetFrameIndex(coord.Z, coord.C, coord.T), value);
4348 }
void SetValue(ZCTXY coord, ushort value)
It takes a coordinate and a value, and sets the value at that coordinate.
Definition Bio.cs:4324

◆ SetValue() [3/3]

void BioLib.BioImage.SetValue ( ZCTXY coord,
ushort value )

It takes a coordinate and a value, and sets the value at that coordinate.

Parameters
ZCTXYa struct that contains the Z, C, T, X, and Y coordinates of the pixel
valuethe value to be set
4325 {
4326 int i = GetFrameIndex(coord.Z, coord.C, coord.T);
4327 Buffers[i].SetValue(coord.X, coord.Y, value);
4328 }

◆ SetValueRGB()

void BioLib.BioImage.SetValueRGB ( ZCTXY coord,
int RGBindex,
ushort value )

It takes a coordinate, an RGB index, and a value, and sets the value of the pixel at that coordinate to the value.

Parameters
ZCTXYa struct that contains the Z, C, T, X, and Y coordinates of the pixel
RGBindex0 = Red, 1 = Green, 2 = Blue
valuethe value to be set
4356 {
4357 int ind = GetFrameIndex(coord.Z, coord.C, coord.T);
4358 Buffers[ind].SetValue(coord.X, coord.Y, RGBindex, value);
4359 }

◆ SplitChannels() [1/3]

BioImage[] BioLib.BioImage.SplitChannels ( )

It takes a single image and splits it into three images, one for each channel.

Returns
A list of BioImages
4047 {
4048 BioImage[] bms;
4049 if (isRGB)
4050 {
4051 bms = new BioImage[3];
4052 BioImage ri = new BioImage(System.IO.Path.GetFileNameWithoutExtension(ID) + "-1" + System.IO.Path.GetExtension(ID));
4053 BioImage gi = new BioImage(System.IO.Path.GetFileNameWithoutExtension(ID) + "-2" + System.IO.Path.GetExtension(ID));
4054 BioImage bi = new BioImage(System.IO.Path.GetFileNameWithoutExtension(ID) + "-3" + System.IO.Path.GetExtension(ID));
4055 ri.sizeC = 1;
4056 gi.sizeC = 1;
4057 bi.sizeC = 1;
4058 ri.sizeZ = SizeZ;
4059 gi.sizeZ = SizeZ;
4060 bi.sizeZ = SizeZ;
4061 ri.sizeT = SizeT;
4062 gi.sizeT = SizeT;
4063 bi.sizeT = SizeT;
4064
4065 ri.Coords = new int[SizeZ, 1, SizeT];
4066 gi.Coords = new int[SizeZ, 1, SizeT];
4067 bi.Coords = new int[SizeZ, 1, SizeT];
4068 int ind = 0;
4069 for (int i = 0; i < ImageCount; i++)
4070 {
4071 if (Buffers[i].PixelFormat == PixelFormat.Format48bppRgb)
4072 {
4073 //For 48bit images we need to use our own function as AForge won't give us a proper image.
4074 Bitmap[] bfs = Bitmap.RGB48To16(ID, SizeX, SizeY, Buffers[i].Stride, Buffers[i].Bytes, Buffers[i].Coordinate, ind, Buffers[i].Plane);
4075 ind += 3;
4076 ri.Buffers.Add(bfs[0]);
4077 gi.Buffers.Add(bfs[1]);
4078 bi.Buffers.Add(bfs[2]);
4079 bfs[0].Stats = Statistics.FromBytes(bfs[0]);
4080 bfs[1].Stats = Statistics.FromBytes(bfs[1]);
4081 bfs[2].Stats = Statistics.FromBytes(bfs[2]);
4082 ri.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4083 gi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4084 bi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4085 }
4086 else
4087 {
4088
4089 Bitmap rImage = extractR.Apply(Buffers[i]);
4090 Bitmap rbf = new Bitmap(ri.ID, rImage, Buffers[i].Coordinate, ind++);
4091 rbf.Stats = Statistics.FromBytes(rbf);
4092 ri.Buffers.Add(rbf);
4093 ri.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4094
4095 Bitmap gImage = extractG.Apply(Buffers[i]);
4096 Bitmap gbf = new Bitmap(gi.ID, gImage, Buffers[i].Coordinate, ind++);
4097 gbf.Stats = Statistics.FromBytes(gbf);
4098 gi.Buffers.Add(gbf);
4099 gi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4100
4101 Bitmap bImage = extractB.Apply(Buffers[i]);
4102 //Clipboard.SetImage(bImage);
4103 Bitmap bbf = new Bitmap(bi.ID, bImage, Buffers[i].Coordinate, ind++);
4104 bbf.Stats = Statistics.FromBytes(bbf);
4105 bi.Buffers.Add(bbf);
4106 bi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4107
4108 }
4109 }
4110 //We wait for threshold image statistics calculation
4111 do
4112 {
4113 Thread.Sleep(100);
4114 } while (bi.Buffers[bi.Buffers.Count - 1].Stats == null);
4115 ri.Resolutions.Add(new Resolution(Buffers[0].SizeX, Buffers[0].SizeY, Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
4116 gi.Resolutions.Add(new Resolution(Buffers[0].SizeX, Buffers[0].SizeY, Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
4117 bi.Resolutions.Add(new Resolution(Buffers[0].SizeX, Buffers[0].SizeY, Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
4118 ri.Channels.Add(Channels[0].Copy());
4119 gi.Channels.Add(Channels[0].Copy());
4120 bi.Channels.Add(Channels[0].Copy());
4121 AutoThreshold(ri, false);
4122 AutoThreshold(gi, false);
4123 AutoThreshold(bi, false);
4124 Images.AddImage(ri);
4125 Images.AddImage(gi);
4126 Images.AddImage(bi);
4127 bms[0] = ri;
4128 bms[1] = gi;
4129 bms[2] = bi;
4130 }
4131 else
4132 {
4133 bms = new BioImage[SizeC];
4134 for (int c = 0; c < SizeC; c++)
4135 {
4136 BioImage b = BioImage.Substack(this, 0, 0, SizeZ, c, c + 1, 0, SizeT);
4137 bms[c] = b;
4138 }
4139 }
4140 return bms;
4141 }
static BioImage Substack(BioImage orig, int ser, int zs, int ze, int cs, int ce, int ts, int te)
It takes a BioImage object, and returns a new BioImage object that is a subset of the original.
Definition Bio.cs:3833

◆ SplitChannels() [2/3]

static BioImage[] BioLib.BioImage.SplitChannels ( BioImage bb)
static

‍SplitChannels splits a BioImage into its constituent channels

Parameters
BioImageThe image to split
Returns
An array of BioImages
4148 {
4149 return bb.SplitChannels();
4150 }
BioImage[] SplitChannels()
It takes a single image and splits it into three images, one for each channel.
Definition Bio.cs:4046

◆ SplitChannels() [3/3]

static BioImage[] BioLib.BioImage.SplitChannels ( string name)
static

This function takes an image and splits it into its individual channels.

Parameters
nameThe name of the image to split.
Returns
An array of BioImage objects.
4157 {
4158 return SplitChannels(Images.GetImage(name));
4159 }

◆ Substack()

static BioImage BioLib.BioImage.Substack ( BioImage orig,
int ser,
int zs,
int ze,
int cs,
int ce,
int ts,
int te )
static

It takes a BioImage object, and returns a new BioImage object that is a subset of the original.

Parameters
BioImagethe image to be processed
serseries number
zsstarting z-plane
zeend of z-stack
cschannel start
cechannel end
tstime start
tetime end
Returns
A new BioImage object.
3834 {
3835 BioImage b = CopyInfo(orig, false, false);
3836 //b.ID = Images.GetImageName(orig.ID);
3837 int i = 0;
3838 b.Coords = new int[ze - zs, ce - cs, te - ts];
3839 b.sizeZ = ze - zs;
3840 b.sizeC = ce - cs;
3841 b.sizeT = te - ts;
3842 for (int ti = 0; ti < b.SizeT; ti++)
3843 {
3844 for (int zi = 0; zi < b.SizeZ; zi++)
3845 {
3846 for (int ci = 0; ci < b.SizeC; ci++)
3847 {
3848 int ind = orig.GetFrameIndex(zs + zi, cs + ci, ts + ti);
3849 Bitmap bf = new Bitmap(Images.GetImageName(orig.id), orig.SizeX, orig.SizeY, orig.Buffers[0].PixelFormat, orig.Buffers[ind].Bytes, new ZCT(zi, ci, ti), i);
3850 bf.Stats = Statistics.FromBytes(bf);
3851 b.Buffers.Add(bf);
3852 b.SetFrameIndex(zi, ci, ti, i);
3853 i++;
3854 }
3855 }
3856 }
3857 for (int ci = cs; ci < ce; ci++)
3858 {
3859 b.Channels.Add(orig.Channels[ci]);
3860 }
3861 b.Resolutions.Add(new Resolution(b.Buffers[0].SizeX, b.Buffers[0].SizeY, b.Buffers[0].PixelFormat, b.PhysicalSizeX, b.PhysicalSizeY, b.PhysicalSizeZ, b.StageSizeX, b.StageSizeY, b.StageSizeZ));
3862 AutoThreshold(b, false);
3863 if (b.bitsPerPixel > 8)
3864 b.StackThreshold(true);
3865 else
3866 b.StackThreshold(false);
3867 Images.AddImage(b);
3868 return b;
3869 }

◆ To16Bit()

void BioLib.BioImage.To16Bit ( )

Converts the image to 16 bit.

3095 {
3096 if (Buffers[0].RGBChannelsCount == 4)
3097 To24Bit();
3098 if (Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale)
3099 return;
3100 if (Buffers[0].PixelFormat == PixelFormat.Format48bppRgb)
3101 {
3102 List<Bitmap> bfs = new List<Bitmap>();
3103 int index = 0;
3104 for (int i = 0; i < Buffers.Count; i++)
3105 {
3106 Array.Reverse(Buffers[i].Bytes);
3107 Bitmap[] bs = Bitmap.RGB48To16(ID, SizeX, SizeY, Buffers[i].Stride, Buffers[i].Bytes, Buffers[i].Coordinate, index, Buffers[i].Plane);
3108 bfs.AddRange(bs);
3109 index += 3;
3110 }
3111 Buffers = bfs;
3112 UpdateCoords(SizeZ, SizeC * 3, SizeT);
3113 if (Channels[0].SamplesPerPixel == 3)
3114 {
3115 Channel c = Channels[0].Copy();
3116 c.SamplesPerPixel = 1;
3117 c.range = new IntRange[1];
3118 Channels.Clear();
3119 Channels.Add(c);
3120 Channels.Add(c.Copy());
3121 Channels.Add(c.Copy());
3122 Channels[1].Index = 1;
3123 Channels[2].Index = 2;
3124 }
3125 }
3126 else if (Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
3127 {
3128 for (int i = 0; i < Buffers.Count; i++)
3129 {
3130 Buffers[i] = AForge.Imaging.Image.Convert8bppTo16bpp(Buffers[i]);
3131 }
3132 for (int c = 0; c < Channels.Count; c++)
3133 {
3134 for (int i = 0; i < Channels[c].range.Length; i++)
3135 {
3136 Channels[c].range[i].Min = (int)(((float)Channels[c].range[i].Min / (float)byte.MaxValue) * ushort.MaxValue);
3137 Channels[c].range[i].Max = (int)(((float)Channels[c].range[i].Max / (float)byte.MaxValue) * ushort.MaxValue);
3138 }
3139 Channels[c].BitsPerPixel = 16;
3140 }
3141 }
3142 else if (Buffers[0].PixelFormat == PixelFormat.Format24bppRgb)
3143 {
3144 To48Bit();
3145 To16Bit();
3146 }
3147 else if (Buffers[0].PixelFormat == PixelFormat.Float)
3148 {
3149 for (int i = 0; i < Buffers.Count; i++)
3150 {
3151 if (Statistics.StackMax <= 1)
3152 Buffers[i].To16Bit(true);
3153 else
3154 Buffers[i].To16Bit(false);
3155 }
3156 }
3157
3158 foreach (var item in Buffers)
3159 {
3160 item.Stats = Statistics.FromBytes(item);
3161 }
3162 AutoThreshold(this, true);
3163 StackThreshold(true);
3164 }
void To16Bit()
Converts the image to 16 bit.
Definition Bio.cs:3094
void To24Bit()
Converts the image to 24 bit.
Definition Bio.cs:3166
void To48Bit()
Definition Bio.cs:3243

◆ To24Bit()

void BioLib.BioImage.To24Bit ( )

Converts the image to 24 bit.

3167 {
3168 if (Buffers[0].PixelFormat == PixelFormat.Format24bppRgb)
3169 return;
3170 if (Buffers[0].PixelFormat == PixelFormat.Format32bppArgb || Buffers[0].PixelFormat == PixelFormat.Format32bppRgb)
3171 {
3172 for (int i = 0; i < Buffers.Count; i++)
3173 {
3174 Buffers[i] = Bitmap.To24Bit(Buffers[i]);
3175 }
3176 if (Channels.Count == 4)
3177 {
3178 Channels.RemoveAt(0);
3179 }
3180 else
3181 {
3182 Channels[0].SamplesPerPixel = 3;
3183 }
3184 }
3185 else
3186 if (Buffers[0].PixelFormat == PixelFormat.Format48bppRgb)
3187 {
3188 //We run 8bit so we get 24 bit rgb.
3189 for (int i = 0; i < Buffers.Count; i++)
3190 {
3191 Buffers[i] = AForge.Imaging.Image.Convert16bppTo8bpp(Buffers[i]);
3192 Buffers[i].SwitchRedBlue();
3193 }
3194 }
3195 else
3196 if (Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale)
3197 {
3198 //We run 8bit so we get 24 bit rgb.
3199 for (int i = 0; i < Buffers.Count; i++)
3200 {
3201 Buffers[i] = AForge.Imaging.Image.Convert16bppTo8bpp(Buffers[i]);
3202 }
3203 To24Bit();
3204 }
3205 else if(Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
3206 {
3207 List<Bitmap> bms = new List<Bitmap>();
3208 //We run 8bit so we get 24 bit rgb.
3209 for (int i = 0; i < Buffers.Count; i+=3)
3210 {
3211 bms.Add(Bitmap.RGB8To24(new Bitmap[] { Buffers[i], Buffers[i+1], Buffers[i+2] }));
3212 }
3213 Buffers.Clear();
3214 Buffers.AddRange(bms);
3215 UpdateCoords(SizeZ, 1, SizeT);
3216 }
3217 foreach (var item in Buffers)
3218 {
3219 item.Stats = Statistics.FromBytes(item);
3220 }
3221 AutoThreshold(this, true);
3222 StackThreshold(false);
3223 }

◆ To32Bit()

void BioLib.BioImage.To32Bit ( )

Converts the image to 32 bit.

3226 {
3227 if (Buffers[0].PixelFormat == PixelFormat.Format32bppArgb)
3228 return;
3229 if (Buffers[0].PixelFormat != PixelFormat.Format24bppRgb)
3230 {
3231 To24Bit();
3232 }
3233 for (int i = 0; i < Buffers.Count; i++)
3234 {
3235 UnmanagedImage b = Bitmap.To32Bit(Buffers[i]);
3236 Buffers[i].Image = b;
3237 }
3238 AutoThreshold(this, true);
3239 }

◆ To48Bit()

void BioLib.BioImage.To48Bit ( )

It converts a 16 bit image to a 48 bit image

Returns
A list of Bitmaps.
3244 {
3245 if (Buffers[0].RGBChannelsCount == 4)
3246 To24Bit();
3247 if (Buffers[0].PixelFormat == PixelFormat.Format48bppRgb)
3248 return;
3249 if (Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed || Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale)
3250 {
3251 if (Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
3252 {
3253 for (int i = 0; i < Buffers.Count; i++)
3254 {
3255 Buffers[i].Image = AForge.Imaging.Image.Convert8bppTo16bpp(Buffers[i]);
3256 }
3257 }
3258 List<Bitmap> bfs = new List<Bitmap>();
3259 if (Buffers.Count % 3 != 0 && Buffers.Count % 2 != 0)
3260 for (int i = 0; i < Buffers.Count; i++)
3261 {
3262 Bitmap bs = new Bitmap(ID, SizeX, SizeY, Buffers[i].PixelFormat, Buffers[i].Bytes, new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i].Coordinate.T), i, Buffers[i].Plane);
3263 Bitmap bbs = Bitmap.RGB16To48(bs);
3264 bs.Dispose();
3265 bs = null;
3266 bfs.Add(bbs);
3267 }
3268 else
3269 for (int i = 0; i < Buffers.Count; i += Channels.Count)
3270 {
3271 Bitmap[] bs = new Bitmap[3];
3272 bs[0] = new Bitmap(ID, SizeX, SizeY, Buffers[i].PixelFormat, Buffers[i].Bytes, new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i].Coordinate.T), i, Buffers[i].Plane);
3273 bs[1] = new Bitmap(ID, SizeX, SizeY, Buffers[i + 1].PixelFormat, Buffers[i + 1].Bytes, new ZCT(Buffers[i + 1].Coordinate.Z, 0, Buffers[i + 1].Coordinate.T), i + 1, Buffers[i + 1].Plane);
3274 if (Channels.Count > 2)
3275 bs[2] = new Bitmap(ID, SizeX, SizeY, Buffers[i + 2].PixelFormat, Buffers[i + 2].Bytes, new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i + 2].Coordinate.T), i + 2, Buffers[i].Plane);
3276 Bitmap bbs = Bitmap.RGB16To48(bs);
3277 for (int b = 0; b < 3; b++)
3278 {
3279 if (bs[b] != null)
3280 bs[b].Dispose();
3281 bs[b] = null;
3282 }
3283 bfs.Add(bbs);
3284 }
3285 Buffers = bfs;
3286 UpdateCoords(SizeZ, 1, SizeT);
3287 Channel c = Channels[0].Copy();
3288 c.SamplesPerPixel = 3;
3289 rgbChannels[0] = 0;
3290 rgbChannels[1] = 0;
3291 rgbChannels[2] = 0;
3292 Channels.Clear();
3293 Channels.Add(c);
3294 }
3295 else
3296 if (Buffers[0].PixelFormat == PixelFormat.Format24bppRgb || Buffers[0].PixelFormat == PixelFormat.Format32bppArgb)
3297 {
3298 for (int i = 0; i < Buffers.Count; i++)
3299 {
3300 Buffers[i] = AForge.Imaging.Image.Convert8bppTo16bpp(Buffers[i]);
3301 Buffers[i].SwitchRedBlue();
3302 }
3303 }
3304 else
3305 {
3306 int index = 0;
3307 List<Bitmap> buffers = new List<Bitmap>();
3308 for (int i = 0; i < Buffers.Count; i += 3)
3309 {
3310 Bitmap[] bf = new Bitmap[3];
3311 bf[0] = Buffers[i];
3312 bf[1] = Buffers[i + 1];
3313 bf[2] = Buffers[i + 2];
3314 Bitmap inf = Bitmap.RGB16To48(bf);
3315 buffers.Add(inf);
3316 for (int b = 0; b < 3; b++)
3317 {
3318 bf[b].Dispose();
3319 }
3320 index++;
3321 }
3322 Buffers = buffers;
3323 UpdateCoords(SizeZ, 1, SizeT);
3324 }
3325 AutoThreshold(this, true);
3326 StackThreshold(true);
3327 }

◆ To8Bit()

void BioLib.BioImage.To8Bit ( )

Converts a 16-bit image to an 8-bit image.

3006 {
3007 if (Buffers[0].RGBChannelsCount == 4)
3008 To24Bit();
3009 PixelFormat px = Buffers[0].PixelFormat;
3010 if (px == PixelFormat.Format8bppIndexed)
3011 return;
3012 if (px == PixelFormat.Format48bppRgb)
3013 {
3014 To24Bit();
3015 List<AForge.Bitmap> bfs = new List<AForge.Bitmap>();
3016 int index = 0;
3017 for (int i = 0; i < Buffers.Count; i++)
3018 {
3019 Bitmap[] bs = Bitmap.RGB24To8(Buffers[i]);
3020 Bitmap br = new Bitmap(ID, bs[2], new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i].Coordinate.T), index, Buffers[i].Plane);
3021 Bitmap bg = new Bitmap(ID, bs[1], new ZCT(Buffers[i].Coordinate.Z, 1, Buffers[i].Coordinate.T), index + 1, Buffers[i].Plane);
3022 Bitmap bb = new Bitmap(ID, bs[0], new ZCT(Buffers[i].Coordinate.Z, 2, Buffers[i].Coordinate.T), index + 2, Buffers[i].Plane);
3023 for (int b = 0; b < 3; b++)
3024 {
3025 bs[b].Dispose();
3026 }
3027 bs = null;
3028 br.Stats = Statistics.FromBytes(br);
3029 bg.Stats = Statistics.FromBytes(bg);
3030 bb.Stats = Statistics.FromBytes(bb);
3031 bfs.Add(br);
3032 bfs.Add(bg);
3033 bfs.Add(bb);
3034 index += 3;
3035 }
3036 Buffers = bfs;
3037 UpdateCoords(SizeZ, 3, SizeT);
3038 }
3039 else
3040 if (px == PixelFormat.Format24bppRgb)
3041 {
3042 List<Bitmap> bfs = new List<Bitmap>();
3043 int index = 0;
3044 for (int i = 0; i < Buffers.Count; i++)
3045 {
3046 Bitmap[] bs = Bitmap.RGB24To8(Buffers[i]);
3047 Bitmap br = new Bitmap(ID, bs[2], new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i].Coordinate.T), index, Buffers[i].Plane);
3048 Bitmap bg = new Bitmap(ID, bs[1], new ZCT(Buffers[i].Coordinate.Z, 1, Buffers[i].Coordinate.T), index + 1, Buffers[i].Plane);
3049 Bitmap bb = new Bitmap(ID, bs[0], new ZCT(Buffers[i].Coordinate.Z, 2, Buffers[i].Coordinate.T), index + 2, Buffers[i].Plane);
3050 for (int b = 0; b < 3; b++)
3051 {
3052 bs[b].Dispose();
3053 bs[b] = null;
3054 }
3055 bs = null;
3056 br.Stats = Statistics.FromBytes(br);
3057 bg.Stats = Statistics.FromBytes(bg);
3058 bb.Stats = Statistics.FromBytes(bb);
3059 bfs.Add(br);
3060 bfs.Add(bg);
3061 bfs.Add(bb);
3062 index += 3;
3063 }
3064 Buffers = bfs;
3065 UpdateCoords(SizeZ, 3, SizeT);
3066 Channels.Clear();
3067 Channels.Add(new Channel(0, 8, 1));
3068 Channels.Add(new Channel(0, 8, 1));
3069 Channels.Add(new Channel(0, 8, 1));
3070 }
3071 else
3072 if (px == PixelFormat.Format16bppGrayScale)
3073 {
3074 foreach (var item in Buffers)
3075 {
3076 item.To8Bit();
3077 }
3078 }
3079 else
3080 if (px == PixelFormat.Float)
3081 {
3082 foreach (var item in Buffers)
3083 {
3084 if (Statistics.StackMax <= 1)
3085 item.To8Bit(true);
3086 else
3087 item.To8Bit(false);
3088 }
3089 }
3090 AutoThreshold(this, true);
3091 StackThreshold(false);
3092 }

◆ ToFloat()

void BioLib.BioImage.ToFloat ( )
3339 {
3340 foreach (var b in Buffers)
3341 {
3342 b.ToFloat();
3343 b.Stats = Statistics.FromBytes(b);
3344 }
3345 AutoThreshold(this, true);
3346 StackThreshold(false);
3347 Recorder.Record($"{this}.ToFloat();");
3348 }

◆ ToImageSizeX()

double BioLib.BioImage.ToImageSizeX ( double d)

Convert a physical size to an image size.

Parameters
dthe distance in microns
Returns
The value of d divided by the physicalSizeX.
3584 {
3585 return d / PhysicalSizeX;
3586 }

◆ ToImageSizeY()

double BioLib.BioImage.ToImageSizeY ( double d)

Convert a physical size in Y direction to an image size in Y direction.

Parameters
dthe distance in microns
Returns
The return value is the value of the parameter d divided by the value of the physicalSizeY field.
3594 {
3595 return d / PhysicalSizeY;
3596 }

◆ ToImageSpace() [1/4]

PointD[] BioLib.BioImage.ToImageSpace ( List< PointD > p)

Convert a list of points from stage space to image space.

Parameters
pList of points in stage space
Returns
A PointD array.
3637 {
3638 PointD[] ps = new PointD[p.Count];
3639 for (int i = 0; i < p.Count; i++)
3640 {
3641 PointD pp = new PointD();
3642 pp.X = ((p[i].X - StageSizeX) / PhysicalSizeX);
3643 pp.Y = ((p[i].Y - StageSizeY) / PhysicalSizeY);
3644 ps[i] = pp;
3645 }
3646 return ps;
3647 }

◆ ToImageSpace() [2/4]

PointD BioLib.BioImage.ToImageSpace ( PointD p)

Convert a point in the stage coordinate system to a point in the image coordinate system.

Parameters
PointD
Returns
A PointF object.
3625 {
3626 PointD pp = new PointD();
3627 pp.X = (float)((p.X - StageSizeX) / PhysicalSizeX);
3628 pp.Y = (float)((p.Y - StageSizeY) / PhysicalSizeY);
3629 return pp;
3630 }

◆ ToImageSpace() [3/4]

PointF[] BioLib.BioImage.ToImageSpace ( PointF[] p)

‍The function takes a list of points in the stage coordinate system and returns a list of points in the image coordinate system

Parameters
pthe points to be converted
Returns
A PointF[]
3655 {
3656 PointF[] ps = new PointF[p.Length];
3657 for (int i = 0; i < p.Length; i++)
3658 {
3659 PointF pp = new PointF();
3660 pp.X = (float)((p[i].X - StageSizeX) / PhysicalSizeX);
3661 pp.Y = (float)((p[i].Y - StageSizeY) / PhysicalSizeY);
3662 ps[i] = pp;
3663 }
3664 return ps;
3665 }

◆ ToImageSpace() [4/4]

RectangleF BioLib.BioImage.ToImageSpace ( RectangleD p)

‍Convert a rectangle in physical space to a rectangle in image space

Parameters
RectangleD
Returns
A RectangleF object.
3672 {
3673 RectangleF r = new RectangleF();
3674 Point pp = new Point();
3675 r.X = (int)((p.X - StageSizeX) / PhysicalSizeX);
3676 r.Y = (int)((p.Y - StageSizeY) / PhysicalSizeY);
3677 r.Width = (int)(p.W / PhysicalSizeX);
3678 r.Height = (int)(p.H / PhysicalSizeY);
3679 return r;
3680 }

◆ ToImageSpaceX()

double BioLib.BioImage.ToImageSpaceX ( double x)

‍Convert a stage coordinate to an image coordinate

Parameters
xthe x coordinate of the point in the image
Returns
The return value is a double.
3603 {
3604 if (isPyramidal)
3605 return x;
3606 return (float)((x - StageSizeX) / PhysicalSizeX);
3607 }

◆ ToImageSpaceY()

double BioLib.BioImage.ToImageSpaceY ( double y)

‍Convert a Y coordinate from stage space to image space

Parameters
ythe y coordinate of the point in the image
Returns
The return value is the y-coordinate of the image.
3614 {
3615 if (isPyramidal)
3616 return y;
3617 return (float)((y - StageSizeY) / PhysicalSizeY);
3618 }

◆ ToShort()

void BioLib.BioImage.ToShort ( )
3329 {
3330 foreach (var b in Buffers)
3331 {
3332 b.ToShort();
3333 }
3334 AutoThreshold(this, true);
3335 StackThreshold(false);
3336 Recorder.Record($"{this}.ToShort();");
3337 }

◆ ToStageSpace() [1/7]

PointD BioLib.BioImage.ToStageSpace ( PointD p)

‍This function converts a point in the image space to a point in the stage space

Parameters
PointDA class that contains an X and Y coordinate.
Returns
A PointD object.
3687 {
3688 PointD pp = new PointD();
3689 if (isPyramidal)
3690 {
3691 pp.X = ((p.X * Resolutions[Level].PhysicalSizeX) + Volume.Location.X);
3692 pp.Y = ((p.Y * Resolutions[Level].PhysicalSizeY) + Volume.Location.Y);
3693 return pp;
3694 }
3695 else
3696 {
3697 pp.X = ((p.X * PhysicalSizeX) + Volume.Location.X);
3698 pp.Y = ((p.Y * PhysicalSizeY) + Volume.Location.Y);
3699 return pp;
3700 }
3701 }

◆ ToStageSpace() [2/7]

static PointD BioLib.BioImage.ToStageSpace ( PointD p,
double physicalSizeX,
double physicalSizeY,
double volumeX,
double volumeY )
static

‍The function takes a point in the volume space and converts it to a point in the stage space

Parameters
PointDA custom class that holds an X and Y coordinate.
physicalSizeXThe width of the stage in mm
physicalSizeYThe height of the stage in mm
volumeXThe X coordinate of the top left corner of the volume in stage space.
volumeYThe Y position of the top left corner of the volume in stage space.
Returns
A PointD object.
3726 {
3727 PointD pp = new PointD();
3728 pp.X = ((p.X * physicalSizeX) + volumeX);
3729 pp.Y = ((p.Y * physicalSizeY) + volumeY);
3730 return pp;
3731 }

◆ ToStageSpace() [3/7]

PointD BioLib.BioImage.ToStageSpace ( PointD p,
int resolution )

Convert a point in the image space to a point in the stage space.

Parameters
PointDA point in the image space
resolutionthe resolution of the image (0, 1, 2, 3, 4)
Returns
A PointD object.
3709 {
3710 PointD pp = new PointD();
3711 pp.X = ((p.X * Resolutions[resolution].PhysicalSizeX) + Volume.Location.X);
3712 pp.Y = ((p.Y * Resolutions[resolution].PhysicalSizeY) + Volume.Location.Y);
3713 return pp;
3714 }

◆ ToStageSpace() [4/7]

PointD[] BioLib.BioImage.ToStageSpace ( PointD[] p)

‍This function takes a list of points in the coordinate system of the image and returns a list of points in the coordinate system of the stage

Parameters
pThe array of points to convert
Returns
A PointD[] array.
3773 {
3774 PointD[] ps = new PointD[p.Length];
3775 for (int i = 0; i < p.Length; i++)
3776 {
3777 PointD pp = new PointD();
3778 pp.X = ((p[i].X * PhysicalSizeX) + Volume.Location.X);
3779 pp.Y = ((p[i].Y * PhysicalSizeY) + Volume.Location.Y);
3780 ps[i] = pp;
3781 }
3782 return ps;
3783 }

◆ ToStageSpace() [5/7]

static PointD[] BioLib.BioImage.ToStageSpace ( PointD[] p,
double physicalSizeX,
double physicalSizeY,
double volumeX,
double volumeY )
static

It takes a list of points, and converts them from a coordinate system where the origin is in the center of the image, to a coordinate system where the origin is in the top left corner of the image.

Parameters
pthe array of points to convert
physicalSizeXThe width of the image in microns
physicalSizeYThe height of the image in microns
volumeXThe X position of the volume in stage space.
volumeYThe Y position of the top left corner of the volume in stage space.
Returns
A PointD array.
3796 {
3797 PointD[] ps = new PointD[p.Length];
3798 for (int i = 0; i < p.Length; i++)
3799 {
3800 PointD pp = new PointD();
3801 pp.X = ((p[i].X * physicalSizeX) + volumeX);
3802 pp.Y = ((p[i].Y * physicalSizeY) + volumeY);
3803 ps[i] = pp;
3804 }
3805 return ps;
3806 }

◆ ToStageSpace() [6/7]

RectangleD BioLib.BioImage.ToStageSpace ( RectangleD p)

‍Convert a rectangle from the coordinate space of the image to the coordinate space of the stage

Parameters
RectangleDA rectangle with double precision coordinates.
Returns
A RectangleD object.
3739 {
3740 RectangleD r = new RectangleD();
3741 r.X = ((p.X * PhysicalSizeX) + Volume.Location.X);
3742 r.Y = ((p.Y * PhysicalSizeY) + Volume.Location.Y);
3743 r.W = (p.W * PhysicalSizeX);
3744 r.H = (p.H * PhysicalSizeY);
3745 return r;
3746 }

◆ ToStageSpace() [7/7]

static RectangleD BioLib.BioImage.ToStageSpace ( RectangleD p,
double physicalSizeX,
double physicalSizeY,
double volumeX,
double volumeY )
static

‍This function takes a rectangle in the coordinate space of the image and converts it to the coordinate space of the stage

Parameters
RectangleDA rectangle with double precision.
physicalSizeXThe width of the physical screen in pixels
physicalSizeYThe height of the stage in pixels
volumeXThe X position of the volume in stage space.
volumeYThe Y position of the top of the volume in stage space.
Returns
A RectangleD object.
3758 {
3759 RectangleD r = new RectangleD();
3760 r.X = ((p.X * physicalSizeX) + volumeX);
3761 r.Y = ((p.Y * physicalSizeY) + volumeY);
3762 r.W = (p.W * physicalSizeX);
3763 r.H = (p.H * physicalSizeY);
3764 return r;
3765 }

◆ UpdateCoords() [1/3]

void BioLib.BioImage.UpdateCoords ( )

It takes a list of images and assigns them to a 3D array of coordinates.

3447 {
3448 Coords = new int[SizeZ, SizeC, SizeT];
3449 int i = 0;
3450 for (int z = 0; z < SizeZ; z++)
3451 {
3452 for (int c = 0; c < SizeC; c++)
3453 {
3454 for (int t = 0; t < SizeT; t++)
3455 {
3456 Coords[z, c, t] = i;
3457 i++;
3458 }
3459 }
3460 }
3461 }

◆ UpdateCoords() [2/3]

void BioLib.BioImage.UpdateCoords ( int sz,
int sc,
int st )

It takes the number of Z, C, and T planes in the image and then assigns each image buffer a coordinate in the ZCT space.

Parameters
szsize of the Z dimension
scnumber of channels
stnumber of time points
3469 {
3470 sizeZ = sz;
3471 sizeC = sc;
3472 sizeT = st;
3473 Coords = new int[sz, sc, st];
3474 int i = 0;
3475 for (int z = 0; z < sz; z++)
3476 {
3477 for (int c = 0; c < sc; c++)
3478 {
3479 for (int t = 0; t < st; t++)
3480 {
3481 Coords[z, c, t] = i;
3482 i++;
3483 }
3484 }
3485 }
3486
3487 }

◆ UpdateCoords() [3/3]

void BioLib.BioImage.UpdateCoords ( int sz,
int sc,
int st,
Order order )

It takes a list of images and assigns them to a 3D array of coordinates.

Parameters
szsize of the Z dimension
scnumber of channels
stnumber of time points
orderXYCZT or XYZCT
3495 {
3496 int z = 0;
3497 int c = 0;
3498 int t = 0;
3499 sizeZ = sz;
3500 sizeC = sc;
3501 sizeT = st;
3502 Coords = new int[sz, sc, st];
3503 int fr = sz * sc * st;
3504 if (order == Order.CZT)
3505 {
3506 for (int im = 0; im < fr; im++)
3507 {
3508 ZCT co = new ZCT(z, c, t);
3509 SetFrameIndex(co.Z, co.C, co.T, im);
3510 if (c < SizeC - 1)
3511 c++;
3512 else
3513 {
3514 c = 0;
3515 if (z < SizeZ - 1)
3516 z++;
3517 else
3518 {
3519 z = 0;
3520 if (t < SizeT - 1)
3521 t++;
3522 else
3523 t = 0;
3524 }
3525 }
3526 }
3527 }
3528 else if (order == Order.ZCT)
3529 {
3530 for (int im = 0; im < fr; im++)
3531 {
3532 ZCT co = new ZCT(z, c, t);
3533 SetFrameIndex(co.Z, co.C, co.T, im);
3534 if (z < SizeZ - 1)
3535 z++;
3536 else
3537 {
3538 z = 0;
3539 if (c < SizeC - 1)
3540 c++;
3541 else
3542 {
3543 c = 0;
3544 if (t < SizeT - 1)
3545 t++;
3546 else
3547 t = 0;
3548 }
3549 }
3550 }
3551 }
3552 else
3553 {
3554 //Order.TZC
3555 for (int im = 0; im < fr; im++)
3556 {
3557 ZCT co = new ZCT(z, c, t);
3558 SetFrameIndex(co.Z, co.C, co.T, im);
3559 if (t < SizeT - 1)
3560 t++;
3561 else
3562 {
3563 t = 0;
3564 if (z < SizeZ - 1)
3565 z++;
3566 else
3567 {
3568 z = 0;
3569 if (c < SizeC - 1)
3570 c++;
3571 else
3572 c = 0;
3573 }
3574 }
3575 }
3576 }
3577 }

Member Data Documentation

◆ rgbChannels

int [] BioLib.BioImage.rgbChannels = new int[3] { 0, 1, 2 }
2056{ 0, 1, 2 };

Property Documentation

◆ AnnotationsB

List<ROI> BioLib.BioImage.AnnotationsB
get
2733 {
2734 get
2735 {
2736 return GetAnnotations(Coordinate.Z, BChannel.Index, Coordinate.T);
2737 }
2738 }

◆ AnnotationsG

List<ROI> BioLib.BioImage.AnnotationsG
get
2725 {
2726 get
2727 {
2728 return GetAnnotations(Coordinate.Z, GChannel.Index, Coordinate.T);
2729 }
2730 }

◆ AnnotationsR

List<ROI> BioLib.BioImage.AnnotationsR
get
2717 {
2718 get
2719 {
2720 return GetAnnotations(Coordinate.Z, RChannel.Index, Coordinate.T);
2721 }
2722 }

◆ BChannel

Channel BioLib.BioImage.BChannel
get
2706 {
2707 get
2708 {
2709 if (Channels.Count >= 3)
2710 return Channels[rgbChannels[2]];
2711 else
2712 return Channels[0];
2713 }
2714 }

◆ bitsPerPixel

int BioLib.BioImage.bitsPerPixel
get
2065 {
2066 get
2067 {
2068 if (Channels != null && Channels.Count > 0)
2069 return Channels[0].BitsPerPixel;
2070
2071 if (Resolutions != null && Resolutions.Count > Level)
2072 {
2073 PixelFormat p = Resolutions[Level].PixelFormat;
2074 switch (p)
2075 {
2076 case PixelFormat.Format8bppIndexed:
2077 case PixelFormat.Format24bppRgb: // 8 bits per channel
2078 case PixelFormat.Format32bppArgb: // 8 bits per channel
2079 return 8;
2080
2081 case PixelFormat.Format16bppGrayScale:
2082 case PixelFormat.Format48bppRgb: // 16 bits per channel
2083 case PixelFormat.Format64bppArgb: // 16 bits per channel
2084 return 16;
2085
2086 default:
2087 return 8; // conservative default
2088 }
2089 }
2090 return 8;
2091 }
2092 }

◆ BRange

IntRange BioLib.BioImage.BRange
get
2927 {
2928 get
2929 {
2930 return BChannel.RangeB;
2931 }
2932 }

◆ Coordinate

ZCT BioLib.BioImage.Coordinate
getset
1950 {
1951 get
1952 {
1953 return coordinate;
1954 }
1955 set
1956 {
1957 coordinate = value;
1958 }
1959 }

◆ Filename

string BioLib.BioImage.Filename
getset
2014 {
2015 get
2016 {
2017 if (filename != null && filename != "")
2018 return filename;
2019 if (file != null && (file.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ||
2020 file.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
2021 file.StartsWith("s3://", StringComparison.OrdinalIgnoreCase) ||
2022 file.IndexOf(".zarr", StringComparison.OrdinalIgnoreCase) >= 0))
2023 {
2024 return file;
2025 }
2026 if (filename == null || filename == "")
2027 return Type.ToString() + ".ome.tif";
2028 return filename;
2029 }
2030 set
2031 {
2032 filename = value;
2033 }
2034 }

◆ GChannel

Channel BioLib.BioImage.GChannel
get
2696 {
2697 get
2698 {
2699 if (Channels.Count >= 3)
2700 return Channels[rgbChannels[1]];
2701 else
2702 return Channels[0];
2703 }
2704 }

◆ GRange

IntRange BioLib.BioImage.GRange
get
2920 {
2921 get
2922 {
2923 return GChannel.RangeG;
2924 }
2925 }

◆ ID

string BioLib.BioImage.ID
getset
2544 {
2545 get { return id; }
2546 set { id = value; }
2547 }

◆ ImageCount

int BioLib.BioImage.ImageCount
get
2549 {
2550 get
2551 {
2552 return Buffers.Count;
2553 }
2554 }

◆ Initialized

bool BioLib.BioImage.Initialized
staticget
2998 {
2999 get
3000 {
3001 return initialized;
3002 }
3003 }

◆ isPyramidal

bool BioLib.BioImage.isPyramidal
get
2972 {
2973 get
2974 {
2975 if (Type == ImageType.pyramidal && (Resolutions.Count > 1))
2976 return true;
2977 else if (Resolutions.Count > 1)
2978 return true;
2979 return false;
2980 }
2981 }

◆ isRGB

bool BioLib.BioImage.isRGB
get
2942 {
2943 get
2944 {
2945 if (RGBChannelCount == 3 || RGBChannelCount == 4)
2946 return true;
2947 else
2948 return false;
2949 }
2950 }

◆ isSeries

bool BioLib.BioImage.isSeries
get
2962 {
2963 get
2964 {
2965 if (seriesCount > 1)
2966 return true;
2967 else
2968 return false;
2969 }
2970 }

◆ isTime

bool BioLib.BioImage.isTime
get
2952 {
2953 get
2954 {
2955 if (SizeT > 1)
2956 return true;
2957 else
2958 return false;
2959 }
2960 }

◆ IsZarrSource

bool BioLib.BioImage.IsZarrSource
get
2045 {
2046 get
2047 {
2048 string source = SourceFile;
2049 return !string.IsNullOrWhiteSpace(source) &&
2050 (source.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ||
2051 source.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
2052 source.StartsWith("s3://", StringComparison.OrdinalIgnoreCase) ||
2053 source.IndexOf(".zarr", StringComparison.OrdinalIgnoreCase) >= 0);
2054 }
2055 }

◆ LabelResolution

int? BioLib.BioImage.LabelResolution
getset
3350{ get; set; }

◆ Level

int BioLib.BioImage.Level
getset
1987 {
1988 get
1989 {
1990 int v = 0;
1991 if (SlideBase != null)
1992 v = OpenSlideGTK.TileUtil.GetLevel(SlideBase.Schema.Resolutions, Resolution);
1993 else if (OpenSlideBase != null)
1994 v = OpenSlideGTK.TileUtil.GetLevel(OpenSlideBase.Schema.Resolutions, Resolution);
1995 else
1997 if (v < Resolutions.Count)
1998 return v;
1999 else
2000 return 0;
2001 }
2002 set
2003 {
2004 if (value < 0)
2005 return;
2006 level = value;
2007 }
2008 }
int LevelFromResolution(double Resolution)
Returns the level of a given resolution.
Definition Bio.cs:2301
Definition SlideBase.cs:18

◆ MacroResolution

int? BioLib.BioImage.MacroResolution
getset
3349{ get; set; }

◆ Magnification

double BioLib.BioImage.Magnification
getset
2904 {
2905 get; set;
2906 }

◆ OpenSlideBase

OpenSlideBase BioLib.BioImage.OpenSlideBase
get
2672{ get { return openslideBase; } }

◆ PhysicalSizeX

double BioLib.BioImage.PhysicalSizeX
get
2556 {
2557 get
2558 {
2559 if (isPyramidal)
2560 return Resolutions[Level].PhysicalSizeX;
2561 else
2562 if (Plate != null)
2563 return Resolutions[serie].PhysicalSizeX;
2564 else if (Resolutions.Count > 0)
2565 return Resolutions[0].PhysicalSizeX;
2566 else
2567 return 0;
2568 }
2569 }

◆ PhysicalSizeY

double BioLib.BioImage.PhysicalSizeY
get
2571 {
2572 get
2573 {
2574 if (isPyramidal)
2575 return Resolutions[Level].PhysicalSizeY;
2576 else
2577 if (Plate != null)
2578 return Resolutions[serie].PhysicalSizeY;
2579 else if (Resolutions.Count > 0)
2580 return Resolutions[0].PhysicalSizeY;
2581 else
2582 return 0;
2583 }
2584 }

◆ PhysicalSizeZ

double BioLib.BioImage.PhysicalSizeZ
get
2586 {
2587 get
2588 {
2589 if (isPyramidal)
2590 return Resolutions[Level].PhysicalSizeZ;
2591 else
2592 if (Plate != null)
2593 return Resolutions[serie].PhysicalSizeZ;
2594 else if (Resolutions.Count > 0)
2595 return Resolutions[0].PhysicalSizeZ;
2596 else
2597 return 0;
2598 }
2599 }

◆ PyramidalOrigin

PointD BioLib.BioImage.PyramidalOrigin
getset
2647 {
2648 get
2649 {
2650 return pyramidalOrigin;
2651 }
2652 set
2653 {
2654 pyramidalOrigin.X = value.X;
2655 pyramidalOrigin.Y = value.Y;
2656 }
2657 }

◆ PyramidalSize

AForge.Size BioLib.BioImage.PyramidalSize
getset
2642{ get { return s; } set { s = value; } }

◆ PyramidNativeLevelCount

int BioLib.BioImage.PyramidNativeLevelCount = 0
getset
1982{ get; set; } = 0;

◆ RChannel

Channel BioLib.BioImage.RChannel
get
2686 {
2687 get
2688 {
2689 if(Channels.Count >= 3)
2690 return Channels[rgbChannels[0]];
2691 else
2692 return Channels[0];
2693 }
2694 }

◆ Resolution

double BioLib.BioImage.Resolution
getset
2117 {
2118 get { return resolution; }
2119 set
2120 {
2121 if (value <= 0)
2122 return;
2123 resolution = value;
2124 }
2125 }

◆ RGBChannelCount

int BioLib.BioImage.RGBChannelCount
get
2058 {
2059 get
2060 {
2061 return Resolutions[0].RGBChannelsCount;
2062 }
2063 }

◆ RRange

IntRange BioLib.BioImage.RRange
get
2913 {
2914 get
2915 {
2916 return RChannel.RangeR;
2917 }
2918 }

◆ SelectedBuffer

Bitmap BioLib.BioImage.SelectedBuffer
get
2934 {
2935 get
2936 {
2937 return Buffers[GetFrameIndex(Coordinate.Z, Coordinate.C, Coordinate.T)];
2938 }
2939 }

◆ series

int BioLib.BioImage.series
getset
2659 {
2660 get
2661 {
2662 return imageInfo.Series;
2663 }
2664 set
2665 {
2666 imageInfo.Series = value;
2667 }
2668 }

◆ SizeC

int BioLib.BioImage.SizeC
get
2886 {
2887 get
2888 {
2889 return sizeC;
2890 }
2891 }

◆ SizeT

int BioLib.BioImage.SizeT
get
2893 {
2894 get { return sizeT; }
2895 }

◆ SizeX

int BioLib.BioImage.SizeX
get
2864 {
2865 get
2866 {
2867 if (Buffers.Count > 0)
2868 return Buffers[0].SizeX;
2869 else return 0;
2870 }
2871 }

◆ SizeY

int BioLib.BioImage.SizeY
get
2873 {
2874 get
2875 {
2876 if (Buffers.Count > 0)
2877 return Buffers[0].SizeY;
2878 else return 0;
2879 }
2880 }

◆ SizeZ

int BioLib.BioImage.SizeZ
get
2882 {
2883 get { return sizeZ; }
2884 }

◆ SlideBase

SlideBase BioLib.BioImage.SlideBase
getset
2674{ get { return slideBase; } set { slideBase = value; } }

◆ SourceFile

string BioLib.BioImage.SourceFile
get
2036 {
2037 get
2038 {
2039 if (!string.IsNullOrWhiteSpace(file))
2040 return file;
2041 return Filename;
2042 }
2043 }

◆ StackOrder

Order BioLib.BioImage.StackOrder
getset
2908 {
2909 get; set;
2910 }

◆ StageSizeX

double BioLib.BioImage.StageSizeX
get
2601 {
2602 get
2603 {
2604 if (isPyramidal)
2605 return Resolutions[Level].StageSizeX;
2606 else
2607 if (Plate != null)
2608 return Resolutions[serie].StageSizeX;
2609 else
2610 return Resolutions[0].StageSizeX;
2611 }
2612
2613 }

◆ StageSizeY

double BioLib.BioImage.StageSizeY
get
2615 {
2616 get
2617 {
2618 if (isPyramidal)
2619 return Resolutions[Level].StageSizeY;
2620 else
2621 if (Plate != null)
2622 return Resolutions[serie].StageSizeY;
2623 else
2624 return Resolutions[0].StageSizeY;
2625 }
2626
2627 }

◆ StageSizeZ

double BioLib.BioImage.StageSizeZ
get
2629 {
2630 get
2631 {
2632 if (isPyramidal)
2633 return Resolutions[Level].StageSizeZ;
2634 else
2635 if (Plate != null)
2636 return Resolutions[serie].StageSizeZ;
2637 else
2638 return Resolutions[0].StageSizeZ;
2639 }
2640 }

◆ Statistics

Statistics BioLib.BioImage.Statistics
getset
2103 {
2104 get
2105 {
2106 return statistics;
2107 }
2108 set
2109 {
2110 statistics = value;
2111 }
2112 }

◆ Status

string BioLib.BioImage.Status
staticgetset
2985 {
2986 get
2987 {
2988 return stat;
2989 }
2990 set
2991 {
2992 stat = value;
2993 Console.WriteLine(stat);
2994 }
2995 }

◆ Tag

object BioLib.BioImage.Tag
getset
2911{ get; set; }

◆ Type

ImageType BioLib.BioImage.Type
get
1968 {
1969 get
1970 {
1971 if (Plate != null || ZarrWellLevels.Count > 0)
1972 return ImageType.well;
1973 if (Resolutions.Count > 1 && Plate == null)
1974 return ImageType.pyramidal;
1975 return ImageType.stack;
1976 }
1977 }

◆ UseOSMNegativeY

bool BioLib.BioImage.UseOSMNegativeY = true
getset
2644{ get; set; } = true;

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