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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/fields/image-info.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/fields/image-info.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/src/image-info/image-info.sml revision 106, Tue Jun 15 15:29:37 2010 UTC trunk/src/compiler/fields/image-info.sml revision 435, Tue Oct 19 13:14:20 2010 UTC
# Line 1  Line 1 
1  (* image-info.sml  (* image-info.sml
2   *   *
3   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * Information about a NRRD file   * Information about a NRRD file
# Line 8  Line 8 
8    
9  structure ImageInfo : sig  structure ImageInfo : sig
10    
11      val getInfo : string -> {    (* Image samples are tensors of some raw representation type *)
12        type sample_ty = (int list * RawTypes.ty)
13    
14        datatype info = ImgInfo of {
15                id : OS.FileSys.file_id,            (* ID of image file *)
16              dim : int,                          (* dimension of space *)              dim : int,                          (* dimension of space *)
17              ty : RawTypes.ty,                   (* types of scalar samples *)              ty : sample_ty,                     (* types of image samples *)
18              origin : FloatLit.float list,       (* center of first sample *)              origin : FloatLit.float list,       (* center of first sample *)
19              ??              sizes : int list                    (* number of samples along each axis *)
20            }            }
21    
22      (* are the underlying files the same? *)
23        val same : info * info -> bool
24    
25      (* hash value (based on image file ID) *)
26        val hash : info -> word
27    
28      (* get image info from a Nrrd file *)
29        val getInfo : string -> info
30    
31        val toString : info -> string
32        val dim : info -> int                       (* dimension of space *)
33    
34    end = struct    end = struct
35    
36      (* Image samples are tensors of some raw representation type *)
37        type sample_ty = (int list * RawTypes.ty)
38    
39        datatype info = ImgInfo of {
40                id : OS.FileSys.file_id,            (* ID of image file *)
41                dim : int,                          (* dimension of space *)
42                ty : sample_ty,                     (* types of image samples *)
43                origin : FloatLit.float list,       (* center of first sample *)
44                sizes : int list                    (* number of samples along each axis *)
45              }
46    
47        fun same (ImgInfo{id=a, ...}, ImgInfo{id=b, ...}) = (a = b)
48    
49        fun hash (ImgInfo{id, ...}) = OS.FileSys.hash id
50    
51        fun getInfo fileName = let
52    (* FIXME: check that file exists! *)
53              val {version, header} = RunDNorm.run fileName
54              fun set (r, v) = (r := SOME v)
55              fun get (tag, r) = (case !r of NONE => raise Fail("missing "^tag) | SOME v => v)
56              val ty = ref NONE
57              val totalDim = ref NONE
58              val dim = ref NONE
59              fun doValue ("type", v) = set(ty, RawTypes.fromString v)
60                | doValue ("dimension", v) = set (totalDim, valOf(Int.fromString v))
61                | doValue ("space dimension", v) = set (dim, valOf(Int.fromString v))
62                | doValue ("sizes", v) = ()
63                | doValue ("space directions", v) = ()
64                | doValue ("kinds", v) = ()
65                | doValue ("endian", v) = ()
66                | doValue ("encoding", v) = ()
67                | doValue ("space origin", v) = ()
68                | doValue _ = ()
69              in
70                Log.msg (concat[fileName, " file header:\n"]);
71                List.app (fn (tag, value) => Log.msg(concat["  ", tag, ": ", value, "\n"])) header;
72                List.app doValue header;
73                ImgInfo{
74                    id = OS.FileSys.fileId fileName,
75                    dim = get ("space dimension", dim),
76    (* FIXME: in general, the type is a tensor of raw values *)
77                    ty = ([], get ("type", ty)),
78                    origin = [],    (* FIXME *)
79                    sizes = []      (* FIXME *)
80                  }
81              end
82    
83        fun toString (ImgInfo{dim, ...}) = concat["IMAGE", Int.toString dim, "D"] (* FIXME *)
84    
85        fun dim (ImgInfo{dim, ...}) = dim
86    
87    end    end

Legend:
Removed from v.106  
changed lines
  Added in v.435

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