This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections; | |
using System.Collections.Generic; | |
// width/height helpers | |
static int Width<TPixel>(this TPixel[,] pixels) => pixels.GetLength(0); | |
static int Height<TPixel>(this TPixel[,] pixels) => pixels.GetLength(1); | |
// range helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// | |
/// </summary> | |
public class ComplexGeometry : List<LineSegments> | |
{ | |
// stores the dictionary | |
Dictionary<Point, LineSegments> _segments = | |
new Dictionary<Point, LineSegments>(); | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Orientation | |
{ | |
Transverse, | |
Sagittal, | |
Coronal | |
} | |
public static class MprGenerator<TPixel> | |
{ | |
// generates an MPR from a volume given an orientation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "FsSampleImage.fsx" | |
open System.Collections.Generic | |
open FsSampleImage | |
let rows<'T> (samples: Map<Index,'T>) = | |
samples // extracts rows of samples from the "image" Map | |
|> Seq.sortBy (fun samp -> samp.Key.x) | |
|> Seq.groupBy (fun samp -> samp.Key.y) | |
|> Seq.map snd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for a 2D array of pixels with some pixel type | |
var pixels = new TPixel[100,100]; | |
// turn into a sequence | |
var pixelSequence = pixels.Cast<TPixelType>(); | |
// group the sequence and turn to a dictionary, with pixel values as key and bin count as value | |
var histo = pixelSequence.GroupBy(px => px).ToDictionary(grp => grp.Key, grp => grp.Count()); |
NewerOlder