Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /trunk/src/compiler/fields/image-info.sml
ViewVC logotype

View of /trunk/src/compiler/fields/image-info.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 238 - (download) (annotate)
Thu Aug 5 23:17:46 2010 UTC (8 years, 9 months ago) by jhr
File size: 1551 byte(s)
  Use the log file for debugging output
(* image-info.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *
 * Information about a NRRD file
 *)

structure ImageInfo : sig

    datatype info = ImgInfo of {
	    id : OS.FileSys.file_id,		(* ID of image file *)
	    dim : int,				(* dimension of space *)
	    ty : RawTypes.ty,			(* types of scalar samples *)
	    origin : FloatLit.float list,	(* center of first sample *)
	    sizes : int list			(* number of samples along each axis *)
	  }

  (* are the underlying files the same? *)
    val same : info * info -> bool

  (* hash value (based on image file ID) *)
    val hash : info -> word

  (* get image info from a Nrrd file *)
    val getInfo : string -> info

    val toString : info -> string

  end = struct

    datatype info = ImgInfo of {
	    id : OS.FileSys.file_id,		(* ID of image file *)
	    dim : int,				(* dimension of space *)
	    ty : RawTypes.ty,			(* types of scalar samples *)
	    origin : FloatLit.float list,	(* center of first sample *)
	    sizes : int list			(* number of samples along each axis *)
	  }

    fun same (ImgInfo{id=a, ...}, ImgInfo{id=b, ...}) = (a = b)

    fun hash (ImgInfo{id, ...}) = OS.FileSys.hash id

    fun getInfo fileName = let
	  val {version, header} = RunDNorm.run fileName
	  in
	    Log.msg (concat[fileName, " file header:\n"]);
	    List.app (fn (tag, value) => Log.msg(concat["  ", tag, ": ", value, "\n"])) header;
(* FIXME*)raise Fail "getInfo"
	  end

    fun toString (ImgInfo{...}) = "IMAGE" (* FIXME *)

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0