Code Monkey home page Code Monkey logo

scitif's People

Contributors

swharden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

scitif's Issues

Image.Crop()

useful for getting stats from rectangular ROIs

Read scale from metadata

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

GetBitmap()

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;
}

Image.CollapseHorizontally and Image.CollapseVertically

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;
}

Image.Copy()

should have a way to create a copy of an image to allow destructive scaling without modifying the original

IImage

implement in Image and ImageRGB

has Width, Height, and GetBitmapBytes()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.