#! /usr/bin/python -t # _*_ coding: iso-8859-1 _*_ # Last edited on 2019-08-30 04:29:31 by jstolfi MODULE_DESC = "In-core format and ops for integer-valued images" MODULE_VERS = "1.0" MODULE_COPYRIGHT = "Copyright © 2019 State University of Campinas (UNICAMP)" import js_disclaimers import js_int_image_IMP class t (js_int_image_IMP.t) : """In-core format for multi-dimensional images with integer samples. A {js_int_image.t} instance is a tuple {dims}, an integer {maxval}, and an array {smp} of integer samples in the range {0..maxval}. The number of indices in the array in {axes=dims.len()}, and the ranges of the indices are the elements of {dims}, in the same order. For a two-dimensional color image, for example, {dims} would be a triple ({axes=3}). Typically one of the indices {row} would be the vertical position on screen, from top to botton; another index {col} would be the horizontal position, from left to right~and the remaining index {chn} selects a color channel such as 'red', 'green', 'blue', or 'alpha'. However, the order of the indices may vary depending on the image source. For a (raw) video clip, {dims} would be a quadruple ({axes=4}), where one index {frm} selects a frame of the video and the other three indices are interpreted as in two-dimensional images. For a simple tomogram, {dims} would usually be a triple ({axes=3}). The three indices would select a plane, a row in that plane, and a sample in that row. The directions of those three axes in space and the order of indices in each""" def get_dims(self): """Returns the array dimension tuple {dims}.""" return js_int_image_IMP.t.get_dims(self) # --------------------------------------------------------------------- def get_maxval(self): """Returns the maximum sample value (an integer in {0..65535}).""" return js_int_image_IMP.t.get_maxval(self) # --------------------------------------------------------------------- def get_samples(self): """Returns the sample array. The array is shared, not copied; therefore, assigning to an element of this array changes the image itself. All array elements must be integers in {0..maxval}, or {None}.""" return js_int_image_IMP.t.get_samples(self) # --------------------------------------------------------------------- def fill_rectangle(self,box,val): """The parameter {box} must be a pair of intervals, and each interval must be a pair of integers {(lo,hi)}. The parameter {val} must be a tuple of {chns} integers in the range {0..maxval}. Sets every pixel def create(dims,maxval,val): """Creates an image with dimensions {dims} and max sample {maxval}. The sample array is filled with the value {val} (which must be an integer in {0..maxval}.""" return js_int_image_IMP.create(dims,maxval,val) help_info_NO_WARRANTY = js_disclaimers.NO_WARRANTY help_info_STANDARD_RIGHTS = js_disclaimers.STANDARD_RIGHTS # ----------------------------------------------------------------------