Exemplo n.º 1
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
"""Data transfer between Gamera and numarray.
"""

from gamera.plugin import *
from gamera.util import warn_deprecated
from gamera import config

try:
    import numpy.numarray as n
except ImportError:
    try:
        verbose = config.get("verbosity_level")
    except Exception:
        verbose = 0
    if verbose:
        print('Info: numpy.numarray could not be imported')
else:
    _typecodes = {
        RGB: n.UInt8,
        GREYSCALE: n.UInt8,
        GREY16: n.UInt32,
        ONEBIT: n.UInt16,
        FLOAT: n.Float64,
        COMPLEX: n.Complex64
    }
    _inverse_typecodes = {
        n.UInt8: GREYSCALE,
Exemplo n.º 2
0
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
"""Data transfer between Gamera and Numpy.
"""

from gamera.plugin import PluginFunction, PluginModule
from gamera.args import ImageType, Args, Class
from gamera.enums import RGB, GREYSCALE, GREY16, FLOAT, DENSE, COMPLEX, ONEBIT, ALL

from gamera import config

try:
    import numpy as n
except ImportError:
    try:
        verbose = config.get("verbosity_level")
    except:
        verbose = 0
    if verbose:
        print ('Info: numpy could not be imported.')
else:
    _typecodes = {RGB: n.dtype('uint8'),
                  GREYSCALE: n.dtype('uint8'),
                  GREY16: n.dtype('uint32'),
                  ONEBIT: n.dtype('uint16'),
                  FLOAT: n.dtype('float64'),
                  COMPLEX: n.dtype('complex128')
                }
    _inverse_typecodes = {n.dtype('uint8'): GREYSCALE,
                           n.dtype('uint32'): GREY16,
                           n.dtype('uint16'): ONEBIT,