def do_imread(*data, **kwargs): """ Returns image file as array. """ # Check to see if the data given is either a file path or a file object if isinstance(data[0], six.string_types) or isinstance(data[0], io.IOBase): return ImageData.fromfile(data[0]) else: raise ValueError("do_imread takes a string filename")
def get_image_from_file(): import os.path filename = os.path.join('..', '..', 'demo', 'basic', 'capitol.jpg') image_source = ImageData.fromfile(filename) w, h = image_source.get_width(), image_source.get_height() index = GridDataSource(np.arange(w), np.arange(h)) index_mapper = GridMapper( range=DataRange2D(low=(0, 0), high=(w - 1, h - 1))) image_plot = ImagePlot(index=index, value=image_source, index_mapper=index_mapper, origin='top left', **PLOT_DEFAULTS) add_axes(image_plot, x_label='x', y_label='y') return image_plot
def get_image_from_file(): import os.path filename = os.path.join('..', '..', '..', 'demo','basic','capitol.jpg') image_source = ImageData.fromfile(filename) w, h = image_source.get_width(), image_source.get_height() index = GridDataSource(np.arange(w), np.arange(h)) index_mapper = GridMapper(range=DataRange2D(low=(0, 0), high=(w-1, h-1))) image_plot = ImagePlot( index=index, value=image_source, index_mapper=index_mapper, origin='top left', **PLOT_DEFAULTS ) add_axes(image_plot, x_label='x', y_label='y') return image_plot