BioLib  4.3.0
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.Images Class Reference

Static Public Member Functions

static BioImage GetImage (string ids)
 
static void AddImage (BioImage im)
 
static int GetImageCountByName (string s)
 
static string RemoveExtensions (string file)
 Removes extensions from filename including multiple extensions like .ome.tif.
 
static string GetExtensions (string file)
 Return extensions of a file including multiple extensions like .ome.tif.
 
static string GetImageName (string s)
 Get a unique image name from a string.
 
static void RemoveImage (BioImage im)
 
static void RemoveImage (string id)
 
static void UpdateImage (BioImage im)
 

Static Public Attributes

static List< BioImage > images = new List<BioImage>()
 

Member Function Documentation

◆ AddImage()

static void BioLib.Images.AddImage ( BioImage im)
static

It adds an image to the list of images

Parameters
BioImageA class that contains the image data and other information.
87 {
88 if (images.Contains(im))
89 return;
90 foreach (var item in Images.images)
91 {
92 if (im.Filename.Contains(item.Filename))
93 return;
94 }
95 im.Filename = im.Filename.Split(' ')[0];
96 images.Add(im);
97 }
string Filename
Definition Bio.cs:2014
Definition Bio.cs:68
static List< BioImage > images
Definition Bio.cs:69

◆ GetExtensions()

static string BioLib.Images.GetExtensions ( string file)
static

Return extensions of a file including multiple extensions like .ome.tif.

Parameters
file
Returns
135 {
136 string[] ex = file.Split(".");
137 if (ex.Length == 1)
138 return "." + ex[0];
139 else
140 if (ex.Length > 2)
141 return "." + ex[ex.Length - 2] + "." + ex[ex.Length - 1];
142 else
143 return "." + ex.Last();
144 }

◆ GetImage()

static BioImage BioLib.Images.GetImage ( string ids)
static
Parameters
idsThe id of the image you want to get.
74 {
75 ids = ids.Replace("\\", "/");
76 for (int i = 0; i < images.Count; i++)
77 {
78 if (images[i].ID.Contains(System.IO.Path.GetFileName(ids)) || images[i].Filename == System.IO.Path.GetFileName(ids))
79 return images[i];
80 }
81 return null;
82 }

◆ GetImageCountByName()

static int BioLib.Images.GetImageCountByName ( string s)
static

It takes a string as an argument, and returns the number of times that string appears in the list of images

Parameters
sThe name of the image
Returns
The number of images that contain the name of the image.
105 {
106 int i = 0;
107 s = RemoveExtensions(s);
108 if (s.Contains("-"))
109 {
110 string ss = RemoveExtensions(s.Substring(s.LastIndexOf("-"), s.Length - s.LastIndexOf("-")));
111 s = ss;
112 }
113 for (int im = 0; im < images.Count; im++)
114 {
115 if (images[im].ID.Contains(s))
116 i++;
117 }
118 return i;
119 }
static string RemoveExtensions(string file)
Removes extensions from filename including multiple extensions like .ome.tif.
Definition Bio.cs:125

◆ GetImageName()

static string BioLib.Images.GetImageName ( string s)
static

Get a unique image name from a string.

Parameters
s
Returns
152 {
153 //Here we create a unique ID for an image.
154 int i = Images.GetImageCountByName(s);
155 if (i == 0)
156 return Path.GetFileName(s);
157 string name = RemoveExtensions(s);
158 string ext = GetExtensions(s);
159 if (name.EndsWith("-" + i))
160 name = name.Substring(name.LastIndexOf('-'), name.Length - name.LastIndexOf('-'));
161 return name + "-" + (i + 1) + ext;
162 }
System.IO.Path Path
Definition Bio.cs:57
static int GetImageCountByName(string s)
Definition Bio.cs:104
static string GetExtensions(string file)
Return extensions of a file including multiple extensions like .ome.tif.
Definition Bio.cs:134

◆ RemoveExtensions()

static string BioLib.Images.RemoveExtensions ( string file)
static

Removes extensions from filename including multiple extensions like .ome.tif.

Parameters
file
Returns
126 {
127 return System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetFileNameWithoutExtension(file));
128 }

◆ RemoveImage() [1/2]

static void BioLib.Images.RemoveImage ( BioImage im)
static

This function removes an image from the table

Parameters
BioImageThis is the image that you want to remove.
167 {
169 }
static void RemoveImage(BioImage im)
Definition Bio.cs:166

◆ RemoveImage() [2/2]

static void BioLib.Images.RemoveImage ( string id)
static

It removes an image from the table

Parameters
idThe id of the image to remove.
Returns
The image is being returned.
176 {
177 BioImage im = GetImage(id);
178 if (im == null)
179 return;
180 images.Remove(im);
181 im.Dispose();
182 }
Definition Bio.cs:1872
static BioImage GetImage(string ids)
Definition Bio.cs:73

◆ UpdateImage()

static void BioLib.Images.UpdateImage ( BioImage im)
static

It updates an image from the table

Parameters
idThe id of the image to update.
imThe BioImage to update with.
Returns
The image is being returned.
189 {
190 for (int i = 0; i < images.Count; i++)
191 {
192 if (images[i].ID == im.ID)
193 {
194 images[i] = im;
195 return;
196 }
197 }
198 }
string ID
Definition Bio.cs:2544

Member Data Documentation

◆ images

List<BioImage> BioLib.Images.images = new List<BioImage>()
static

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