swharden / scitif Goto Github PK
View Code? Open in Web Editor NEWA .NET library for working with scientific image data in TIFF files
Home Page: https://www.nuget.org/packages/SciTIF
License: MIT License
A .NET library for working with scientific image data in TIFF files
Home Page: https://www.nuget.org/packages/SciTIF
License: MIT License
Image needs Clone()
useful for getting stats from rectangular ROIs
ScaleBy() needs ScaledBy() which performs a copy
e.g., 16-bit PNG files
interpolation mode is fixed at bilinear. subclass the picturebox class to intercept graphics rendering to control this in the future.
https://www.codeproject.com/Articles/717312/PixelBox-A-PictureBox-with-configurable-Interpolat
if X is outside bounds, because of how indexing works it won't throw an exception
using Tiff image = Tiff.Open("demo.tif", "r");
StringBuilder sb = new();
foreach (TiffTag tag in Enum.GetValues(typeof(TiffTag)))
{
FieldValue[] values = image.GetField(tag);
if (values is null)
continue;
foreach (FieldValue value in values)
sb.AppendLine($"{tag} = {value}");
}
Console.WriteLine(sb);
SUBFILETYPE = 0
IMAGEWIDTH = 256
IMAGELENGTH = 256
BITSPERSAMPLE = 16
COMPRESSION = NONE
PHOTOMETRIC = MINISBLACK
IMAGEDESCRIPTION = ImageJ=1.53q
images=48
channels=2
frames=24
hyperstack=true
mode=composite
unit=micron
finterval=1
loop=false
min=169.0
max=8191.0
STRIPOFFSETS = System.UInt64[]
SAMPLESPERPIXEL = 1
ROWSPERSTRIP = 16
STRIPBYTECOUNTS = System.UInt64[]
XRESOLUTION = 0.848324
YRESOLUTION = 0.848324
PLANARCONFIG = CONTIG
RESOLUTIONUNIT = NONE
TILEOFFSETS = System.UInt64[]
TILEBYTECOUNTS = System.UInt64[]
public static double GetMicronsPerPixel(string tifFilePath)
{
using Tiff image = Tiff.Open(tifFilePath, "r");
return 1.0 / (float)image.GetField(TiffTag.XRESOLUTION).First().Value;
}
metrics of interest:
unit=micron
XRESOLUTION = 0.848324
YRESOLUTION = 0.848324
It would be nice if there were simple extension methods for converting images to common bitmap types for System.Drawing and/or SkiaSharp
public static System.Drawing.Bitmap GetBitmap(this SciTIF.ImageRGB img)
{
byte[] bytes = img.GetBitmapBytes();
using MemoryStream ms = new(bytes);
System.Drawing.Bitmap bmp = new(ms);
return bmp;
}
Something like
public static double[] CollapseHorizontally(SciTIF.Image imgR)
{
double[] collapsed = new double[imgR.Height];
for (int y = 0; y < imgR.Height; y++)
{
double xSum = 0;
for (int x = 0; x < imgR.Width; x++)
{
int offset = y * imgR.Width + x;
xSum += imgR.Values[offset];
}
double xMean = xSum / imgR.Width;
collapsed[y] = xMean;
}
return collapsed;
}
create stack from string[]
min, max, mean, etc
should have a way to create a copy of an image to allow destructive scaling without modifying the original
ImageRGB needs ScaleBy()
implement in Image and ImageRGB
has Width, Height, and GetBitmapBytes()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.