#! /usr/bin/python -t # _*_ coding: iso-8859-1 _*_ # Last edited on 2019-08-25 21:24:52 by jstolfi MODULE_NAME = "js_int_image" MODULE_DESC = "Routines to read and write PNM (Portable Bitmap) image files" MODULE_VERS = "1.0" MODULE_COPYRIGHT = "Copyright © 2019 State University of Campinas (UNICAMP)" import js_int_image def read_named(fname): "Reads a PNM (Portable Bitmap) image file with name {fname} and returns its contents as an object of class {js_int_image.t}. Currently only reads ASCII-type PGM or PPM images. Other PNM variants must be converted to one of those." return js_int_image_PNM_IMP.read_named(fname) # ---------------------------------------------------------------------- def write_named(img,ch,fname): "Writes selected channels of a {js_int_image.t} object as a PNM.\n\n The parameter {ch} should be a list or tuple with the indices of the channels to be written; if {None}, all channels of {img} will be written.\n\n The output format will be ASCII PGM (grayscale) if the number of channels is 1, or ASCII PPM (color) if the number of channels is 3. In the latter case, the channels should be red, green, and blue, in that order. Fails for other channel counts." return js_int_image_PNM_IMP.write_named(img,ch,fname) # ----------------------------------------------------------------------