Function iaimginfo

Synopse

Print image size and pixel data type information

  • s = iaimginfo(f)
    • s: String
    • f: Image
01. import numpy as np
02. 
03. def iaimginfo(f):
04.     t = type(f)
05.     if t != np.ndarray:
06.         return 'Not a ndarray. It is %s' % (t,)
07.     else:
08.         dt = f.dtype
09.         if dt == 'bool':
10.             return '%s %s %s %s %s' % (t, np.shape(f), f.dtype, f.min(), f.max())
11.         elif dt == 'uint8':
12.             return '%s %s %s %d %d' % (t, np.shape(f), f.dtype, f.min(), f.max())
13.         else:
14.             return '%s %s %s %f %f' % (t, np.shape(f), f.dtype, f.min(), f.max())

Description

iaimginfo gives a string with the image size and pixel data type. The string also gives the minimum and maximum values of the image.

Examples

Example 1

1. from ia636 import iaimginfo
2. 
3. a = adread('danaus.tif')
4. print 'a:',iaimginfo(a)
5. a_bin = a > 128
6. print 'a_bin:', iaimginfo(a_bin)
7. a_f = a * 3.5
8. print 'a_f:', iaimginfo(a_f)
a: <type 'numpy.ndarray'> (3, 256, 256) uint8 0 255
a_bin: <type 'numpy.ndarray'> (3, 256, 256) bool False True
a_f: <type 'numpy.ndarray'> (3, 256, 256) float64 0.000000 892.500000