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

SCM Repository

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

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

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

revision 4431, Thu Aug 18 23:21:27 2016 UTC revision 4432, Fri Aug 19 15:10:12 2016 UTC
# Line 13  Line 13 
13    
14  structure ImageInfo : sig  structure ImageInfo : sig
15    
16      type info      type t
17    
18    (* Do the images have the same dimension and voxel type? *)    (* Do the images have the same dimension and voxel type? *)
19      val sameShape : info * info -> bool      val sameShape : t * t -> bool
20    
21    (* Are two image infos the same? *)    (* Are two image infos the same? *)
22      val same : info * info -> bool      val same : t * t -> bool
23    
24    (* hash value (based on image file ID) *)    (* hash value (based on image file ID) *)
25      val hash : info -> word      val hash : t -> word
26    
27    (* make image info from a proxy Nrrd file, target domain dimension, and range shape;    (* make image info from a proxy Nrrd file, target domain dimension, and range shape;
28     * return NONE if the domain and/or range do not match the structure of the nrrd file.     * return NONE if the domain and/or range do not match the structure of the nrrd file.
29     *)     *)
30      val fromNrrd : NrrdInfo.info * int * int list -> info option      val fromNrrd : NrrdInfo.t * int * int list -> t option
31    
32    (* create a default image from a domain dimension and range shape. *)    (* create a default image from a domain dimension and range shape. *)
33      val mkInfo : int * int list -> info      val mkInfo : int * int list -> t
34    
35      val toString : info -> string      val toString : t -> string          (* return a string representation of the info *)
36      val dim : info -> int               (* dimension of space *)      val dim : t -> int                  (* dimension of space *)
37      val sizes : info -> int list        (* size of each dimension (not including the data axis) *)      val sizes : t -> int list           (* size of each dimension (not including the data axis) *)
38      val voxelShape : info -> int list   (* shape of voxels; empty list for scalars *)      val voxelShape : t -> int list      (* shape of voxels; empty list for scalars *)
39      val stride : info -> int            (* for non-scalar images, this returns the *)      val stride : t -> int               (* for non-scalar images, this returns the *)
40                                          (* number of samples between voxels *)                                          (* number of samples between voxels *)
41      val sampleTy : info -> RawTypes.t option      val sampleTy : t -> RawTypes.t      (* representation type of samples.  If there isn't
42                                          (* representation type of samples; NONE means default                                           * a proxy, then this will be float.
                                          * real type, since there wasn't a proxy.  
43                                           *)                                           *)
44        val hasProxy : t -> bool            (* return true if the image has a proxy *)
45    
46    end = struct    end = struct
47    
48    (* Image voxels are tensors of some raw representation type *)    (* Image voxels are tensors of some raw representation type *)
49      type voxel_ty = (int list * RawTypes.t option)      type voxel_ty = (int list * RawTypes.t)
50    
51      datatype info = ImgInfo of {      datatype t = ImgInfo of {
52          stamp : Stamp.stamp,            (* unique ID *)          stamp : Stamp.stamp,            (* unique ID *)
53          dim : int,                      (* dimension of space *)          dim : int,                      (* dimension of space *)
54          sizes : int list,               (* number of samples along each axis (not including          sizes : int list,               (* number of samples along each axis (not including
# Line 58  Line 58 
58          ty : voxel_ty          ty : voxel_ty
59        }        }
60    
61      fun sameVoxelTy ((dd1, NONE), (dd2, NONE)) = (dd1 = dd2)      fun sameVoxelTy ((dd1, ty1), (dd2, ty2)) = (ty1 = ty2) andalso (dd1 = dd2)
       | sameVoxelTy ((dd1, SOME ty1), (dd2, SOME ty2)) = (ty1 = ty2) andalso (dd1 = dd2)  
       | sameVoxelTy _ = false  
62    
63      fun sameShape (ImgInfo{stamp=s1, dim=d1, ty=ty1, ...}, ImgInfo{stamp=s2, dim=d2, ty=ty2, ...}) =      fun sameShape (ImgInfo{stamp=s1, dim=d1, ty=ty1, ...}, ImgInfo{stamp=s2, dim=d2, ty=ty2, ...}) =
64            Stamp.same(s1, s2) orelse ((d1 = d2) andalso sameVoxelTy(ty1, ty2))            Stamp.same(s1, s2) orelse ((d1 = d2) andalso sameVoxelTy(ty1, ty2))
# Line 80  Line 78 
78                    stamp = Stamp.new(),                    stamp = Stamp.new(),
79                    dim = dim,                    dim = dim,
80                    sizes = NrrdInfo.sizes nrrd,                    sizes = NrrdInfo.sizes nrrd,
81                    ty = (dd, SOME elemTy)                    ty = (dd, elemTy)
82                  })                  })
83            end            end
84    
# Line 88  Line 86 
86              stamp = Stamp.new(),              stamp = Stamp.new(),
87              dim = dim,              dim = dim,
88              sizes = [], (* unknown *)              sizes = [], (* unknown *)
89              ty = (dd, NONE)              ty = (dd, RawTypes.RT_Float)
90            }            }
91    
92      fun toString (ImgInfo{dim, ty=(dd, rTy), ...}) = let      fun toString (ImgInfo{dim, ty=(dd, rTy), ...}) = let
# Line 97  Line 95 
95                    | [d] => concat["[", Int.toString d, "]"]                    | [d] => concat["[", Int.toString d, "]"]
96                    | dd => concat["[", String.concatWith "," (List.map Int.toString dd), "]"]                    | dd => concat["[", String.concatWith "," (List.map Int.toString dd), "]"]
97                  (* end case *))                  (* end case *))
           val rTy = (case rTy of SOME rTy => RawTypes.toString rTy | _ => "real")  
98            in            in
99              concat[              concat[
100                  "IMAGE", Int.toString dim, "D<", rTy, shape, ">"                  "IMAGE", Int.toString dim, "D<", RawTypes.toString rTy, shape, ">"
101                ]                ]
102            end            end
103    
# Line 114  Line 111 
111    
112      fun sampleTy (ImgInfo{ty=(_, rTy), ...}) = rTy      fun sampleTy (ImgInfo{ty=(_, rTy), ...}) = rTy
113    
114        fun hasProxy (ImgInfo{sizes=[], ...}) = false
115          | hasProxy _ = true
116    
117    end    end

Legend:
Removed from v.4431  
changed lines
  Added in v.4432

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