BioLib  3.6.2
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 }
 
enum  BackEnd { OpenSlide , Bioformats , LibVips }
 

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 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.
 
int GetFrameIndex (int z, int c, int t)
 
void SetFrameIndex (int z, int c, int t, int val)
 
BioImage GetRegion (int x, int y, int w, int h)
 
void StackThreshold (bool bit16)
 This function sets the minimum and maximum values of the image to the minimum and maximum values of the stack.
 
async Task UpdateBuffersPyramidal ()
 Updates the Buffers based on current pyramidal origin and resolution.
 
void UpdateBuffersWells ()
 
async Task< Bitmap[]> GetSlice (int x, int y, int w, int h, double resolution)
 
void Update ()
 
void Rename (string name)
 
void Dispose ()
 It disposes of all the buffers and channels in the image, removes the image from the Images list, and then forces the garbage collector to run.
 
override string ToString ()
 This function returns the filename of the object, and the location of the object in the 3D space.
 

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 Initialize ()
 
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.
 
static BioImage[] OpenSeries (string file, bool tab)
 It opens a tiff file, reads the number of pages, reads the number of channels, and then reads each page into a BioImage object.
 
static BioImage OpenFile (string file)
 This function opens a file and returns a BioImage object.
 
static BioImage OpenFile (string file, bool tab)
 
static BioImage OpenFile (string file, int series, bool tab, bool addToImages)
 It opens a TIFF file and returns a BioImage object.
 
static BioImage OpenFile (string file, int series, bool tab, bool addToImages, bool tile, int tileX, int tileY, int tileSizeX, int tileSizeY)
 The OpenFile function opens a BioImage file, reads its metadata, and loads the image data into a BioImage object.
 
static bool isTiffSeries (string file)
 
static bool isOME (string file)
 If the file is a TIFF, check the ImageDescription tag for the string "OME-XML". If it's there, return true. If it's not a TIFF, return true. If it's a PNG, JPG, JPEG, or BMP, return false.
 
static bool isOMESeries (string file)
 
static void SaveOME (string file, string ID)
 
static void SaveOME (BioImage image, string file)
 
static void SaveOMESeries (BioImage[] files, string f, bool planes)
 This function takes a list of image files and saves them as a single OME-TIFF file.
 
static int GetBands (PixelFormat format)
 The function "GetBands" returns the number of color bands for a given pixel format in the AForge library.
 
static void SaveOMEPyramidal (BioImage[] bms, string file, Enums.ForeignTiffCompression compression, int compressionLevel)
 The function SaveOMEPyramidal saves a collection of BioImages as a pyramidal OME-TIFF file.
 
static BioImage OpenOME (string file, bool tab)
 The function "OpenOME" opens a bioimage file in the OME format and returns the first image in the series.
 
static BioImage OpenOME (string file, int serie)
 
static BioImage FromNumpy (string file)
 Converts a numpy array to BioImage.
 
static BioImage FilesToStack (string[] files, int sizeZ, int sizeC, int sizeT)
 It takes a list of files, and creates a new BioImage object with the first file in the list. Then it loops through the rest of the files, adding the buffers from each file to the new BioImage object. Finally, it updates the coordinates of the new BioImage object, and adds it to the Images list.
 
static BioImage FolderToStack (string path, bool tab)
 It takes a folder of images and creates a stack from them.
 
static void OpenVips (BioImage b)
 The function "OpenVips" takes a BioImage object and an integer representing the number of pages, and adds each page of the image file to the BioImage's vipPages list using the NetVips library.
 
static Bitmap ExtractRegionFromTiledTiff (BioImage b, int x, int y, int width, int height, int level)
 The function ExtractRegionFromTiledTiff takes a BioImage object, coordinates, width, height, and resolution as input, and returns a Bitmap object representing the extracted region from the tiled TIFF image.
 
static BioImage OpenOME (string file, int serie, bool tab, bool addToImages, bool tile, int tilex, int tiley, int tileSizeX, int tileSizeY, bool useOpenSlide=true)
 The function "OpenOME" opens a bioimage file, with options to specify the series, whether to display it in a tab, whether to add it to existing images, whether to tile the image, and the tile size.
 
static Bitmap GetTile (BioImage b, int index, int level, int tilex, int tiley, int tileSizeX, int tileSizeY)
 It reads a tile from a file, and returns a bitmap.
 
static int GetBitsPerPixel (int bt)
 
static int GetBitMaxValue (int bt)
 It returns the maximum value of a bit.
 
static PointD[] ToImageSpace (List< PointD > p, double stageSizeX, double stageSizeY, double physicalSizeX, double physicalSizeY)
 The function takes a list of points in stage space and converts them to image space using the provided stage and physical size parameters.
 
static PixelFormat GetPixelFormat (int rgbChannelCount, int bitsPerPixel)
 If the bits per pixel is 8, then the pixel format is either 8bppIndexed, 24bppRgb, or 32bppArgb. If the bits per pixel is 16, then the pixel format is either 16bppGrayScale or 48bppRgb.
 
static PixelFormat GetPixelFormat (int rgbChannelCount, BioFormats::ome.xml.model.enums.PixelType px)
 The function returns the appropriate PixelFormat based on the number of RGB channels and the pixel type.
 
static BioImage[] OpenOMESeries (string file, bool tab, bool addToImages)
 It opens a file, checks if it's tiled, if it is, it opens it as a tiled image, if not, it opens it as a normal image.
 
static async Task OpenAsync (string file, bool OME, bool newtab, bool images, int series)
 It opens a file in a new thread.
 
static async Task OpenAsync (string[] files, bool OME, bool tab, bool images)
 It opens a file asynchronously.
 
static void Open (string file)
 It opens a file.
 
static void Open (string[] files)
 It opens a file.
 
static BioImage ImagesToStack (string[] files, bool tab)
 It takes a list of files, opens them, and then combines them into a single BioImage object.
 
static void Update (BioImage b)
 The function takes a BioImage object, opens the file, and returns a updated BioImage object.
 
static async Task SaveAsync (string file, string id, int serie, bool ome)
 The SaveAsync function saves data to a file asynchronously.
 
static async Task SaveSeriesAsync (BioImage[] imgs, string file, bool ome)
 The function SaveSeriesAsync saves a series of BioImage objects to a file asynchronously.
 
static async Task SavePyramidalAsync (BioImage[] imgs, string file, Enums.ForeignTiffCompression com, int compLevel)
 The function SavePyramidalAsync saves an array of BioImage objects as a pyramidal TIFF file asynchronously.
 
static bool VipsSupport (string file)
 The function checks if a given file is supported by the Vips library and returns true if it is, false otherwise.
 
static string OpenXML (string file)
 
static List< ROIOpenOMEROIs (string file, int series)
 It reads the OME-XML file and converts the ROIs to a list of ROI objects.
 
static string ROIsToString (List< ROI > Annotations)
 It takes a list of ROI objects and returns a string of all the ROI objects in the list.
 
static string ROIToString (ROI an)
 This function takes an ROI object and returns a string that contains all the information about the ROI.
 
static ROI StringToROI (string sts)
 It takes a string and returns an ROI object.
 
static void ExportROIsCSV (string filename, List< ROI > Annotations)
 This function takes a list of ROIs and writes them to a CSV file.
 
static List< ROIImportROIsCSV (string filename)
 It reads the CSV file and converts each line into a ROI object.
 
static void ExportROIFolder (string path, string filename)
 ExportROIFolder(path, filename)
 
static void AutoThreshold (BioImage b, bool updateImageStats)
 It takes a BioImage object, and calculates the mean histogram for each channel, and for the entire image.
 
static void AutoThreshold ()
 It takes the current image, and finds the best threshold value for it.
 
static void AutoThresholdThread (BioImage b)
 It creates a new thread that calls the AutoThreshold function.
 
static int FindFocus (BioImage im, int Channel, int Time)
 The function finds the focus of a given BioImage at a specific channel and time by calculating the focus quality of each Z-plane and returning the coordinate with the highest focus quality.
 
static long CalculateFocusQuality (Bitmap b)
 The function calculates the focus quality of a given bitmap image.
 
static int GetSeriesCount (string file)
 
static BioImage operator/ (BioImage a, float b)
 This function divides each pixel in the image by a constant value.
 
static BioImage operator* (BioImage a, float b)
 
static BioImage operator+ (BioImage a, float b)
 This function adds a constant value to each pixel in the image.
 
static BioImage operator- (BioImage a, float b)
 Subtracts a scalar value from each pixel in the image.
 
static BioImage operator/ (BioImage a, ColorS b)
 This function divides each pixel in the image by the value of the color.
 
static BioImage operator* (BioImage a, ColorS b)
 This function takes a BioImage object and a ColorS object and returns a BioImage object.
 
static BioImage operator+ (BioImage a, ColorS b)
 It takes a BioImage object and a ColorS object and adds the ColorS object to each buffer in the BioImage object.
 
static BioImage operator- (BioImage a, ColorS b)
 The function subtracts a color from each pixel in the image.
 

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 bitsPerPixel
 
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
 
ImageReader imRead
 
Tiff tifRead
 
OpenSlideImage openSlideImage
 

Static Public Attributes

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()
 
const char NewLine = '\n'
 
const string columns = "ROIID,ROINAME,TYPE,ID,SHAPEINDEX,TEXT,S,C,Z,T,X,Y,W,H,POINTS,STROKECOLOR,STROKECOLORW,FILLCOLOR,FONTSIZE\n"
 

Properties

ZCT Coordinate [get, set]
 
ImageType Type [get, set]
 
int Level [get, set]
 
string Filename [get, set]
 
int RGBChannelCount [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, set]
 
double StageSizeY [get, set]
 
double StageSizeZ [get, set]
 
AForge.Size PyramidalSize [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]
 

Detailed Description

Definition at line 2910 of file Bio.cs.

Member Enumeration Documentation

◆ BackEnd

enum BioLib.BioImage.BackEnd

Definition at line 8225 of file Bio.cs.

8226 {
8227 OpenSlide,
8228 Bioformats,
8229 LibVips,
8230 }

◆ ImageType

enum BioLib.BioImage.ImageType

Definition at line 2995 of file Bio.cs.

2996 {
2997 stack,
2998 pyramidal,
2999 well,
3000 }

◆ Order

enum BioLib.BioImage.Order

Definition at line 3642 of file Bio.cs.

3643 {
3644 ZCT,
3645 CZT,
3646 TCZ
3647 }

Constructor & Destructor Documentation

◆ BioImage()

BioLib.BioImage.BioImage ( string file)

Definition at line 4596 of file Bio.cs.

4597 {
4598 id = file;
4599 this.file = file;
4600 filename = Images.GetImageName(id);
4601 Coordinate = new ZCT();
4602 rgbChannels[0] = 0;
4603 rgbChannels[1] = 0;
4604 rgbChannels[2] = 0;
4605 }

Member Function Documentation

◆ AutoThreshold() [1/2]

static void BioLib.BioImage.AutoThreshold ( )
static

It takes the current image, and finds the best threshold value for it.

Definition at line 9710 of file Bio.cs.

9711 {
9712 AutoThreshold(bstats, update);
9713 }
static void AutoThreshold()
It takes the current image, and finds the best threshold value for it.
Definition Bio.cs:9710

◆ AutoThreshold() [2/2]

static void BioLib.BioImage.AutoThreshold ( BioImage b,
bool updateImageStats )
static

It takes a BioImage object, and calculates the mean histogram for each channel, and for the entire image.

The BioImage object is a class that contains a list of buffers, each of which contains a byte array of pixel data.

The function also calculates the mean histogram for each buffer, and stores it in the buffer's stats property.

The function also calculates the mean histogram for each channel, and stores it in the channel's stats property.

The function also calculates the mean histogram for the entire image, and stores it in the image's statistics property.

The mean histogram is calculated by adding up the histograms of each buffer, and then dividing by the number of buffers.

The histogram is calculated by looping through the byte array of pixel data, and incrementing the value of the histogram at the index of the pixel value.

The histogram

Parameters
BioImageThis is the image object that contains the image data.
updateImageStatsif true, the image stats will be updated.

Definition at line 9636 of file Bio.cs.

9637 {
9638 bstats = b;
9639 Statistics statistics = null;
9640 if (b.bitsPerPixel > 8)
9641 statistics = new Statistics(true);
9642 else
9643 statistics = new Statistics(false);
9644 for (int i = 0; i < b.Buffers.Count; i++)
9645 {
9646 if (b.Buffers[i].Stats == null || updateImageStats)
9647 b.Buffers[i].Stats = Statistics.FromBytes(b.Buffers[i]);
9648 if (b.Buffers[i].RGBChannelsCount == 1)
9649 statistics.AddStatistics(b.Buffers[i].Stats[0]);
9650 else
9651 {
9652 for (int r = 0; r < b.Buffers[i].RGBChannelsCount; r++)
9653 {
9654 statistics.AddStatistics(b.Buffers[i].Stats[r]);
9655 }
9656 }
9657 }
9658 for (int c = 0; c < b.Channels.Count; c++)
9659 {
9660 Statistics[] sts = new Statistics[b.Buffers[0].RGBChannelsCount];
9661 for (int i = 0; i < b.Buffers[0].RGBChannelsCount; i++)
9662 {
9663 if (b.bitsPerPixel > 8)
9664 {
9665 sts[i] = new Statistics(true);
9666 }
9667 else
9668 sts[i] = new Statistics(false);
9669 }
9670 for (int z = 0; z < b.SizeZ; z++)
9671 {
9672 for (int t = 0; t < b.SizeT; t++)
9673 {
9674 int ind;
9675 if (b.Channels.Count > b.SizeC)
9676 {
9677 ind = b.GetFrameIndex(z, 0, t);
9678 }
9679 else
9680 ind = b.GetFrameIndex(z, c, t);
9681 if (b.Buffers[ind].RGBChannelsCount == 1)
9682 sts[0].AddStatistics(b.Buffers[ind].Stats[0]);
9683 else
9684 {
9685 sts[0].AddStatistics(b.Buffers[ind].Stats[0]);
9686 sts[1].AddStatistics(b.Buffers[ind].Stats[1]);
9687 sts[2].AddStatistics(b.Buffers[ind].Stats[2]);
9688 if (b.Buffers[ind].RGBChannelsCount == 4)
9689 sts[3].AddStatistics(b.Buffers[ind].Stats[3]);
9690 }
9691 }
9692 }
9693 if (b.RGBChannelCount == 1)
9694 sts[0].MeanHistogram();
9695 else
9696 {
9697 sts[0].MeanHistogram();
9698 sts[1].MeanHistogram();
9699 sts[2].MeanHistogram();
9700 if (b.Buffers[0].RGBChannelsCount == 4)
9701 sts[3].MeanHistogram();
9702 }
9703 b.Channels[c].stats = sts;
9704 }
9705 statistics.MeanHistogram();
9706 b.statistics = statistics;
9707 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), true, b, updateImageStats);
9708 }
Definition Bio.cs:35

◆ AutoThresholdThread()

static void BioLib.BioImage.AutoThresholdThread ( BioImage b)
static

It creates a new thread that calls the AutoThreshold function.

Parameters
BioImageThis is a class that holds the image data and some other information.

Definition at line 9717 of file Bio.cs.

9718 {
9719 bstats = b;
9720 Thread th = new Thread(AutoThreshold);
9721 th.Start();
9722 }

◆ 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.

Definition at line 4172 of file Bio.cs.

4173 {
4174 Bake(new IntRange(rmin, rmax), new IntRange(gmin, gmax), new IntRange(bmin, bmax));
4175 }
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:4172

◆ 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

Definition at line 4182 of file Bio.cs.

4183 {
4184 BioImage bm = new BioImage(Images.GetImageName(ID));
4185 bm = CopyInfo(this, true, true);
4186 for (int i = 0; i < Buffers.Count; i++)
4187 {
4188 ZCT co = Buffers[i].Coordinate;
4189 UnmanagedImage b = GetFiltered(i, rf, gf, bf);
4190 Bitmap inf = new Bitmap(bm.ID, b, co, i);
4191 bm.SetFrameIndex(co.Z, co.C, co.T, i);
4192 bm.Buffers.Add(inf);
4193 }
4194 foreach (Channel item in bm.Channels)
4195 {
4196 for (int i = 0; i < item.range.Length; i++)
4197 {
4198 item.range[i].Min = 0;
4199 if (bm.bitsPerPixel > 8)
4200 item.range[i].Max = ushort.MaxValue;
4201 else
4202 item.range[i].Max = 255;
4203 }
4204 }
4205 AutoThreshold(bm, true);
4206 Images.AddImage(bm);
4207 }
Bitmap GetFiltered(ZCT coord, IntRange r, IntRange g, IntRange b)
Definition Bio.cs:5162
static BioImage CopyInfo(BioImage b, bool copyAnnotations, bool copyChannels)
Definition Bio.cs:3182

◆ CalculateFocusQuality()

static long BioLib.BioImage.CalculateFocusQuality ( Bitmap b)
static

The function calculates the focus quality of a given bitmap image.

Parameters
BitmapA class representing a bitmap image, which contains information about the image's size, pixel data, and color channels.
Returns
The method is returning a long value which represents the calculated focus quality of the input Bitmap image.

Definition at line 9761 of file Bio.cs.

9762 {
9763 if (b.RGBChannelsCount == 1)
9764 {
9765 long sum = 0;
9766 long sumOfSquaresR = 0;
9767 for (int y = 0; y < b.SizeY; y++)
9768 for (int x = 0; x < b.SizeX; x++)
9769 {
9770 ColorS pixel = b.GetPixel(x, y);
9771 sum += pixel.R;
9772 sumOfSquaresR += pixel.R * pixel.R;
9773 }
9774 return sumOfSquaresR * b.SizeX * b.SizeY - sum * sum;
9775 }
9776 else
9777 {
9778 long sum = 0;
9779 long sumOfSquares = 0;
9780 for (int y = 0; y < b.SizeY; y++)
9781 for (int x = 0; x < b.SizeX; x++)
9782 {
9783 ColorS pixel = b.GetPixel(x, y);
9784 int p = (pixel.R + pixel.G + pixel.B) / 3;
9785 sum += p;
9786 sumOfSquares += p * p;
9787 }
9788 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), true, b);
9789 return sumOfSquares * b.SizeX * b.SizeY - sum * sum;
9790 }
9791 }

◆ 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.

Definition at line 3171 of file Bio.cs.

3172 {
3173 return BioImage.Copy(this, true);
3174 }

◆ 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.

Definition at line 3155 of file Bio.cs.

3156 {
3157 return Copy(b, true);
3158 }
BioImage Copy()
Definition Bio.cs:3171

◆ 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.

Definition at line 3093 of file Bio.cs.

3094 {
3095 BioImage bi = new BioImage(b.ID);
3096 if (rois)
3097 foreach (ROI an in b.Annotations)
3098 {
3099 bi.Annotations.Add(an);
3100 }
3101 foreach (Bitmap bf in b.Buffers)
3102 {
3103 bi.Buffers.Add(bf.Copy());
3104 }
3105 foreach (Channel c in b.Channels)
3106 {
3107 bi.Channels.Add(c);
3108 }
3109 bi.Volume = b.Volume;
3110 bi.Coords = b.Coords;
3111 bi.sizeZ = b.sizeZ;
3112 bi.sizeC = b.sizeC;
3113 bi.sizeT = b.sizeT;
3114 bi.series = b.series;
3115 bi.seriesCount = b.seriesCount;
3116 bi.frameInterval = b.frameInterval;
3117 bi.littleEndian = b.littleEndian;
3118 bi.isGroup = b.isGroup;
3119 bi.imageInfo = b.imageInfo;
3120 bi.bitsPerPixel = b.bitsPerPixel;
3121 bi.file = b.file;
3122 bi.filename = b.filename;
3123 foreach (var item in b.Resolutions)
3124 {
3125 bi.Resolutions.Add(item);
3126 }
3127 bi.statistics = b.statistics;
3128 bi.MacroResolution = b.MacroResolution;
3129 bi.LabelResolution = b.LabelResolution;
3130 bi.Resolution = b.Resolution;
3131 bi.imagesPerSeries = b.imagesPerSeries;
3132 bi.imRead = b.imRead;
3133 bi.Type = b.Type;
3134 bi.tifRead = b.tifRead;
3135 if (b.OpenSlideBase != null)
3136 {
3137 bi.openslideBase = b.openslideBase;
3138 bi.openSlideImage = b.openSlideImage;
3139 }
3140 else
3141 {
3142 bi.slideBase = b.slideBase;
3143 }
3144 bi.PyramidalOrigin = b.PyramidalOrigin;
3145 bi.PyramidalSize = b.PyramidalSize;
3146 bi.Plate = b.Plate;
3147 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, b, rois);
3148 return bi;
3149 }

◆ 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.

Definition at line 3164 of file Bio.cs.

3165 {
3166 return BioImage.Copy(this, rois);
3167 }

◆ 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.

Definition at line 3182 of file Bio.cs.

3183 {
3184 BioImage bi = new BioImage(b.ID);
3185 if (copyAnnotations)
3186 foreach (ROI an in b.Annotations)
3187 {
3188 bi.Annotations.Add(an);
3189 }
3190 if (copyChannels)
3191 foreach (Channel c in b.Channels)
3192 {
3193 bi.Channels.Add(c.Copy());
3194 }
3195 foreach (var item in b.Resolutions)
3196 {
3197 bi.Resolutions.Add(item);
3198 }
3199 bi.Coords = b.Coords;
3200 bi.Volume = b.Volume;
3201 bi.sizeZ = b.sizeZ;
3202 bi.sizeC = b.sizeC;
3203 bi.sizeT = b.sizeT;
3204 bi.series = b.series;
3205 bi.seriesCount = b.seriesCount;
3206 bi.frameInterval = b.frameInterval;
3207 bi.littleEndian = b.littleEndian;
3208 bi.isGroup = b.isGroup;
3209 bi.imageInfo = b.imageInfo;
3210 bi.bitsPerPixel = b.bitsPerPixel;
3211 bi.Coordinate = b.Coordinate;
3212 bi.file = b.file;
3213 bi.Filename = b.Filename;
3214 bi.ID = Images.GetImageName(b.file);
3215 bi.statistics = b.statistics;
3216 bi.MacroResolution = b.MacroResolution;
3217 bi.LabelResolution = b.LabelResolution;
3218 bi.Resolution = b.Resolution;
3219 bi.imagesPerSeries = b.imagesPerSeries;
3220 bi.imRead = b.imRead;
3221 bi.tifRead = b.tifRead;
3222 bi.Type = b.Type;
3223 bi.PyramidalOrigin = b.PyramidalOrigin;
3224 bi.PyramidalSize = b.PyramidalSize;
3225 if (b.OpenSlideBase != null)
3226 {
3227 bi.openslideBase = b.openslideBase;
3228 bi.openSlideImage = b.openSlideImage;
3229 }
3230 else
3231 {
3232 bi.slideBase = b.slideBase;
3233 }
3234 bi.Plate = b.Plate;
3235 return bi;
3236 }

◆ Dispose()

void BioLib.BioImage.Dispose ( )

It disposes of all the buffers and channels in the image, removes the image from the Images list, and then forces the garbage collector to run.

Definition at line 9794 of file Bio.cs.

9795 {
9796 for (int i = 0; i < Buffers.Count; i++)
9797 {
9798 Buffers[i].Dispose();
9799 }
9800 for (int i = 0; i < Channels.Count; i++)
9801 {
9802 Channels[i].Dispose();
9803 }
9804 for (int i = 0; i < Annotations.Count; i++)
9805 {
9806 Annotations[i].Dispose();
9807 }
9808 }

◆ ExportROIFolder()

static void BioLib.BioImage.ExportROIFolder ( string path,
string filename )
static

ExportROIFolder(path, filename)

This function takes a folder path and a filename as input and exports all the ROIs in the folder as CSV files

Parameters
paththe path to the folder containing the OMERO ROI files
filenamethe name of the file you want to export

Definition at line 9595 of file Bio.cs.

9596 {
9597 string[] fs = Directory.GetFiles(path);
9598 int i = 0;
9599 foreach (string f in fs)
9600 {
9601 List<ROI> annotations = OpenOMEROIs(f, 0);
9602 string ff = Path.GetFileNameWithoutExtension(f);
9603 ExportROIsCSV(path + "//" + ff + "-" + i.ToString() + ".csv", annotations);
9604 i++;
9605 }
9606 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, path, filename);
9607 }
static void ExportROIsCSV(string filename, List< ROI > Annotations)
This function takes a list of ROIs and writes them to a CSV file.
Definition Bio.cs:9562
static List< ROI > OpenOMEROIs(string file, int series)
It reads the OME-XML file and converts the ROIs to a list of ROI objects.
Definition Bio.cs:8979

◆ ExportROIsCSV()

static void BioLib.BioImage.ExportROIsCSV ( string filename,
List< ROI > Annotations )
static

This function takes a list of ROIs and writes them to a CSV file.

Parameters
filenamethe name of the file to be saved
AnnotationsList of ROI objects

Definition at line 9562 of file Bio.cs.

9563 {
9564 string con = columns;
9565 con += ROIsToString(Annotations);
9566 File.WriteAllText(filename, con);
9567 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, filename, Annotations);
9568 }
static string ROIsToString(List< ROI > Annotations)
It takes a list of ROI objects and returns a string of all the ROI objects in the list.
Definition Bio.cs:9363

◆ ExtractRegionFromTiledTiff()

static Bitmap BioLib.BioImage.ExtractRegionFromTiledTiff ( BioImage b,
int x,
int y,
int width,
int height,
int level )
static

The function ExtractRegionFromTiledTiff takes a BioImage object, coordinates, width, height, and resolution as input, and returns a Bitmap object representing the extracted region from the tiled TIFF image.

Parameters
BioImageThe BioImage object represents an image file that contains multiple pages or resolutions. It contains information about the image file, such as the file path, the number of pages, and the format of each page.
xThe x-coordinate of the top-left corner of the region to extract from the tiled TIFF image.
yThe parameter "y" represents the starting y-coordinate of the region to be extracted from the tiled TIFF image.
widthThe width parameter represents the width of the region to be extracted from the tiled TIFF image.
heightThe height parameter represents the height of the region to be extracted from the tiled TIFF image.
resThe parameter "res" represents the resolution level of the tiled TIFF image. It is used to specify the level of detail or zoom level at which the image is being extracted.
Returns
The method is returning a Bitmap object.

Definition at line 7348 of file Bio.cs.

7349 {
7350 try
7351 {
7352 // Validate inputs
7353 if (b == null) throw new ArgumentNullException(nameof(b));
7354 if (b.vipPages == null || b.vipPages.Count <= level) throw new ArgumentException("Invalid image level.");
7355
7356 // Extract the region from the specified level
7357 NetVips.Image subImage = b.vipPages[level].ExtractArea(x, y, width, height);
7358
7359 // Convert the NetVips.Image to Bitmap
7360 Bitmap bitmap = ConvertVipsImageToBitmap(subImage, b.bitsPerPixel);
7361
7362 // Clean up
7363 subImage.Dispose();
7364
7365 return bitmap;
7366 }
7367 catch (Exception ex)
7368 {
7369 Console.WriteLine($"Error: {ex.Message}\n{ex.StackTrace}");
7370 return null;
7371 }
7372 }

◆ FilesToStack()

static BioImage BioLib.BioImage.FilesToStack ( string[] files,
int sizeZ,
int sizeC,
int sizeT )
static

It takes a list of files, and creates a new BioImage object with the first file in the list. Then it loops through the rest of the files, adding the buffers from each file to the new BioImage object. Finally, it updates the coordinates of the new BioImage object, and adds it to the Images list.

Parameters
filesan array of file paths
sizeZnumber of slices in the stack
sizeCnumber of channels
sizeTnumber of time points
Returns
A BioImage object.

Definition at line 7240 of file Bio.cs.

7241 {
7242 BioImage b = new BioImage(files[0]);
7243 for (int i = 0; i < files.Length; i++)
7244 {
7245 BioImage bb = OpenFile(files[i], false);
7246 b.Buffers.AddRange(bb.Buffers);
7247 }
7248 b.UpdateCoords(sizeZ, sizeC, sizeT);
7249 Images.AddImage(b);
7250 return b;
7251 }
static BioImage OpenFile(string file)
This function opens a file and returns a BioImage object.
Definition Bio.cs:5885

◆ FindFocus()

static int BioLib.BioImage.FindFocus ( BioImage im,
int Channel,
int Time )
static

The function finds the focus of a given BioImage at a specific channel and time by calculating the focus quality of each Z-plane and returning the coordinate with the highest focus quality.

Parameters
BioImageA BioImage object that contains the image data.
ChannelThe channel of the BioImage to analyze. A BioImage can have multiple channels, each representing a different fluorescent label or imaging modality.
TimeThe time point at which the focus is being calculated.
Returns
an integer value which represents the coordinate of the image with the highest focus quality in a given channel and time.

Definition at line 9734 of file Bio.cs.

9735 {
9736 long mf = 0;
9737 int fr = 0;
9738 List<double> dt = new List<double>();
9739 ZCT c = new ZCT(0, 0, 0);
9740 for (int i = 0; i < im.SizeZ; i++)
9741 {
9742 long f = CalculateFocusQuality(im.Buffers[im.GetFrameIndex(i, Channel, Time)]);
9743 dt.Add(f);
9744 if (f > mf)
9745 {
9746 mf = f;
9747 fr = im.GetFrameIndex(i, Channel, Time);
9748 }
9749 }
9750
9751 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, im, Channel, Time);
9752 return fr;
9753 }
static long CalculateFocusQuality(Bitmap b)
The function calculates the focus quality of a given bitmap image.
Definition Bio.cs:9761

◆ FolderToStack()

static BioImage BioLib.BioImage.FolderToStack ( string path,
bool tab )
static

It takes a folder of images and creates a stack from them.

Parameters
paththe path to the folder containing the images
Returns
A BioImage object.

Definition at line 7257 of file Bio.cs.

7258 {
7259 string[] files = Directory.GetFiles(path);
7260 BioImage b = new BioImage(files[0]);
7261 int z = 0;
7262 int c = 0;
7263 int t = 0;
7264 BioImage bb = null;
7265 for (int i = 0; i < files.Length; i++)
7266 {
7267 string[] st = files[i].Split('_');
7268 if (st.Length > 3)
7269 {
7270 z = int.Parse(st[1].Replace("Z", ""));
7271 c = int.Parse(st[2].Replace("C", ""));
7272 t = int.Parse(st[3].Replace("T", ""));
7273 }
7274 bb = OpenFile(files[i], tab);
7275 b.Buffers.AddRange(bb.Buffers);
7276 }
7277 if (z == 0)
7278 {
7279 /*TO DO
7280 ImagesToStack im = new ImagesToStack();
7281 if (im.ShowDialog() != DialogResult.OK)
7282 return null;
7283 b.UpdateCoords(im.SizeZ, im.SizeC, im.SizeT);
7284 */
7285 }
7286 else
7287 b.UpdateCoords(z + 1, c + 1, t + 1);
7288 Images.AddImage(b);
7289 return b;
7290 }

◆ FromNumpy()

static BioImage BioLib.BioImage.FromNumpy ( string file)
static

Converts a numpy array to BioImage.

Parameters
file
Returns

Definition at line 7016 of file Bio.cs.

7017 {
7018 BioImage bm = new BioImage(file);
7019 var (shape, dataType, data) = NumPy.ReadNpyFile(file);
7020
7021 // Handle different shapes and cast the data into appropriate multi-dimensional arrays
7022 if (shape.Length == 5)
7023 {
7024 if (dataType == NumPy.NpyDataType.Float32)
7025 {
7026 float[,,,,] fs = NumPy.ConvertToMultidimensional<float, float[,,,,]>(data, shape);
7027 for (int z = 0; z < shape[2]; z++)
7028 {
7029 for (int c = 0; c < shape[1]; c++)
7030 {
7031 for (int t = 0; t < shape[0]; t++)
7032 {
7033 Bitmap b = new Bitmap(shape[3], shape[4], PixelFormat.Float);
7034 for (int y = 0; y < shape[4]; y++)
7035 {
7036 for (int x = 0; x < shape[3]; x++)
7037 {
7038 b.SetValue(x, y, fs[t, c, z, x, y]);
7039 }
7040 }
7041 bm.Buffers.Add(b);
7042 }
7043 }
7044 }
7045 }
7046 else if (dataType == NumPy.NpyDataType.UInt8)
7047 {
7048 uint[,,,,] fs = NumPy.ConvertToMultidimensional<uint, uint[,,,,]>(data, shape);
7049 for (int z = 0; z < shape[2]; z++)
7050 {
7051 for (int c = 0; c < shape[1]; c++)
7052 {
7053 for (int t = 0; t < shape[0]; t++)
7054 {
7055 Bitmap b = new Bitmap(shape[3], shape[4], PixelFormat.Format8bppIndexed);
7056 for (int y = 0; y < shape[4]; y++)
7057 {
7058 for (int x = 0; x < shape[3]; x++)
7059 {
7060 b.SetValue(x, y, fs[t, c, z, x, y]);
7061 }
7062 }
7063 bm.Buffers.Add(b);
7064 }
7065 }
7066 }
7067 }
7068 bm.sizeZ = shape[2];
7069 bm.sizeC = shape[1];
7070 bm.sizeT = shape[0];
7071 }
7072 else if (shape.Length == 4)
7073 {
7074 if (dataType == NumPy.NpyDataType.Float32)
7075 {
7076 float[,,,] fs = NumPy.ConvertToMultidimensional<float, float[,,,]>(data, shape);
7077 for (int z = 0; z < shape[1]; z++)
7078 {
7079 for (int c = 0; c < shape[0]; c++)
7080 {
7081 Bitmap b = new Bitmap(shape[2], shape[3], PixelFormat.Float);
7082 for (int y = 0; y < shape[3]; y++)
7083 {
7084 for (int x = 0; x < shape[2]; x++)
7085 {
7086 b.SetValue(x, y, fs[c, z, x, y]);
7087 }
7088 }
7089 bm.Buffers.Add(b);
7090 }
7091 }
7092 }
7093 else if (dataType == NumPy.NpyDataType.UInt8)
7094 {
7095 uint[,,,] fs = NumPy.ConvertToMultidimensional<uint, uint[,,,]>(data, shape);
7096 for (int z = 0; z < shape[1]; z++)
7097 {
7098 for (int c = 0; c < shape[0]; c++)
7099 {
7100 Bitmap b = new Bitmap(shape[2], shape[3], PixelFormat.Format8bppIndexed);
7101 for (int y = 0; y < shape[3]; y++)
7102 {
7103 for (int x = 0; x < shape[2]; x++)
7104 {
7105 b.SetValue(x, y, fs[c, z, x, y]);
7106 }
7107 }
7108 bm.Buffers.Add(b);
7109 }
7110 }
7111 }
7112 bm.sizeZ = shape[1];
7113 bm.sizeC = shape[0];
7114 }
7115 else if (shape.Length == 3)
7116 {
7117 if (dataType == NumPy.NpyDataType.Float32)
7118 {
7119 float[,,] fs = NumPy.ConvertToMultidimensional<float, float[,,]>(data, shape);
7120 for (int z = 0; z < shape[0]; z++)
7121 {
7122 Bitmap b = new Bitmap(shape[1], shape[2], PixelFormat.Float);
7123 for (int y = 0; y < shape[1]; y++)
7124 {
7125 for (int x = 0; x < shape[2]; x++)
7126 {
7127 b.SetValue(x, y, fs[z, x, y]);
7128 }
7129 }
7130 bm.Buffers.Add(b);
7131 }
7132 }
7133 else if (dataType == NumPy.NpyDataType.UInt8)
7134 {
7135 uint[,,] fs = NumPy.ConvertToMultidimensional<uint, uint[,,]>(data, shape);
7136 for (int z = 0; z < shape[0]; z++)
7137 {
7138 Bitmap b = new Bitmap(shape[1], shape[2], PixelFormat.Format8bppIndexed);
7139 for (int y = 0; y < shape[1]; y++)
7140 {
7141 for (int x = 0; x < shape[2]; x++)
7142 {
7143 b.SetValue(x, y, fs[z, x, y]);
7144 }
7145 }
7146 bm.Buffers.Add(b);
7147 }
7148 }
7149 bm.sizeZ = shape[0];
7150 bm.sizeC = 1;
7151 }
7152 else if (shape.Length == 2)
7153 {
7154 if (dataType == NumPy.NpyDataType.Float32)
7155 {
7156 float[,] fs = NumPy.ConvertToMultidimensional<float, float[,]>(data, shape);
7157 Bitmap b = new Bitmap(shape[0], shape[1], PixelFormat.Float);
7158 for (int y = 0; y < shape[1]; y++)
7159 {
7160 for (int x = 0; x < shape[0]; x++)
7161 {
7162 b.SetValue(x, y, fs[x, y]);
7163 }
7164 }
7165 bm.Buffers.Add(b);
7166 }
7167 else if (dataType == NumPy.NpyDataType.UInt8)
7168 {
7169 uint[,] fs = NumPy.ConvertToMultidimensional<uint, uint[,]>(data, shape);
7170 Bitmap b = new Bitmap(shape[0], shape[1], PixelFormat.Format8bppIndexed);
7171 for (int y = 0; y < shape[1]; y++)
7172 {
7173 for (int x = 0; x < shape[0]; x++)
7174 {
7175 b.SetValue(x, y, fs[x, y]);
7176 }
7177 }
7178 bm.Buffers.Add(b);
7179 }
7180 bm.sizeC = 1;
7181 bm.sizeZ = 1;
7182 }
7183 else
7184 {
7185 throw new InvalidOperationException("Unsupported array shape.");
7186 }
7187
7188 for (int i = 0; i < bm.SizeC; i++)
7189 {
7190 if (bm.Buffers[0].PixelFormat == PixelFormat.Float || bm.Buffers[0].PixelFormat == PixelFormat.UInt || bm.Buffers[0].PixelFormat == PixelFormat.Int)
7191 bm.Channels.Add(new Channel(i, 32, 1));
7192 else
7193 if (bm.Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
7194 bm.Channels.Add(new Channel(i, 8, 1));
7195 }
7196 bm.sizeT = 1;
7197 bm.Coords = new int[bm.SizeZ, bm.SizeC, bm.SizeT];
7198 bm.UpdateCoords();
7199 bm.bitsPerPixel = 8;
7200 if (dataType == NumPy.NpyDataType.Float32)
7201 bm.Resolutions.Add(new Resolution(bm.SizeX, bm.SizeY, PixelFormat.Float, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 0, 0, 0));
7202 else
7203 if (dataType == NumPy.NpyDataType.UInt32)
7204 bm.Resolutions.Add(new Resolution(bm.SizeX, bm.SizeY, PixelFormat.UInt, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 0, 0, 0));
7205 else
7206 if (dataType == NumPy.NpyDataType.Int32)
7207 bm.Resolutions.Add(new Resolution(bm.SizeX, bm.SizeY, PixelFormat.Int, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 0, 0, 0));
7208 else
7209 if (dataType == NumPy.NpyDataType.UInt8)
7210 bm.Resolutions.Add(new Resolution(bm.SizeX, bm.SizeY, PixelFormat.Format8bppIndexed, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 0, 0, 0));
7211 foreach (var item in bm.Buffers)
7212 {
7213 item.Stats = Statistics.FromBytes(item);
7214 }
7215 bm.Type = ImageType.stack;
7216 bm.Volume = new VolumeD(new Point3D(bm.StageSizeX, bm.StageSizeY, bm.StageSizeZ), new Point3D(bm.PhysicalSizeX * bm.SizeX, bm.PhysicalSizeY * bm.SizeY, bm.PhysicalSizeZ * bm.SizeZ));
7217 AutoThreshold(bm, false);
7218 if (bm.bitsPerPixel > 8)
7219 bm.StackThreshold(true);
7220 else
7221 bm.StackThreshold(false);
7222 bm.StackOrder = Order.ZCT;
7223 bm.ID = Path.GetFileName(file);
7224 bm.Filename = bm.ID;
7225 bm.file = file;
7226 Images.AddImage(bm);
7227 return bm;
7228 }

◆ 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.

Definition at line 5507 of file Bio.cs.

5508 {
5509 List<ROI> annotations = new List<ROI>();
5510 foreach (ROI an in Annotations)
5511 {
5512 if (an.coord.Z == Z && an.coord.Z == Z && an.coord.C == C && an.coord.T == T)
5513 annotations.Add(an);
5514 }
5515 return annotations;
5516 }

◆ 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.

Definition at line 5487 of file Bio.cs.

5488 {
5489 List<ROI> annotations = new List<ROI>();
5490 foreach (ROI an in Annotations)
5491 {
5492 if (an == null)
5493 continue;
5494 if (an.coord == coord)
5495 annotations.Add(an);
5496 }
5497 return annotations;
5498 }

◆ GetBands()

static int BioLib.BioImage.GetBands ( PixelFormat format)
static

The function "GetBands" returns the number of color bands for a given pixel format in the AForge library.

Parameters
PixelFormatThe PixelFormat parameter is an enumeration that represents the format of a pixel in an image. It specifies the number of bits per pixel and the color space used by the pixel. The PixelFormat enumeration is defined in the AForge.Imaging namespace.
Returns
The method is returning the number of color bands for a given pixel format.

Definition at line 6827 of file Bio.cs.

6828 {
6829 switch (format)
6830 {
6831 case AForge.PixelFormat.Format8bppIndexed: return 1;
6832 case AForge.PixelFormat.Format16bppGrayScale: return 1;
6833 case AForge.PixelFormat.Format24bppRgb: return 3;
6834 case AForge.PixelFormat.Format32bppArgb:
6835 case AForge.PixelFormat.Format32bppPArgb:
6836 case AForge.PixelFormat.Format32bppRgb:
6837 return 4;
6838 case AForge.PixelFormat.Format48bppRgb:
6839 return 3;
6840 default:
6841 throw new NotSupportedException($"Unsupported pixel format: {format}");
6842 }
6843 }

◆ 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.

Definition at line 4975 of file Bio.cs.

4976 {
4977 return Buffers[GetFrameIndex(z, c, t)];
4978 }

◆ 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.

Definition at line 5150 of file Bio.cs.

5151 {
5152 return (Bitmap)GetImageByCoord(coord.Z, coord.C, coord.T);
5153 }
Bitmap GetImageByCoord(int z, int c, int t)
Definition Bio.cs:4962

◆ 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.

Definition at line 5321 of file Bio.cs.

5322 {
5323 if (px == PixelFormat.Format32bppArgb)
5324 {
5325 //opening a 8 bit per pixel jpg image
5326 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
5327 //creating the bitmapdata and lock bits
5328 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
5329 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
5330 //iterating through all the pixels in y direction
5331 for (int y = 0; y < h; y++)
5332 {
5333 //getting the pixels of current row
5334 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
5335 int rowRGB = y * w * 4;
5336 //iterating through all the pixels in x direction
5337 for (int x = 0; x < w; x++)
5338 {
5339 int indexRGB = x * 4;
5340 int indexRGBA = x * 4;
5341 row[indexRGBA + 3] = bts[rowRGB + indexRGB + 3];//byte A
5342 row[indexRGBA + 2] = bts[rowRGB + indexRGB + 2];//byte R
5343 row[indexRGBA + 1] = bts[rowRGB + indexRGB + 1];//byte G
5344 row[indexRGBA] = bts[rowRGB + indexRGB];//byte B
5345 }
5346 }
5347 //unlocking bits and disposing image
5348 bmp.UnlockBits(bmd);
5349 return bmp;
5350 }
5351 else if (px == PixelFormat.Format24bppRgb)
5352 {
5353 //opening a 8 bit per pixel jpg image
5354 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
5355 //creating the bitmapdata and lock bits
5356 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
5357 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
5358 //iterating through all the pixels in y direction
5359 for (int y = 0; y < h; y++)
5360 {
5361 //getting the pixels of current row
5362 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
5363 int rowRGB = y * w * 3;
5364 //iterating through all the pixels in x direction
5365 for (int x = 0; x < w; x++)
5366 {
5367 int indexRGB = x * 3;
5368 int indexRGBA = x * 4;
5369 row[indexRGBA + 3] = byte.MaxValue;//byte A
5370 row[indexRGBA + 2] = bts[rowRGB + indexRGB + 2];//byte R
5371 row[indexRGBA + 1] = bts[rowRGB + indexRGB + 1];//byte G
5372 row[indexRGBA] = bts[rowRGB + indexRGB];//byte B
5373 }
5374 }
5375 //unlocking bits and disposing image
5376 bmp.UnlockBits(bmd);
5377 return bmp;
5378 }
5379 else
5380 if (px == PixelFormat.Format48bppRgb)
5381 {
5382 //opening a 8 bit per pixel jpg image
5383 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
5384 //creating the bitmapdata and lock bits
5385 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
5386 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
5387 unsafe
5388 {
5389 //iterating through all the pixels in y direction
5390 for (int y = 0; y < h; y++)
5391 {
5392 //getting the pixels of current row
5393 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
5394 int rowRGB = y * w * 6;
5395 //iterating through all the pixels in x direction
5396 for (int x = 0; x < w; x++)
5397 {
5398 int indexRGB = x * 6;
5399 int indexRGBA = x * 4;
5400 int b = (int)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB) / 255);
5401 int g = (int)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB + 2) / 255);
5402 int r = (int)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB + 4) / 255);
5403 row[indexRGBA + 3] = 255;//byte A
5404 row[indexRGBA + 2] = (byte)(b);//byte R
5405 row[indexRGBA + 1] = (byte)(g);//byte G
5406 row[indexRGBA] = (byte)(r);//byte B
5407 }
5408 }
5409 }
5410 bmp.UnlockBits(bmd);
5411 return bmp;
5412 }
5413 else
5414 if (px == PixelFormat.Format8bppIndexed)
5415 {
5416 //opening a 8 bit per pixel jpg image
5417 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
5418 //creating the bitmapdata and lock bits
5419 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
5420 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
5421 unsafe
5422 {
5423 //iterating through all the pixels in y direction
5424 for (int y = 0; y < h; y++)
5425 {
5426 //getting the pixels of current row
5427 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
5428 int rowRGB = y * w;
5429 //iterating through all the pixels in x direction
5430 for (int x = 0; x < w; x++)
5431 {
5432 int indexRGB = x;
5433 int indexRGBA = x * 4;
5434 byte b = bts[rowRGB + indexRGB];
5435 row[indexRGBA + 3] = 255;//byte A
5436 row[indexRGBA + 2] = (byte)(b);//byte R
5437 row[indexRGBA + 1] = (byte)(b);//byte G
5438 row[indexRGBA] = (byte)(b);//byte B
5439 }
5440 }
5441 }
5442 bmp.UnlockBits(bmd);
5443 return bmp;
5444 }
5445 else
5446 if (px == PixelFormat.Format16bppGrayScale)
5447 {
5448 //opening a 8 bit per pixel jpg image
5449 Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
5450 //creating the bitmapdata and lock bits
5451 AForge.Rectangle rec = new AForge.Rectangle(0, 0, w, h);
5452 BitmapData bmd = bmp.LockBits(rec, ImageLockMode.ReadWrite, bmp.PixelFormat);
5453 unsafe
5454 {
5455 //iterating through all the pixels in y direction
5456 for (int y = 0; y < h; y++)
5457 {
5458 //getting the pixels of current row
5459 byte* row = (byte*)bmd.Scan0 + (y * bmd.Stride);
5460 int rowRGB = y * w * 2;
5461 //iterating through all the pixels in x direction
5462 for (int x = 0; x < w; x++)
5463 {
5464 int indexRGB = x * 2;
5465 int indexRGBA = x * 4;
5466 ushort b = (ushort)((float)BitConverter.ToUInt16(bts, rowRGB + indexRGB) / 255);
5467 row[indexRGBA + 3] = 255;//byte A
5468 row[indexRGBA + 2] = (byte)(b);//byte R
5469 row[indexRGBA + 1] = (byte)(b);//byte G
5470 row[indexRGBA] = (byte)(b);//byte B
5471 }
5472 }
5473 }
5474 bmp.UnlockBits(bmd);
5475 return bmp;
5476 }
5477
5478 throw new NotSupportedException("Pixelformat " + px + " is not supported.");
5479 }

◆ GetBitMaxValue()

static int BioLib.BioImage.GetBitMaxValue ( int bt)
static

It returns the maximum value of a bit.

Parameters
btbit depth
Returns
The maximum value of a bit.

Definition at line 8425 of file Bio.cs.

8426 {
8427 if (bt == 8)
8428 return 255;
8429 if (bt == 9)
8430 return 512;
8431 else if (bt == 10)
8432 return 1023;
8433 else if (bt == 11)
8434 return 2047;
8435 else if (bt == 12)
8436 return 4095;
8437 else if (bt == 13)
8438 return 8191;
8439 else if (bt == 14)
8440 return 16383;
8441 else if (bt == 15)
8442 return 32767;
8443 else
8444 return 65535;
8445 }

◆ GetBitsPerPixel()

static int BioLib.BioImage.GetBitsPerPixel ( int bt)
static

‍If the number is less than or equal to 255, then it's 8 bits. If it's less than or equal to 512, then it's 9 bits. If it's less than or equal to 1023, then it's 10 bits. If it's less than or equal to 2047, then it's 11 bits. If it's less than or equal to 4095, then it's 12 bits. If it's less than or equal to 8191, then it's 13 bits. If it's less than or equal to 16383, then it's 14 bits. If it's less than or equal to 32767, then it's 15 bits. If it's less than or equal to 65535, then it's 16 bits

Parameters
btThe number of bits per pixel.
Returns
The number of bits per pixel.

Definition at line 8399 of file Bio.cs.

8400 {
8401 if (bt <= 255)
8402 return 8;
8403 if (bt <= 512)
8404 return 9;
8405 else if (bt <= 1023)
8406 return 10;
8407 else if (bt <= 2047)
8408 return 11;
8409 else if (bt <= 4095)
8410 return 12;
8411 else if (bt <= 8191)
8412 return 13;
8413 else if (bt <= 16383)
8414 return 14;
8415 else if (bt <= 32767)
8416 return 15;
8417 else
8418 return 16;
8419 }

◆ 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

Definition at line 5227 of file Bio.cs.

5228 {
5229 Bitmap bf = Buffers[ind];
5230 if (bf.isRGB)
5231 {
5232 if (s == 0)
5233 return extractR.Apply(Buffers[ind].Image);
5234 else
5235 if (s == 1)
5236 return extractG.Apply(Buffers[ind].Image);
5237 else
5238 return extractB.Apply(Buffers[ind].Image);
5239 }
5240 else
5241 throw new InvalidOperationException();
5242 }

◆ 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.

Definition at line 5252 of file Bio.cs.

5253 {
5254 if (RGBChannelCount == 1)
5255 {
5256 Bitmap[] bs = new Bitmap[Channels.Count];
5257 List<Channel> chs = new List<Channel>();
5258 for (int c = 0; c < Channels.Count; c++)
5259 {
5260 int index = GetFrameIndex(coord.Z, c, coord.T);
5261 bs[c] = Buffers[index];
5262 chs.Add(Channels[c]);
5263 }
5264 Bitmap bm = (Bitmap)Bitmap.GetEmissionBitmap(bs, chs.ToArray());
5265 return bm;
5266 }
5267 else
5268 {
5269 int index = GetFrameIndex(coord.Z, coord.C, coord.T);
5270 return Buffers[index];
5271 }
5272 }

◆ 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.

Definition at line 5187 of file Bio.cs.

5188 {
5189 if (Buffers[ind].PixelFormat == PixelFormat.Float)
5190 {
5191 if (Statistics.StackMax <= 1)
5192 {
5193 Bitmap bm = Buffers[ind].GetImageRGBA(true);
5194 return bm;
5195 }
5196 else
5197 {
5198 BioImage.filter8.InRed = MapIntRangeToByteRange(r);
5199 BioImage.filter8.InGreen = MapIntRangeToByteRange(g);
5200 BioImage.filter8.InBlue = MapIntRangeToByteRange(b);
5201 Bitmap bm = BioImage.filter8.Apply(Buffers[ind].GetImageRGBA(false));
5202 return bm;
5203 }
5204 }
5205 else
5206 if (Buffers[ind].BitsPerPixel > 8)
5207 {
5208 BioImage.filter16.InRed = r;
5209 BioImage.filter16.InGreen = g;
5210 BioImage.filter16.InBlue = b;
5211 Bitmap bm = BioImage.filter16.Apply(Buffers[ind]);
5212 return bm;
5213 }
5214 else
5215 {
5216 // set ranges
5217 BioImage.filter8.InRed = r;
5218 BioImage.filter8.InGreen = g;
5219 BioImage.filter8.InBlue = b;
5220 return BioImage.filter8.Apply(Buffers[ind]);
5221 }
5222 }

◆ 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.

Definition at line 5162 of file Bio.cs.

5163 {
5164 int index = GetFrameIndex(coord.Z, coord.C, coord.T);
5165 return GetFiltered(index, r, g, b);
5166 }

◆ GetFrameIndex()

int BioLib.BioImage.GetFrameIndex ( int z,
int c,
int t )

Definition at line 8196 of file Bio.cs.

8197 {
8198 try
8199 {
8200 if (StackOrder == Order.ZCT)
8201 {
8202 return Coords[z, c, t];
8203 }
8204 else if (StackOrder == Order.CZT)
8205 {
8206 return Coords[c, z, t];
8207 }
8208 else
8209 return Coords[t, c, z];
8210 }
8211 catch (Exception e)
8212 {
8213 return 0;
8214 }
8215
8216 }

◆ 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.

Definition at line 4962 of file Bio.cs.

4963 {
4964 return Buffers[GetFrameIndex(z, c, t)];
4965 }

◆ 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.

Definition at line 4989 of file Bio.cs.

4990 {
4991 if (ix > SizeX || iy > SizeY || ix < 0 || iy < 0)
4992 return 0;
4993 int stridex = SizeX;
4994 int x = ix;
4995 int y = iy;
4996 if (bitsPerPixel > 8)
4997 {
4998 return (y * stridex + x) * 2;
4999 }
5000 else
5001 {
5002 return (y * stridex + x);
5003 }
5004 }

◆ 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.

Definition at line 5012 of file Bio.cs.

5013 {
5014 int stridex = SizeX;
5015 //For 16bit (2*8bit) images we multiply buffer index by 2
5016 int x = ix;
5017 int y = iy;
5018 if (bitsPerPixel > 8)
5019 {
5020 return (y * stridex + x) * 2 * index;
5021 }
5022 else
5023 {
5024 return (y * stridex + x) * index;
5025 }
5026 }

◆ 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

Definition at line 3245 of file Bio.cs.

3246 {
3247 int originalWidth = Resolutions[0].SizeX; // Width of the original level
3248 int nextLevelWidth = Resolutions[level].SizeX; // Width of the next level (downsampled)
3249 return (double)originalWidth / (double)nextLevelWidth;
3250 }

◆ GetLevelDownsamples()

double[] BioLib.BioImage.GetLevelDownsamples ( )

Definition at line 3251 of file Bio.cs.

3252 {
3253 double[] ds = new double[Resolutions.Count];
3254 for (int i = 0; i < Resolutions.Count; i++)
3255 {
3256 ds[i] = Resolutions[0].PhysicalSizeX * GetLevelDownsample(i);
3257 }
3258 return ds;
3259 }
double GetLevelDownsample(int level)
Get the downsampling factor of a given level.
Definition Bio.cs:3245

◆ GetPixelFormat() [1/2]

static PixelFormat BioLib.BioImage.GetPixelFormat ( int rgbChannelCount,
BioFormats.ome.xml.model.enums.PixelType px )
static

The function returns the appropriate PixelFormat based on the number of RGB channels and the pixel type.

Parameters
rgbChannelCountThe rgbChannelCount parameter represents the number of channels in the RGB color model. It can have a value of either 1 (for grayscale images) or 3 (for RGB color images).
pxThe parameter "px" is of type BioFormats::ome.xml.model.enums.PixelType. It represents the pixel type of the image, such as INT8, UINT8, INT16, or UINT16.
Returns
The method returns a PixelFormat value based on the input parameters.

Definition at line 8512 of file Bio.cs.

8513 {
8514 if (rgbChannelCount == 1)
8515 {
8516 if (px == BioFormats::ome.xml.model.enums.PixelType.INT8 || px == BioFormats::ome.xml.model.enums.PixelType.UINT8)
8517 return PixelFormat.Format8bppIndexed;
8518 else if (px == BioFormats::ome.xml.model.enums.PixelType.INT16 || px == BioFormats::ome.xml.model.enums.PixelType.UINT16)
8519 return PixelFormat.Format16bppGrayScale;
8520 }
8521 else if (rgbChannelCount == 3)
8522 {
8523 if (px == BioFormats::ome.xml.model.enums.PixelType.INT8 || px == BioFormats::ome.xml.model.enums.PixelType.UINT8)
8524 return PixelFormat.Format24bppRgb;
8525 else if (px == BioFormats::ome.xml.model.enums.PixelType.INT16 || px == BioFormats::ome.xml.model.enums.PixelType.UINT16)
8526 return PixelFormat.Format48bppRgb;
8527 }
8528 else
8529 return PixelFormat.Format32bppArgb;
8530 throw new InvalidDataException("RGBChannels Count of " + rgbChannelCount + " not supported.");
8531 }

◆ GetPixelFormat() [2/2]

static PixelFormat BioLib.BioImage.GetPixelFormat ( int rgbChannelCount,
int bitsPerPixel )
static

If the bits per pixel is 8, then the pixel format is either 8bppIndexed, 24bppRgb, or 32bppArgb. If the bits per pixel is 16, then the pixel format is either 16bppGrayScale or 48bppRgb.

Parameters
rgbChannelCountThe number of channels in the image. For example, a grayscale image has 1 channel, a color image has 3 channels (red, green, blue).
bitsPerPixel8 or 16
Returns
The PixelFormat of the image.

Definition at line 8482 of file Bio.cs.

8483 {
8484 if (bitsPerPixel == 8)
8485 {
8486 if (rgbChannelCount == 1)
8487 return PixelFormat.Format8bppIndexed;
8488 else if (rgbChannelCount == 3)
8489 return PixelFormat.Format24bppRgb;
8490 else if (rgbChannelCount == 4)
8491 return PixelFormat.Format32bppArgb;
8492 }
8493 else
8494 {
8495 if (rgbChannelCount == 1)
8496 return PixelFormat.Format16bppGrayScale;
8497 if (rgbChannelCount == 3)
8498 return PixelFormat.Format48bppRgb;
8499 }
8500 throw new NotSupportedException("Not supported pixel format.");
8501 }

◆ GetRegion()

BioImage BioLib.BioImage.GetRegion ( int x,
int y,
int w,
int h )

Definition at line 8341 of file Bio.cs.

8342 {
8343 string id = System.IO.Path.GetFileNameWithoutExtension(Filename);
8344 id.Replace(".BioFormats::ome", "");
8345 BioImage bm = Copy();
8346 bm.ID = id + ".BioFormats::ome.tif";
8347 bm.Filename = id + ".BioFormats::ome.tif";
8348 bm.Volume = new VolumeD(new Point3D(StageSizeX + (PhysicalSizeX * PyramidalOrigin.X), StageSizeY + (PhysicalSizeY * PyramidalOrigin.Y), StageSizeZ),
8349 new Point3D(w * PhysicalSizeX, h * PhysicalSizeY, SizeZ * PhysicalSizeZ));
8350 bm.Resolutions.Add(new Resolution(w, h, bm.Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
8351 bm.Resolutions.RemoveAt(0);
8352 Recorder.AddLine("BioLib.Images.GetImage(\"" + bm.ID + "\").GetRegion(" + x + "," + y + "," + w + "," + h + ");", false);
8353 return bm;
8354 }

◆ 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.

Definition at line 5281 of file Bio.cs.

5282 {
5283 int index = GetFrameIndex(coord.Z, 0, coord.T);
5284 if (Buffers[0].RGBChannelsCount == 1)
5285 {
5286 if (Channels.Count >= 3)
5287 {
5288 Bitmap[] bs = new Bitmap[3];
5289 bs[2] = Buffers[index + RChannel.Index];
5290 bs[1] = Buffers[index + GChannel.Index];
5291 bs[0] = Buffers[index + BChannel.Index];
5292 return Bitmap.GetRGBBitmap(bs, rf, gf, bf);
5293 }
5294 else
5295 {
5296 Bitmap[] bs = new Bitmap[3];
5297 bs[2] = Buffers[index + RChannel.Index];
5298 bs[1] = Buffers[index + RChannel.Index + 1];
5299 bs[0] = Buffers[index + RChannel.Index + 2];
5300 return Bitmap.GetRGBBitmap(bs, rf, gf, bf);
5301 }
5302 }
5303 else
5304 {
5305 if (Buffers[0].PixelFormat == PixelFormat.Float || Buffers[0].PixelFormat == PixelFormat.Short)
5306 {
5307 return Buffers[index].GetImageRGBA();
5308 }
5309 else
5310 return Buffers[index];
5311 }
5312 }

◆ GetSeriesCount()

static int BioLib.BioImage.GetSeriesCount ( string file)
static

Definition at line 9817 of file Bio.cs.

9818 {
9819 ImageReader r = new ImageReader();
9820 r.setId(file);
9821 return r.getSeriesCount();
9822 }

◆ GetSlice()

async Task< Bitmap[]> BioLib.BioImage.GetSlice ( int x,
int y,
int w,
int h,
double resolution )

Definition at line 8765 of file Bio.cs.

8766 {
8767 List<Bitmap> Buffers = new List<Bitmap>();
8768 for (int i = 0; i < imagesPerSeries; i++)
8769 {
8770 if (openSlideImage != null)
8771 {
8772 int lev = LevelFromResolution(Resolution);
8773 openslideBase.SetSliceInfo(lev, Resolutions[lev].PixelFormat, Coordinate);
8774 byte[] bts = openslideBase.GetSlice(new OpenSlideGTK.SliceInfo(x, y, w, h, resolution));
8775 Buffers.Add(new Bitmap((int)Math.Round(OpenSlideBase.destExtent.Width), (int)Math.Round(OpenSlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, new ZCT(), ""));
8776 }
8777 else
8778 {
8779 start:
8780 byte[] bts = await slideBase.GetSlice(new SliceInfo(x, y, w, h, resolution, Coordinate));
8781 if (bts == null)
8782 {
8783 if (x == 0 && y == 0)
8784 {
8785 Resolution = GetUnitPerPixel(0);
8786 }
8787 pyramidalOrigin = new PointD(0, 0);
8788 goto start;
8789 }
8790 Buffers.Add(new Bitmap((int)Math.Round(SlideBase.destExtent.Width), (int)Math.Round(SlideBase.destExtent.Height), Resolutions[Level].PixelFormat, bts, new ZCT(), ""));
8791 }
8792 }
8793 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), true, x, y, w, h, resolution);
8794 return Buffers.ToArray();
8795 }
int LevelFromResolution(double Resolution)
Returns the level of a given resolution.
Definition Bio.cs:3265
double GetUnitPerPixel(int level)
Get Unit Per Pixel for pyramidal images.
Definition Bio.cs:3292
async Task< byte[]> GetSlice(SliceInfo sliceInfo)
Get slice.

◆ GetTile()

static Bitmap BioLib.BioImage.GetTile ( BioImage b,
int index,
int level,
int tilex,
int tiley,
int tileSizeX,
int tileSizeY )
static

It reads a tile from a file, and returns a bitmap.

Parameters
BioImageThis is a class that contains the image file name, the image reader, and the coordinates of the image.
ZCTZ, C, T
seriethe series number (0-based)
tilexthe x coordinate of the tile
tileythe y coordinate of the tile
tileSizeXthe width of the tile
tileSizeYthe height of the tile
Returns
A Bitmap object.

Definition at line 8245 of file Bio.cs.

8246 {
8247 if (b.Tag != null)
8248 {
8249 if (b.Tag.ToString() != "OMERO")
8250 return null;
8251 //This is a OMERO file we need to update it.
8252 int i = 0;
8253 for (int z = 0; z < b.SizeZ; z++)
8254 {
8255 for (int c = 0; c < b.SizeC; c++)
8256 {
8257 for (int t = 0; t < b.SizeT; t++)
8258 {
8259 if(i == index)
8260 return OMERO.GetTile(b, new ZCT(z,c,t), tilex, tiley, tileSizeX, tileSizeY, level);
8261 i++;
8262 }
8263 }
8264 }
8265 }
8266 if (vips && b.vipPages.Count > 0)
8267 {
8268 //We can get a tile faster with libvips rather than bioformats.
8269 Bitmap bmp = ExtractRegionFromTiledTiff(b, tilex, tiley, tileSizeX, tileSizeY, level);
8270 if (bmp != null)
8271 {
8272 return bmp;
8273 }
8274 }
8275 //We check if we can open this with OpenSlide as this is faster than Bioformats with IKVM.
8276 if (b.openSlideImage != null)
8277 {
8278 byte[] bts = b.openSlideImage.ReadRegion(level, tilex, tiley, tileSizeX, tileSizeY);
8279 Bitmap bm = new Bitmap("", tileSizeX, tileSizeY, AForge.PixelFormat.Format32bppArgb, bts, new ZCT(), 0, null, true, true);
8280 return bm;
8281 }
8282
8283 string curfile = b.imRead.getCurrentFile();
8284 if (curfile == null)
8285 {
8286 b.meta = (IMetadata)((OMEXMLService)factory.getInstance(typeof(OMEXMLService))).createOMEXMLMetadata();
8287 b.imRead.close();
8288 b.imRead.setMetadataStore(b.meta);
8289 b.imRead.setId(b.file);
8290 }
8291 else
8292 {
8293 string fi = b.file.Replace("\\", "/");
8294 string cf = curfile.Replace("\\", "/");
8295 if (cf != fi)
8296 {
8297 b.imRead.close();
8298 b.meta = (IMetadata)((OMEXMLService)factory.getInstance(typeof(OMEXMLService))).createOMEXMLMetadata();
8299 b.imRead.setMetadataStore(b.meta);
8300 b.imRead.setId(b.file);
8301 }
8302 }
8303 if (b.imRead.getSeries() != level)
8304 b.imRead.setSeries(level);
8305 int SizeX = b.imRead.getSizeX();
8306 int SizeY = b.imRead.getSizeY();
8307 bool flat = b.imRead.hasFlattenedResolutions();
8308 bool littleEndian = b.imRead.isLittleEndian();
8309 bool interleaved = b.imRead.isInterleaved();
8310 PixelFormat PixelFormat = b.Resolutions[level].PixelFormat;
8311 if (tilex < 0)
8312 tilex = 0;
8313 if (tiley < 0)
8314 tiley = 0;
8315 if (tilex >= SizeX)
8316 tilex = SizeX;
8317 if (tiley >= SizeY)
8318 tiley = SizeY;
8319 int sx = tileSizeX;
8320 if (tilex + tileSizeX > SizeX)
8321 sx -= (tilex + tileSizeX) - (SizeX);
8322 int sy = tileSizeY;
8323 if (tiley + tileSizeY > SizeY)
8324 sy -= (tiley + tileSizeY) - (SizeY);
8325 //For some reason calling openBytes with 1x1px area causes an exception.
8326 if (sx <= 1)
8327 return null;
8328 if (sy <= 1)
8329 return null;
8330 try
8331 {
8332 byte[] bytesr = b.imRead.openBytes(index, tilex, tiley, sx, sy);
8333 return new Bitmap(b.file, sx, sy, PixelFormat, bytesr, new ZCT(), index, null, littleEndian, interleaved);
8334 }
8335 catch (Exception e)
8336 {
8337 Console.WriteLine(e.Message);
8338 return null;
8339 }
8340 }
static Bitmap ExtractRegionFromTiledTiff(BioImage b, int x, int y, int width, int height, int level)
The function ExtractRegionFromTiledTiff takes a BioImage object, coordinates, width,...
Definition Bio.cs:7348

◆ GetUnitPerPixel()

double BioLib.BioImage.GetUnitPerPixel ( int level)

Get Unit Per Pixel for pyramidal images.

Parameters
level
Returns

Definition at line 3292 of file Bio.cs.

3293 {
3294 return Resolutions[0].PhysicalSizeX * GetLevelDownsample(level);
3295 }

◆ 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.

Definition at line 5073 of file Bio.cs.

5074 {
5075 return GetValueRGB(new ZCTXY(z, c, t, x, y), 0);
5076 }
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:5043

◆ 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.

Definition at line 5060 of file Bio.cs.

5061 {
5062 return GetValueRGB(new ZCTXY(coord.Z, coord.C, coord.T, x, y), 0);
5063 }

◆ 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.

Definition at line 5033 of file Bio.cs.

5034 {
5035 return GetValueRGB(coord, 0);
5036 }

◆ 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.

Definition at line 5101 of file Bio.cs.

5102 {
5103 return GetValueRGB(new ZCT(z, c, t), x, y, RGBindex);
5104 }

◆ 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.

Definition at line 5085 of file Bio.cs.

5086 {
5087 int i = GetFrameIndex(coord.Z, coord.C, coord.T);
5088 return Buffers[i].GetValue(x, y, RGBindex);
5089 }

◆ 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.

Definition at line 5043 of file Bio.cs.

5044 {
5045 int ind = 0;
5046 if (coord.C >= SizeC)
5047 {
5048 coord.C = 0;
5049 }
5050 ind = GetFrameIndex(coord.Z, coord.C, coord.T);
5051 return (ushort)Buffers[ind].GetValue(coord.X, coord.Y, index);
5052 }

◆ ImagesToStack()

static BioImage BioLib.BioImage.ImagesToStack ( string[] files,
bool tab )
static

It takes a list of files, opens them, and then combines them into a single BioImage object.

Parameters
filesan array of file paths
Returns
A BioImage object.

Definition at line 8618 of file Bio.cs.

8619 {
8620 BioImage[] bs = new BioImage[files.Length];
8621 int z = 0;
8622 int c = 0;
8623 int t = 0;
8624 for (int i = 0; i < files.Length; i++)
8625 {
8626 string str = Path.GetFileNameWithoutExtension(files[i]);
8627 str = str.Replace(".BioFormats::ome", "");
8628 string[] st = str.Split('_');
8629 if (st.Length > 3)
8630 {
8631 z = int.Parse(st[1].Replace("Z", ""));
8632 c = int.Parse(st[2].Replace("C", ""));
8633 t = int.Parse(st[3].Replace("T", ""));
8634 }
8635 if (i == 0)
8636 bs[0] = OpenOME(files[i], tab);
8637 else
8638 {
8639 bs[i] = OpenFile(files[i], 0, tab, false);
8640 }
8641 }
8642 BioImage b = BioImage.CopyInfo(bs[0], true, true);
8643 for (int i = 0; i < files.Length; i++)
8644 {
8645 for (int bc = 0; bc < bs[i].Buffers.Count; bc++)
8646 {
8647 b.Buffers.Add(bs[i].Buffers[bc]);
8648 }
8649 }
8650 b.UpdateCoords(z + 1, c + 1, t + 1);
8651 b.Volume = new VolumeD(bs[0].Volume.Location, new Point3D(bs[0].SizeX * bs[0].PhysicalSizeX, bs[0].SizeY * bs[0].PhysicalSizeY, (z + 1) * bs[0].PhysicalSizeZ));
8652 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, files, tab);
8653 return b;
8654 }
static BioImage OpenOME(string file, bool tab)
The function "OpenOME" opens a bioimage file in the OME format and returns the first image in the ser...
Definition Bio.cs:6995

◆ ImportROIsCSV()

static List< ROI > BioLib.BioImage.ImportROIsCSV ( string filename)
static

It reads the CSV file and converts each line into a ROI object.

Parameters
filenameThe path to the CSV file.
Returns
A list of ROI objects.

Definition at line 9574 of file Bio.cs.

9575 {
9576 List<ROI> list = new List<ROI>();
9577 if (!File.Exists(filename))
9578 return list;
9579 string[] sts = File.ReadAllLines(filename);
9580 //We start reading from line 1.
9581 for (int i = 1; i < sts.Length; i++)
9582 {
9583 list.Add(StringToROI(sts[i]));
9584 }
9585 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, filename);
9586 return list;
9587 }
static ROI StringToROI(string sts)
It takes a string and returns an ROI object.
Definition Bio.cs:9403

◆ Initialize() [1/2]

static void BioLib.BioImage.Initialize ( )
static

Definition at line 5536 of file Bio.cs.

5537 {
5538 //We initialize OME on a seperate thread so the user doesn't have to wait for initialization to
5539 //view images.
5540 InitFactory();
5541 InitReader();
5542 InitWriter();
5543 }

◆ Initialize() [2/2]

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

Initializes ImageJ/Fiji with the given path.

Parameters
imageJPath

Definition at line 5522 of file Bio.cs.

5523 {
5524 //We initialize OME on a seperate thread so the user doesn't have to wait for initialization to
5525 //view images.
5526 InitFactory();
5527 InitReader();
5528 InitWriter();
5529 if (imageJPath.Contains("Fiji"))
5530 {
5531 Fiji.Initialize(imageJPath);
5532 }
5533 else
5534 ImageJ.Initialize(imageJPath);
5535 }

◆ isOME()

static bool BioLib.BioImage.isOME ( string file)
static

If the file is a TIFF, check the ImageDescription tag for the string "OME-XML". If it's there, return true. If it's not a TIFF, return true. If it's a PNG, JPG, JPEG, or BMP, return false.

Parameters
filethe path to the image file
Returns
A boolean value.

Definition at line 6358 of file Bio.cs.

6359 {
6360 if (file.EndsWith("BioFormats::ome.tif") || file.EndsWith("BioFormats::ome.tiff"))
6361 {
6362 return true;
6363 }
6364 if (file.EndsWith(".tif") || file.EndsWith(".TIF") || file.EndsWith("tiff") || file.EndsWith("TIFF"))
6365 {
6366 Tiff image = Tiff.Open(file, "r");
6367 string desc = "";
6368 FieldValue[] f = image.GetField(TiffTag.IMAGEDESCRIPTION);
6369 desc = f[0].ToString();
6370 image.Close();
6371 if (desc.Contains("OME-XML"))
6372 return true;
6373 else
6374 return false;
6375 }
6376 if ((file.EndsWith("png") || file.EndsWith("PNG") || file.EndsWith("jpg") || file.EndsWith("JPG") ||
6377 file.EndsWith("jpeg") || file.EndsWith("JPEG") || file.EndsWith("bmp") || file.EndsWith("BMP")))
6378 {
6379 return false;
6380 }
6381 else return true;
6382 }

◆ isOMESeries()

static bool BioLib.BioImage.isOMESeries ( string file)
static

‍If the file is an OME file and has more than one series, return true

Parameters
filethe file to be checked
Returns
A boolean value.

Definition at line 6388 of file Bio.cs.

6389 {
6390 if (!isOME(file))
6391 return false;
6392 ImageReader reader = new ImageReader();
6393 var meta = (IMetadata)((OMEXMLService)new ServiceFactory().getInstance(typeof(OMEXMLService))).createOMEXMLMetadata();
6394 reader.setMetadataStore((MetadataStore)meta);
6395 file = file.Replace("\\", "/");
6396 reader.setId(file);
6397 bool ser = false;
6398 if (reader.getSeriesCount() > 1)
6399 ser = true;
6400 reader.close();
6401 reader = null;
6402 return ser;
6403 }
static bool isOME(string file)
If the file is a TIFF, check the ImageDescription tag for the string "OME-XML". If it's there,...
Definition Bio.cs:6358

◆ isTiffSeries()

static bool BioLib.BioImage.isTiffSeries ( string file)
static

‍The function checks if the image is a Tiff image and if it is, it checks if the image is a series of images

Parameters
filethe path to the file
Returns
a boolean value.

Definition at line 6323 of file Bio.cs.

6324 {
6325 Tiff image = Tiff.Open(file, "r");
6326 string desc = "";
6327 FieldValue[] f = image.GetField(TiffTag.IMAGEDESCRIPTION);
6328 image.Close();
6329 string[] sts = desc.Split('\n');
6330 int index = 0;
6331 for (int i = 0; i < sts.Length; i++)
6332 {
6333 if (sts[i].StartsWith("-ImageInfo"))
6334 {
6335 string val = sts[i].Substring(11);
6336 val = val.Substring(0, val.IndexOf(':'));
6337 int serie = int.Parse(val);
6338 if (sts[i].Length > 10)
6339 {
6340 string cht = sts[i].Substring(sts[i].IndexOf('{'), sts[i].Length - sts[i].IndexOf('{'));
6341 ImageInfo info = JsonConvert.DeserializeObject<ImageInfo>(cht);
6342 if (info.Series > 1)
6343 return true;
6344 else
6345 return false;
6346 }
6347 }
6348 }
6349 return false;
6350 }

◆ LevelFromResolution()

int BioLib.BioImage.LevelFromResolution ( double Resolution)

Returns the level of a given resolution.

Parameters
Resolution
Returns

Definition at line 3265 of file Bio.cs.

3266 {
3267 int l = 0;
3268 double[] ds = GetLevelDownsamples();
3269 if (MacroResolution.HasValue)
3270 {
3271 for (int i = 0; i < MacroResolution.Value; i++)
3272 {
3273 if (ds[i] < Resolution)
3274 l = i;
3275 }
3276 }
3277 else
3278 {
3279 for (int i = 0; i < Resolutions.Count; i++)
3280 {
3281 if (ds[i] < Resolution)
3282 l = i;
3283 }
3284 }
3285 return l;
3286 }

◆ MapIntRangeToByteRange()

static IntRange BioLib.BioImage.MapIntRangeToByteRange ( IntRange ushortRange)
static

Definition at line 5167 of file Bio.cs.

5168 {
5169 // Ensure the range is valid
5170 if (ushortRange.Min < 0 || ushortRange.Max > ushort.MaxValue)
5171 throw new ArgumentOutOfRangeException(nameof(ushortRange), "Range must be within 0 to ushort.MaxValue.");
5172
5173 // Map each value in the range
5174 int mappedMin = (int)((ushortRange.Min / (float)ushort.MaxValue) * byte.MaxValue);
5175 int mappedMax = (int)((ushortRange.Max / (float)ushort.MaxValue) * byte.MaxValue);
5176
5177 return new IntRange(mappedMin, mappedMax);
5178 }

◆ 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.

Definition at line 4662 of file Bio.cs.

4663 {
4664 BioImage res = new BioImage(b2.ID);
4665 res.ID = Images.GetImageName(b2.ID);
4666 res.series = b2.series;
4667 res.sizeZ = b2.SizeZ;
4668 int cOrig = b2.SizeC;
4669 res.sizeC = b2.SizeC + b.SizeC;
4670 res.sizeT = b2.SizeT;
4671 res.bitsPerPixel = b2.bitsPerPixel;
4672 res.imageInfo = b2.imageInfo;
4673 res.littleEndian = b2.littleEndian;
4674 res.seriesCount = b2.seriesCount;
4675 res.imagesPerSeries = res.ImageCount / res.seriesCount;
4676 res.Coords = new int[res.SizeZ, res.SizeC, res.SizeT];
4677 res.Resolutions.Add(b2.Resolutions[0]);
4678 res.Volume = new VolumeD(new Point3D(res.StageSizeX, res.StageSizeY, res.StageSizeZ), new Point3D(b2.SizeX, b2.SizeY, b2.SizeZ));
4679 int i = 0;
4680 for (int ci = 0; ci < res.SizeC; ci++)
4681 {
4682 for (int ti = 0; ti < res.SizeT; ti++)
4683 {
4684 for (int zi = 0; zi < res.SizeZ; zi++)
4685 {
4686 if (i < b.ImageCount)
4687 {
4688 ZCT co = new ZCT(zi, ci, ti);
4689 int ind = b.GetFrameIndex(zi, 0, ti);
4690 //This plane is not part of b1 so we add the planes from b2 channels.
4691 Bitmap copy = new Bitmap(b.id, b.SizeX, b.SizeY, b.Buffers[0].PixelFormat, b.Buffers[ind].Bytes, co, ind);
4692 res.SetFrameIndex(zi, ci, ti, ind);
4693 res.Buffers.Add(copy);
4694 //Lets copy the ROI's from the original image.
4695 List<ROI> anns = b.GetAnnotations(zi, ci, ti);
4696 if (anns.Count > 0)
4697 res.Annotations.AddRange(anns);
4698 }
4699 else
4700 {
4701 ZCT co = new ZCT(zi, ci, ti);
4702 int ind = b2.GetFrameIndex(zi, 0, ti);
4703 //This plane is not part of b1 so we add the planes from b2 channels.
4704 Bitmap copy = new Bitmap(b2.id, b2.SizeX, b2.SizeY, b2.Buffers[0].PixelFormat, b2.Buffers[ind].Bytes, co, ind);
4705 res.SetFrameIndex(zi, ci, ti, b.ImageCount + ind);
4706 res.Buffers.Add(copy);
4707 //Lets copy the ROI's from the original image.
4708 List<ROI> anns = b2.GetAnnotations(zi, ci, ti);
4709 if (anns.Count > 0)
4710 res.Annotations.AddRange(anns);
4711 }
4712 i++;
4713 }
4714 }
4715 }
4716 for (int ci = 0; ci < b.SizeC; ci++)
4717 {
4718 res.Channels.Add(b.Channels[ci].Copy());
4719 }
4720 for (int ci = 0; ci < b2.SizeC; ci++)
4721 {
4722 res.Channels.Add(b2.Channels[ci].Copy());
4723 }
4724 res.rgbChannels[0] = 0;
4725 if (res.Channels.Count > 1)
4726 res.rgbChannels[1] = 1;
4727 if (res.Channels.Count > 2)
4728 res.rgbChannels[2] = 2;
4729 Images.AddImage(res);
4730 res.imagesPerSeries = res.Buffers.Count;
4731 //We wait for threshold image statistics calculation
4732 do
4733 {
4734 Thread.Sleep(100);
4735 } while (res.Buffers[res.Buffers.Count - 1].Stats == null);
4736 AutoThreshold(res, false);
4737 if (res.bitsPerPixel > 8)
4738 res.StackThreshold(true);
4739 else
4740 res.StackThreshold(false);
4741 return res;
4742 }

◆ 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.

Definition at line 4749 of file Bio.cs.

4750 {
4751 BioImage b = Images.GetImage(bname);
4752 BioImage b2 = Images.GetImage(b2name);
4753 return MergeChannels(b, b2);
4754 }
static BioImage MergeChannels(BioImage b2, BioImage b)
This function takes two images and merges them together.
Definition Bio.cs:4662

◆ 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.

Definition at line 4798 of file Bio.cs.

4799 {
4800 BioImage bi = BioImage.CopyInfo(b, true, true);
4801 int ind = 0;
4802 for (int c = 0; c < b.SizeC; c++)
4803 {
4804 for (int z = 0; z < b.sizeZ; z++)
4805 {
4806 Merge m = new Merge(b.Buffers[b.GetFrameIndex(z, c, 0)]);
4807 Bitmap bm = new Bitmap(b.SizeX, b.SizeY, b.Buffers[0].PixelFormat);
4808 for (int i = 1; i < b.sizeT; i++)
4809 {
4810 m.OverlayImage = bm;
4811 bm = m.Apply(b.Buffers[b.GetFrameIndex(z, c, i)]);
4812 }
4813 Bitmap bf = new Bitmap(b.file, bm, new ZCT(z, c, 0), ind);
4814 bi.Buffers.Add(bf);
4815 bf.Stats = Statistics.FromBytes(bf);
4816 ind++;
4817 }
4818 }
4819 Images.AddImage(bi);
4820 bi.UpdateCoords(1, b.SizeC, b.SizeT);
4821 bi.Coordinate = new ZCT(0, 0, 0);
4822 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));
4823 AutoThreshold(bi, false);
4824 if (bi.bitsPerPixel > 8)
4825 bi.StackThreshold(true);
4826 else
4827 bi.StackThreshold(false);
4828 return bi;
4829 }

◆ 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.

Definition at line 4760 of file Bio.cs.

4761 {
4762 BioImage bi = BioImage.CopyInfo(b, true, true);
4763 int ind = 0;
4764 for (int c = 0; c < b.SizeC; c++)
4765 {
4766 for (int t = 0; t < b.sizeT; t++)
4767 {
4768 Merge m = new Merge(b.Buffers[b.GetFrameIndex(0, c, t)]);
4769 Bitmap bm = new Bitmap(b.SizeX, b.SizeY, b.Buffers[0].PixelFormat);
4770 for (int i = 1; i < b.sizeZ; i++)
4771 {
4772 m.OverlayImage = bm;
4773 bm = m.Apply(b.Buffers[b.GetFrameIndex(i, c, t)]);
4774 }
4775 Bitmap bf = new Bitmap(b.file, bm, new ZCT(0, c, t), ind);
4776 bi.Buffers.Add(bf);
4777 bf.Stats = Statistics.FromBytes(bf);
4778 ind++;
4779 }
4780 }
4781 Images.AddImage(bi);
4782 bi.UpdateCoords(1, b.SizeC, b.SizeT);
4783 bi.Coordinate = new ZCT(0, 0, 0);
4784 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));
4785
4786 AutoThreshold(bi, false);
4787 if (bi.bitsPerPixel > 8)
4788 bi.StackThreshold(true);
4789 else
4790 bi.StackThreshold(false);
4791 return bi;
4792 }

◆ Open() [1/2]

static void BioLib.BioImage.Open ( string file)
static

It opens a file.

Parameters
fileThe file to open.

Definition at line 8599 of file Bio.cs.

8600 {
8601 OpenFile(file);
8602 }

◆ Open() [2/2]

static void BioLib.BioImage.Open ( string[] files)
static

It opens a file.

Parameters
filesThe files to open.

Definition at line 8606 of file Bio.cs.

8607 {
8608 foreach (string file in files)
8609 {
8610 Open(file);
8611 }
8612 }
static void Open(string file)
It opens a file.
Definition Bio.cs:8599

◆ OpenAsync() [1/2]

static async Task BioLib.BioImage.OpenAsync ( string file,
bool OME,
bool newtab,
bool images,
int series )
static

It opens a file in a new thread.

Parameters
fileThe file to open

Definition at line 8577 of file Bio.cs.

8578 {
8579 openfile = file;
8580 omes = OME;
8581 tab = newtab;
8582 add = images;
8583 serie = series;
8584 await Task.Run(OpenThread);
8585 }

◆ OpenAsync() [2/2]

static async Task BioLib.BioImage.OpenAsync ( string[] files,
bool OME,
bool tab,
bool images )
static

It opens a file asynchronously.

Parameters
filesThe file(s) to open.

Definition at line 8589 of file Bio.cs.

8590 {
8591 foreach (string file in files)
8592 {
8593 await OpenAsync(file, OME, tab, images, 0);
8594 }
8595 }
static async Task OpenAsync(string file, bool OME, bool newtab, bool images, int series)
It opens a file in a new thread.
Definition Bio.cs:8577

◆ OpenFile() [1/4]

static BioImage BioLib.BioImage.OpenFile ( string file)
static

This function opens a file and returns a BioImage object.

Parameters
fileThe path to the file to open.
Returns
A BioImage object.

Definition at line 5885 of file Bio.cs.

5886 {
5887 return OpenFile(file, 0, true, true);
5888 }

◆ OpenFile() [2/4]

static BioImage BioLib.BioImage.OpenFile ( string file,
bool tab )
static

Definition at line 5889 of file Bio.cs.

5890 {
5891 return OpenFile(file, 0, tab, true);
5892 }

◆ OpenFile() [3/4]

static BioImage BioLib.BioImage.OpenFile ( string file,
int series,
bool tab,
bool addToImages )
static

It opens a TIFF file and returns a BioImage object.

Parameters
filethe file path
seriesthe series number of the image to open
Returns
A BioImage object.

Definition at line 5899 of file Bio.cs.

5900 {
5901 return OpenFile(file, series, tab, addToImages, false, 0, 0, 0, 0);
5902 }

◆ OpenFile() [4/4]

static BioImage BioLib.BioImage.OpenFile ( string file,
int series,
bool tab,
bool addToImages,
bool tile,
int tileX,
int tileY,
int tileSizeX,
int tileSizeY )
static

The OpenFile function opens a BioImage file, reads its metadata, and loads the image data into a BioImage object.

Parameters
fileThe file path of the bioimage to be opened.
seriesThe series parameter is an integer that specifies the series number of the image to open.
tabThe "tab" parameter is a boolean value that determines whether the BioImage should be opened in a new tab or not. If set to true, the BioImage will be opened in a new tab. If set to false, the BioImage will be opened in the current tab.
addToImagesA boolean value indicating whether the BioImage should be added to the Images collection.
tileThe "tile" parameter is a boolean value that determines whether the image should be opened as a tiled image or not. If set to true, the image will be opened as a tiled image. If set to false, the image will be opened as a regular image.
tileXThe tileX parameter is an integer that represents the starting X coordinate of the tile. It is used when opening a tiled image to specify the position of the tile within the image.
tileYThe tileY parameter is used to specify the starting Y coordinate of the tile when opening a tiled image. It determines the position of the tile within the image.
tileSizeXThe tileSizeX parameter is the width of each tile in pixels. It is used when opening a tiled TIFF image to specify the size of the tiles.
tileSizeYThe tileSizeY parameter is the height of each tile in pixels when the image is tiled.
Returns
The method is returning a BioImage object.

Definition at line 6026 of file Bio.cs.

6027 {
6028 string fs = file.Replace("\\", "/");
6029 vips = VipsSupport(file);
6030 Console.WriteLine("Opening BioImage: " + file);
6031 if (file.EndsWith(".npy"))
6032 return BioImage.FromNumpy(file);
6033 bool ome = isOME(file);
6034 if (ome) return OpenOME(file, series, tab, addToImages, tile, tileX, tileY, tileSizeX, tileSizeY);
6035 bool tiled = IsTiffTiled(file);
6036 Console.WriteLine("IsTiled=" + tiled.ToString());
6037 tile = tiled;
6038
6039 Stopwatch st = new Stopwatch();
6040 st.Start();
6041 Status = "Opening Image";
6042 progFile = file;
6043 BioImage b = new BioImage(file);
6044 if (tiled && file.EndsWith(".tif") && !file.EndsWith(".ome.tif"))
6045 {
6046 //To open this we need libvips
6047 vips = VipsSupport(b.file);
6048 }
6049 b.series = series;
6050 b.file = file;
6051 if (tiled)
6052 b.Type = ImageType.pyramidal;
6053 string fn = Path.GetFileNameWithoutExtension(file);
6054 string dir = Path.GetDirectoryName(file);
6055 if (File.Exists(fn + ".csv"))
6056 {
6057 string f = dir + "//" + fn + ".csv";
6058 b.Annotations = BioImage.ImportROIsCSV(f);
6059 }
6060 if (file.EndsWith("tif") || file.EndsWith("tiff") || file.EndsWith("TIF") || file.EndsWith("TIFF"))
6061 {
6062 Tiff image = Tiff.Open(file, "r");
6063 b.tifRead = image;
6064 int SizeX = image.GetField(TiffTag.IMAGEWIDTH)[0].ToInt();
6065 int SizeY = image.GetField(TiffTag.IMAGELENGTH)[0].ToInt();
6066 b.bitsPerPixel = image.GetField(TiffTag.BITSPERSAMPLE)[0].ToInt();
6067 b.littleEndian = !image.IsBigEndian();
6068 int RGBChannelCount = image.GetField(TiffTag.SAMPLESPERPIXEL)[0].ToInt();
6069 string desc = "";
6070
6071 FieldValue[] f = image.GetField(TiffTag.IMAGEDESCRIPTION);
6072 desc = f[0].ToString();
6073 ImageJDesc imDesc = null;
6074 b.sizeC = 1;
6075 b.sizeT = 1;
6076 b.sizeZ = 1;
6077 bool imagej = false;
6078 if (f != null && !tile)
6079 {
6080 imDesc = new ImageJDesc();
6081 desc = f[0].ToString();
6082 if (desc.StartsWith("ImageJ"))
6083 {
6084 imDesc.SetString(desc);
6085 if (imDesc.channels != 0)
6086 b.sizeC = imDesc.channels;
6087 else
6088 b.sizeC = 1;
6089 if (imDesc.slices != 0)
6090 b.sizeZ = imDesc.slices;
6091 else
6092 b.sizeZ = 1;
6093 if (imDesc.frames != 0)
6094 b.sizeT = imDesc.frames;
6095 else
6096 b.sizeT = 1;
6097 if (imDesc.finterval != 0)
6098 b.frameInterval = imDesc.finterval;
6099 else
6100 b.frameInterval = 1;
6101 if (imDesc.spacing != 0)
6102 b.imageInfo.PhysicalSizeZ = imDesc.spacing;
6103 else
6104 b.imageInfo.PhysicalSizeZ = 1;
6105 imagej = true;
6106 }
6107 }
6108 int stride = 0;
6109 PixelFormat PixelFormat;
6110 if (RGBChannelCount == 1)
6111 {
6112 if (b.bitsPerPixel > 8)
6113 {
6114 PixelFormat = PixelFormat.Format16bppGrayScale;
6115 stride = SizeX * 2;
6116 }
6117 else
6118 {
6119 PixelFormat = PixelFormat.Format8bppIndexed;
6120 stride = SizeX;
6121 }
6122 }
6123 else
6124 if (RGBChannelCount == 3)
6125 {
6126 b.sizeC = 1;
6127 if (b.bitsPerPixel > 8)
6128 {
6129 PixelFormat = PixelFormat.Format48bppRgb;
6130 stride = SizeX * 2 * 3;
6131 }
6132 else
6133 {
6134 PixelFormat = PixelFormat.Format24bppRgb;
6135 stride = SizeX * 3;
6136 }
6137 }
6138 else
6139 {
6140 PixelFormat = PixelFormat.Format32bppArgb;
6141 stride = SizeX * 4;
6142 }
6143
6144 string[] sts = desc.Split('\n');
6145 int index = 0;
6146 for (int i = 0; i < sts.Length; i++)
6147 {
6148 if (sts[i].StartsWith("-Channel"))
6149 {
6150 string val = sts[i].Substring(9);
6151 val = val.Substring(0, val.IndexOf(':'));
6152 int serie = int.Parse(val);
6153 if (serie == series && sts[i].Length > 7)
6154 {
6155 string cht = sts[i].Substring(sts[i].IndexOf('{'), sts[i].Length - sts[i].IndexOf('{'));
6156 Channel.ChannelInfo info = JsonConvert.DeserializeObject<Channel.ChannelInfo>(cht);
6157 Channel ch = new Channel(index, b.bitsPerPixel, info.SamplesPerPixel);
6158 ch.info = info;
6159 b.Channels.Add(ch);
6160 if (index == 0)
6161 {
6162 b.rgbChannels[0] = 0;
6163 }
6164 else
6165 if (index == 1)
6166 {
6167 b.rgbChannels[1] = 1;
6168 }
6169 else
6170 if (index == 2)
6171 {
6172 b.rgbChannels[2] = 2;
6173 }
6174 index++;
6175 }
6176 }
6177 else
6178 if (sts[i].StartsWith("-ROI"))
6179 {
6180 string val = sts[i].Substring(5);
6181 val = val.Substring(0, val.IndexOf(':'));
6182 int serie = int.Parse(val);
6183 if (serie == series && sts[i].Length > 7)
6184 {
6185 string s = sts[i].Substring(sts[i].IndexOf("ROI:") + 4, sts[i].Length - (sts[i].IndexOf("ROI:") + 4));
6186 string ro = s.Substring(s.IndexOf(":") + 1, s.Length - (s.IndexOf(':') + 1));
6187 ROI roi = StringToROI(ro);
6188 b.Annotations.Add(roi);
6189 }
6190 }
6191 else
6192 if (sts[i].StartsWith("-ImageInfo"))
6193 {
6194 string val = sts[i].Substring(11);
6195 val = val.Substring(0, val.IndexOf(':'));
6196 int serie = int.Parse(val);
6197 if (serie == series && sts[i].Length > 10)
6198 {
6199 string cht = sts[i].Substring(sts[i].IndexOf('{'), sts[i].Length - sts[i].IndexOf('{'));
6200 b.imageInfo = JsonConvert.DeserializeObject<ImageInfo>(cht);
6201 }
6202 }
6203 }
6204 b.Coords = new int[b.SizeZ, b.SizeC, b.SizeT];
6205 if (tiled && tileSizeX == 0 && tileSizeY == 0)
6206 {
6207 tileSizeX = 1920;
6208 tileSizeY = 1080;
6209 }
6210
6211 //If this is a tiff file not made by Bio we init channels based on RGBChannels.
6212 if (b.Channels.Count == 0)
6213 b.Channels.Add(new Channel(0, b.bitsPerPixel, RGBChannelCount));
6214
6215 //Lets check to see the channels are correctly defined in this file
6216 for (int ch = 0; ch < b.Channels.Count; ch++)
6217 {
6218 if (b.Channels[ch].SamplesPerPixel != RGBChannelCount)
6219 {
6220 b.Channels[ch].SamplesPerPixel = RGBChannelCount;
6221 }
6222 }
6223
6224 b.Buffers = new List<Bitmap>();
6225 int pages = image.NumberOfDirectories() / b.seriesCount;
6226 if (!imagej)
6227 b.sizeZ = pages;
6228 int str = image.ScanlineSize();
6229 bool inter = true;
6230 if (stride != str)
6231 inter = false;
6232 InitDirectoryResolution(b, image, imDesc);
6233 if (tiled)
6234 {
6235 Console.WriteLine("Opening tiles.");
6236 if (vips)
6237 OpenVips(b);
6238 for (int t = 0; t < b.SizeT; t++)
6239 {
6240 for (int c = 0; c < b.SizeC; c++)
6241 {
6242 for (int z = 0; z < b.SizeZ; z++)
6243 {
6244 Bitmap bmp = GetTile(b, b.GetFrameIndex(z, c, t), b.level, tileX, tileY, tileSizeX, tileSizeY);
6245 b.Buffers.Add(bmp);
6246 bmp.Stats = Statistics.FromBytes(bmp);
6247 }
6248 }
6249 }
6250 Console.WriteLine("Calculating statisitics.");
6251 }
6252 else
6253 {
6254 for (int p = series * pages; p < (series + 1) * pages; p++)
6255 {
6256 image.SetDirectory((short)p);
6257
6258 byte[] bytes = new byte[stride * SizeY];
6259 for (int im = 0, offset = 0; im < SizeY; im++)
6260 {
6261 image.ReadScanline(bytes, offset, im, 0);
6262 offset += stride;
6263 }
6264 Bitmap inf = new Bitmap(file, SizeX, SizeY, b.Resolutions[series].PixelFormat, bytes, new ZCT(0, 0, 0), p, null, b.littleEndian, inter);
6265 b.Buffers.Add(inf);
6266 inf.Stats = Statistics.FromBytes(inf);
6267 }
6268 }
6269 image.Close();
6270 b.UpdateCoords();
6271 }
6272 else
6273 {
6274 Gdk.Pixbuf pf = new Gdk.Pixbuf(file);
6275 b.littleEndian = BitConverter.IsLittleEndian;
6276 PixelFormat px = GetPixelFormat(pf.NChannels, pf.BitsPerSample);
6277 b.Resolutions.Add(new Resolution(pf.Width, pf.Height, px, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 96 * (1 / 2.54) / 1000, 0, 0, 0));
6278 b.bitsPerPixel = pf.BitsPerSample;
6279 b.Buffers.Add(new Bitmap(pf.Width, pf.Height, pf.Width * pf.NChannels, px, pf.Pixels));
6280 b.Buffers.Last().ID = Bitmap.CreateID(file, 0);
6281 b.Buffers.Last().Stats = Statistics.FromBytes(b.Buffers.Last());
6282 b.Channels.Add(new Channel(0, b.bitsPerPixel, b.RGBChannelCount));
6283 b.Coords = new int[1, 1, 1];
6284 b.sizeC = 1;
6285 b.sizeT = 1;
6286 b.sizeZ = 1;
6287 }
6288 if (b.StageSizeX == -1)
6289 {
6290 b.imageInfo.Series = 0;
6291 b.StageSizeX = 0;
6292 b.StageSizeY = 0;
6293 b.StageSizeZ = 0;
6294 }
6295 b.Volume = new VolumeD(new Point3D(b.StageSizeX, b.StageSizeY, b.StageSizeZ), new Point3D(b.PhysicalSizeX * b.SizeX, b.PhysicalSizeY * b.SizeY, b.PhysicalSizeZ * b.SizeZ));
6296
6297 //If file is ome and we have OME support then check for annotation in metadata.
6298 if (ome)
6299 {
6300 b.Annotations.AddRange(OpenOMEROIs(file, series));
6301 }
6302 AutoThreshold(b, false);
6303 if (b.bitsPerPixel > 8)
6304 b.StackThreshold(true);
6305 else
6306 b.StackThreshold(false);
6307 if (addToImages)
6308 Images.AddImage(b);
6309 //pr.Close();
6310 //pr.Dispose();
6311 st.Stop();
6312 b.loadTimeMS = st.ElapsedMilliseconds;
6313 Console.WriteLine("BioImage loaded " + b.ToString());
6314 BioLib.Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, file, series, tab, addToImages, tile, tileX, tileY, tileSizeX, tileSizeY);
6315 return b;
6316 }
static PixelFormat GetPixelFormat(int rgbChannelCount, int bitsPerPixel)
If the bits per pixel is 8, then the pixel format is either 8bppIndexed, 24bppRgb,...
Definition Bio.cs:8482
static bool VipsSupport(string file)
The function checks if a given file is supported by the Vips library and returns true if it is,...
Definition Bio.cs:8932
static void OpenVips(BioImage b)
The function "OpenVips" takes a BioImage object and an integer representing the number of pages,...
Definition Bio.cs:7300
static Bitmap GetTile(BioImage b, int index, int level, int tilex, int tiley, int tileSizeX, int tileSizeY)
It reads a tile from a file, and returns a bitmap.
Definition Bio.cs:8245

◆ OpenOME() [1/3]

static BioImage BioLib.BioImage.OpenOME ( string file,
bool tab )
static

The function "OpenOME" opens a bioimage file in the OME format and returns the first image in the series.

Parameters
fileThe "file" parameter is a string that represents the file path or name of the OME file that you want to open.
tabThe "tab" parameter is a boolean value that determines whether the image is opened in a new tab.
Returns
The method is returning a BioImage object.

Definition at line 6995 of file Bio.cs.

6996 {
6997 return OpenOMESeries(file, tab, true)[0];
6998 }
static BioImage[] OpenOMESeries(string file, bool tab, bool addToImages)
It opens a file, checks if it's tiled, if it is, it opens it as a tiled image, if not,...
Definition Bio.cs:8539

◆ OpenOME() [2/3]

static BioImage BioLib.BioImage.OpenOME ( string file,
int serie )
static

OpenOME(string file, int serie)

The first parameter is a string, the second is an integer

Parameters
filethe path to the file
seriethe image series to open
Returns
A BioImage object.

Definition at line 7007 of file Bio.cs.

7008 {
7009 return OpenOME(file, serie, true, false, false, 0, 0, 0, 0);
7010 }

◆ OpenOME() [3/3]

static BioImage BioLib.BioImage.OpenOME ( string file,
int serie,
bool tab,
bool addToImages,
bool tile,
int tilex,
int tiley,
int tileSizeX,
int tileSizeY,
bool useOpenSlide = true )
static

The function "OpenOME" opens a bioimage file, with options to specify the series, whether to display it in a tab, whether to add it to existing images, whether to tile the image, and the tile size.

Parameters
fileThe file parameter is a string that represents the file path or name of the OME (Open Microscopy Environment) file that you want to open.
serieThe "serie" parameter is an integer that represents the series number of the image to be opened.
tabThe "tab" parameter is a boolean value that determines whether the image should be opened in a new tab or not. If set to true, the image will be opened in a new tab. If set to false, the image will be opened in the current tab.
addToImagesThe "addToImages" parameter is a boolean value that determines whether the opened image should be added to a collection of images. If set to true, the image will be added to the collection. If set to false, the image will not be added.
tileThe "tile" parameter is a boolean value that determines whether or not to tile the images. If set to true, the images will be tiled according to the specified tilex, tiley, tileSizeX, and tileSizeY parameters. If set to false, the images will not be tiled.
tilexThe parameter "tilex" is an integer that represents the starting x-coordinate of the tile.
tileyThe parameter "tiley" is used to specify the number of tiles in the y-direction when tiling the image.
tileSizeXThe tileSizeX parameter specifies the width of each tile in pixels when tiling the images.
tileSizeYThe tileSizeY parameter is the height of each tile in pixels when tiling the images.

The function "OpenOME" opens a bioimage file, with options to specify the series, whether to

Definition at line 7456 of file Bio.cs.

7457 {
7458 if (file == null || file == "")
7459 throw new InvalidDataException("File is empty or null");
7460 //We wait incase OME has not initialized.
7461 do
7462 {
7463 Thread.Sleep(10);
7464 } while (!initialized);
7465 Console.WriteLine("OpenOME " + file);
7466 reader = new ImageReader();
7467 if (tileSizeX == 0)
7468 tileSizeX = 1920;
7469 if (tileSizeY == 0)
7470 tileSizeY = 1080;
7471 progFile = file;
7472 BioImage b = new BioImage(file);
7473 b.Type = ImageType.stack;
7474 b.Loading = true;
7475 if (b.meta == null)
7476 b.meta = service.createOMEXMLMetadata();
7477 string f = file.Replace("\\", "/");
7478 string cf = reader.getCurrentFile();
7479 if (cf != null)
7480 cf = cf.Replace("\\", "/");
7481 if (cf != f)
7482 {
7483 reader.close();
7484 reader.setMetadataStore(b.meta);
7485 try
7486 {
7487 Status = "Opening file " + b.Filename;
7488 reader.setId(f);
7489 }
7490 catch (Exception e)
7491 {
7492 Console.WriteLine(e.Message);
7493 return null;
7494 }
7495 }
7496
7497 //status = "Reading OME Metadata.";
7498 reader.setSeries(serie);
7499 int RGBChannelCount = reader.getRGBChannelCount();
7500 //OME reader.getBitsPerPixel(); sometimes returns incorrect bits per pixel, like when opening ImageJ images.
7501 //So we check the pixel type from xml metadata and if it fails we use the readers value.
7502 PixelFormat PixelFormat;
7503 try
7504 {
7505 PixelFormat = GetPixelFormat(RGBChannelCount, b.meta.getPixelsType(serie));
7506 }
7507 catch (Exception)
7508 {
7509 PixelFormat = GetPixelFormat(RGBChannelCount, reader.getBitsPerPixel());
7510 }
7511
7512 b.id = file;
7513 b.file = file;
7514 int SizeX, SizeY;
7515 SizeX = reader.getSizeX();
7516 SizeY = reader.getSizeY();
7517 int SizeZ = reader.getSizeZ();
7518 b.sizeC = reader.getSizeC();
7519 b.sizeZ = reader.getSizeZ();
7520 b.sizeT = reader.getSizeT();
7521 b.littleEndian = reader.isLittleEndian();
7522 b.seriesCount = reader.getSeriesCount();
7523 b.imagesPerSeries = reader.getImageCount();
7524 b.imRead = reader;
7525 List<Resolution> ress = new List<Resolution>();
7526 if (PixelFormat == PixelFormat.Format8bppIndexed || PixelFormat == PixelFormat.Format24bppRgb || PixelFormat == PixelFormat.Format32bppArgb)
7527 b.bitsPerPixel = 8;
7528 else
7529 b.bitsPerPixel = 16;
7530 b.series = serie;
7531 string order = reader.getDimensionOrder();
7532 if (vips)
7533 OpenVips(b);
7534 //Lets get the channels and initialize them
7535 int i = 0;
7536 int sumSamples = 0;
7537 while (true)
7538 {
7539 Status = "Reading channels.";
7540 bool def = false;
7541 try
7542 {
7543 int s = b.meta.getChannelSamplesPerPixel(serie, i).getNumberValue().intValue();
7544 Channel ch = new Channel(i, b.bitsPerPixel, s);
7545 if (b.meta.getChannelSamplesPerPixel(serie, i) != null)
7546 {
7547 ch.SamplesPerPixel = s;
7548 sumSamples += s;
7549 def = true;
7550 b.Channels.Add(ch);
7551 }
7552 if (i == 0)
7553 {
7554 b.rgbChannels[0] = 0;
7555 }
7556 else
7557 if (i == 1)
7558 {
7559 b.rgbChannels[1] = 1;
7560 }
7561 else
7562 if (i == 2)
7563 {
7564 b.rgbChannels[2] = 2;
7565 }
7566 //If this channel is not defined we have loaded all the channels in the file.
7567 if (!def)
7568 break;
7569 if (b.meta.getChannelName(serie, i) != null)
7570 ch.Name = b.meta.getChannelName(serie, i);
7571 if (b.meta.getChannelAcquisitionMode(serie, i) != null)
7572 ch.AcquisitionMode = b.meta.getChannelAcquisitionMode(serie, i).ToString();
7573 if (b.meta.getChannelID(serie, i) != null)
7574 ch.info.ID = b.meta.getChannelID(serie, i);
7575 if (b.meta.getChannelFluor(serie, i) != null)
7576 ch.Fluor = b.meta.getChannelFluor(serie, i);
7577 if (b.meta.getChannelColor(serie, i) != null)
7578 {
7579 BioFormats::ome.xml.model.primitives.Color cc = b.meta.getChannelColor(serie, i);
7580 ch.Color = Color.FromArgb(cc.getRed(), cc.getGreen(), cc.getBlue());
7581 }
7582 if (b.meta.getChannelIlluminationType(serie, i) != null)
7583 ch.IlluminationType = b.meta.getChannelIlluminationType(serie, i).ToString();
7584 if (b.meta.getChannelContrastMethod(serie, i) != null)
7585 ch.ContrastMethod = b.meta.getChannelContrastMethod(serie, i).ToString();
7586 if (b.meta.getChannelEmissionWavelength(serie, i) != null)
7587 ch.Emission = b.meta.getChannelEmissionWavelength(serie, i).value().intValue();
7588 if (b.meta.getChannelExcitationWavelength(serie, i) != null)
7589 ch.Excitation = b.meta.getChannelExcitationWavelength(serie, i).value().intValue();
7590 if (b.meta.getLightEmittingDiodePower(serie, i) != null)
7591 ch.LightSourceIntensity = b.meta.getLightEmittingDiodePower(serie, i).value().doubleValue();
7592 if (b.meta.getLightEmittingDiodeID(serie, i) != null)
7593 ch.DiodeName = b.meta.getLightEmittingDiodeID(serie, i);
7594 if (b.meta.getChannelLightSourceSettingsAttenuation(serie, i) != null)
7595 ch.LightSourceAttenuation = b.meta.getChannelLightSourceSettingsAttenuation(serie, i).toString();
7596
7597
7598 }
7599 catch (Exception e)
7600 {
7601 Console.WriteLine(e.Message);
7602 if (!def)
7603 break;
7604 }
7605 i++;
7606 }
7607 try
7608 {
7609 if (b.meta.getObjectiveNominalMagnification(serie, 0) != null)
7610 {
7611 b.Magnification = b.meta.getObjectiveNominalMagnification(serie, 0).intValue();
7612 }
7613 }
7614 catch (Exception e)
7615 {
7616 Console.WriteLine(e.Message);
7617 }
7618
7619 //If the file doens't have channels we initialize them.
7620 if (b.Channels.Count == 0)
7621 {
7622 b.Channels.Add(new Channel(0, b.bitsPerPixel, RGBChannelCount));
7623 }
7624 try
7625 {
7626 Status = "Reading wells.";
7627 int wells = b.meta.getWellCount(0);
7628 if (wells > 0)
7629 {
7630 b.Type = ImageType.well;
7631 b.Plate = new WellPlate(b);
7632 tile = false;
7633 }
7634 }
7635 catch (Exception e)
7636 {
7637 //This file is not a well plate.
7638 Console.WriteLine(e.Message);
7639 }
7640 if (reader.getResolutionCount() > 0)
7641 ress.AddRange(GetResolutions(b));
7642 Console.WriteLine("Done reading resolutions.");
7643 reader.setSeries(serie);
7644
7645 int pyramidCount = 0;
7646 int pyramidResolutions = 0;
7647 List<Tuple<int, int>> prs = new List<Tuple<int, int>>();
7648 Console.WriteLine("Determining pyramidal levels.");
7649 //We need to determine if this image is pyramidal or not.
7650 //We do this by seeing if the resolutions are downsampled or not.
7651 if (ress.Count > 1 && b.Type != ImageType.well)
7652 {
7653 if (ress[0].SizeX > ress[1].SizeX)
7654 {
7655 b.Type = ImageType.pyramidal;
7656 tile = true;
7657 //We need to determine number of pyramids in this image and which belong to the series we are opening.
7658 int? sr = null;
7659 for (int r = 0; r < ress.Count - 1; r++)
7660 {
7661 if (ress[r].SizeX > ress[r + 1].SizeX && ress[r].PixelFormat == ress[r + 1].PixelFormat)
7662 {
7663 if (sr == null)
7664 {
7665 sr = r;
7666 prs.Add(new Tuple<int, int>(r, 0));
7667 }
7668 }
7669 else
7670 {
7671 if (ress[prs[prs.Count - 1].Item1].PixelFormat == ress[r].PixelFormat)
7672 prs[prs.Count - 1] = new Tuple<int, int>(prs[prs.Count - 1].Item1, r);
7673 sr = null;
7674 }
7675 }
7676 pyramidCount = prs.Count;
7677 for (int p = 0; p < prs.Count; p++)
7678 {
7679 pyramidResolutions += (prs[p].Item2 - prs[p].Item1) + 1;
7680 }
7681 if (prs[serie].Item2 == 0)
7682 {
7683 prs[serie] = new Tuple<int, int>(prs[serie].Item1, b.seriesCount - 1);
7684 }
7685 }
7686 }
7687 if (b.Type == ImageType.pyramidal)
7688 {
7689 Console.WriteLine("Determining Label and Macro resolutions.");
7690 for (int p = 0; p < prs.Count; p++)
7691 {
7692 for (int r = prs[p].Item1; r < prs[p].Item2 + 1; r++)
7693 {
7694 b.Resolutions.Add(ress[r]);
7695 }
7696 }
7697 //If we have 2 resolutions that we're not added they are the label & macro resolutions so we add them to the image.
7698 if (ress.Count > b.Resolutions.Count)
7699 {
7700 b.LabelResolution = ress.Count - 1;
7701 b.Resolutions.Add(ress[ress.Count - 1]);
7702 b.MacroResolution = ress.Count - 2;
7703 b.Resolutions.Add(ress[ress.Count - 2]);
7704 }
7705 }
7706 if (b.Resolutions.Count == 0)
7707 b.Resolutions.AddRange(ress);
7708 try
7709 {
7710 string s = b.meta.getStageLabelName(serie);
7711 if (s != null)
7712 {
7713 b.StageSizeX = b.meta.getStageLabelX(serie).value().doubleValue();
7714 b.StageSizeY = b.meta.getStageLabelY(serie).value().doubleValue();
7715 b.StageSizeZ = b.meta.getStageLabelZ(serie).value().doubleValue();
7716 }
7717 }
7718 catch (Exception e)
7719 {
7720 Console.WriteLine("No Stage Cooordinates");
7721 }
7722
7723 b.Volume = new VolumeD(new Point3D(b.StageSizeX, b.StageSizeY, b.StageSizeZ), new Point3D(b.PhysicalSizeX * SizeX, b.PhysicalSizeY * SizeY, b.PhysicalSizeZ * SizeZ));
7724 int rc = b.meta.getROICount();
7725 for (int im = 0; im < rc; im++)
7726 {
7727 string roiID = b.meta.getROIID(im);
7728 string roiName = b.meta.getROIName(im);
7729 ZCT co = new ZCT(0, 0, 0);
7730 int scount = 1;
7731 try
7732 {
7733 scount = b.meta.getShapeCount(im);
7734 }
7735 catch (Exception e)
7736 {
7737 Console.WriteLine(e.Message.ToString());
7738 }
7739 for (int sc = 0; sc < scount; sc++)
7740 {
7741 Status = "Reading ROI " + (sc + 1).ToString() + "/" + scount;
7742 string typ = b.meta.getShapeType(im, sc);
7743 ROI an = new ROI();
7744 an.roiID = roiID;
7745 an.roiName = roiName;
7746 an.shapeIndex = sc;
7747 if (typ == "Point")
7748 {
7749 an.type = ROI.Type.Point;
7750 an.id = b.meta.getPointID(im, sc);
7751 double dx = b.meta.getPointX(im, sc).doubleValue();
7752 double dy = b.meta.getPointY(im, sc).doubleValue();
7753 an.AddPoint(b.ToStageSpace(new PointD(dx, dy)));
7754 an.coord = new ZCT();
7755 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getPointTheZ(im, sc);
7756 if (nz != null)
7757 an.coord.Z = nz.getNumberValue().intValue();
7758 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getPointTheC(im, sc);
7759 if (nc != null)
7760 an.coord.C = nc.getNumberValue().intValue();
7761 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getPointTheT(im, sc);
7762 if (nt != null)
7763 an.coord.T = nt.getNumberValue().intValue();
7764 an.Text = b.meta.getPointText(im, sc);
7765 BioFormats::ome.units.quantity.Length fl = b.meta.getPointFontSize(im, sc);
7766 if (fl != null)
7767 an.fontSize = fl.value().intValue();
7768 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getPointFontFamily(im, sc);
7769 if (ff != null)
7770 an.family = ff.name();
7771 BioFormats::ome.xml.model.primitives.Color col = b.meta.getPointStrokeColor(im, sc);
7772 if (col != null)
7773 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
7774 BioFormats::ome.units.quantity.Length fw = b.meta.getPointStrokeWidth(im, sc);
7775 if (fw != null)
7776 an.strokeWidth = (float)fw.value().floatValue();
7777 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getPointStrokeColor(im, sc);
7778 if (colf != null)
7779 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
7780 }
7781 else
7782 if (typ == "Line")
7783 {
7784 an.type = ROI.Type.Line;
7785 an.id = b.meta.getLineID(im, sc);
7786 double px1 = b.meta.getLineX1(im, sc).doubleValue();
7787 double py1 = b.meta.getLineY1(im, sc).doubleValue();
7788 double px2 = b.meta.getLineX2(im, sc).doubleValue();
7789 double py2 = b.meta.getLineY2(im, sc).doubleValue();
7790 an.AddPoint(b.ToStageSpace(new PointD(px1, py1)));
7791 an.AddPoint(b.ToStageSpace(new PointD(px2, py2)));
7792 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getLineTheZ(im, sc);
7793 if (nz != null)
7794 co.Z = nz.getNumberValue().intValue();
7795 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getLineTheC(im, sc);
7796 if (nc != null)
7797 co.C = nc.getNumberValue().intValue();
7798 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getLineTheT(im, sc);
7799 if (nt != null)
7800 co.T = nt.getNumberValue().intValue();
7801 an.coord = co;
7802 an.Text = b.meta.getLineText(im, sc);
7803 BioFormats::ome.units.quantity.Length fl = b.meta.getLineFontSize(im, sc);
7804 if (fl != null)
7805 an.fontSize = fl.value().intValue();
7806 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getLineFontFamily(im, sc);
7807 if (ff != null)
7808 an.family = ff.name();
7809 BioFormats::ome.xml.model.primitives.Color col = b.meta.getLineStrokeColor(im, sc);
7810 if (col != null)
7811 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
7812 BioFormats::ome.units.quantity.Length fw = b.meta.getLineStrokeWidth(im, sc);
7813 if (fw != null)
7814 an.strokeWidth = (float)fw.value().floatValue();
7815 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getLineFillColor(im, sc);
7816 if (colf != null)
7817 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
7818 }
7819 else
7820 if (typ == "Rectangle")
7821 {
7822 an.type = ROI.Type.Rectangle;
7823 an.id = b.meta.getRectangleID(im, sc);
7824 double px = b.meta.getRectangleX(im, sc).doubleValue();
7825 double py = b.meta.getRectangleY(im, sc).doubleValue();
7826 double pw = b.meta.getRectangleWidth(im, sc).doubleValue();
7827 double ph = b.meta.getRectangleHeight(im, sc).doubleValue();
7828 an.Rect = b.ToStageSpace(new RectangleD(px, py, pw, ph));
7829 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getRectangleTheZ(im, sc);
7830 if (nz != null)
7831 co.Z = nz.getNumberValue().intValue();
7832 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getRectangleTheC(im, sc);
7833 if (nc != null)
7834 co.C = nc.getNumberValue().intValue();
7835 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getRectangleTheT(im, sc);
7836 if (nt != null)
7837 co.T = nt.getNumberValue().intValue();
7838 an.coord = co;
7839
7840 an.Text = b.meta.getRectangleText(im, sc);
7841 BioFormats::ome.units.quantity.Length fl = b.meta.getRectangleFontSize(im, sc);
7842 if (fl != null)
7843 an.fontSize = fl.value().intValue();
7844 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getRectangleFontFamily(im, sc);
7845 if (ff != null)
7846 an.family = ff.name();
7847 BioFormats::ome.xml.model.primitives.Color col = b.meta.getRectangleStrokeColor(im, sc);
7848 if (col != null)
7849 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
7850 BioFormats::ome.units.quantity.Length fw = b.meta.getRectangleStrokeWidth(im, sc);
7851 if (fw != null)
7852 an.strokeWidth = (float)fw.value().floatValue();
7853 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getRectangleFillColor(im, sc);
7854 if (colf != null)
7855 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
7856 BioFormats::ome.xml.model.enums.FillRule fr = b.meta.getRectangleFillRule(im, sc);
7857
7858 }
7859 else
7860 if (typ == "Ellipse")
7861 {
7862 an.type = ROI.Type.Ellipse;
7863 an.id = b.meta.getEllipseID(im, sc);
7864 double px = b.meta.getEllipseX(im, sc).doubleValue();
7865 double py = b.meta.getEllipseY(im, sc).doubleValue();
7866 double ew = b.meta.getEllipseRadiusX(im, sc).doubleValue();
7867 double eh = b.meta.getEllipseRadiusY(im, sc).doubleValue();
7868 //We convert the ellipse radius to Rectangle
7869 double w = ew * 2;
7870 double h = eh * 2;
7871 double x = px - ew;
7872 double y = py - eh;
7873 an.Rect = b.ToStageSpace(new RectangleD(x, y, w, h));
7874 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getEllipseTheZ(im, sc);
7875 if (nz != null)
7876 co.Z = nz.getNumberValue().intValue();
7877 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getEllipseTheC(im, sc);
7878 if (nc != null)
7879 co.C = nc.getNumberValue().intValue();
7880 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getEllipseTheT(im, sc);
7881 if (nt != null)
7882 co.T = nt.getNumberValue().intValue();
7883 an.coord = co;
7884 an.Text = b.meta.getEllipseText(im, sc);
7885 BioFormats::ome.units.quantity.Length fl = b.meta.getEllipseFontSize(im, sc);
7886 if (fl != null)
7887 an.fontSize = fl.value().intValue();
7888 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getEllipseFontFamily(im, sc);
7889 if (ff != null)
7890 an.family = ff.name();
7891 BioFormats::ome.xml.model.primitives.Color col = b.meta.getEllipseStrokeColor(im, sc);
7892 if (col != null)
7893 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
7894 BioFormats::ome.units.quantity.Length fw = b.meta.getEllipseStrokeWidth(im, sc);
7895 if (fw != null)
7896 an.strokeWidth = (float)fw.value().floatValue();
7897 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getEllipseFillColor(im, sc);
7898 if (colf != null)
7899 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
7900 }
7901 else
7902 if (typ == "Polygon")
7903 {
7904 an.type = ROI.Type.Polygon;
7905 an.id = b.meta.getPolygonID(im, sc);
7906 an.closed = true;
7907 string pxs = b.meta.getPolygonPoints(im, sc);
7908 PointD[] pts = an.stringToPoints(pxs);
7909 pts = b.ToStageSpace(pts);
7910 if (pts.Length > 100)
7911 {
7912 an.type = ROI.Type.Freeform;
7913 }
7914 an.AddPoints(pts);
7915 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getPolygonTheZ(im, sc);
7916 if (nz != null)
7917 co.Z = nz.getNumberValue().intValue();
7918 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getPolygonTheC(im, sc);
7919 if (nc != null)
7920 co.C = nc.getNumberValue().intValue();
7921 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getPolygonTheT(im, sc);
7922 if (nt != null)
7923 co.T = nt.getNumberValue().intValue();
7924 an.coord = co;
7925 an.Text = b.meta.getPolygonText(im, sc);
7926 BioFormats::ome.units.quantity.Length fl = b.meta.getPolygonFontSize(im, sc);
7927 if (fl != null)
7928 an.fontSize = fl.value().intValue();
7929 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getPolygonFontFamily(im, sc);
7930 if (ff != null)
7931 an.family = ff.name();
7932 BioFormats::ome.xml.model.primitives.Color col = b.meta.getPolygonStrokeColor(im, sc);
7933 if (col != null)
7934 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
7935 BioFormats::ome.units.quantity.Length fw = b.meta.getPolygonStrokeWidth(im, sc);
7936 if (fw != null)
7937 an.strokeWidth = (float)fw.value().floatValue();
7938 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getPolygonFillColor(im, sc);
7939 if (colf != null)
7940 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
7941 }
7942 else
7943 if (typ == "Polyline")
7944 {
7945 an.type = ROI.Type.Polyline;
7946 an.id = b.meta.getPolylineID(im, sc);
7947 string pxs = b.meta.getPolylinePoints(im, sc);
7948 PointD[] pts = an.stringToPoints(pxs);
7949 for (int pi = 0; pi < pts.Length; pi++)
7950 {
7951 pts[pi] = b.ToStageSpace(pts[pi]);
7952 }
7953 an.AddPoints(an.stringToPoints(pxs));
7954 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getPolylineTheZ(im, sc);
7955 if (nz != null)
7956 co.Z = nz.getNumberValue().intValue();
7957 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getPolylineTheC(im, sc);
7958 if (nc != null)
7959 co.C = nc.getNumberValue().intValue();
7960 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getPolylineTheT(im, sc);
7961 if (nt != null)
7962 co.T = nt.getNumberValue().intValue();
7963 an.coord = co;
7964 an.Text = b.meta.getPolylineText(im, sc);
7965 BioFormats::ome.units.quantity.Length fl = b.meta.getPolylineFontSize(im, sc);
7966 if (fl != null)
7967 an.fontSize = fl.value().intValue();
7968 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getPolylineFontFamily(im, sc);
7969 if (ff != null)
7970 an.family = ff.name();
7971 BioFormats::ome.xml.model.primitives.Color col = b.meta.getPolylineStrokeColor(im, sc);
7972 if (col != null)
7973 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
7974 BioFormats::ome.units.quantity.Length fw = b.meta.getPolylineStrokeWidth(im, sc);
7975 if (fw != null)
7976 an.strokeWidth = (float)fw.value().floatValue();
7977 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getPolylineFillColor(im, sc);
7978 if (colf != null)
7979 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
7980 }
7981 else
7982 if (typ == "Label")
7983 {
7984 an.type = ROI.Type.Label;
7985 an.id = b.meta.getLabelID(im, sc);
7986
7987 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getLabelTheZ(im, sc);
7988 if (nz != null)
7989 co.Z = nz.getNumberValue().intValue();
7990 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getLabelTheC(im, sc);
7991 if (nc != null)
7992 co.C = nc.getNumberValue().intValue();
7993 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getLabelTheT(im, sc);
7994 if (nt != null)
7995 co.T = nt.getNumberValue().intValue();
7996 an.coord = co;
7997
7998 BioFormats::ome.units.quantity.Length fl = b.meta.getLabelFontSize(im, sc);
7999 if (fl != null)
8000 an.fontSize = fl.value().intValue();
8001 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getLabelFontFamily(im, sc);
8002 if (ff != null)
8003 an.family = ff.name();
8004 BioFormats::ome.xml.model.primitives.Color col = b.meta.getLabelStrokeColor(im, sc);
8005 if (col != null)
8006 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
8007 BioFormats::ome.units.quantity.Length fw = b.meta.getLabelStrokeWidth(im, sc);
8008 if (fw != null)
8009 an.strokeWidth = (float)fw.value().floatValue();
8010 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getLabelFillColor(im, sc);
8011 if (colf != null)
8012 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
8013 PointD p = new PointD(b.meta.getLabelX(im, sc).doubleValue(), b.meta.getLabelY(im, sc).doubleValue());
8014 an.AddPoint(b.ToStageSpace(p));
8015 an.Text = b.meta.getLabelText(im, sc);
8016 }
8017 else
8018 if (typ == "Mask")
8019 {
8020 byte[] bts = b.meta.getMaskBinData(im, sc);
8021 bool end = b.meta.getMaskBinDataBigEndian(im, sc).booleanValue();
8022 double h = b.meta.getMaskHeight(im, sc).doubleValue();
8023 double w = b.meta.getMaskWidth(im, sc).doubleValue();
8024 double x = b.meta.getMaskX(im, sc).doubleValue();
8025 double y = b.meta.getMaskY(im, sc).doubleValue();
8026 an = ROI.CreateMask(co, bts, (int)Math.Round(w / b.PhysicalSizeX), (int)Math.Round(h / b.PhysicalSizeY), new PointD(x * b.PhysicalSizeX, y * b.PhysicalSizeY), b.PhysicalSizeX, b.PhysicalSizeY);
8027 an.Text = b.meta.getMaskText(im, sc);
8028 an.id = b.meta.getMaskID(im, sc);
8029 an.Rect = new RectangleD(an.X, an.Y, an.W, an.H);
8030 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = b.meta.getMaskTheZ(im, sc);
8031 if (nz != null)
8032 co.Z = nz.getNumberValue().intValue();
8033 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = b.meta.getMaskTheC(im, sc);
8034 if (nc != null)
8035 co.C = nc.getNumberValue().intValue();
8036 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = b.meta.getMaskTheT(im, sc);
8037 if (nt != null)
8038 co.T = nt.getNumberValue().intValue();
8039 an.coord = co;
8040
8041 BioFormats::ome.units.quantity.Length fl = b.meta.getMaskFontSize(im, sc);
8042 if (fl != null)
8043 an.fontSize = fl.value().intValue();
8044 BioFormats::ome.xml.model.enums.FontFamily ff = b.meta.getMaskFontFamily(im, sc);
8045 if (ff != null)
8046 an.family = ff.name();
8047 BioFormats::ome.xml.model.primitives.Color col = b.meta.getMaskStrokeColor(im, sc);
8048 if (col != null)
8049 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
8050 BioFormats::ome.units.quantity.Length fw = b.meta.getMaskStrokeWidth(im, sc);
8051 if (fw != null)
8052 an.strokeWidth = (float)fw.value().floatValue();
8053 BioFormats::ome.xml.model.primitives.Color colf = b.meta.getMaskFillColor(im, sc);
8054 if (colf != null)
8055 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
8056 }
8057 b.Annotations.Add(an);
8058 }
8059 }
8060
8061 List<string> serFiles = new List<string>();
8062 serFiles.AddRange(reader.getSeriesUsedFiles());
8063
8064 b.Buffers = new List<Bitmap>();
8065 if (b.Type == ImageType.pyramidal)
8066 {
8067
8068 try
8069 {
8070
8071 string st = OpenSlideImage.DetectVendor(file);
8072 if (st != null && !file.EndsWith("ome.tif") && useOpenSlide)
8073 {
8074 Status = "Opening file with OpenSlide.";
8075 b.openSlideImage = OpenSlideImage.Open(file);
8076 b.openslideBase = (OpenSlideBase)OpenSlideGTK.SlideSourceBase.Create(file, true);
8077 }
8078 else
8079 {
8080 Status = "Opening file with BioFormats.";
8081 b.slideBase = new SlideBase(b, SlideImage.Open(b));
8082 }
8083 }
8084 catch (Exception e)
8085 {
8086 Console.WriteLine(e.Message.ToString());
8087 b.slideBase = new SlideBase(b, SlideImage.Open(b));
8088 }
8089 tile = true;
8090 }
8091 // read the image data bytes
8092 int pages = reader.getImageCount();
8093 bool inter = reader.isInterleaved();
8094 int z = 0;
8095 int c = 0;
8096 int t = 0;
8097 if (!tile)
8098 {
8099 Status = "Reading image planes.";
8100 try
8101 {
8102 for (int p = 0; p < pages; p++)
8103 {
8104 Progress = ((float)p / (float)pages) * 100;
8105 Bitmap bf;
8106 byte[] bytes = reader.openBytes(p);
8107 bf = new Bitmap(file, SizeX, SizeY, PixelFormat, bytes, new ZCT(z, c, t), p, null, b.littleEndian, inter);
8108 b.Buffers.Add(bf);
8109 }
8110 }
8111 catch (Exception ex)
8112 {
8113 Console.WriteLine(ex.Message);
8114 }
8115
8116 }
8117 else
8118 {
8119 Status = "Reading tiles.";
8120 b.imRead = reader;
8121 for (int p = 0; p < pages; p++)
8122 {
8123 Progress = ((float)p / (float)pages) * 100;
8124 b.Buffers.Add(GetTile(b, p, b.Level, tilex, tiley, tileSizeX, tileSizeY));
8125 }
8126 }
8127 int pls;
8128 try
8129 {
8130 pls = b.meta.getPlaneCount(serie);
8131 }
8132 catch (Exception)
8133 {
8134 pls = 0;
8135 }
8136 if (pls == b.Buffers.Count)
8137 for (int bi = 0; bi < b.Buffers.Count; bi++)
8138 {
8139 Plane pl = new Plane();
8140 pl.Coordinate = new ZCT();
8141 double px = 0; double py = 0; double pz = 0;
8142 if (b.meta.getPlanePositionX(serie, bi) != null)
8143 px = b.meta.getPlanePositionX(serie, bi).value().doubleValue();
8144 if (b.meta.getPlanePositionY(serie, bi) != null)
8145 py = b.meta.getPlanePositionY(serie, bi).value().doubleValue();
8146 if (b.meta.getPlanePositionZ(serie, bi) != null)
8147 pz = b.meta.getPlanePositionZ(serie, bi).value().doubleValue();
8148 pl.Location = new AForge.Point3D(px, py, pz);
8149 int cc = 0; int zc = 0; int tc = 0;
8150 if (b.meta.getPlaneTheC(serie, bi) != null)
8151 cc = b.meta.getPlaneTheC(serie, bi).getNumberValue().intValue();
8152 if (b.meta.getPlaneTheZ(serie, bi) != null)
8153 zc = b.meta.getPlaneTheZ(serie, bi).getNumberValue().intValue();
8154 if (b.meta.getPlaneTheT(serie, bi) != null)
8155 tc = b.meta.getPlaneTheT(serie, bi).getNumberValue().intValue();
8156 pl.Coordinate = new ZCT(zc, cc, tc);
8157 if (b.meta.getPlaneDeltaT(serie, bi) != null)
8158 pl.Delta = b.meta.getPlaneDeltaT(serie, bi).value().doubleValue();
8159 if (b.meta.getPlaneExposureTime(serie, bi) != null)
8160 pl.Exposure = b.meta.getPlaneExposureTime(serie, bi).value().doubleValue();
8161 b.Buffers[bi].Plane = pl;
8162 }
8163 //Bioformats gives a size of 3 for C when saved in ImageJ as RGB. We need to correct for this as C should be 1 for RGB.
8164 if (RGBChannelCount >= 3)
8165 {
8166 b.sizeC = sumSamples / b.Channels[0].SamplesPerPixel;
8167 }
8168 string ord = reader.getDimensionOrder();
8169 if (ord == "XYZCT")
8170 b.UpdateCoords(b.SizeZ, b.SizeC, b.SizeT, Order.ZCT);
8171 else if (ord == "XYCZT")
8172 b.UpdateCoords(b.SizeZ, b.SizeC, b.SizeT, Order.CZT);
8173 else if (ord == "XYTCZ")
8174 b.UpdateCoords(b.SizeZ, b.SizeC, b.SizeT, Order.TCZ);
8175 AutoThreshold(b, true);
8176 if (b.bitsPerPixel > 8)
8177 b.StackThreshold(true);
8178 else
8179 b.StackThreshold(false);
8180 try
8181 {
8182 if (b.Type == ImageType.stack)
8183 reader.close();
8184 if (addToImages)
8185 Images.AddImage(b);
8186 }
8187 catch (Exception e)
8188 {
8189 Console.WriteLine(e.Message);
8190 }
8191 b.Loading = false;
8192 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, file, serie, tab, addToImages, tile, tilex, tiley, tileSizeX, tileSizeY);
8193 return b;
8194 }
override string ToString()
This function returns the filename of the object, and the location of the object in the 3D space.
Definition Bio.cs:9813

◆ OpenOMEROIs()

static List< ROI > BioLib.BioImage.OpenOMEROIs ( string file,
int series )
static

It reads the OME-XML file and converts the ROIs to a list of ROI objects.

Parameters
filethe path to the OME-TIFF file
seriesthe series number of the image you want to open
Returns
A list of ROI objects.

Definition at line 8979 of file Bio.cs.

8980 {
8981 List<ROI> Annotations = new List<ROI>();
8982 // create OME-XML metadata store
8983 ServiceFactory factory = new ServiceFactory();
8984 OMEXMLService service = (OMEXMLService)factory.getInstance(typeof(OMEXMLService));
8985 BioFormats::loci.formats.ome.OMEXMLMetadata meta = service.createOMEXMLMetadata();
8986 // create format reader
8987 ImageReader imageReader = new ImageReader();
8988 imageReader.setMetadataStore(meta);
8989 // initialize file
8990 file = file.Replace("\\", "/");
8991 imageReader.setId(file);
8992 int imageCount = imageReader.getImageCount();
8993 int seriesCount = imageReader.getSeriesCount();
8994 double physicalSizeX = 0;
8995 double physicalSizeY = 0;
8996 double physicalSizeZ = 0;
8997 double stageSizeX = 0;
8998 double stageSizeY = 0;
8999 double stageSizeZ = 0;
9000 int SizeX = imageReader.getSizeX();
9001 int SizeY = imageReader.getSizeY();
9002 int SizeZ = imageReader.getSizeY();
9003 try
9004 {
9005 bool hasPhysical = false;
9006 if (meta.getPixelsPhysicalSizeX(series) != null)
9007 {
9008 physicalSizeX = meta.getPixelsPhysicalSizeX(series).value().doubleValue();
9009 hasPhysical = true;
9010 }
9011 if (meta.getPixelsPhysicalSizeY(series) != null)
9012 {
9013 physicalSizeY = meta.getPixelsPhysicalSizeY(series).value().doubleValue();
9014 }
9015 if (meta.getPixelsPhysicalSizeZ(series) != null)
9016 {
9017 physicalSizeZ = meta.getPixelsPhysicalSizeZ(series).value().doubleValue();
9018 }
9019 else
9020 {
9021 physicalSizeZ = 1;
9022 }
9023 if (meta.getStageLabelX(series) != null)
9024 stageSizeX = meta.getStageLabelX(series).value().doubleValue();
9025 if (meta.getStageLabelY(series) != null)
9026 stageSizeY = meta.getStageLabelY(series).value().doubleValue();
9027 if (meta.getStageLabelZ(series) != null)
9028 stageSizeZ = meta.getStageLabelZ(series).value().doubleValue();
9029 else
9030 stageSizeZ = 1;
9031 }
9032 catch (Exception e)
9033 {
9034 stageSizeX = 0;
9035 stageSizeY = 0;
9036 stageSizeZ = 1;
9037 }
9038 VolumeD volume = new VolumeD(new Point3D(stageSizeX, stageSizeY, stageSizeZ), new Point3D(physicalSizeX * SizeX, physicalSizeY * SizeY, physicalSizeZ * SizeZ));
9039 int rc = meta.getROICount();
9040 for (int im = 0; im < rc; im++)
9041 {
9042 string roiID = meta.getROIID(im);
9043 string roiName = meta.getROIName(im);
9044 ZCT co = new ZCT(0, 0, 0);
9045 int scount = 1;
9046 try
9047 {
9048 scount = meta.getShapeCount(im);
9049 }
9050 catch (Exception e)
9051 {
9052 Console.WriteLine(e.Message.ToString());
9053 }
9054 for (int sc = 0; sc < scount; sc++)
9055 {
9056 string type = meta.getShapeType(im, sc);
9057 ROI an = new ROI();
9058 an.roiID = roiID;
9059 an.roiName = roiName;
9060 an.shapeIndex = sc;
9061 if (type == "Point")
9062 {
9063 an.type = ROI.Type.Point;
9064 an.id = meta.getPointID(im, sc);
9065 double dx = meta.getPointX(im, sc).doubleValue();
9066 double dy = meta.getPointY(im, sc).doubleValue();
9067 an.AddPoint(ToStageSpace(new PointD(dx, dy), physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y));
9068 an.coord = new ZCT();
9069 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getPointTheZ(im, sc);
9070 if (nz != null)
9071 an.coord.Z = nz.getNumberValue().intValue();
9072 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getPointTheC(im, sc);
9073 if (nc != null)
9074 an.coord.C = nc.getNumberValue().intValue();
9075 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getPointTheT(im, sc);
9076 if (nt != null)
9077 an.coord.T = nt.getNumberValue().intValue();
9078 an.Text = meta.getPointText(im, sc);
9079 BioFormats::ome.units.quantity.Length fl = meta.getPointFontSize(im, sc);
9080 if (fl != null)
9081 an.fontSize = fl.value().intValue();
9082 an.family = meta.getPointFontFamily(im, sc).name();
9083 BioFormats::ome.xml.model.primitives.Color col = meta.getPointStrokeColor(im, sc);
9084 if (col != null)
9085 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9086 BioFormats::ome.units.quantity.Length fw = meta.getPointStrokeWidth(im, sc);
9087 if (fw != null)
9088 an.strokeWidth = (float)fw.value().floatValue();
9089 BioFormats::ome.xml.model.primitives.Color colf = meta.getPointStrokeColor(im, sc);
9090 if (colf != null)
9091 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9092 }
9093 else
9094 if (type == "Line")
9095 {
9096 an.type = ROI.Type.Line;
9097 an.id = meta.getLineID(im, sc);
9098 double px1 = meta.getLineX1(im, sc).doubleValue();
9099 double py1 = meta.getLineY1(im, sc).doubleValue();
9100 double px2 = meta.getLineX2(im, sc).doubleValue();
9101 double py2 = meta.getLineY2(im, sc).doubleValue();
9102 an.AddPoint(ToStageSpace(new PointD(px1, py1), physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y));
9103 an.AddPoint(ToStageSpace(new PointD(px2, py2), physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y));
9104 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getLineTheZ(im, sc);
9105 if (nz != null)
9106 co.Z = nz.getNumberValue().intValue();
9107 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getLineTheC(im, sc);
9108 if (nc != null)
9109 co.C = nc.getNumberValue().intValue();
9110 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getLineTheT(im, sc);
9111 if (nt != null)
9112 co.T = nt.getNumberValue().intValue();
9113 an.coord = co;
9114 an.Text = meta.getLineText(im, sc);
9115 BioFormats::ome.units.quantity.Length fl = meta.getLineFontSize(im, sc);
9116 if (fl != null)
9117 an.fontSize = fl.value().intValue();
9118 an.family = meta.getPointFontFamily(im, sc).name();
9119 BioFormats::ome.xml.model.primitives.Color col = meta.getLineStrokeColor(im, sc);
9120 if (col != null)
9121 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9122 BioFormats::ome.units.quantity.Length fw = meta.getLineStrokeWidth(im, sc);
9123 if (fw != null)
9124 an.strokeWidth = (float)fw.value().floatValue();
9125 BioFormats::ome.xml.model.primitives.Color colf = meta.getLineFillColor(im, sc);
9126 if (colf != null)
9127 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9128 }
9129 else
9130 if (type == "Rectangle")
9131 {
9132 an.type = ROI.Type.Rectangle;
9133 an.id = meta.getRectangleID(im, sc);
9134 double px = meta.getRectangleX(im, sc).doubleValue();
9135 double py = meta.getRectangleY(im, sc).doubleValue();
9136 double pw = meta.getRectangleWidth(im, sc).doubleValue();
9137 double ph = meta.getRectangleHeight(im, sc).doubleValue();
9138 an.Rect = ToStageSpace(new RectangleD(px, py, pw, ph), physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y);
9139 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getRectangleTheZ(im, sc);
9140 if (nz != null)
9141 co.Z = nz.getNumberValue().intValue();
9142 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getRectangleTheC(im, sc);
9143 if (nc != null)
9144 co.C = nc.getNumberValue().intValue();
9145 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getRectangleTheT(im, sc);
9146 if (nt != null)
9147 co.T = nt.getNumberValue().intValue();
9148 an.coord = co;
9149
9150 an.Text = meta.getRectangleText(im, sc);
9151 BioFormats::ome.units.quantity.Length fl = meta.getRectangleFontSize(im, sc);
9152 if (fl != null)
9153 an.fontSize = fl.value().intValue();
9154 an.family = meta.getPointFontFamily(im, sc).name();
9155 BioFormats::ome.xml.model.primitives.Color col = meta.getRectangleStrokeColor(im, sc);
9156 if (col != null)
9157 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9158 BioFormats::ome.units.quantity.Length fw = meta.getRectangleStrokeWidth(im, sc);
9159 if (fw != null)
9160 an.strokeWidth = (float)fw.value().floatValue();
9161 BioFormats::ome.xml.model.primitives.Color colf = meta.getRectangleFillColor(im, sc);
9162 if (colf != null)
9163 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9164 BioFormats::ome.xml.model.enums.FillRule fr = meta.getRectangleFillRule(im, sc);
9165 }
9166 else
9167 if (type == "Ellipse")
9168 {
9169 an.type = ROI.Type.Ellipse;
9170 an.id = meta.getEllipseID(im, sc);
9171 double px = meta.getEllipseX(im, sc).doubleValue();
9172 double py = meta.getEllipseY(im, sc).doubleValue();
9173 double ew = meta.getEllipseRadiusX(im, sc).doubleValue();
9174 double eh = meta.getEllipseRadiusY(im, sc).doubleValue();
9175 //We convert the ellipse radius to Rectangle
9176 double w = ew * 2;
9177 double h = eh * 2;
9178 double x = px - ew;
9179 double y = py - eh;
9180 an.Rect = ToStageSpace(new RectangleD(px, py, w, h), physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y);
9181 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getEllipseTheZ(im, sc);
9182 if (nz != null)
9183 co.Z = nz.getNumberValue().intValue();
9184 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getEllipseTheC(im, sc);
9185 if (nc != null)
9186 co.C = nc.getNumberValue().intValue();
9187 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getEllipseTheT(im, sc);
9188 if (nt != null)
9189 co.T = nt.getNumberValue().intValue();
9190 an.coord = co;
9191 an.Text = meta.getEllipseText(im, sc);
9192 BioFormats::ome.units.quantity.Length fl = meta.getEllipseFontSize(im, sc);
9193 if (fl != null)
9194 an.fontSize = fl.value().intValue();
9195 an.family = meta.getPointFontFamily(im, sc).name();
9196 BioFormats::ome.xml.model.primitives.Color col = meta.getEllipseStrokeColor(im, sc);
9197 if (col != null)
9198 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9199 BioFormats::ome.units.quantity.Length fw = meta.getEllipseStrokeWidth(im, sc);
9200 if (fw != null)
9201 an.strokeWidth = (float)fw.value().floatValue();
9202 BioFormats::ome.xml.model.primitives.Color colf = meta.getEllipseFillColor(im, sc);
9203 if (colf != null)
9204 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9205 }
9206 else
9207 if (type == "Polygon")
9208 {
9209 an.type = ROI.Type.Polygon;
9210 an.id = meta.getPolygonID(im, sc);
9211 an.closed = true;
9212 string pxs = meta.getPolygonPoints(im, sc);
9213 PointD[] pts = an.stringToPoints(pxs);
9214 pts = ToStageSpace(pts, physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y);
9215 if (pts.Length > 100)
9216 {
9217 an.type = ROI.Type.Freeform;
9218 }
9219 an.AddPoints(pts);
9220 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getPolygonTheZ(im, sc);
9221 if (nz != null)
9222 co.Z = nz.getNumberValue().intValue();
9223 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getPolygonTheC(im, sc);
9224 if (nc != null)
9225 co.C = nc.getNumberValue().intValue();
9226 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getPolygonTheT(im, sc);
9227 if (nt != null)
9228 co.T = nt.getNumberValue().intValue();
9229 an.coord = co;
9230 an.Text = meta.getPolygonText(im, sc);
9231 BioFormats::ome.units.quantity.Length fl = meta.getPolygonFontSize(im, sc);
9232 if (fl != null)
9233 an.fontSize = fl.value().intValue();
9234 an.family = meta.getPointFontFamily(im, sc).name();
9235 BioFormats::ome.xml.model.primitives.Color col = meta.getPolygonStrokeColor(im, sc);
9236 if (col != null)
9237 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9238 BioFormats::ome.units.quantity.Length fw = meta.getPolygonStrokeWidth(im, sc);
9239 if (fw != null)
9240 an.strokeWidth = (float)fw.value().floatValue();
9241 BioFormats::ome.xml.model.primitives.Color colf = meta.getPolygonFillColor(im, sc);
9242 if (colf != null)
9243 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9244 }
9245 else
9246 if (type == "Polyline")
9247 {
9248 an.type = ROI.Type.Polyline;
9249 an.id = meta.getPolylineID(im, sc);
9250 string pxs = meta.getPolylinePoints(im, sc);
9251 PointD[] pts = an.stringToPoints(pxs);
9252 for (int pi = 0; pi < pts.Length; pi++)
9253 {
9254 pts[pi] = ToStageSpace(pts[pi], physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y);
9255 }
9256 an.AddPoints(an.stringToPoints(pxs));
9257 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getPolylineTheZ(im, sc);
9258 if (nz != null)
9259 co.Z = nz.getNumberValue().intValue();
9260 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getPolylineTheC(im, sc);
9261 if (nc != null)
9262 co.C = nc.getNumberValue().intValue();
9263 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getPolylineTheT(im, sc);
9264 if (nt != null)
9265 co.T = nt.getNumberValue().intValue();
9266 an.coord = co;
9267 an.Text = meta.getPolylineText(im, sc);
9268 BioFormats::ome.units.quantity.Length fl = meta.getPolylineFontSize(im, sc);
9269 if (fl != null)
9270 an.fontSize = fl.value().intValue();
9271 an.family = meta.getPointFontFamily(im, sc).name();
9272 BioFormats::ome.xml.model.primitives.Color col = meta.getPolylineStrokeColor(im, sc);
9273 if (col != null)
9274 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9275 BioFormats::ome.units.quantity.Length fw = meta.getPolylineStrokeWidth(im, sc);
9276 if (fw != null)
9277 an.strokeWidth = (float)fw.value().floatValue();
9278 BioFormats::ome.xml.model.primitives.Color colf = meta.getPolylineFillColor(im, sc);
9279 if (colf != null)
9280 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9281 }
9282 else
9283 if (type == "Label")
9284 {
9285 an.type = ROI.Type.Label;
9286 an.id = meta.getLabelID(im, sc);
9287
9288 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getLabelTheZ(im, sc);
9289 if (nz != null)
9290 co.Z = nz.getNumberValue().intValue();
9291 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getLabelTheC(im, sc);
9292 if (nc != null)
9293 co.C = nc.getNumberValue().intValue();
9294 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getLabelTheT(im, sc);
9295 if (nt != null)
9296 co.T = nt.getNumberValue().intValue();
9297 an.coord = co;
9298
9299 BioFormats::ome.units.quantity.Length fl = meta.getLabelFontSize(im, sc);
9300 if (fl != null)
9301 an.fontSize = fl.value().intValue();
9302 an.family = meta.getPointFontFamily(im, sc).name();
9303 BioFormats::ome.xml.model.primitives.Color col = meta.getLabelStrokeColor(im, sc);
9304 if (col != null)
9305 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9306 BioFormats::ome.units.quantity.Length fw = meta.getLabelStrokeWidth(im, sc);
9307 if (fw != null)
9308 an.strokeWidth = (float)fw.value().floatValue();
9309 BioFormats::ome.xml.model.primitives.Color colf = meta.getLabelFillColor(im, sc);
9310 if (colf != null)
9311 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9312 PointD p = new PointD(meta.getLabelX(im, sc).doubleValue(), meta.getLabelY(im, sc).doubleValue());
9313 an.AddPoint(ToStageSpace(p, physicalSizeX, physicalSizeY, volume.Location.X, volume.Location.Y));
9314 an.Text = meta.getLabelText(im, sc);
9315 }
9316 else
9317 if (type == "Mask")
9318 {
9319 byte[] bts = meta.getMaskBinData(im, sc);
9320 bool end = meta.getMaskBinDataBigEndian(im, sc).booleanValue();
9321 an = ROI.CreateMask(co, bts, (int)(an.W * physicalSizeX), (int)(an.H * physicalSizeY), new PointD(stageSizeX, stageSizeY), physicalSizeX, physicalSizeY);
9322 an.Text = meta.getMaskText(im, sc);
9323 an.id = meta.getMaskID(im, sc);
9324 BioFormats::ome.xml.model.primitives.NonNegativeInteger nz = meta.getMaskTheZ(im, sc);
9325 if (nz != null)
9326 co.Z = nz.getNumberValue().intValue();
9327 BioFormats::ome.xml.model.primitives.NonNegativeInteger nc = meta.getMaskTheC(im, sc);
9328 if (nc != null)
9329 co.C = nc.getNumberValue().intValue();
9330 BioFormats::ome.xml.model.primitives.NonNegativeInteger nt = meta.getMaskTheT(im, sc);
9331 if (nt != null)
9332 co.T = nt.getNumberValue().intValue();
9333 an.coord = co;
9334
9335 BioFormats::ome.units.quantity.Length fl = meta.getMaskFontSize(im, sc);
9336 if (fl != null)
9337 an.fontSize = fl.value().intValue();
9338 BioFormats::ome.xml.model.enums.FontFamily ff = meta.getMaskFontFamily(im, sc);
9339 if (ff != null)
9340 an.family = ff.name();
9341 BioFormats::ome.xml.model.primitives.Color col = meta.getMaskStrokeColor(im, sc);
9342 if (col != null)
9343 an.strokeColor = Color.FromArgb(col.getAlpha(), col.getRed(), col.getGreen(), col.getBlue());
9344 BioFormats::ome.units.quantity.Length fw = meta.getMaskStrokeWidth(im, sc);
9345 if (fw != null)
9346 an.strokeWidth = (float)fw.value().floatValue();
9347 BioFormats::ome.xml.model.primitives.Color colf = meta.getMaskFillColor(im, sc);
9348 if (colf != null)
9349 an.fillColor = Color.FromArgb(colf.getAlpha(), colf.getRed(), colf.getGreen(), colf.getBlue());
9350 }
9351 }
9352 }
9353
9354 imageReader.close();
9355 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, file, series);
9356 return Annotations;
9357 }
PointD ToStageSpace(PointD p)
Definition Bio.cs:4474

◆ OpenOMESeries()

static BioImage[] BioLib.BioImage.OpenOMESeries ( string file,
bool tab,
bool addToImages )
static

It opens a file, checks if it's tiled, if it is, it opens it as a tiled image, if not, it opens it as a normal image.

Parameters
filethe file path
tabopen in new tab
addToImagesadd to images list.
Returns
An array of BioImage objects.

Definition at line 8539 of file Bio.cs.

8540 {
8541 //We wait incase OME has not initialized yet.
8542 if (!initialized)
8543 do
8544 {
8545 Thread.Sleep(100);
8546 //Application.DoEvents();
8547 } while (!Initialized);
8548 var meta = (IMetadata)((OMEXMLService)new ServiceFactory().getInstance(typeof(OMEXMLService))).createOMEXMLMetadata();
8549 reader.setMetadataStore((MetadataStore)meta);
8550 file = file.Replace("\\", "/");
8551 try
8552 {
8553 if (reader.getCurrentFile() != file)
8554 {
8555 Status = "Opening OME Image: " + file;
8556 file = file.Replace("\\", "/");
8557 reader.setId(file);
8558 }
8559 }
8560 catch (Exception e)
8561 {
8562 return null;
8563 }
8564 int count = reader.getSeriesCount();
8565 BioImage[] bs = new BioImage[count];
8566 for (int i = 0; i < count; i++)
8567 {
8568 bs[i] = OpenOME(file, i, tab, addToImages, false, 0, 0, 0, 0);
8569 if (bs[i] == null)
8570 return null;
8571 }
8572 return bs;
8573 }

◆ OpenSeries()

static BioImage[] BioLib.BioImage.OpenSeries ( string file,
bool tab )
static

It opens a tiff file, reads the number of pages, reads the number of channels, and then reads each page into a BioImage object.

Parameters
filethe path to the file
tabopen image in new tab.
Returns
An array of BioImage objects.

Definition at line 5853 of file Bio.cs.

5854 {
5855 Tiff image = Tiff.Open(file, "r");
5856 int pages = image.NumberOfDirectories();
5857 FieldValue[] f = image.GetField(TiffTag.IMAGEDESCRIPTION);
5858 int sp = image.GetField(TiffTag.SAMPLESPERPIXEL)[0].ToInt();
5859 ImageJDesc imDesc = new ImageJDesc();
5860 int count = 1;
5861 if (f != null)
5862 {
5863 string desc = f[0].ToString();
5864 if (desc.StartsWith("ImageJ"))
5865 {
5866 imDesc.SetString(desc);
5867 if (imDesc.channels != 0)
5868 count = imDesc.channels;
5869 }
5870 }
5871 int scount = (pages * sp) / count;
5872 BioImage[] bs = new BioImage[pages];
5873 image.Close();
5874 for (int i = 0; i < pages; i++)
5875 {
5876 bs[i] = OpenFile(file, i, tab, true);
5877 }
5878 return bs;
5879 }

◆ OpenVips()

static void BioLib.BioImage.OpenVips ( BioImage b)
static

The function "OpenVips" takes a BioImage object and an integer representing the number of pages, and adds each page of the image file to the BioImage's vipPages list using the NetVips library.

Parameters
BioImageThe BioImage parameter is an object that represents a bio image. It likely contains information about the image file, such as the file path and other metadata.
pagecountThe parameter "pagecount" represents the number of pages in the TIFF file that needs to be loaded into the "vipPages" list of the "BioImage" object.

Definition at line 7300 of file Bio.cs.

7301 {
7302 try
7303 {
7304 List<NetVips.Image> ims = new List<NetVips.Image>();
7305 for (int i = 0; i < b.seriesCount; i++)
7306 {
7307 b.vipPages.Add(NetVips.Image.Tiffload(b.file, i));
7308 }
7309 b.vipPages = SortImagesBySizeDescending(b.vipPages.ToArray()).ToList();
7310 }
7311 catch (Exception e)
7312 {
7313 Console.WriteLine(e.Message);
7314 }
7315
7316 }

◆ OpenXML()

static string BioLib.BioImage.OpenXML ( string file)
static

‍Open the file, get the image description field, and return it as a string

Parameters
filethe path to the file
Returns
The image description of the tiff file.

Definition at line 8964 of file Bio.cs.

8965 {
8966 if (!file.EndsWith(".tif"))
8967 return null;
8968 Tiff image = Tiff.Open(file, "r");
8969 FieldValue[] f = image.GetField(TiffTag.IMAGEDESCRIPTION);
8970 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, file);
8971 return f[0].ToString();
8972 }

◆ operator*() [1/2]

static BioImage BioLib.BioImage.operator* ( BioImage a,
ColorS b )
static

This function takes a BioImage object and a ColorS object and returns a BioImage object.

Parameters
BioImagea class that contains a list of ColorS objects.
ColorSa struct that contains a byte for each color channel (R, G, B, A)
Returns
A BioImage object

Definition at line 9896 of file Bio.cs.

9897 {
9898 for (int i = 0; i < a.Buffers.Count; i++)
9899 {
9900 a.Buffers[i] = a.Buffers[i] * b;
9901 }
9902 return a;
9903 }

◆ operator*() [2/2]

static BioImage BioLib.BioImage.operator* ( BioImage a,
float b )
static

Definition at line 9838 of file Bio.cs.

9839 {
9840 for (int i = 0; i < a.Buffers.Count; i++)
9841 {
9842 a.Buffers[i] = a.Buffers[i] / b;
9843 }
9844 return a;
9845 }

◆ operator+() [1/2]

static BioImage BioLib.BioImage.operator+ ( BioImage a,
ColorS b )
static

It takes a BioImage object and a ColorS object and adds the ColorS object to each buffer in the BioImage object.

Parameters
BioImagea class that contains a list of ColorS objects.
ColorSa struct that contains a byte for each color channel (R, G, B, A)
Returns
A BioImage object

Definition at line 9911 of file Bio.cs.

9912 {
9913 for (int i = 0; i < a.Buffers.Count; i++)
9914 {
9915 a.Buffers[i] = a.Buffers[i] + b;
9916 }
9917 return a;
9918 }

◆ operator+() [2/2]

static BioImage BioLib.BioImage.operator+ ( BioImage a,
float b )
static

This function adds a constant value to each pixel in the image.

Parameters
BioImagea class that contains a list of buffers (float[])
bthe value to add to the image
Returns
The image itself.

Definition at line 9852 of file Bio.cs.

9853 {
9854 for (int i = 0; i < a.Buffers.Count; i++)
9855 {
9856 a.Buffers[i] = a.Buffers[i] + b;
9857 }
9858 return a;
9859 }

◆ operator-() [1/2]

static BioImage BioLib.BioImage.operator- ( BioImage a,
ColorS b )
static

The function subtracts a color from each pixel in the image.

Parameters
BioImagea class that contains a list of ColorS objects.
ColorSa struct that contains a byte for each color channel (R, G, B, A)
Returns
The image itself.

Definition at line 9925 of file Bio.cs.

9926 {
9927 for (int i = 0; i < a.Buffers.Count; i++)
9928 {
9929 a.Buffers[i] = a.Buffers[i] - b;
9930 }
9931 return a;
9932 }

◆ operator-() [2/2]

static BioImage BioLib.BioImage.operator- ( BioImage a,
float b )
static

Subtracts a scalar value from each pixel in the image.

Parameters
BioImagea class that contains a list of buffers (which are 2D arrays of floats)
bthe value to subtract from the image
Returns
The BioImage object is being returned.

Definition at line 9866 of file Bio.cs.

9867 {
9868 for (int i = 0; i < a.Buffers.Count; i++)
9869 {
9870 a.Buffers[i] = a.Buffers[i] - b;
9871 }
9872 return a;
9873 }

◆ operator/() [1/2]

static BioImage BioLib.BioImage.operator/ ( BioImage a,
ColorS b )
static

This function divides each pixel in the image by the value of the color.

Parameters
BioImagea class that contains a list of ColorS objects.
ColorSa struct that contains a byte for each color channel (R, G, B, A)
Returns
A BioImage object.

Definition at line 9882 of file Bio.cs.

9883 {
9884 for (int i = 0; i < a.Buffers.Count; i++)
9885 {
9886 a.Buffers[i] = a.Buffers[i] / b;
9887 }
9888 return a;
9889 }

◆ operator/() [2/2]

static BioImage BioLib.BioImage.operator/ ( BioImage a,
float b )
static

This function divides each pixel in the image by a constant value.

Parameters
BioImagea class that contains a list of buffers (which are 2D arrays of floats)
bthe value to divide by
Returns
The image is being returned.

Definition at line 9830 of file Bio.cs.

9831 {
9832 for (int i = 0; i < a.Buffers.Count; i++)
9833 {
9834 a.Buffers[i] = a.Buffers[i] / b;
9835 }
9836 return a;
9837 }

◆ Rename()

void BioLib.BioImage.Rename ( string name)

Definition at line 8802 of file Bio.cs.

8803 {
8804 this.Filename = Path.GetFileName(name);
8805 this.ID = name;
8806 }

◆ ROIsToString()

static string BioLib.BioImage.ROIsToString ( List< ROI > Annotations)
static

It takes a list of ROI objects and returns a string of all the ROI objects in the list.

Parameters
AnnotationsList of ROI objects
Returns
A string of the ROI's

Definition at line 9363 of file Bio.cs.

9364 {
9365 string s = "";
9366 for (int i = 0; i < Annotations.Count; i++)
9367 {
9368 s += ROIToString(Annotations[i]);
9369 }
9370 return s;
9371 }
static string ROIToString(ROI an)
This function takes an ROI object and returns a string that contains all the information about the RO...
Definition Bio.cs:9378

◆ ROIToString()

static string BioLib.BioImage.ROIToString ( ROI an)
static

This function takes an ROI object and returns a string that contains all the information about the ROI.

Parameters
ROIThe ROI object
Returns
A string

Definition at line 9378 of file Bio.cs.

9379 {
9380 PointD[] points = an.GetPoints();
9381 string pts = "";
9382 for (int j = 0; j < points.Length; j++)
9383 {
9384 if (j == points.Length - 1)
9385 pts += points[j].X.ToString(CultureInfo.InvariantCulture) + "," + points[j].Y.ToString(CultureInfo.InvariantCulture);
9386 else
9387 pts += points[j].X.ToString(CultureInfo.InvariantCulture) + "," + points[j].Y.ToString(CultureInfo.InvariantCulture) + " ";
9388 }
9389 char sep = (char)34;
9390 string sColor = sep.ToString() + an.strokeColor.A.ToString() + ',' + an.strokeColor.R.ToString() + ',' + an.strokeColor.G.ToString() + ',' + an.strokeColor.B.ToString() + sep.ToString();
9391 string bColor = sep.ToString() + an.fillColor.A.ToString() + ',' + an.fillColor.R.ToString() + ',' + an.fillColor.G.ToString() + ',' + an.fillColor.B.ToString() + sep.ToString();
9392
9393 string line = an.roiID + ',' + an.roiName + ',' + an.type.ToString() + ',' + an.id + ',' + an.shapeIndex.ToString() + ',' +
9394 an.Text + ',' + an.serie + ',' + an.coord.Z.ToString() + ',' + an.coord.C.ToString() + ',' + an.coord.T.ToString() + ',' + an.X.ToString(CultureInfo.InvariantCulture) + ',' + an.Y.ToString(CultureInfo.InvariantCulture) + ',' +
9395 an.W.ToString(CultureInfo.InvariantCulture) + ',' + an.H.ToString(CultureInfo.InvariantCulture) + ',' + sep.ToString() + pts + sep.ToString() + ',' + sColor + ',' + an.strokeWidth.ToString(CultureInfo.InvariantCulture) + ',' + bColor + ',' + an.fontSize.ToString(CultureInfo.InvariantCulture) + ',' + NewLine;
9396 return line;
9397 }

◆ RotateFlip()

void BioLib.BioImage.RotateFlip ( AForge.RotateFlipType rot)

Definition at line 4156 of file Bio.cs.

4157 {
4158 for (int i = 0; i < Buffers.Count; i++)
4159 {
4160 Buffers[i].RotateFlip(rot);
4161 }
4162 Volume = new VolumeD(new Point3D(StageSizeX, StageSizeY, StageSizeZ), new Point3D(PhysicalSizeX * SizeX, PhysicalSizeY * SizeY, PhysicalSizeZ * SizeZ));
4163 }

◆ SaveAsync()

static async Task BioLib.BioImage.SaveAsync ( string file,
string id,
int serie,
bool ome )
static

The SaveAsync function saves data to a file asynchronously.

Parameters
fileThe file parameter is a string that represents the file path or name where the data will be saved.
idThe "id" parameter is a string that represents an identifier for the save operation. It could be used to uniquely identify the saved data or to specify a specific location or format for the saved file.
serieThe "serie" parameter is an integer that represents a series or sequence number. It is used as a parameter in the SaveAsync method.
BioFormats::omeThe "ome" parameter is a boolean value that determines whether or not to perform a specific action in the saving process.

Definition at line 8839 of file Bio.cs.

8840 {
8841 savefile = file;
8842 saveid = id;
8843 some = ome;
8844 await Task.Run(SaveThread);
8845 }

◆ 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.

Definition at line 5741 of file Bio.cs.

5742 {
5743 string[] sts = new string[1];
5744 sts[0] = ID;
5745 SaveSeries(sts, file);
5746 }
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:5751

◆ SaveOME() [1/2]

static void BioLib.BioImage.SaveOME ( BioImage image,
string file )
static

Definition at line 6411 of file Bio.cs.

6412 {
6413 BioImage[] sts = new BioImage[1];
6414 sts[0] = image;
6415 SaveOMESeries(sts, file, BioImage.Planes);
6416 }
static void SaveOMESeries(BioImage[] files, string f, bool planes)
This function takes a list of image files and saves them as a single OME-TIFF file.
Definition Bio.cs:6422

◆ SaveOME() [2/2]

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

Definition at line 6404 of file Bio.cs.

6405 {
6406 BioImage[] sts = new BioImage[1];
6407 sts[0] = Images.GetImage(ID);
6408 SaveOMESeries(sts, file, BioImage.Planes);
6409 }

◆ SaveOMEPyramidal()

static void BioLib.BioImage.SaveOMEPyramidal ( BioImage[] bms,
string file,
Enums.ForeignTiffCompression compression,
int compressionLevel )
static

The function SaveOMEPyramidal saves a collection of BioImages as a pyramidal OME-TIFF file.

Parameters
bmsAn array of BioImage objects representing the images to be saved.
fileThe file parameter is a string that represents the file path where the OME Pyramidal TIFF file will be saved.
compressionThe compression parameter is of type Enums.ForeignTiffCompression and it specifies the compression method to be used when saving the TIFF file.

Definition at line 6854 of file Bio.cs.

6855 {
6856 if (File.Exists(file))
6857 File.Delete(file);
6858 Status = "Saving OME Pyramidal";
6859 //We need to go through the images and find the ones belonging to each resolution.
6860 //As well we need to determine the dimensions of the tiles.
6861 Dictionary<double, List<BioImage>> bis = new Dictionary<double, List<BioImage>>();
6862 Dictionary<double, Point3D> min = new Dictionary<double, Point3D>();
6863 Dictionary<double, Point3D> max = new Dictionary<double, Point3D>();
6864 for (int i = 0; i < bms.Length; i++)
6865 {
6866 Resolution res = bms[i].Resolutions[bms[i].Level];
6867 if (bis.ContainsKey(res.PhysicalSizeX))
6868 {
6869 bis[res.PhysicalSizeX].Add(bms[i]);
6870 if (bms[i].StageSizeX < min[res.PhysicalSizeX].X || bms[i].StageSizeY < min[res.PhysicalSizeX].Y)
6871 {
6872 min[res.PhysicalSizeX] = bms[i].Volume.Location;
6873 }
6874 if (bms[i].StageSizeX > max[res.PhysicalSizeX].X || bms[i].StageSizeY > max[res.PhysicalSizeX].Y)
6875 {
6876 max[res.PhysicalSizeX] = bms[i].Volume.Location;
6877 }
6878 }
6879 else
6880 {
6881 bis.Add(res.PhysicalSizeX, new List<BioImage>());
6882 min.Add(res.PhysicalSizeX, new Point3D(double.MaxValue, double.MaxValue, double.MaxValue));
6883 max.Add(res.PhysicalSizeX, new Point3D(double.MinValue, double.MinValue, double.MinValue));
6884 if (bms[i].StageSizeX < min[res.PhysicalSizeX].X || bms[i].StageSizeY < min[res.PhysicalSizeX].Y)
6885 {
6886 min[res.PhysicalSizeX] = bms[i].Volume.Location;
6887 }
6888 if (bms[i].StageSizeX > max[res.PhysicalSizeX].X || bms[i].StageSizeY > max[res.PhysicalSizeX].Y)
6889 {
6890 max[res.PhysicalSizeX] = bms[i].Volume.Location;
6891 }
6892 bis[res.PhysicalSizeX].Add(bms[i]);
6893 }
6894 }
6895 int s = 0;
6896 //We determine the sizes of each resolution.
6897 Dictionary<double, AForge.Size> ss = new Dictionary<double, AForge.Size>();
6898 int minx = int.MaxValue;
6899 int miny = int.MaxValue;
6900 double last = 0;
6901 foreach (double px in bis.Keys)
6902 {
6903 int xs = (1 + (int)Math.Ceiling((max[px].X - min[px].X) / bis[px][0].Resolutions[0].VolumeWidth)) * bis[px][0].SizeX;
6904 int ys = (1 + (int)Math.Ceiling((max[px].Y - min[px].Y) / bis[px][0].Resolutions[0].VolumeHeight)) * bis[px][0].SizeY;
6905 if (minx > xs)
6906 minx = xs;
6907 if (miny > ys)
6908 miny = ys;
6909 ss.Add(px, new AForge.Size(xs, ys));
6910 last = px;
6911 }
6912 s = 0;
6913 string met = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
6914 "<OME xmlns=\"http://www.openmicroscopy.org/Schemas/OME/2016-06\" " +
6915 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
6916 "xsi:schemaLocation=\"http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/BioFormats::ome.xsd\">";
6917 NetVips.Image img = null;
6918 int ib = 0;
6919
6920 foreach (double px in bis.Keys)
6921 {
6922 int c = bis[px][s].SizeC;
6923 if (bis[px][s].Buffers[0].isRGB)
6924 c = 3;
6925 string endian = (bis[px][s].Buffers[0].LittleEndian).ToString().ToLower();
6926 met +=
6927 "<Image ID=\"Image:" + ib + "\">" +
6928 "<Pixels BigEndian=\"" + endian + "\" DimensionOrder= \"XYCZT\" ID= \"Pixels:0\" Interleaved=\"true\" " +
6929 "PhysicalSizeX=\"" + bis[px][s].PhysicalSizeX + "\" PhysicalSizeXUnit=\"µm\" PhysicalSizeY=\"" + bis[px][s].PhysicalSizeY + "\" PhysicalSizeYUnit=\"µm\" SignificantBits=\"" + bis[px][s].bitsPerPixel + "\" " +
6930 "SizeC = \"" + c + "\" SizeT = \"" + bis[px][s].SizeT + "\" SizeX =\"" + ss[px].Width +
6931 "\" SizeY= \"" + ss[px].Height + "\" SizeZ=\"" + bis[px][s].SizeZ;
6932 if (bis[px][s].bitsPerPixel > 8) met += "\" Type= \"uint16\">";
6933 else met += "\" Type= \"uint8\">";
6934 int i = 0;
6935 foreach (Channel ch in bis[px][s].Channels)
6936 {
6937 met += "<Channel ID=\"Channel:" + ib + ":" + i + "\" SamplesPerPixel=\"1\"></Channel>";
6938 i++;
6939 }
6940 met += "</Pixels></Image>";
6941 ib++;
6942 }
6943 met += "</OME>";
6944 foreach (double px in bis.Keys)
6945 {
6946 PixelFormat pf = bis[px][0].Buffers[0].PixelFormat;
6947 Bitmap level = new Bitmap(ss[px].Width, ss[px].Height, pf);
6948 int bands = GetBands(pf);
6949 if (bis[px][0].bitsPerPixel > 8)
6950 img = NetVips.Image.NewFromMemory(level.Data, (ulong)level.Length, level.Width, level.Height, bands, Enums.BandFormat.Ushort);
6951 else
6952 img = NetVips.Image.NewFromMemory(level.Data, (ulong)level.Length, level.Width, level.Height, bands, Enums.BandFormat.Uchar);
6953 int i = 0;
6954 foreach (BioImage b in bis[px])
6955 {
6956 Progress = ((float)i / (float)bis[px].Count) * 100;
6957 AForge.Size si = ss[px];
6958 double xs = (-(min[px].X - bis[px][i].Volume.Location.X) / bis[px][i].Resolutions[0].VolumeWidth) * bis[px][i].SizeX;
6959 double ys = (-(min[px].Y - bis[px][i].Volume.Location.Y) / bis[px][i].Resolutions[0].VolumeHeight) * bis[px][i].SizeY;
6960 NetVips.Image tile;
6961 if (b.bitsPerPixel > 8)
6962 tile = NetVips.Image.NewFromMemory(bis[px][i].Buffers[0].Data, (ulong)bis[px][i].Buffers[0].Length, bis[px][i].Buffers[0].Width, bis[px][i].Buffers[0].Height, bands, Enums.BandFormat.Ushort);
6963 else
6964 tile = NetVips.Image.NewFromMemory(bis[px][i].Buffers[0].Data, (ulong)bis[px][i].Buffers[0].Length, bis[px][i].Buffers[0].Width, bis[px][i].Buffers[0].Height, bands, Enums.BandFormat.Uchar);
6965 img = img.Insert(tile, (int)xs, (int)ys);
6966 i++;
6967 };
6968 using var mutated = img.Mutate(mutable =>
6969 {
6970 // Set the ImageDescription tag
6971 mutable.Set(GValue.GStrType, "image-description", met);
6972 mutable.Set(GValue.GIntType, "page-height", ss[last].Height);
6973 });
6974 if (bis[px][0].bitsPerPixel > 8)
6975 mutated.Tiffsave(file, compression, 1, Enums.ForeignTiffPredictor.None, true, ss[px].Width, ss[px].Height, true, false, 16,
6976 Enums.ForeignTiffResunit.Cm, 1000 * bis[px][0].PhysicalSizeX, 1000 * bis[px][0].PhysicalSizeY, true, null, Enums.RegionShrink.Nearest,
6977 compressionLevel, true, Enums.ForeignDzDepth.One, true, false, null, null, ss[px].Height);
6978 else
6979 mutated.Tiffsave(file, compression, 1, Enums.ForeignTiffPredictor.None, true, ss[px].Width, ss[px].Height, true, false, 8,
6980 Enums.ForeignTiffResunit.Cm, 1000 * bis[px][0].PhysicalSizeX, 1000 * bis[px][0].PhysicalSizeY, true, null, Enums.RegionShrink.Nearest,
6981 compressionLevel, true, Enums.ForeignDzDepth.One, true, false, null, null, ss[px].Height);
6982 s++;
6983 }
6984
6985 }
static int GetBands(PixelFormat format)
The function "GetBands" returns the number of color bands for a given pixel format in the AForge libr...
Definition Bio.cs:6827

◆ SaveOMESeries()

static void BioLib.BioImage.SaveOMESeries ( BioImage[] files,
string f,
bool planes )
static

This function takes a list of image files and saves them as a single OME-TIFF file.

Parameters
filesan array of file paths to the images to be saved
fthe file name to save to
planesif true, the planes will be saved as well.

Definition at line 6422 of file Bio.cs.

6423 {
6424 if (File.Exists(f))
6425 File.Delete(f);
6426 BioFormats::loci.formats.meta.IMetadata omexml = service.createOMEXMLMetadata();
6427 Status = "Saving OME Image Metadata.";
6428 for (int fi = 0; fi < files.Length; fi++)
6429 {
6430 int serie = fi;
6431 BioImage b = files[fi];
6432 // create OME-XML metadata store
6433
6434 omexml.setImageID("Image:" + serie, serie);
6435 omexml.setPixelsID("Pixels:" + serie, serie);
6436 omexml.setPixelsInterleaved(java.lang.Boolean.TRUE, serie);
6437 omexml.setPixelsDimensionOrder(BioFormats::ome.xml.model.enums.DimensionOrder.XYCZT, serie);
6438 if (b.bitsPerPixel > 8)
6439 omexml.setPixelsType(BioFormats::ome.xml.model.enums.PixelType.UINT16, serie);
6440 else
6441 omexml.setPixelsType(BioFormats::ome.xml.model.enums.PixelType.UINT8, serie);
6442 omexml.setPixelsSizeX(new PositiveInteger(java.lang.Integer.valueOf(b.SizeX)), serie);
6443 omexml.setPixelsSizeY(new PositiveInteger(java.lang.Integer.valueOf(b.SizeY)), serie);
6444 omexml.setPixelsSizeZ(new PositiveInteger(java.lang.Integer.valueOf(b.SizeZ)), serie);
6445 omexml.setPixelsSizeC(new PositiveInteger(java.lang.Integer.valueOf(b.SizeC)), serie);
6446 omexml.setPixelsSizeT(new PositiveInteger(java.lang.Integer.valueOf(b.SizeT)), serie);
6447 if (BitConverter.IsLittleEndian)
6448 omexml.setPixelsBigEndian(java.lang.Boolean.FALSE, serie);
6449 else
6450 omexml.setPixelsBigEndian(java.lang.Boolean.TRUE, serie);
6451 BioFormats::ome.units.quantity.Length p1 = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.PhysicalSizeX), BioFormats::ome.units.UNITS.MICROMETER);
6452 omexml.setPixelsPhysicalSizeX(p1, serie);
6453 BioFormats::ome.units.quantity.Length p2 = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.PhysicalSizeY), BioFormats::ome.units.UNITS.MICROMETER);
6454 omexml.setPixelsPhysicalSizeY(p2, serie);
6455 BioFormats::ome.units.quantity.Length p3 = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.PhysicalSizeZ), BioFormats::ome.units.UNITS.MICROMETER);
6456 if (b.PhysicalSizeZ == 0)
6457 omexml.setPixelsPhysicalSizeZ(new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(1), BioFormats::ome.units.UNITS.MICROMETER), serie);
6458 else
6459 omexml.setPixelsPhysicalSizeZ(new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.PhysicalSizeZ), BioFormats::ome.units.UNITS.MICROMETER), serie);
6460 BioFormats::ome.units.quantity.Length s1 = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.Volume.Location.X), BioFormats::ome.units.UNITS.MICROMETER);
6461 omexml.setStageLabelX(s1, serie);
6462 BioFormats::ome.units.quantity.Length s2 = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.Volume.Location.Y), BioFormats::ome.units.UNITS.MICROMETER);
6463 omexml.setStageLabelY(s2, serie);
6464 BioFormats::ome.units.quantity.Length s3 = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.Volume.Location.Z), BioFormats::ome.units.UNITS.MICROMETER);
6465 omexml.setStageLabelZ(s3, serie);
6466 omexml.setStageLabelName("StageLabel:" + serie, serie);
6467 List<Channel> chs = new List<Channel>();
6468 if (b.Channels.Count == 1)
6469 {
6470 if (b.Channels[0].range.Length == 3)
6471 {
6472 for (int c = 0; c < 3; c++)
6473 {
6474 Channel ch = b.Channels[0].Copy();
6475 ch.SamplesPerPixel = 1;
6476 ch.range = new IntRange[] { b.Channels[0].range[c] };
6477 chs.Add(ch);
6478 }
6479 }
6480 else
6481 chs.Add(b.Channels[0]);
6482 }
6483 else
6484 chs.AddRange(b.Channels);
6485
6486 for (int channel = 0; channel < chs.Count; channel++)
6487 {
6488 Channel c = chs[channel];
6489 for (int r = 0; r < c.range.Length; r++)
6490 {
6491 omexml.setChannelID("Channel:" + channel + ":" + serie, r, channel);
6492 omexml.setChannelSamplesPerPixel(new PositiveInteger(java.lang.Integer.valueOf(c.range.Length)), r, channel);
6493 if (c.LightSourceWavelength != 0)
6494 {
6495 omexml.setChannelLightSourceSettingsID("LightSourceSettings:" + channel, r, channel);
6496 BioFormats::ome.units.quantity.Length lw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(c.LightSourceWavelength), BioFormats::ome.units.UNITS.NANOMETER);
6497 omexml.setChannelLightSourceSettingsWavelength(lw, r, channel);
6498 omexml.setChannelLightSourceSettingsAttenuation(PercentFraction.valueOf(c.LightSourceAttenuation), r, channel);
6499 }
6500 omexml.setChannelName(c.Name, r, channel);
6501 if (c.Color != null)
6502 {
6503 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(c.Color.Value.R, c.Color.Value.G, c.Color.Value.B, c.Color.Value.A);
6504 omexml.setChannelColor(col, r, channel);
6505 }
6506 if (c.Emission != 0)
6507 {
6508 BioFormats::ome.units.quantity.Length em = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(c.Emission), BioFormats::ome.units.UNITS.NANOMETER);
6509 omexml.setChannelEmissionWavelength(em, r, channel);
6510 BioFormats::ome.units.quantity.Length ex = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(c.Excitation), BioFormats::ome.units.UNITS.NANOMETER);
6511 omexml.setChannelExcitationWavelength(ex, r, channel);
6512 }
6513 /*
6514 if (c.ContrastMethod != null)
6515 {
6516 BioFormats::ome.xml.model.enums.ContrastMethod cm = (BioFormats::ome.xml.model.enums.ContrastMethod)Enum.Parse(typeof(BioFormats::ome.xml.model.enums.ContrastMethod), c.ContrastMethod);
6517 omexml.setChannelContrastMethod(cm, serie, channel + r);
6518 }
6519 if (c.IlluminationType != null)
6520 {
6521 BioFormats::ome.xml.model.enums.IlluminationType il = (BioFormats::ome.xml.model.enums.IlluminationType)Enum.Parse(typeof(BioFormats::ome.xml.model.enums.IlluminationType), c.IlluminationType.ToUpper());
6522 omexml.setChannelIlluminationType(il, serie, channel + r);
6523 }
6524 if (c.AcquisitionMode != null)
6525 {
6526 BioFormats::ome.xml.model.enums.AcquisitionMode am = (BioFormats::ome.xml.model.enums.AcquisitionMode)Enum.Parse(typeof(BioFormats::ome.xml.model.enums.AcquisitionMode), c.AcquisitionMode.ToUpper());
6527 omexml.setChannelAcquisitionMode(am, serie, channel + r);
6528 }
6529 */
6530 omexml.setChannelFluor(c.Fluor, r, channel);
6531 if (c.LightSourceIntensity != 0)
6532 {
6533 BioFormats::ome.units.quantity.Power pw = new BioFormats::ome.units.quantity.Power(java.lang.Double.valueOf(c.LightSourceIntensity), BioFormats::ome.units.UNITS.VOLT);
6534 omexml.setLightEmittingDiodePower(pw, r, channel);
6535 omexml.setLightEmittingDiodeID(c.DiodeName, r, channel);
6536 }
6537 }
6538 }
6539
6540 int i = 0;
6541 foreach (ROI an in b.Annotations)
6542 {
6543 if (an.roiID == "")
6544 omexml.setROIID("ROI:" + i.ToString() + ":" + serie, i);
6545 else
6546 omexml.setROIID(an.roiID, i);
6547 if (an.roiName != "")
6548 omexml.setROIName(an.roiName, i);
6549 else
6550 omexml.setROIName("ROI:" + i.ToString() + ":" + serie, i);
6551 if (an.type == ROI.Type.Point)
6552 {
6553 if (an.id != "")
6554 omexml.setPointID(an.id, i, serie);
6555 else
6556 omexml.setPointID("Shape:" + i + ":" + serie, i, serie);
6557 omexml.setPointX(java.lang.Double.valueOf(b.ToImageSpaceX(an.X)), i, serie);
6558 omexml.setPointY(java.lang.Double.valueOf(b.ToImageSpaceY(an.Y)), i, serie);
6559 omexml.setPointTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6560 omexml.setPointTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6561 omexml.setPointTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6562 if (an.Text != "")
6563 omexml.setPointText(an.Text, i, serie);
6564 else
6565 omexml.setPointText(i.ToString(), i, serie);
6566 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6567 omexml.setPointFontSize(fl, i, serie);
6568 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6569 omexml.setPointStrokeColor(col, i, serie);
6570 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6571 omexml.setPointStrokeWidth(sw, i, serie);
6572 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6573 omexml.setPointFillColor(colf, i, serie);
6574 }
6575 else
6576 if (an.type == ROI.Type.Polygon || an.type == ROI.Type.Freeform)
6577 {
6578 if (an.id != "")
6579 omexml.setPolygonID(an.id, i, serie);
6580 else
6581 omexml.setPolygonID("Shape:" + i + ":" + serie, i, serie);
6582 omexml.setPolygonPoints(an.PointsToString(b), i, serie);
6583 omexml.setPolygonTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6584 omexml.setPolygonTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6585 omexml.setPolygonTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6586 if (an.Text != "")
6587 omexml.setPolygonText(an.Text, i, serie);
6588 else
6589 omexml.setPolygonText(i.ToString(), i, serie);
6590 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6591 omexml.setPolygonFontSize(fl, i, serie);
6592 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6593 omexml.setPolygonStrokeColor(col, i, serie);
6594 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6595 omexml.setPolygonStrokeWidth(sw, i, serie);
6596 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6597 omexml.setPolygonFillColor(colf, i, serie);
6598 }
6599 else
6600 if (an.type == ROI.Type.Rectangle)
6601 {
6602 if (an.id != "")
6603 omexml.setRectangleID(an.id, i, serie);
6604 else
6605 omexml.setRectangleID("Shape:" + i + ":" + serie, i, serie);
6606 omexml.setRectangleWidth(java.lang.Double.valueOf(b.ToImageSizeX(an.W)), i, serie);
6607 omexml.setRectangleHeight(java.lang.Double.valueOf(b.ToImageSizeY(an.H)), i, serie);
6608 omexml.setRectangleX(java.lang.Double.valueOf(b.ToImageSpaceX(an.Rect.X)), i, serie);
6609 omexml.setRectangleY(java.lang.Double.valueOf(b.ToImageSpaceY(an.Rect.Y)), i, serie);
6610 omexml.setRectangleTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6611 omexml.setRectangleTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6612 omexml.setRectangleTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6613 omexml.setRectangleText(i.ToString(), i, serie);
6614 if (an.Text != "")
6615 omexml.setRectangleText(an.Text, i, serie);
6616 else
6617 omexml.setRectangleText(i.ToString(), i, serie);
6618 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6619 omexml.setRectangleFontSize(fl, i, serie);
6620 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6621 omexml.setRectangleStrokeColor(col, i, serie);
6622 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6623 omexml.setRectangleStrokeWidth(sw, i, serie);
6624 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6625 omexml.setRectangleFillColor(colf, i, serie);
6626 }
6627 else
6628 if (an.type == ROI.Type.Line)
6629 {
6630 if (an.id != "")
6631 omexml.setLineID(an.id, i, serie);
6632 else
6633 omexml.setLineID("Shape:" + i + ":" + serie, i, serie);
6634 omexml.setLineX1(java.lang.Double.valueOf(b.ToImageSpaceX(an.GetPoint(0).X)), i, serie);
6635 omexml.setLineY1(java.lang.Double.valueOf(b.ToImageSpaceY(an.GetPoint(0).Y)), i, serie);
6636 omexml.setLineX2(java.lang.Double.valueOf(b.ToImageSpaceX(an.GetPoint(1).X)), i, serie);
6637 omexml.setLineY2(java.lang.Double.valueOf(b.ToImageSpaceY(an.GetPoint(1).Y)), i, serie);
6638 omexml.setLineTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6639 omexml.setLineTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6640 omexml.setLineTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6641 if (an.Text != "")
6642 omexml.setLineText(an.Text, i, serie);
6643 else
6644 omexml.setLineText(i.ToString(), i, serie);
6645 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6646 omexml.setLineFontSize(fl, i, serie);
6647 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6648 omexml.setLineStrokeColor(col, i, serie);
6649 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6650 omexml.setLineStrokeWidth(sw, i, serie);
6651 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6652 omexml.setLineFillColor(colf, i, serie);
6653 }
6654 else
6655 if (an.type == ROI.Type.Ellipse)
6656 {
6657
6658 if (an.id != "")
6659 omexml.setEllipseID(an.id, i, serie);
6660 else
6661 omexml.setEllipseID("Shape:" + i + ":" + serie, i, serie);
6662 //We need to change System.Drawing.Rectangle to ellipse radius;
6663 double w = (double)an.W / 2;
6664 double h = (double)an.H / 2;
6665 omexml.setEllipseRadiusX(java.lang.Double.valueOf(b.ToImageSizeX(w)), i, serie);
6666 omexml.setEllipseRadiusY(java.lang.Double.valueOf(b.ToImageSizeY(h)), i, serie);
6667
6668 double x = an.Point.X + w;
6669 double y = an.Point.Y + h;
6670 omexml.setEllipseX(java.lang.Double.valueOf(b.ToImageSpaceX(x)), i, serie);
6671 omexml.setEllipseY(java.lang.Double.valueOf(b.ToImageSpaceX(y)), i, serie);
6672 omexml.setEllipseTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6673 omexml.setEllipseTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6674 omexml.setEllipseTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6675 if (an.Text != "")
6676 omexml.setEllipseText(an.Text, i, serie);
6677 else
6678 omexml.setEllipseText(i.ToString(), i, serie);
6679 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6680 omexml.setEllipseFontSize(fl, i, serie);
6681 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6682 omexml.setEllipseStrokeColor(col, i, serie);
6683 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6684 omexml.setEllipseStrokeWidth(sw, i, serie);
6685 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6686 omexml.setEllipseFillColor(colf, i, serie);
6687 }
6688 else
6689 if (an.type == ROI.Type.Label)
6690 {
6691 if (an.id != "")
6692 omexml.setLabelID(an.id, i, serie);
6693 else
6694 omexml.setLabelID("Shape:" + i + ":" + serie, i, serie);
6695 omexml.setLabelX(java.lang.Double.valueOf(b.ToImageSpaceX(an.Rect.X)), i, serie);
6696 omexml.setLabelY(java.lang.Double.valueOf(b.ToImageSpaceY(an.Rect.Y)), i, serie);
6697 omexml.setLabelTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6698 omexml.setLabelTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6699 omexml.setLabelTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6700 omexml.setLabelText(i.ToString(), i, serie);
6701 if (an.Text != "")
6702 omexml.setLabelText(an.Text, i, serie);
6703 else
6704 omexml.setLabelText(i.ToString(), i, serie);
6705 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6706 omexml.setLabelFontSize(fl, i, serie);
6707 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6708 omexml.setLabelStrokeColor(col, i, serie);
6709 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6710 omexml.setLabelStrokeWidth(sw, i, serie);
6711 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6712 omexml.setLabelFillColor(colf, i, serie);
6713 }
6714 else
6715 if (an.type == ROI.Type.Mask || an.roiMask != null)
6716 {
6717 if (an.id != "")
6718 omexml.setMaskID(an.id, i, serie);
6719 else
6720 omexml.setMaskID("Shape:" + i + ":" + serie, i, serie);
6721 omexml.setMaskX(java.lang.Double.valueOf(b.ToImageSpaceX(b.StageSizeX + (an.roiMask.X * an.roiMask.PhysicalSizeX))), i, serie);
6722 omexml.setMaskY(java.lang.Double.valueOf(b.ToImageSpaceY(b.StageSizeY + (an.roiMask.Y * an.roiMask.PhysicalSizeY))), i, serie);
6723 omexml.setMaskTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.Z)), i, serie);
6724 omexml.setMaskTheC(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.C)), i, serie);
6725 omexml.setMaskTheT(new NonNegativeInteger(java.lang.Integer.valueOf(an.coord.T)), i, serie);
6726 omexml.setMaskWidth(new java.lang.Double(an.roiMask.Width * an.roiMask.PhysicalSizeX), i, serie);
6727 omexml.setMaskHeight(new java.lang.Double(an.roiMask.Height * an.roiMask.PhysicalSizeY), i, serie);
6728 if (an.Text != "")
6729 omexml.setMaskText(an.Text, i, serie);
6730 else
6731 omexml.setMaskText(i.ToString(), i, serie);
6732
6733 BioFormats::ome.units.quantity.Length fl = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.fontSize), BioFormats::ome.units.UNITS.PIXEL);
6734 omexml.setMaskFontSize(fl, i, serie);
6735 BioFormats::ome.xml.model.primitives.Color col = new BioFormats::ome.xml.model.primitives.Color(an.strokeColor.R, an.strokeColor.G, an.strokeColor.B, an.strokeColor.A);
6736 omexml.setMaskStrokeColor(col, i, serie);
6737 BioFormats::ome.units.quantity.Length sw = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(an.strokeWidth), BioFormats::ome.units.UNITS.PIXEL);
6738 omexml.setMaskStrokeWidth(sw, i, serie);
6739 BioFormats::ome.xml.model.primitives.Color colf = new BioFormats::ome.xml.model.primitives.Color(an.fillColor.R, an.fillColor.G, an.fillColor.B, an.fillColor.A);
6740 omexml.setMaskFillColor(colf, i, serie);
6741 byte[] bts = an.roiMask.GetBytes();
6742 omexml.setMaskBinData(bts, i, serie);
6743 omexml.setMaskBinDataBigEndian(new java.lang.Boolean(!BitConverter.IsLittleEndian), i, serie);
6744 omexml.setMaskBinDataLength(new NonNegativeLong(new java.lang.Long(bts.Length)), i, serie);
6745 omexml.setMaskBinDataCompression(BioFormats::ome.xml.model.enums.Compression.NONE, i, serie);
6746 }
6747
6748 i++;
6749 }
6750
6751 if (b.Buffers[0].Plane != null && planes)
6752 for (int bu = 0; bu < b.Buffers.Count; bu++)
6753 {
6754 //Correct order of parameters.
6755 if (b.Buffers[bu].Plane.Delta != 0)
6756 {
6757 BioFormats::ome.units.quantity.Time t = new BioFormats::ome.units.quantity.Time(java.lang.Double.valueOf(b.Buffers[bu].Plane.Delta), BioFormats::ome.units.UNITS.MILLISECOND);
6758 omexml.setPlaneDeltaT(t, serie, bu);
6759 }
6760 if (b.Buffers[bu].Plane.Exposure != 0)
6761 {
6762 BioFormats::ome.units.quantity.Time et = new BioFormats::ome.units.quantity.Time(java.lang.Double.valueOf(b.Buffers[bu].Plane.Exposure), BioFormats::ome.units.UNITS.MILLISECOND);
6763 omexml.setPlaneExposureTime(et, serie, bu);
6764 }
6765 BioFormats::ome.units.quantity.Length lx = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.Buffers[bu].Plane.Location.X), BioFormats::ome.units.UNITS.MICROMETER);
6766 BioFormats::ome.units.quantity.Length ly = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.Buffers[bu].Plane.Location.Y), BioFormats::ome.units.UNITS.MICROMETER);
6767 BioFormats::ome.units.quantity.Length lz = new BioFormats::ome.units.quantity.Length(java.lang.Double.valueOf(b.Buffers[bu].Plane.Location.Z), BioFormats::ome.units.UNITS.MICROMETER);
6768 omexml.setPlanePositionX(lx, serie, bu);
6769 omexml.setPlanePositionY(ly, serie, bu);
6770 omexml.setPlanePositionZ(lz, serie, bu);
6771 omexml.setPlaneTheC(new NonNegativeInteger(java.lang.Integer.valueOf(b.Buffers[bu].Plane.Coordinate.C)), serie, bu);
6772 omexml.setPlaneTheZ(new NonNegativeInteger(java.lang.Integer.valueOf(b.Buffers[bu].Plane.Coordinate.Z)), serie, bu);
6773 omexml.setPlaneTheT(new NonNegativeInteger(java.lang.Integer.valueOf(b.Buffers[bu].Plane.Coordinate.T)), serie, bu);
6774
6775 omexml.setTiffDataPlaneCount(new NonNegativeInteger(java.lang.Integer.valueOf(1)), serie, bu);
6776 omexml.setTiffDataIFD(new NonNegativeInteger(java.lang.Integer.valueOf(bu)), serie, bu);
6777 omexml.setTiffDataFirstC(new NonNegativeInteger(java.lang.Integer.valueOf(b.Buffers[bu].Plane.Coordinate.C)), serie, bu);
6778 omexml.setTiffDataFirstZ(new NonNegativeInteger(java.lang.Integer.valueOf(b.Buffers[bu].Plane.Coordinate.Z)), serie, bu);
6779 omexml.setTiffDataFirstT(new NonNegativeInteger(java.lang.Integer.valueOf(b.Buffers[bu].Plane.Coordinate.T)), serie, bu);
6780
6781 }
6782
6783 }
6784 writer = new ImageWriter();
6785 writer.setMetadataRetrieve(omexml);
6786 try
6787 {
6788 Status = "Saving OME Image Planes.";
6789 for (int i = 0; i < files.Length; i++)
6790 {
6791 Console.WriteLine("Writer setId: " + files[i]);
6792 writer.setId(f);
6793 BioImage b = files[i];
6794 progFile = files[i].Filename;
6795 writer.setSeries(i);
6796 for (int bu = 0; bu < b.Buffers.Count; bu++)
6797 {
6798 byte[] bts = b.Buffers[bu].GetSaveBytes(BitConverter.IsLittleEndian);
6799 writer.saveBytes(bu, bts);
6800 Progress = ((float)bu / (float)b.Buffers.Count) * 100;
6801 }
6802 }
6803 if (!OperatingSystem.IsMacOS())
6804 {
6805 Console.WriteLine("Closing writer.");
6806 writer.close();
6807 }
6808 }
6809 catch (Exception e)
6810 {
6811 Console.WriteLine(e.Message);
6812 }
6813
6814 Recorder.Record(BioLib.Recorder.GetCurrentMethodInfo(), false, files, f, planes);
6815 }

◆ SavePyramidalAsync()

static async Task BioLib.BioImage.SavePyramidalAsync ( BioImage[] imgs,
string file,
Enums.ForeignTiffCompression com,
int compLevel )
static

The function SavePyramidalAsync saves an array of BioImage objects as a pyramidal TIFF file asynchronously.

Parameters
imgsimgs is an array of BioImage objects.
fileThe "file" parameter is a string that represents the file path where the pyramidal image will be saved.
comThe parameter "com" is of type Enums.ForeignTiffCompression, which is an enumeration representing different compression options for the TIFF file.
compLevelThe compLevel parameter is an integer that represents the compression level for the TIFF file. It is used to specify the level of compression to be applied to the image data when saving the pyramidal image. The higher the compression level, the smaller the file size but potentially lower image quality.

Definition at line 8903 of file Bio.cs.

8904 {
8905 bms = imgs;
8906 savefile = file;
8907 comp = com;
8908 compLev = compLevel;
8909 await Task.Run(SavePyramidalThread);
8910 }

◆ 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.

Definition at line 5751 of file Bio.cs.

5752 {
5753 string desc = "";
5754 int stride = 0;
5755 ImageJDesc j = new ImageJDesc();
5756 BioImage bi = Images.GetImage(IDs[0]);
5757 j.FromImage(bi);
5758 desc = j.GetString();
5759 for (int fi = 0; fi < IDs.Length; fi++)
5760 {
5761 string id = IDs[fi];
5762 BioImage b = Images.GetImage(id);
5763 string fn = Path.GetFileNameWithoutExtension(id);
5764 string dir = Path.GetDirectoryName(file);
5765 stride = b.Buffers[0].Stride;
5766
5767 //Save ROIs to CSV file.
5768 if (b.Annotations.Count > 0)
5769 {
5770 string f = dir + "//" + fn + ".csv";
5771 ExportROIsCSV(f, b.Annotations);
5772 }
5773
5774 //Embed ROI's to image description.
5775 for (int i = 0; i < b.Annotations.Count; i++)
5776 {
5777 desc += "-ROI:" + b.series + ":" + ROIToString(b.Annotations[i]) + NewLine;
5778 }
5779 foreach (Channel c in b.Channels)
5780 {
5781 string cj = JsonConvert.SerializeObject(c.info, Formatting.None);
5782 desc += "-Channel:" + fi + ":" + cj + NewLine;
5783 }
5784 string json = JsonConvert.SerializeObject(b.imageInfo, Formatting.None);
5785 desc += "-ImageInfo:" + fi + ":" + json + NewLine;
5786 }
5787
5788 Tiff image = Tiff.Open(file, "w");
5789 for (int fi = 0; fi < IDs.Length; fi++)
5790 {
5791 int im = 0;
5792 string id = IDs[fi];
5793 BioImage b = Images.GetImage(id);
5794 int sizec = 1;
5795 if (!b.isRGB)
5796 {
5797 sizec = b.SizeC;
5798 }
5799 byte[] buffer;
5800 for (int c = 0; c < sizec; c++)
5801 {
5802 for (int z = 0; z < b.SizeZ; z++)
5803 {
5804 for (int t = 0; t < b.SizeT; t++)
5805 {
5806 image.SetDirectory((short)(im + (b.Buffers.Count * fi)));
5807 image.SetField(TiffTag.IMAGEWIDTH, b.SizeX);
5808 image.SetField(TiffTag.IMAGEDESCRIPTION, desc);
5809 image.SetField(TiffTag.IMAGELENGTH, b.SizeY);
5810 image.SetField(TiffTag.BITSPERSAMPLE, b.bitsPerPixel);
5811 image.SetField(TiffTag.SAMPLESPERPIXEL, b.RGBChannelCount);
5812 image.SetField(TiffTag.ROWSPERSTRIP, b.SizeY);
5813 image.SetField(TiffTag.ORIENTATION, BitMiracle.LibTiff.Classic.Orientation.TOPLEFT);
5814 image.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
5815 image.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);
5816 image.SetField(TiffTag.ROWSPERSTRIP, image.DefaultStripSize(0));
5817 if (b.PhysicalSizeX != -1 && b.PhysicalSizeY != -1)
5818 {
5819 image.SetField(TiffTag.XRESOLUTION, (b.PhysicalSizeX * b.SizeX) / ((b.PhysicalSizeX * b.SizeX) * b.PhysicalSizeX));
5820 image.SetField(TiffTag.YRESOLUTION, (b.PhysicalSizeY * b.SizeY) / ((b.PhysicalSizeY * b.SizeY) * b.PhysicalSizeY));
5821 image.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.NONE);
5822 }
5823 else
5824 {
5825 image.SetField(TiffTag.XRESOLUTION, 100.0);
5826 image.SetField(TiffTag.YRESOLUTION, 100.0);
5827 image.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.INCH);
5828 }
5829 // specify that it's a page within the multipage file
5830 image.SetField(TiffTag.SUBFILETYPE, FileType.PAGE);
5831 // specify the page number
5832 buffer = b.Buffers[im].GetSaveBytes(true);
5833 image.SetField(TiffTag.PAGENUMBER, im + (b.Buffers.Count * fi), b.Buffers.Count * IDs.Length);
5834 for (int i = 0, offset = 0; i < b.SizeY; i++)
5835 {
5836 image.WriteScanline(buffer, offset, i, 0);
5837 offset += stride;
5838 }
5839 image.WriteDirectory();
5840 im++;
5841 }
5842 }
5843 }
5844 }
5845 image.Dispose();
5846 }

◆ SaveSeriesAsync()

static async Task BioLib.BioImage.SaveSeriesAsync ( BioImage[] imgs,
string file,
bool ome )
static

The function SaveSeriesAsync saves a series of BioImage objects to a file asynchronously.

Parameters
imgsimgs is an array of BioImage objects.
fileThe "file" parameter is a string that represents the file path where the series of BioImages will be saved.
omeThe "ome" parameter is a boolean flag that indicates whether the images should be saved in OME-TIFF format or not. If "ome" is set to true, the images will be saved in OME-TIFF format. If "ome" is set to false, the images will be

Definition at line 8872 of file Bio.cs.

8873 {
8874 sts.Clear();
8875 foreach (BioImage item in imgs)
8876 {
8877 sts.Add(item.ID);
8878 }
8879 savefile = file;
8880 some = ome;
8881 await Task.Run(SaveSeriesThread);
8882 }

◆ SetFrameIndex()

void BioLib.BioImage.SetFrameIndex ( int z,
int c,
int t,
int val )

Definition at line 8217 of file Bio.cs.

8218 {
8219 Coords[z, c, t] = val;
8220 }

◆ 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.

Definition at line 5120 of file Bio.cs.

5121 {
5122 Buffers[ind].SetValue(x, y, value);
5123 }

◆ 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

Definition at line 5130 of file Bio.cs.

5131 {
5132 SetValue(x, y, GetFrameIndex(coord.Z, coord.C, coord.T), value);
5133 }
void SetValue(ZCTXY coord, ushort value)
It takes a coordinate and a value, and sets the value at that coordinate.
Definition Bio.cs:5109

◆ 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

Definition at line 5109 of file Bio.cs.

5110 {
5111 int i = GetFrameIndex(coord.Z, coord.C, coord.T);
5112 Buffers[i].SetValue(coord.X, coord.Y, value);
5113 }

◆ 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

Definition at line 5140 of file Bio.cs.

5141 {
5142 int ind = GetFrameIndex(coord.Z, coord.C, coord.T);
5143 Buffers[ind].SetValue(coord.X, coord.Y, RGBindex, value);
5144 }

◆ 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

Definition at line 4833 of file Bio.cs.

4834 {
4835 BioImage[] bms;
4836 if (isRGB)
4837 {
4838 bms = new BioImage[3];
4839 BioImage ri = new BioImage(Path.GetFileNameWithoutExtension(ID) + "-1" + Path.GetExtension(ID));
4840 BioImage gi = new BioImage(Path.GetFileNameWithoutExtension(ID) + "-2" + Path.GetExtension(ID));
4841 BioImage bi = new BioImage(Path.GetFileNameWithoutExtension(ID) + "-3" + Path.GetExtension(ID));
4842 ri.sizeC = 1;
4843 gi.sizeC = 1;
4844 bi.sizeC = 1;
4845 ri.sizeZ = SizeZ;
4846 gi.sizeZ = SizeZ;
4847 bi.sizeZ = SizeZ;
4848 ri.sizeT = SizeT;
4849 gi.sizeT = SizeT;
4850 bi.sizeT = SizeT;
4851
4852 ri.Coords = new int[SizeZ, 1, SizeT];
4853 gi.Coords = new int[SizeZ, 1, SizeT];
4854 bi.Coords = new int[SizeZ, 1, SizeT];
4855 int ind = 0;
4856 for (int i = 0; i < ImageCount; i++)
4857 {
4858 if (Buffers[i].PixelFormat == PixelFormat.Format48bppRgb)
4859 {
4860 //For 48bit images we need to use our own function as AForge won't give us a proper image.
4861 Bitmap[] bfs = Bitmap.RGB48To16(ID, SizeX, SizeY, Buffers[i].Stride, Buffers[i].Bytes, Buffers[i].Coordinate, ind, Buffers[i].Plane);
4862 ind += 3;
4863 ri.Buffers.Add(bfs[0]);
4864 gi.Buffers.Add(bfs[1]);
4865 bi.Buffers.Add(bfs[2]);
4866 bfs[0].Stats = Statistics.FromBytes(bfs[0]);
4867 bfs[1].Stats = Statistics.FromBytes(bfs[1]);
4868 bfs[2].Stats = Statistics.FromBytes(bfs[2]);
4869 ri.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4870 gi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4871 bi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4872 }
4873 else
4874 {
4875
4876 Bitmap rImage = extractR.Apply(Buffers[i]);
4877 Bitmap rbf = new Bitmap(ri.ID, rImage, Buffers[i].Coordinate, ind++);
4878 rbf.Stats = Statistics.FromBytes(rbf);
4879 ri.Buffers.Add(rbf);
4880 ri.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4881
4882 Bitmap gImage = extractG.Apply(Buffers[i]);
4883 Bitmap gbf = new Bitmap(gi.ID, gImage, Buffers[i].Coordinate, ind++);
4884 gbf.Stats = Statistics.FromBytes(gbf);
4885 gi.Buffers.Add(gbf);
4886 gi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4887
4888 Bitmap bImage = extractB.Apply(Buffers[i]);
4889 //Clipboard.SetImage(bImage);
4890 Bitmap bbf = new Bitmap(bi.ID, bImage, Buffers[i].Coordinate, ind++);
4891 bbf.Stats = Statistics.FromBytes(bbf);
4892 bi.Buffers.Add(bbf);
4893 bi.SetFrameIndex(Buffers[i].Coordinate.Z, Buffers[i].Coordinate.C, Buffers[i].Coordinate.T, i);
4894
4895 }
4896 }
4897 //We wait for threshold image statistics calculation
4898 do
4899 {
4900 Thread.Sleep(100);
4901 } while (bi.Buffers[bi.Buffers.Count - 1].Stats == null);
4902 ri.Resolutions.Add(new Resolution(Buffers[0].SizeX, Buffers[0].SizeY, Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
4903 gi.Resolutions.Add(new Resolution(Buffers[0].SizeX, Buffers[0].SizeY, Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
4904 bi.Resolutions.Add(new Resolution(Buffers[0].SizeX, Buffers[0].SizeY, Buffers[0].PixelFormat, PhysicalSizeX, PhysicalSizeY, PhysicalSizeZ, StageSizeX, StageSizeY, StageSizeZ));
4905 ri.Channels.Add(Channels[0].Copy());
4906 gi.Channels.Add(Channels[0].Copy());
4907 bi.Channels.Add(Channels[0].Copy());
4908 AutoThreshold(ri, false);
4909 AutoThreshold(gi, false);
4910 AutoThreshold(bi, false);
4911 Images.AddImage(ri);
4912 Images.AddImage(gi);
4913 Images.AddImage(bi);
4914 bms[0] = ri;
4915 bms[1] = gi;
4916 bms[2] = bi;
4917 }
4918 else
4919 {
4920 bms = new BioImage[SizeC];
4921 for (int c = 0; c < SizeC; c++)
4922 {
4923 BioImage b = BioImage.Substack(this, 0, 0, SizeZ, c, c + 1, 0, SizeT);
4924 bms[c] = b;
4925 }
4926 }
4927 return bms;
4928 }

◆ 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

Definition at line 4934 of file Bio.cs.

4935 {
4936 return bb.SplitChannels();
4937 }

◆ 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.

Definition at line 4943 of file Bio.cs.

4944 {
4945 return SplitChannels(Images.GetImage(name));
4946 }
BioImage[] SplitChannels()
It takes a single image and splits it into three images, one for each channel.
Definition Bio.cs:4833

◆ StackThreshold()

void BioLib.BioImage.StackThreshold ( bool bit16)

This function sets the minimum and maximum values of the image to the minimum and maximum values of the stack.

Parameters
bit16true = 16 bit, false = 8 bit

Definition at line 8359 of file Bio.cs.

8360 {
8361 if (bit16)
8362 {
8363 for (int ch = 0; ch < Channels.Count; ch++)
8364 {
8365 for (int i = 0; i < Channels[ch].range.Length; i++)
8366 {
8367 Channels[ch].range[i].Min = (int)Channels[ch].stats[i].StackMin;
8368 Channels[ch].range[i].Max = (int)Channels[ch].stats[i].StackMax;
8369 }
8370 Channels[ch].BitsPerPixel = 16;
8371 }
8372 bitsPerPixel = 16;
8373 }
8374 else
8375 {
8376 for (int ch = 0; ch < Channels.Count; ch++)
8377 {
8378 for (int i = 0; i < Channels[ch].range.Length; i++)
8379 {
8380 Channels[ch].range[i].Min = (int)Channels[ch].stats[i].StackMin;
8381 Channels[ch].range[i].Max = (int)Channels[ch].stats[i].StackMax;
8382 }
8383 Channels[ch].BitsPerPixel = 8;
8384 }
8385 bitsPerPixel = 8;
8386 }
8387 Recorder.AddLine("BioLib.Images.GetImage(\"" + id + "\").StackThreshold(" + bit16.ToString().ToLower() + ");", true);
8388 }

◆ StringToROI()

static ROI BioLib.BioImage.StringToROI ( string sts)
static

It takes a string and returns an ROI object.

Parameters
ststhe string that contains the ROI data
Returns
A ROI object.

Definition at line 9403 of file Bio.cs.

9404 {
9405 //Works with either comma or tab separated values.
9406 if (sts.StartsWith("<?xml") || sts.StartsWith("{"))
9407 return null;
9408 ROI an = new ROI();
9409 string val = "";
9410 bool inSep = false;
9411 int col = 0;
9412 double x = 0;
9413 double y = 0;
9414 double w = 0;
9415 double h = 0;
9416 string line = sts;
9417 bool points = false;
9418 char sep = '"';
9419 for (int i = 0; i < line.Length; i++)
9420 {
9421 char c = line[i];
9422 if (c == sep)
9423 {
9424 if (!inSep)
9425 {
9426 inSep = true;
9427 }
9428 else
9429 inSep = false;
9430 continue;
9431 }
9432
9433 if ((c == ',' || c == '\t') && (!inSep || points))
9434 {
9435 //ROIID,ROINAME,TYPE,ID,SHAPEINDEX,TEXT,C,Z,T,X,Y,W,H,POINTS,STROKECOLOR,STROKECOLORW,FILLCOLOR,FONTSIZE
9436 if (col == 0)
9437 {
9438 //ROIID
9439 an.roiID = val;
9440 }
9441 else
9442 if (col == 1)
9443 {
9444 //ROINAME
9445 an.roiName = val;
9446 }
9447 else
9448 if (col == 2)
9449 {
9450 //TYPE
9451 an.type = (ROI.Type)Enum.Parse(typeof(ROI.Type), val);
9452 if (an.type == ROI.Type.Freeform || an.type == ROI.Type.Polygon)
9453 an.closed = true;
9454 }
9455 else
9456 if (col == 3)
9457 {
9458 //ID
9459 an.id = val;
9460 }
9461 else
9462 if (col == 4)
9463 {
9464 //SHAPEINDEX/
9465 an.shapeIndex = int.Parse(val);
9466 }
9467 else
9468 if (col == 5)
9469 {
9470 //TEXT/
9471 an.Text = val;
9472 }
9473 else
9474 if (col == 6)
9475 {
9476 an.serie = int.Parse(val);
9477 }
9478 else
9479 if (col == 7)
9480 {
9481 an.coord.Z = int.Parse(val);
9482 }
9483 else
9484 if (col == 8)
9485 {
9486 an.coord.C = int.Parse(val);
9487 }
9488 else
9489 if (col == 9)
9490 {
9491 an.coord.T = int.Parse(val);
9492 }
9493 else
9494 if (col == 10)
9495 {
9496 x = double.Parse(val, CultureInfo.InvariantCulture);
9497 }
9498 else
9499 if (col == 11)
9500 {
9501 y = double.Parse(val, CultureInfo.InvariantCulture);
9502 }
9503 else
9504 if (col == 12)
9505 {
9506 w = double.Parse(val, CultureInfo.InvariantCulture);
9507 }
9508 else
9509 if (col == 13)
9510 {
9511 h = double.Parse(val, CultureInfo.InvariantCulture);
9512 }
9513 else
9514 if (col == 14)
9515 {
9516 //POINTS
9517 an.AddPoints(an.stringToPoints(val));
9518 points = false;
9519 an.Rect = new RectangleD(x, y, w, h);
9520 }
9521 else
9522 if (col == 15)
9523 {
9524 //STROKECOLOR
9525 string[] st = val.Split(',');
9526 an.strokeColor = Color.FromArgb(int.Parse(st[0]), int.Parse(st[1]), int.Parse(st[2]), int.Parse(st[3]));
9527 }
9528 else
9529 if (col == 16)
9530 {
9531 //STROKECOLORW
9532 an.strokeWidth = double.Parse(val, CultureInfo.InvariantCulture);
9533 }
9534 else
9535 if (col == 17)
9536 {
9537 //FILLCOLOR
9538 string[] st = val.Split(',');
9539 an.fillColor = Color.FromArgb(int.Parse(st[0]), int.Parse(st[1]), int.Parse(st[2]), int.Parse(st[3]));
9540 }
9541 else
9542 if (col == 18)
9543 {
9544 //FONTSIZE
9545 double s = double.Parse(val, CultureInfo.InvariantCulture);
9546 an.fontSize = (float)s;
9547 an.family = "Times New Roman";
9548 }
9549 col++;
9550 val = "";
9551 }
9552 else
9553 val += c;
9554 }
9555
9556 return an;
9557 }

◆ 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.

Definition at line 4619 of file Bio.cs.

4620 {
4621 BioImage b = CopyInfo(orig, false, false);
4622 //b.ID = Images.GetImageName(orig.ID);
4623 int i = 0;
4624 b.Coords = new int[ze - zs, ce - cs, te - ts];
4625 b.sizeZ = ze - zs;
4626 b.sizeC = ce - cs;
4627 b.sizeT = te - ts;
4628 for (int ti = 0; ti < b.SizeT; ti++)
4629 {
4630 for (int zi = 0; zi < b.SizeZ; zi++)
4631 {
4632 for (int ci = 0; ci < b.SizeC; ci++)
4633 {
4634 int ind = orig.GetFrameIndex(zs + zi, cs + ci, ts + ti);
4635 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);
4636 bf.Stats = Statistics.FromBytes(bf);
4637 b.Buffers.Add(bf);
4638 b.SetFrameIndex(zi, ci, ti, i);
4639 i++;
4640 }
4641 }
4642 }
4643 for (int ci = cs; ci < ce; ci++)
4644 {
4645 b.Channels.Add(orig.Channels[ci]);
4646 }
4647 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));
4648 AutoThreshold(b, false);
4649 if (b.bitsPerPixel > 8)
4650 b.StackThreshold(true);
4651 else
4652 b.StackThreshold(false);
4653 Images.AddImage(b);
4654 return b;
4655 }

◆ To16Bit()

void BioLib.BioImage.To16Bit ( )

Converts the image to 16 bit.

Definition at line 3839 of file Bio.cs.

3840 {
3841 if (Buffers[0].RGBChannelsCount == 4)
3842 To24Bit();
3843 if (Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale)
3844 return;
3845 bitsPerPixel = 16;
3846 if (Buffers[0].PixelFormat == PixelFormat.Format48bppRgb)
3847 {
3848 List<Bitmap> bfs = new List<Bitmap>();
3849 int index = 0;
3850 for (int i = 0; i < Buffers.Count; i++)
3851 {
3852 Array.Reverse(Buffers[i].Bytes);
3853 Bitmap[] bs = Bitmap.RGB48To16(ID, SizeX, SizeY, Buffers[i].Stride, Buffers[i].Bytes, Buffers[i].Coordinate, index, Buffers[i].Plane);
3854 bfs.AddRange(bs);
3855 index += 3;
3856 }
3857 Buffers = bfs;
3858 UpdateCoords(SizeZ, SizeC * 3, SizeT);
3859 if (Channels[0].SamplesPerPixel == 3)
3860 {
3861 Channel c = Channels[0].Copy();
3862 c.SamplesPerPixel = 1;
3863 c.range = new IntRange[1];
3864 Channels.Clear();
3865 Channels.Add(c);
3866 Channels.Add(c.Copy());
3867 Channels.Add(c.Copy());
3868 Channels[1].Index = 1;
3869 Channels[2].Index = 2;
3870 }
3871 }
3872 else if (Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
3873 {
3874 for (int i = 0; i < Buffers.Count; i++)
3875 {
3876 Buffers[i] = AForge.Imaging.Image.Convert8bppTo16bpp(Buffers[i]);
3877 }
3878 for (int c = 0; c < Channels.Count; c++)
3879 {
3880 for (int i = 0; i < Channels[c].range.Length; i++)
3881 {
3882 Channels[c].range[i].Min = (int)(((float)Channels[c].range[i].Min / (float)byte.MaxValue) * ushort.MaxValue);
3883 Channels[c].range[i].Max = (int)(((float)Channels[c].range[i].Max / (float)byte.MaxValue) * ushort.MaxValue);
3884 }
3885 Channels[c].BitsPerPixel = 16;
3886 }
3887 bitsPerPixel = 16;
3888 }
3889 else if (Buffers[0].PixelFormat == PixelFormat.Format24bppRgb)
3890 {
3891 To48Bit();
3892 To16Bit();
3893 }
3894 else if (Buffers[0].PixelFormat == PixelFormat.Float)
3895 {
3896 for (int i = 0; i < Buffers.Count; i++)
3897 {
3898 if (Statistics.StackMax <= 1)
3899 Buffers[i].To16Bit(true);
3900 else
3901 Buffers[i].To16Bit(false);
3902 }
3903 }
3904
3905 foreach (var item in Buffers)
3906 {
3907 item.Stats = Statistics.FromBytes(item);
3908 }
3909 AutoThreshold(this, true);
3910 StackThreshold(true);
3911 }
void To16Bit()
Converts the image to 16 bit.
Definition Bio.cs:3839
void UpdateCoords()
It takes a list of images and assigns them to a 3D array of coordinates.
Definition Bio.cs:4209
void To24Bit()
Converts the image to 24 bit.
Definition Bio.cs:3913
void StackThreshold(bool bit16)
This function sets the minimum and maximum values of the image to the minimum and maximum values of t...
Definition Bio.cs:8359
void To48Bit()
Definition Bio.cs:4007

◆ To24Bit()

void BioLib.BioImage.To24Bit ( )

Converts the image to 24 bit.

Definition at line 3913 of file Bio.cs.

3914 {
3915 if (Buffers[0].PixelFormat == PixelFormat.Format24bppRgb)
3916 return;
3917 bitsPerPixel = 8;
3918 if (Buffers[0].PixelFormat == PixelFormat.Format32bppArgb || Buffers[0].PixelFormat == PixelFormat.Format32bppRgb)
3919 {
3920 for (int i = 0; i < Buffers.Count; i++)
3921 {
3922 Buffers[i] = Bitmap.To24Bit(Buffers[i]);
3923 }
3924 if (Channels.Count == 4)
3925 {
3926 Channels.RemoveAt(0);
3927 }
3928 else
3929 {
3930 Channels[0].SamplesPerPixel = 3;
3931 }
3932 }
3933 else
3934 if (Buffers[0].PixelFormat == PixelFormat.Format48bppRgb)
3935 {
3936 //We run 8bit so we get 24 bit rgb.
3937 for (int i = 0; i < Buffers.Count; i++)
3938 {
3939 Buffers[i] = AForge.Imaging.Image.Convert16bppTo8bpp(Buffers[i]);
3940 Buffers[i].SwitchRedBlue();
3941 }
3942 }
3943 else
3944 if (Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale || Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
3945 {
3946 if (Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale)
3947 {
3948 for (int i = 0; i < Buffers.Count; i++)
3949 {
3950 Buffers[i].Image = AForge.Imaging.Image.Convert16bppTo8bpp(Buffers[i]);
3951 }
3952 for (int c = 0; c < Channels.Count; c++)
3953 {
3954 for (int i = 0; i < Channels[c].range.Length; i++)
3955 {
3956 Channels[c].range[i].Min = (int)(((float)Channels[c].range[i].Min / (float)ushort.MaxValue) * byte.MaxValue);
3957 Channels[c].range[i].Max = (int)(((float)Channels[c].range[i].Max / (float)ushort.MaxValue) * byte.MaxValue);
3958 }
3959 Channels[c].BitsPerPixel = 8;
3960 }
3961 }
3962 List<Bitmap> bfs = new List<Bitmap>();
3963 if (Buffers.Count % 3 != 0)
3964 for (int i = 0; i < Buffers.Count; i++)
3965 {
3966 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);
3967 Bitmap bbs = Bitmap.RGB8To24(bs);
3968 bs.Dispose();
3969 bs = null;
3970 bfs.Add(bbs);
3971 }
3972 else
3973 for (int i = 0; i < Buffers.Count; i++)
3974 {
3975 Bitmap bs = Bitmap.GetBitmapRGB(Buffers[i].SizeX, Buffers[i].SizeY, PixelFormat.Format24bppRgb, Buffers[i].Bytes);
3976 bfs.Add(bs);
3977 }
3978 Buffers = bfs;
3979 UpdateCoords(SizeZ, 1, SizeT);
3980 }
3981 foreach (var item in Buffers)
3982 {
3983 item.Stats = Statistics.FromBytes(item);
3984 }
3985 AutoThreshold(this, true);
3986 StackThreshold(false);
3987 }

◆ To32Bit()

void BioLib.BioImage.To32Bit ( )

Converts the image to 32 bit.

Definition at line 3989 of file Bio.cs.

3990 {
3991 if (Buffers[0].PixelFormat == PixelFormat.Format32bppArgb)
3992 return;
3993 if (Buffers[0].PixelFormat != PixelFormat.Format24bppRgb)
3994 {
3995 To24Bit();
3996 }
3997 for (int i = 0; i < Buffers.Count; i++)
3998 {
3999 UnmanagedImage b = Bitmap.To32Bit(Buffers[i]);
4000 Buffers[i].Image = b;
4001 }
4002 AutoThreshold(this, true);
4003 }

◆ To48Bit()

void BioLib.BioImage.To48Bit ( )

It converts a 16 bit image to a 48 bit image

Returns
A list of Bitmaps.

Definition at line 4007 of file Bio.cs.

4008 {
4009 if (Buffers[0].RGBChannelsCount == 4)
4010 To24Bit();
4011 if (Buffers[0].PixelFormat == PixelFormat.Format48bppRgb)
4012 return;
4013 if (Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed || Buffers[0].PixelFormat == PixelFormat.Format16bppGrayScale)
4014 {
4015 if (Buffers[0].PixelFormat == PixelFormat.Format8bppIndexed)
4016 {
4017 for (int i = 0; i < Buffers.Count; i++)
4018 {
4019 Buffers[i].Image = AForge.Imaging.Image.Convert8bppTo16bpp(Buffers[i]);
4020 }
4021 }
4022 List<Bitmap> bfs = new List<Bitmap>();
4023 if (Buffers.Count % 3 != 0 && Buffers.Count % 2 != 0)
4024 for (int i = 0; i < Buffers.Count; i++)
4025 {
4026 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);
4027 Bitmap bbs = Bitmap.RGB16To48(bs);
4028 bs.Dispose();
4029 bs = null;
4030 bfs.Add(bbs);
4031 }
4032 else
4033 for (int i = 0; i < Buffers.Count; i += Channels.Count)
4034 {
4035 Bitmap[] bs = new Bitmap[3];
4036 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);
4037 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);
4038 if (Channels.Count > 2)
4039 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);
4040 Bitmap bbs = Bitmap.RGB16To48(bs);
4041 for (int b = 0; b < 3; b++)
4042 {
4043 if (bs[b] != null)
4044 bs[b].Dispose();
4045 bs[b] = null;
4046 }
4047 bfs.Add(bbs);
4048 }
4049 Buffers = bfs;
4050 UpdateCoords(SizeZ, 1, SizeT);
4051 Channel c = Channels[0].Copy();
4052 c.SamplesPerPixel = 3;
4053 rgbChannels[0] = 0;
4054 rgbChannels[1] = 0;
4055 rgbChannels[2] = 0;
4056 Channels.Clear();
4057 Channels.Add(c);
4058 }
4059 else
4060 if (Buffers[0].PixelFormat == PixelFormat.Format24bppRgb || Buffers[0].PixelFormat == PixelFormat.Format32bppArgb)
4061 {
4062 for (int i = 0; i < Buffers.Count; i++)
4063 {
4064 Buffers[i] = AForge.Imaging.Image.Convert8bppTo16bpp(Buffers[i]);
4065 Buffers[i].SwitchRedBlue();
4066 }
4067 }
4068 else
4069 {
4070 int index = 0;
4071 List<Bitmap> buffers = new List<Bitmap>();
4072 for (int i = 0; i < Buffers.Count; i += 3)
4073 {
4074 Bitmap[] bf = new Bitmap[3];
4075 bf[0] = Buffers[i];
4076 bf[1] = Buffers[i + 1];
4077 bf[2] = Buffers[i + 2];
4078 Bitmap inf = Bitmap.RGB16To48(bf);
4079 buffers.Add(inf);
4080 for (int b = 0; b < 3; b++)
4081 {
4082 bf[b].Dispose();
4083 }
4084 index++;
4085 }
4086 Buffers = buffers;
4087 UpdateCoords(SizeZ, 1, SizeT);
4088 }
4089 bitsPerPixel = 16;
4090 AutoThreshold(this, true);
4091 StackThreshold(true);
4092 }

◆ To8Bit()

void BioLib.BioImage.To8Bit ( )

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

Definition at line 3749 of file Bio.cs.

3750 {
3751 if (Buffers[0].RGBChannelsCount == 4)
3752 To24Bit();
3753 PixelFormat px = Buffers[0].PixelFormat;
3754 if (px == PixelFormat.Format8bppIndexed)
3755 return;
3756 if (px == PixelFormat.Format48bppRgb)
3757 {
3758 To24Bit();
3759 List<AForge.Bitmap> bfs = new List<AForge.Bitmap>();
3760 int index = 0;
3761 for (int i = 0; i < Buffers.Count; i++)
3762 {
3763 Bitmap[] bs = Bitmap.RGB24To8(Buffers[i]);
3764 Bitmap br = new Bitmap(ID, bs[2], new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i].Coordinate.T), index, Buffers[i].Plane);
3765 Bitmap bg = new Bitmap(ID, bs[1], new ZCT(Buffers[i].Coordinate.Z, 1, Buffers[i].Coordinate.T), index + 1, Buffers[i].Plane);
3766 Bitmap bb = new Bitmap(ID, bs[0], new ZCT(Buffers[i].Coordinate.Z, 2, Buffers[i].Coordinate.T), index + 2, Buffers[i].Plane);
3767 for (int b = 0; b < 3; b++)
3768 {
3769 bs[b].Dispose();
3770 }
3771 bs = null;
3772 br.Stats = Statistics.FromBytes(br);
3773 bg.Stats = Statistics.FromBytes(bg);
3774 bb.Stats = Statistics.FromBytes(bb);
3775 bfs.Add(br);
3776 bfs.Add(bg);
3777 bfs.Add(bb);
3778 index += 3;
3779 }
3780 Buffers = bfs;
3781 UpdateCoords(SizeZ, 3, SizeT);
3782 }
3783 else
3784 if (px == PixelFormat.Format24bppRgb)
3785 {
3786 List<Bitmap> bfs = new List<Bitmap>();
3787 int index = 0;
3788 for (int i = 0; i < Buffers.Count; i++)
3789 {
3790 Bitmap[] bs = Bitmap.RGB24To8(Buffers[i]);
3791 Bitmap br = new Bitmap(ID, bs[2], new ZCT(Buffers[i].Coordinate.Z, 0, Buffers[i].Coordinate.T), index, Buffers[i].Plane);
3792 Bitmap bg = new Bitmap(ID, bs[1], new ZCT(Buffers[i].Coordinate.Z, 1, Buffers[i].Coordinate.T), index + 1, Buffers[i].Plane);
3793 Bitmap bb = new Bitmap(ID, bs[0], new ZCT(Buffers[i].Coordinate.Z, 2, Buffers[i].Coordinate.T), index + 2, Buffers[i].Plane);
3794 for (int b = 0; b < 3; b++)
3795 {
3796 bs[b].Dispose();
3797 bs[b] = null;
3798 }
3799 bs = null;
3800 br.Stats = Statistics.FromBytes(br);
3801 bg.Stats = Statistics.FromBytes(bg);
3802 bb.Stats = Statistics.FromBytes(bb);
3803 bfs.Add(br);
3804 bfs.Add(bg);
3805 bfs.Add(bb);
3806 index += 3;
3807 }
3808 Buffers = bfs;
3809 UpdateCoords(SizeZ, 3, SizeT);
3810 Channels.Clear();
3811 Channels.Add(new Channel(0, 8, 1));
3812 Channels.Add(new Channel(0, 8, 1));
3813 Channels.Add(new Channel(0, 8, 1));
3814 }
3815 else
3816 if (px == PixelFormat.Format16bppGrayScale)
3817 {
3818 foreach (var item in Buffers)
3819 {
3820 item.To8Bit();
3821 }
3822 }
3823 else
3824 if (px == PixelFormat.Float)
3825 {
3826 foreach (var item in Buffers)
3827 {
3828 if (Statistics.StackMax <= 1)
3829 item.To8Bit(true);
3830 else
3831 item.To8Bit(false);
3832 }
3833 }
3834 AutoThreshold(this, true);
3835 StackThreshold(false);
3836 bitsPerPixel = 8;
3837 }

◆ ToFloat()

void BioLib.BioImage.ToFloat ( )

Definition at line 4102 of file Bio.cs.

4103 {
4104 foreach (var b in Buffers)
4105 {
4106 b.ToFloat();
4107 b.Stats = Statistics.FromBytes(b);
4108 }
4109 AutoThreshold(this, true);
4110 StackThreshold(false);
4111 }

◆ 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.

Definition at line 4371 of file Bio.cs.

4372 {
4373 return d / PhysicalSizeX;
4374 }

◆ 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.

Definition at line 4381 of file Bio.cs.

4382 {
4383 return d / PhysicalSizeY;
4384 }

◆ ToImageSpace() [1/5]

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.

Definition at line 4424 of file Bio.cs.

4425 {
4426 PointD[] ps = new PointD[p.Count];
4427 for (int i = 0; i < p.Count; i++)
4428 {
4429 PointD pp = new PointD();
4430 pp.X = ((p[i].X - StageSizeX) / PhysicalSizeX);
4431 pp.Y = ((p[i].Y - StageSizeY) / PhysicalSizeY);
4432 ps[i] = pp;
4433 }
4434 return ps;
4435 }

◆ ToImageSpace() [2/5]

static PointD[] BioLib.BioImage.ToImageSpace ( List< PointD > p,
double stageSizeX,
double stageSizeY,
double physicalSizeX,
double physicalSizeY )
static

The function takes a list of points in stage space and converts them to image space using the provided stage and physical size parameters.

Parameters
pA list of PointD objects representing points in stage space.
stageSizeXThe width of the stage or canvas in pixels.
stageSizeYThe stageSizeY parameter represents the size of the stage or canvas in the Y-axis direction. It is used to calculate the Y-coordinate of each point in the p list in image space.
physicalSizeXThe physical size of the X-axis in the image space.
physicalSizeYThe physical size of the Y-axis in the coordinate system of the stage or image.
Returns
The method is returning an array of PointD objects.

Definition at line 8461 of file Bio.cs.

8462 {
8463 PointD[] ps = new PointD[p.Count];
8464 for (int i = 0; i < p.Count; i++)
8465 {
8466 PointD pp = new PointD();
8467 pp.X = ((p[i].X - stageSizeX) / physicalSizeX);
8468 pp.Y = ((p[i].Y - stageSizeY) / physicalSizeY);
8469 ps[i] = pp;
8470 }
8471 return ps;
8472 }

◆ ToImageSpace() [3/5]

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.

Definition at line 4412 of file Bio.cs.

4413 {
4414 PointD pp = new PointD();
4415 pp.X = (float)((p.X - StageSizeX) / PhysicalSizeX);
4416 pp.Y = (float)((p.Y - StageSizeY) / PhysicalSizeY);
4417 return pp;
4418 }

◆ ToImageSpace() [4/5]

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[]

Definition at line 4442 of file Bio.cs.

4443 {
4444 PointF[] ps = new PointF[p.Length];
4445 for (int i = 0; i < p.Length; i++)
4446 {
4447 PointF pp = new PointF();
4448 pp.X = (float)((p[i].X - StageSizeX) / PhysicalSizeX);
4449 pp.Y = (float)((p[i].Y - StageSizeY) / PhysicalSizeY);
4450 ps[i] = pp;
4451 }
4452 return ps;
4453 }

◆ ToImageSpace() [5/5]

RectangleF BioLib.BioImage.ToImageSpace ( RectangleD p)

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

Parameters
RectangleD
Returns
A RectangleF object.

Definition at line 4459 of file Bio.cs.

4460 {
4461 RectangleF r = new RectangleF();
4462 Point pp = new Point();
4463 r.X = (int)((p.X - StageSizeX) / PhysicalSizeX);
4464 r.Y = (int)((p.Y - StageSizeY) / PhysicalSizeY);
4465 r.Width = (int)(p.W / PhysicalSizeX);
4466 r.Height = (int)(p.H / PhysicalSizeY);
4467 return r;
4468 }

◆ 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.

Definition at line 4390 of file Bio.cs.

4391 {
4392 if (isPyramidal)
4393 return x;
4394 return (float)((x - StageSizeX) / PhysicalSizeX);
4395 }

◆ 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.

Definition at line 4401 of file Bio.cs.

4402 {
4403 if (isPyramidal)
4404 return y;
4405 return (float)((y - StageSizeY) / PhysicalSizeY);
4406 }

◆ ToShort()

void BioLib.BioImage.ToShort ( )

Definition at line 4093 of file Bio.cs.

4094 {
4095 foreach (var b in Buffers)
4096 {
4097 b.ToShort();
4098 }
4099 AutoThreshold(this, true);
4100 StackThreshold(false);
4101 }

◆ 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.

Definition at line 4474 of file Bio.cs.

4475 {
4476 PointD pp = new PointD();
4477 if (isPyramidal)
4478 {
4479 pp.X = ((p.X * Resolutions[Level].PhysicalSizeX) + Volume.Location.X);
4480 pp.Y = ((p.Y * Resolutions[Level].PhysicalSizeY) + Volume.Location.Y);
4481 return pp;
4482 }
4483 else
4484 {
4485 pp.X = ((p.X * PhysicalSizeX) + Volume.Location.X);
4486 pp.Y = ((p.Y * PhysicalSizeY) + Volume.Location.Y);
4487 return pp;
4488 }
4489 }

◆ 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.

Definition at line 4513 of file Bio.cs.

4514 {
4515 PointD pp = new PointD();
4516 pp.X = ((p.X * physicalSizeX) + volumeX);
4517 pp.Y = ((p.Y * physicalSizeY) + volumeY);
4518 return pp;
4519 }

◆ 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.

Definition at line 4496 of file Bio.cs.

4497 {
4498 PointD pp = new PointD();
4499 pp.X = ((p.X * Resolutions[resolution].PhysicalSizeX) + Volume.Location.X);
4500 pp.Y = ((p.Y * Resolutions[resolution].PhysicalSizeY) + Volume.Location.Y);
4501 return pp;
4502 }

◆ 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.

Definition at line 4560 of file Bio.cs.

4561 {
4562 PointD[] ps = new PointD[p.Length];
4563 for (int i = 0; i < p.Length; i++)
4564 {
4565 PointD pp = new PointD();
4566 pp.X = ((p[i].X * PhysicalSizeX) + Volume.Location.X);
4567 pp.Y = ((p[i].Y * PhysicalSizeY) + Volume.Location.Y);
4568 ps[i] = pp;
4569 }
4570 return ps;
4571 }

◆ 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.

Definition at line 4583 of file Bio.cs.

4584 {
4585 PointD[] ps = new PointD[p.Length];
4586 for (int i = 0; i < p.Length; i++)
4587 {
4588 PointD pp = new PointD();
4589 pp.X = ((p[i].X * physicalSizeX) + volumeX);
4590 pp.Y = ((p[i].Y * physicalSizeY) + volumeY);
4591 ps[i] = pp;
4592 }
4593 return ps;
4594 }

◆ 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.

Definition at line 4526 of file Bio.cs.

4527 {
4528 RectangleD r = new RectangleD();
4529 r.X = ((p.X * PhysicalSizeX) + Volume.Location.X);
4530 r.Y = ((p.Y * PhysicalSizeY) + Volume.Location.Y);
4531 r.W = (p.W * PhysicalSizeX);
4532 r.H = (p.H * PhysicalSizeY);
4533 return r;
4534 }

◆ 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.

Definition at line 4545 of file Bio.cs.

4546 {
4547 RectangleD r = new RectangleD();
4548 r.X = ((p.X * physicalSizeX) + volumeX);
4549 r.Y = ((p.Y * physicalSizeY) + volumeY);
4550 r.W = (p.W * physicalSizeX);
4551 r.H = (p.H * physicalSizeY);
4552 return r;
4553 }

◆ ToString()

override string BioLib.BioImage.ToString ( )

This function returns the filename of the object, and the location of the object in the 3D space.

Returns
The filename, and the location of the volume.

Definition at line 9813 of file Bio.cs.

9814 {
9815 return "BioLib.Images.GetImage(\"" + id + "\")";
9816 }

◆ Update() [1/2]

void BioLib.BioImage.Update ( )

Update() is a function that calls the Update() function of the parent class

Definition at line 8797 of file Bio.cs.

8798 {
8799 Update(this);
8800 }
void Update()
Definition Bio.cs:8797

◆ Update() [2/2]

static void BioLib.BioImage.Update ( BioImage b)
static

The function takes a BioImage object, opens the file, and returns a updated BioImage object.

Parameters
BioImageThis is the class that contains the image data.

Definition at line 8658 of file Bio.cs.

8659 {
8660 b = OpenFile(b.file);
8661 }

◆ UpdateBuffersPyramidal()

async Task BioLib.BioImage.UpdateBuffersPyramidal ( )

Updates the Buffers based on current pyramidal origin and resolution.

Definition at line 8665 of file Bio.cs.

8666 {
8667 try
8668 {
8669 if (Type != ImageType.pyramidal)
8670 return;
8671 for (int i = 0; i < Buffers.Count; i++)
8672 {
8673 Buffers[i].Dispose();
8674 }
8675 Buffers.Clear();
8676 for (int z = 0; z < SizeZ; z++)
8677 {
8678 for (int c = 0; c < SizeC; c++)
8679 {
8680 for (int t = 0; t < SizeT; t++)
8681 {
8682 ZCT co = new ZCT(z, c, t);
8683 if (openSlideImage != null)
8684 {
8685 startos:
8686 int lev = LevelFromResolution(this.Resolution);
8687 openslideBase.SetSliceInfo(lev, PixelFormat.Format24bppRgb, co);
8688 byte[] bts = openslideBase.GetSlice(new OpenSlideGTK.SliceInfo(PyramidalOrigin.X, PyramidalOrigin.Y, PyramidalSize.Width, PyramidalSize.Height, resolution));
8689 if (bts == null)
8690 {
8691 pyramidalOrigin = new PointD(0, 0);
8692 Resolution = GetUnitPerPixel(lev) * 1.1f;
8693 goto startos;
8694 }
8695 Buffers.Add(new Bitmap((int)Math.Round(OpenSlideBase.destExtent.Width), (int)Math.Round(OpenSlideBase.destExtent.Height), PixelFormat.Format24bppRgb, bts, co, ""));
8696 }
8697 else
8698 {
8699 start:
8700 int lev = LevelFromResolution(this.Resolution);
8701 byte[] bts = await slideBase.GetSlice(new BioLib.SliceInfo(Math.Round(PyramidalOrigin.X), Math.Round(PyramidalOrigin.Y), PyramidalSize.Width, PyramidalSize.Height, resolution, co));
8702 if (bts == null)
8703 {
8704 pyramidalOrigin = new PointD(0, 0);
8705 Resolution = GetUnitPerPixel(lev) * 1.1f;
8706 goto start;
8707 }
8708 Bitmap bmp = new Bitmap((int)Math.Round(SlideBase.destExtent.Width), (int)Math.Round(SlideBase.destExtent.Height), Resolutions[Level].PixelFormat, bts, co, "");
8709 Buffers.Add(bmp);
8710 }
8711 }
8712 }
8713 }
8714 BioImage.AutoThreshold(this, false);
8715 if (bitsPerPixel > 8)
8716 StackThreshold(true);
8717 else
8718 StackThreshold(false);
8719 }
8720 catch (Exception e)
8721 {
8722 Console.WriteLine(e.Message);
8723 }
8724 }

◆ UpdateBuffersWells()

void BioLib.BioImage.UpdateBuffersWells ( )

Definition at line 8726 of file Bio.cs.

8727 {
8728 try
8729 {
8730 if (Type != ImageType.well)
8731 return;
8732 for (int i = 0; i < Buffers.Count; i++)
8733 {
8734 Buffers[i].Dispose();
8735 }
8736 Buffers.Clear();
8737 if (imRead.getSeries() != Level)
8738 this.imRead.setSeries(Level);
8739 int w = imRead.getSizeX();
8740 int h = imRead.getSizeY();
8741 for (int z = 0; z < SizeZ; z++)
8742 {
8743 for (int c = 0; c < SizeC; c++)
8744 {
8745 for (int t = 0; t < SizeT; t++)
8746 {
8747 byte[] bm = this.imRead.openBytes(Coords[z, c, t]);
8748 Bitmap bmp = new Bitmap(w, h, Resolutions[Level].PixelFormat, bm, new ZCT(z, c, t), "");
8749 bmp.Stats = Statistics.FromBytes(bmp);
8750 Buffers.Add(bmp);
8751 }
8752 }
8753 }
8754 BioImage.AutoThreshold(this, false);
8755 if (bitsPerPixel > 8)
8756 StackThreshold(true);
8757 else
8758 StackThreshold(false);
8759 }
8760 catch (Exception e)
8761 {
8762 Console.WriteLine(e.Message);
8763 }
8764 }

◆ UpdateCoords() [1/3]

void BioLib.BioImage.UpdateCoords ( )

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

Definition at line 4209 of file Bio.cs.

4210 {
4211 int z = 0;
4212 int c = 0;
4213 int t = 0;
4214 Coords = new int[SizeZ, SizeC, SizeT];
4215 for (int im = 0; im < Buffers.Count; im++)
4216 {
4217 ZCT co = new ZCT(z, c, t);
4218 SetFrameIndex(co.Z, co.C, co.T, im);
4219 Buffers[im].Coordinate = co;
4220 if (c < SizeC - 1)
4221 c++;
4222 else
4223 {
4224 c = 0;
4225 if (z < SizeZ - 1)
4226 z++;
4227 else
4228 {
4229 z = 0;
4230 if (t < SizeT - 1)
4231 t++;
4232 else
4233 t = 0;
4234 }
4235 }
4236 }
4237 }

◆ 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

Definition at line 4244 of file Bio.cs.

4245 {
4246 int z = 0;
4247 int c = 0;
4248 int t = 0;
4249 sizeZ = sz;
4250 sizeC = sc;
4251 sizeT = st;
4252 Coords = new int[sz, sc, st];
4253 for (int im = 0; im < Buffers.Count; im++)
4254 {
4255 ZCT co = new ZCT(z, c, t);
4256 SetFrameIndex(co.Z, co.C, co.T, im);
4257 Buffers[im].Coordinate = co;
4258 if (c < SizeC - 1)
4259 c++;
4260 else
4261 {
4262 c = 0;
4263 if (z < SizeZ - 1)
4264 z++;
4265 else
4266 {
4267 z = 0;
4268 if (t < SizeT - 1)
4269 t++;
4270 else
4271 t = 0;
4272 }
4273 }
4274 }
4275 }

◆ 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

Definition at line 4282 of file Bio.cs.

4283 {
4284 int z = 0;
4285 int c = 0;
4286 int t = 0;
4287 sizeZ = sz;
4288 sizeC = sc;
4289 sizeT = st;
4290 Coords = new int[sz, sc, st];
4291 int fr = sz * sc * st;
4292 if (order == Order.CZT)
4293 {
4294 for (int im = 0; im < fr; im++)
4295 {
4296 ZCT co = new ZCT(z, c, t);
4297 SetFrameIndex(co.Z, co.C, co.T, im);
4298 if (c < SizeC - 1)
4299 c++;
4300 else
4301 {
4302 c = 0;
4303 if (z < SizeZ - 1)
4304 z++;
4305 else
4306 {
4307 z = 0;
4308 if (t < SizeT - 1)
4309 t++;
4310 else
4311 t = 0;
4312 }
4313 }
4314 }
4315 }
4316 else if (order == Order.ZCT)
4317 {
4318 for (int im = 0; im < fr; im++)
4319 {
4320 ZCT co = new ZCT(z, c, t);
4321 SetFrameIndex(co.Z, co.C, co.T, im);
4322 if (z < SizeZ - 1)
4323 z++;
4324 else
4325 {
4326 z = 0;
4327 if (c < SizeC - 1)
4328 c++;
4329 else
4330 {
4331 c = 0;
4332 if (t < SizeT - 1)
4333 t++;
4334 else
4335 t = 0;
4336 }
4337 }
4338 }
4339 }
4340 else
4341 {
4342 //Order.TZC
4343 for (int im = 0; im < fr; im++)
4344 {
4345 ZCT co = new ZCT(z, c, t);
4346 SetFrameIndex(co.Z, co.C, co.T, im);
4347 if (t < SizeT - 1)
4348 t++;
4349 else
4350 {
4351 t = 0;
4352 if (z < SizeZ - 1)
4353 z++;
4354 else
4355 {
4356 z = 0;
4357 if (c < SizeC - 1)
4358 c++;
4359 else
4360 c = 0;
4361 }
4362 }
4363 }
4364 }
4365 }

◆ VipsSupport()

static bool BioLib.BioImage.VipsSupport ( string file)
static

The function checks if a given file is supported by the Vips library and returns true if it is, false otherwise.

Parameters
fileThe "file" parameter is a string that represents the file path of the TIFF image that you want to load using the NetVips library.
Returns
The method is returning a boolean value. If the try block is executed successfully, it will return true. If an exception is caught, it will return false.

Definition at line 8932 of file Bio.cs.

8933 {
8934 try
8935 {
8936 netim = NetVips.Image.Tiffload(file);
8937 Settings.AddSettings("VipsSupport", "true");
8938 }
8939 catch (Exception e)
8940 {
8941 Console.WriteLine(e.ToString());
8942 return false;
8943 }
8944 netim.Close();
8945 netim.Dispose();
8946 return true;
8947 }

Member Data Documentation

◆ Annotations

List<ROI> BioLib.BioImage.Annotations = new List<ROI>()

Definition at line 3032 of file Bio.cs.

◆ bitsPerPixel

int BioLib.BioImage.bitsPerPixel

Definition at line 3054 of file Bio.cs.

◆ Buffers

List<AForge.Bitmap> BioLib.BioImage.Buffers = new List<AForge.Bitmap>()

Definition at line 3005 of file Bio.cs.

◆ Channels

List<Channel> BioLib.BioImage.Channels = new List<Channel>()

Definition at line 3003 of file Bio.cs.

◆ columns

const string BioLib.BioImage.columns = "ROIID,ROINAME,TYPE,ID,SHAPEINDEX,TEXT,S,C,Z,T,X,Y,W,H,POINTS,STROKECOLOR,STROKECOLORW,FILLCOLOR,FONTSIZE\n"
static

Definition at line 8957 of file Bio.cs.

◆ Coords

int [,,] BioLib.BioImage.Coords

Definition at line 2982 of file Bio.cs.

◆ file

string BioLib.BioImage.file

Definition at line 3726 of file Bio.cs.

◆ filename

string BioLib.BioImage.filename = ""

Definition at line 3033 of file Bio.cs.

◆ filter16

LevelsLinear16bpp BioLib.BioImage.filter16 = new LevelsLinear16bpp()
static

Definition at line 4950 of file Bio.cs.

◆ filter8

LevelsLinear BioLib.BioImage.filter8 = new LevelsLinear()
static

Definition at line 4949 of file Bio.cs.

◆ frameInterval

double BioLib.BioImage.frameInterval = 0

Definition at line 3057 of file Bio.cs.

◆ imagesPerSeries

int BioLib.BioImage.imagesPerSeries = 0

Definition at line 3055 of file Bio.cs.

◆ imRead

ImageReader BioLib.BioImage.imRead

Definition at line 8221 of file Bio.cs.

◆ isGroup

bool BioLib.BioImage.isGroup = false

Definition at line 3059 of file Bio.cs.

◆ littleEndian

bool BioLib.BioImage.littleEndian = false

Definition at line 3058 of file Bio.cs.

◆ Loading

bool BioLib.BioImage.Loading = false

Definition at line 5517 of file Bio.cs.

◆ loadTimeMS

long BioLib.BioImage.loadTimeMS = 0

Definition at line 3060 of file Bio.cs.

◆ loadTimeTicks

long BioLib.BioImage.loadTimeTicks = 0

Definition at line 3061 of file Bio.cs.

◆ NewLine

const char BioLib.BioImage.NewLine = '\n'
static

Definition at line 8956 of file Bio.cs.

◆ openSlideImage

OpenSlideImage BioLib.BioImage.openSlideImage

Definition at line 8223 of file Bio.cs.

◆ Planes

bool BioLib.BioImage.Planes = false
static

Definition at line 3641 of file Bio.cs.

◆ Plate

WellPlate BioLib.BioImage.Plate = null

Definition at line 2981 of file Bio.cs.

◆ progFile

string BioLib.BioImage.progFile
static

Definition at line 3740 of file Bio.cs.

◆ Progress

float BioLib.BioImage.Progress = 0
static

Definition at line 3087 of file Bio.cs.

◆ Resolutions

List<Resolution> BioLib.BioImage.Resolutions = new List<Resolution>()

Definition at line 3004 of file Bio.cs.

◆ rgbChannels

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

Definition at line 3046 of file Bio.cs.

3046{ 0, 1, 2 };

◆ script

string BioLib.BioImage.script = ""

Definition at line 3034 of file Bio.cs.

◆ selected

bool BioLib.BioImage.selected = false

Definition at line 3062 of file Bio.cs.

◆ seriesCount

int BioLib.BioImage.seriesCount = 1

Definition at line 3056 of file Bio.cs.

◆ swatch

Stopwatch BioLib.BioImage.swatch = new Stopwatch()
static

Definition at line 5480 of file Bio.cs.

◆ tifRead

Tiff BioLib.BioImage.tifRead

Definition at line 8222 of file Bio.cs.

◆ vipPages

List<NetVips.Image> BioLib.BioImage.vipPages = new List<NetVips.Image>()

Definition at line 3006 of file Bio.cs.

◆ Volume

VolumeD BioLib.BioImage.Volume

Definition at line 3031 of file Bio.cs.

◆ watch

Stopwatch BioLib.BioImage.watch = new Stopwatch()

Definition at line 3685 of file Bio.cs.

Property Documentation

◆ AnnotationsB

List<ROI> BioLib.BioImage.AnnotationsB
get

Definition at line 3480 of file Bio.cs.

3481 {
3482 get
3483 {
3484 return GetAnnotations(Coordinate.Z, BChannel.Index, Coordinate.T);
3485 }
3486 }
List< ROI > GetAnnotations(ZCT coord)
Definition Bio.cs:5487

◆ AnnotationsG

List<ROI> BioLib.BioImage.AnnotationsG
get

Definition at line 3472 of file Bio.cs.

3473 {
3474 get
3475 {
3476 return GetAnnotations(Coordinate.Z, GChannel.Index, Coordinate.T);
3477 }
3478 }

◆ AnnotationsR

List<ROI> BioLib.BioImage.AnnotationsR
get

Definition at line 3464 of file Bio.cs.

3465 {
3466 get
3467 {
3468 return GetAnnotations(Coordinate.Z, RChannel.Index, Coordinate.T);
3469 }
3470 }

◆ BChannel

Channel BioLib.BioImage.BChannel
get

Definition at line 3453 of file Bio.cs.

3454 {
3455 get
3456 {
3457 if (Channels.Count >= 3)
3458 return Channels[rgbChannels[2]];
3459 else
3460 return Channels[0];
3461 }
3462 }

◆ BRange

IntRange BioLib.BioImage.BRange
get

Definition at line 3671 of file Bio.cs.

3672 {
3673 get
3674 {
3675 return BChannel.RangeB;
3676 }
3677 }

◆ Coordinate

ZCT BioLib.BioImage.Coordinate
getset

Definition at line 2984 of file Bio.cs.

2985 {
2986 get
2987 {
2988 return coordinate;
2989 }
2990 set
2991 {
2992 coordinate = value;
2993 }
2994 }

◆ Filename

string BioLib.BioImage.Filename
getset

Definition at line 3035 of file Bio.cs.

3036 {
3037 get
3038 {
3039 return filename;
3040 }
3041 set
3042 {
3043 filename = value;
3044 }
3045 }

◆ GChannel

Channel BioLib.BioImage.GChannel
get

Definition at line 3443 of file Bio.cs.

3444 {
3445 get
3446 {
3447 if (Channels.Count >= 3)
3448 return Channels[rgbChannels[1]];
3449 else
3450 return Channels[0];
3451 }
3452 }

◆ GRange

IntRange BioLib.BioImage.GRange
get

Definition at line 3664 of file Bio.cs.

3665 {
3666 get
3667 {
3668 return GChannel.RangeG;
3669 }
3670 }

◆ ID

string BioLib.BioImage.ID
getset

Definition at line 3296 of file Bio.cs.

3297 {
3298 get { return id; }
3299 set { id = value; }
3300 }

◆ ImageCount

int BioLib.BioImage.ImageCount
get

Definition at line 3301 of file Bio.cs.

3302 {
3303 get
3304 {
3305 return Buffers.Count;
3306 }
3307 }

◆ Initialized

bool BioLib.BioImage.Initialized
staticget

Definition at line 3741 of file Bio.cs.

3742 {
3743 get
3744 {
3745 return initialized;
3746 }
3747 }

◆ isPyramidal

bool BioLib.BioImage.isPyramidal
get

Definition at line 3716 of file Bio.cs.

3717 {
3718 get
3719 {
3720 if (Type == ImageType.pyramidal)
3721 return true;
3722 else
3723 return false;
3724 }
3725 }

◆ isRGB

bool BioLib.BioImage.isRGB
get

Definition at line 3686 of file Bio.cs.

3687 {
3688 get
3689 {
3690 if (RGBChannelCount == 3 || RGBChannelCount == 4)
3691 return true;
3692 else
3693 return false;
3694 }
3695 }

◆ isSeries

bool BioLib.BioImage.isSeries
get

Definition at line 3706 of file Bio.cs.

3707 {
3708 get
3709 {
3710 if (seriesCount > 1)
3711 return true;
3712 else
3713 return false;
3714 }
3715 }

◆ isTime

bool BioLib.BioImage.isTime
get

Definition at line 3696 of file Bio.cs.

3697 {
3698 get
3699 {
3700 if (SizeT > 1)
3701 return true;
3702 else
3703 return false;
3704 }
3705 }

◆ LabelResolution

int? BioLib.BioImage.LabelResolution
getset

Definition at line 4113 of file Bio.cs.

4113{ get; set; }

◆ Level

int BioLib.BioImage.Level
getset

Definition at line 3008 of file Bio.cs.

3009 {
3010 get
3011 {
3012 if (Type == ImageType.well)
3013 return level;
3014 int l = 0;
3015 if (openslideBase != null)
3016 l = OpenSlideGTK.TileUtil.GetLevel(openslideBase.Schema.Resolutions, Resolution);
3017 else
3018 if (slideBase != null)
3019 l = LevelFromResolution(Resolution);
3020 if (l < 0)
3021 return 0;
3022 return l;
3023 }
3024 set
3025 {
3026 if (value < 0)
3027 return;
3028 level = value;
3029 }
3030 }

◆ MacroResolution

int? BioLib.BioImage.MacroResolution
getset

Definition at line 4112 of file Bio.cs.

4112{ get; set; }

◆ Magnification

double BioLib.BioImage.Magnification
getset

Definition at line 3648 of file Bio.cs.

3649 {
3650 get; set;
3651 }

◆ OpenSlideBase

OpenSlideBase BioLib.BioImage.OpenSlideBase
get

Definition at line 3430 of file Bio.cs.

3430{ get { return openslideBase; } }

◆ PhysicalSizeX

double BioLib.BioImage.PhysicalSizeX
get

Definition at line 3308 of file Bio.cs.

3309 {
3310 get
3311 {
3312 if (isPyramidal)
3313 return Resolutions[Level].PhysicalSizeX;
3314 else
3315 if (Plate != null)
3316 return Resolutions[serie].PhysicalSizeX;
3317 else if (Resolutions.Count > 0)
3318 return Resolutions[0].PhysicalSizeX;
3319 else
3320 return 0;
3321 }
3322 }

◆ PhysicalSizeY

double BioLib.BioImage.PhysicalSizeY
get

Definition at line 3323 of file Bio.cs.

3324 {
3325 get
3326 {
3327 if (isPyramidal)
3328 return Resolutions[Level].PhysicalSizeY;
3329 else
3330 if (Plate != null)
3331 return Resolutions[serie].PhysicalSizeY;
3332 else if (Resolutions.Count > 0)
3333 return Resolutions[0].PhysicalSizeY;
3334 else
3335 return 0;
3336 }
3337 }

◆ PhysicalSizeZ

double BioLib.BioImage.PhysicalSizeZ
get

Definition at line 3338 of file Bio.cs.

3339 {
3340 get
3341 {
3342 if (isPyramidal)
3343 return Resolutions[Level].PhysicalSizeZ;
3344 else
3345 if (Plate != null)
3346 return Resolutions[serie].PhysicalSizeZ;
3347 else if (Resolutions.Count > 0)
3348 return Resolutions[0].PhysicalSizeZ;
3349 else
3350 return 0;
3351 }
3352 }

◆ PyramidalOrigin

PointD BioLib.BioImage.PyramidalOrigin
getset

Definition at line 3408 of file Bio.cs.

3409 {
3410 get { return pyramidalOrigin; }
3411 set
3412 {
3413 pyramidalOrigin = value;
3414 }
3415 }

◆ PyramidalSize

AForge.Size BioLib.BioImage.PyramidalSize
getset

Definition at line 3406 of file Bio.cs.

3406{ get { return s; } set { s = value; } }

◆ RChannel

Channel BioLib.BioImage.RChannel
get

Definition at line 3433 of file Bio.cs.

3434 {
3435 get
3436 {
3437 if(Channels.Count >= 3)
3438 return Channels[rgbChannels[0]];
3439 else
3440 return Channels[0];
3441 }
3442 }

◆ Resolution

double BioLib.BioImage.Resolution
getset

Definition at line 3077 of file Bio.cs.

3078 {
3079 get { return resolution; }
3080 set
3081 {
3082 if (value < 0)
3083 return;
3084 resolution = value;
3085 }
3086 }

◆ RGBChannelCount

int BioLib.BioImage.RGBChannelCount
get

Definition at line 3047 of file Bio.cs.

3048 {
3049 get
3050 {
3051 return Buffers[0].RGBChannelsCount;
3052 }
3053 }

◆ RRange

IntRange BioLib.BioImage.RRange
get

Definition at line 3657 of file Bio.cs.

3658 {
3659 get
3660 {
3661 return RChannel.RangeR;
3662 }
3663 }

◆ SelectedBuffer

Bitmap BioLib.BioImage.SelectedBuffer
get

Definition at line 3678 of file Bio.cs.

3679 {
3680 get
3681 {
3682 return Buffers[GetFrameIndex(Coordinate.Z, Coordinate.C, Coordinate.T)];
3683 }
3684 }

◆ series

int BioLib.BioImage.series
getset

Definition at line 3416 of file Bio.cs.

3417 {
3418 get
3419 {
3420 return imageInfo.Series;
3421 }
3422 set
3423 {
3424 imageInfo.Series = value;
3425 }
3426 }

◆ SizeC

int BioLib.BioImage.SizeC
get

Definition at line 3633 of file Bio.cs.

3634 {
3635 get { return sizeC; }
3636 }

◆ SizeT

int BioLib.BioImage.SizeT
get

Definition at line 3637 of file Bio.cs.

3638 {
3639 get { return sizeT; }
3640 }

◆ SizeX

int BioLib.BioImage.SizeX
get

Definition at line 3611 of file Bio.cs.

3612 {
3613 get
3614 {
3615 if (Buffers.Count > 0)
3616 return Buffers[0].SizeX;
3617 else return 0;
3618 }
3619 }

◆ SizeY

int BioLib.BioImage.SizeY
get

Definition at line 3620 of file Bio.cs.

3621 {
3622 get
3623 {
3624 if (Buffers.Count > 0)
3625 return Buffers[0].SizeY;
3626 else return 0;
3627 }
3628 }

◆ SizeZ

int BioLib.BioImage.SizeZ
get

Definition at line 3629 of file Bio.cs.

3630 {
3631 get { return sizeZ; }
3632 }

◆ SlideBase

SlideBase BioLib.BioImage.SlideBase
getset

Definition at line 3432 of file Bio.cs.

3432{ get { return slideBase; } set { slideBase = value; } }

◆ StackOrder

Order BioLib.BioImage.StackOrder
getset

Definition at line 3652 of file Bio.cs.

3653 {
3654 get; set;
3655 }

◆ StageSizeX

double BioLib.BioImage.StageSizeX
getset

Definition at line 3353 of file Bio.cs.

3354 {
3355 get
3356 {
3357 if (isPyramidal)
3358 return Resolutions[Level].StageSizeX;
3359 else
3360 if (Plate != null)
3361 return Resolutions[serie].StageSizeX;
3362 else if (Resolutions.Count > 0)
3363 return Resolutions[0].StageSizeX;
3364 else
3365 return imageInfo.stageSizeX;
3366 }
3367 set
3368 {
3369 imageInfo.StageSizeX = value;
3370 }
3371 }

◆ StageSizeY

double BioLib.BioImage.StageSizeY
getset

Definition at line 3372 of file Bio.cs.

3373 {
3374 get
3375 {
3376 if (isPyramidal)
3377 return Resolutions[Level].StageSizeY;
3378 else
3379 if (Plate != null)
3380 return Resolutions[serie].StageSizeY;
3381 else if (Resolutions.Count > 0)
3382 return Resolutions[0].StageSizeY;
3383 else
3384 return imageInfo.stageSizeY;
3385 }
3386 set { imageInfo.StageSizeY = value; }
3387 }

◆ StageSizeZ

double BioLib.BioImage.StageSizeZ
getset

Definition at line 3388 of file Bio.cs.

3389 {
3390 get
3391 {
3392 if (isPyramidal)
3393 return Resolutions[Level].StageSizeZ;
3394 else
3395 if (Plate != null)
3396 return Resolutions[serie].StageSizeZ;
3397 else if (Resolutions.Count > 1)
3398 return Resolutions[0].StageSizeZ;
3399 else
3400 return imageInfo.stageSizeZ;
3401 }
3402 set { imageInfo.StageSizeZ = value; }
3403 }

◆ Statistics

Statistics BioLib.BioImage.Statistics
getset

Definition at line 3063 of file Bio.cs.

3064 {
3065 get
3066 {
3067 return statistics;
3068 }
3069 set
3070 {
3071 statistics = value;
3072 }
3073 }

◆ Status

string BioLib.BioImage.Status
staticgetset

Definition at line 3728 of file Bio.cs.

3729 {
3730 get
3731 {
3732 return stat;
3733 }
3734 set
3735 {
3736 stat = value;
3737 Console.WriteLine(stat);
3738 }
3739 }

◆ Tag

object BioLib.BioImage.Tag
getset

Definition at line 3656 of file Bio.cs.

3656{ get; set; }

◆ Type

ImageType BioLib.BioImage.Type
getset

Definition at line 3002 of file Bio.cs.

3002{ get; set; }

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