Python matplotlib._image.NEAREST Examples
The following are 10
code examples of matplotlib._image.NEAREST().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib._image
, or try the search function
.
Example #1
Source File: image.py From Computable with MIT License | 5 votes |
def make_image(self, magnification=1.0): if self._A is None: raise RuntimeError('You must first set the image array') x = self.to_rgba(self._A, bytes=True) self.magnification = magnification # if magnification is not one, we need to resize ismag = magnification != 1 #if ismag: raise RuntimeError if ismag: isoutput = 0 else: isoutput = 1 im = _image.frombyte(x, isoutput) fc = self.figure.get_facecolor() im.set_bg(*mcolors.colorConverter.to_rgba(fc, 0)) im.is_grayscale = (self.cmap.name == "gray" and len(self._A.shape) == 2) if ismag: numrows, numcols = self.get_size() numrows *= magnification numcols *= magnification im.set_interpolation(_image.NEAREST) im.resize(numcols, numrows) if self.origin == 'upper': im.flipud_out() return im
Example #2
Source File: image.py From matplotlib-4-abaqus with MIT License | 5 votes |
def make_image(self, magnification=1.0): if self._A is None: raise RuntimeError('You must first set the image array') x = self.to_rgba(self._A, bytes=True) self.magnification = magnification # if magnification is not one, we need to resize ismag = magnification != 1 #if ismag: raise RuntimeError if ismag: isoutput = 0 else: isoutput = 1 im = _image.frombyte(x, isoutput) fc = self.figure.get_facecolor() im.set_bg(*mcolors.colorConverter.to_rgba(fc, 0)) im.is_grayscale = (self.cmap.name == "gray" and len(self._A.shape) == 2) if ismag: numrows, numcols = self.get_size() numrows *= magnification numcols *= magnification im.set_interpolation(_image.NEAREST) im.resize(numcols, numrows) if self.origin == 'upper': im.flipud_out() return im
Example #3
Source File: image.py From neural-network-animation with MIT License | 5 votes |
def make_image(self, magnification=1.0): if self._A is None: raise RuntimeError('You must first set the image array') x = self.to_rgba(self._A, bytes=True) self.magnification = magnification # if magnification is not one, we need to resize ismag = magnification != 1 #if ismag: raise RuntimeError if ismag: isoutput = 0 else: isoutput = 1 im = _image.frombyte(x, isoutput) fc = self.figure.get_facecolor() im.set_bg(*mcolors.colorConverter.to_rgba(fc, 0)) im.is_grayscale = (self.cmap.name == "gray" and len(self._A.shape) == 2) if ismag: numrows, numcols = self.get_size() numrows *= magnification numcols *= magnification im.set_interpolation(_image.NEAREST) im.resize(numcols, numrows) if self.origin == 'upper': im.flipud_out() return im
Example #4
Source File: image.py From ImageFusion with MIT License | 5 votes |
def make_image(self, magnification=1.0): if self._A is None: raise RuntimeError('You must first set the image array') x = self.to_rgba(self._A, bytes=True) self.magnification = magnification # if magnification is not one, we need to resize ismag = magnification != 1 #if ismag: raise RuntimeError if ismag: isoutput = 0 else: isoutput = 1 im = _image.frombyte(x, isoutput) fc = self.figure.get_facecolor() im.set_bg(*mcolors.colorConverter.to_rgba(fc, 0)) im.is_grayscale = (self.cmap.name == "gray" and len(self._A.shape) == 2) if ismag: numrows, numcols = self.get_size() numrows *= magnification numcols *= magnification im.set_interpolation(_image.NEAREST) im.resize(numcols, numrows) if self.origin == 'upper': im.flipud_out() return im
Example #5
Source File: image.py From Mastering-Elasticsearch-7.0 with MIT License | 4 votes |
def composite_images(images, renderer, magnification=1.0): """ Composite a number of RGBA images into one. The images are composited in the order in which they appear in the `images` list. Parameters ---------- images : list of Images Each must have a `make_image` method. For each image, `can_composite` should return `True`, though this is not enforced by this function. Each image must have a purely affine transformation with no shear. renderer : RendererBase instance magnification : float The additional magnification to apply for the renderer in use. Returns ------- tuple : image, offset_x, offset_y Returns the tuple: - image: A numpy array of the same type as the input images. - offset_x, offset_y: The offset of the image (left, bottom) in the output figure. """ if len(images) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 parts = [] bboxes = [] for image in images: data, x, y, trans = image.make_image(renderer, magnification) if data is not None: x *= magnification y *= magnification parts.append((data, x, y, image.get_alpha() or 1.0)) bboxes.append( Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) if len(parts) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 bbox = Bbox.union(bboxes) output = np.zeros( (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) for data, x, y, alpha in parts: trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) _image.resample(data, output, trans, _image.NEAREST, resample=False, alpha=alpha) return output, bbox.x0 / magnification, bbox.y0 / magnification
Example #6
Source File: image.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def composite_images(images, renderer, magnification=1.0): """ Composite a number of RGBA images into one. The images are composited in the order in which they appear in the `images` list. Parameters ---------- images : list of Images Each must have a `make_image` method. For each image, `can_composite` should return `True`, though this is not enforced by this function. Each image must have a purely affine transformation with no shear. renderer : RendererBase instance magnification : float The additional magnification to apply for the renderer in use. Returns ------- tuple : image, offset_x, offset_y Returns the tuple: - image: A numpy array of the same type as the input images. - offset_x, offset_y: The offset of the image (left, bottom) in the output figure. """ if len(images) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 parts = [] bboxes = [] for image in images: data, x, y, trans = image.make_image(renderer, magnification) if data is not None: x *= magnification y *= magnification parts.append((data, x, y, image.get_alpha() or 1.0)) bboxes.append( Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) if len(parts) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 bbox = Bbox.union(bboxes) output = np.zeros( (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) for data, x, y, alpha in parts: trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) _image.resample(data, output, trans, _image.NEAREST, resample=False, alpha=alpha) return output, bbox.x0 / magnification, bbox.y0 / magnification
Example #7
Source File: image.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def composite_images(images, renderer, magnification=1.0): """ Composite a number of RGBA images into one. The images are composited in the order in which they appear in the `images` list. Parameters ---------- images : list of Images Each must have a `make_image` method. For each image, `can_composite` should return `True`, though this is not enforced by this function. Each image must have a purely affine transformation with no shear. renderer : RendererBase instance magnification : float The additional magnification to apply for the renderer in use. Returns ------- tuple : image, offset_x, offset_y Returns the tuple: - image: A numpy array of the same type as the input images. - offset_x, offset_y: The offset of the image (left, bottom) in the output figure. """ if len(images) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 parts = [] bboxes = [] for image in images: data, x, y, trans = image.make_image(renderer, magnification) if data is not None: x *= magnification y *= magnification parts.append((data, x, y, image.get_alpha() or 1.0)) bboxes.append( Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) if len(parts) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 bbox = Bbox.union(bboxes) output = np.zeros( (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) for data, x, y, alpha in parts: trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) _image.resample(data, output, trans, _image.NEAREST, resample=False, alpha=alpha) return output, bbox.x0 / magnification, bbox.y0 / magnification
Example #8
Source File: image.py From coffeegrindsize with MIT License | 4 votes |
def composite_images(images, renderer, magnification=1.0): """ Composite a number of RGBA images into one. The images are composited in the order in which they appear in the `images` list. Parameters ---------- images : list of Images Each must have a `make_image` method. For each image, `can_composite` should return `True`, though this is not enforced by this function. Each image must have a purely affine transformation with no shear. renderer : RendererBase instance magnification : float The additional magnification to apply for the renderer in use. Returns ------- tuple : image, offset_x, offset_y Returns the tuple: - image: A numpy array of the same type as the input images. - offset_x, offset_y: The offset of the image (left, bottom) in the output figure. """ if len(images) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 parts = [] bboxes = [] for image in images: data, x, y, trans = image.make_image(renderer, magnification) if data is not None: x *= magnification y *= magnification parts.append((data, x, y, image.get_alpha() or 1.0)) bboxes.append( Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) if len(parts) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 bbox = Bbox.union(bboxes) output = np.zeros( (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) for data, x, y, alpha in parts: trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) _image.resample(data, output, trans, _image.NEAREST, resample=False, alpha=alpha) return output, bbox.x0 / magnification, bbox.y0 / magnification
Example #9
Source File: image.py From CogAlg with MIT License | 4 votes |
def composite_images(images, renderer, magnification=1.0): """ Composite a number of RGBA images into one. The images are composited in the order in which they appear in the `images` list. Parameters ---------- images : list of Images Each must have a `make_image` method. For each image, `can_composite` should return `True`, though this is not enforced by this function. Each image must have a purely affine transformation with no shear. renderer : RendererBase instance magnification : float The additional magnification to apply for the renderer in use. Returns ------- tuple : image, offset_x, offset_y Returns the tuple: - image: A numpy array of the same type as the input images. - offset_x, offset_y: The offset of the image (left, bottom) in the output figure. """ if len(images) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 parts = [] bboxes = [] for image in images: data, x, y, trans = image.make_image(renderer, magnification) if data is not None: x *= magnification y *= magnification parts.append((data, x, y, image.get_alpha() or 1.0)) bboxes.append( Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) if len(parts) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 bbox = Bbox.union(bboxes) output = np.zeros( (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) for data, x, y, alpha in parts: trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) _image.resample(data, output, trans, _image.NEAREST, resample=False, alpha=alpha) return output, bbox.x0 / magnification, bbox.y0 / magnification
Example #10
Source File: image.py From twitter-stock-recommendation with MIT License | 4 votes |
def composite_images(images, renderer, magnification=1.0): """ Composite a number of RGBA images into one. The images are composited in the order in which they appear in the `images` list. Parameters ---------- images : list of Images Each must have a `make_image` method. For each image, `can_composite` should return `True`, though this is not enforced by this function. Each image must have a purely affine transformation with no shear. renderer : RendererBase instance magnification : float The additional magnification to apply for the renderer in use. Returns ------- tuple : image, offset_x, offset_y Returns the tuple: - image: A numpy array of the same type as the input images. - offset_x, offset_y: The offset of the image (left, bottom) in the output figure. """ if len(images) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 parts = [] bboxes = [] for image in images: data, x, y, trans = image.make_image(renderer, magnification) if data is not None: x *= magnification y *= magnification parts.append((data, x, y, image.get_alpha() or 1.0)) bboxes.append( Bbox([[x, y], [x + data.shape[1], y + data.shape[0]]])) if len(parts) == 0: return np.empty((0, 0, 4), dtype=np.uint8), 0, 0 bbox = Bbox.union(bboxes) output = np.zeros( (int(bbox.height), int(bbox.width), 4), dtype=np.uint8) for data, x, y, alpha in parts: trans = Affine2D().translate(x - bbox.x0, y - bbox.y0) _image.resample(data, output, trans, _image.NEAREST, resample=False, alpha=alpha) return output, bbox.x0 / magnification, bbox.y0 / magnification