def rgbimage(self, data=None, filename=None, title=None, alpha_mask=False, alpha=1.0, xdata=[None, None], ydata=[None, None], pixel_size=None, center_on=None, interpolation='linear'): """ Make a RGB image `plot item` from data (:py:class:`guiqwt.image.RGBImageItem` object) """ assert isinstance(xdata, (tuple, list)) and len(xdata) == 2 assert isinstance(ydata, (tuple, list)) and len(ydata) == 2 param = RGBImageParam(title=_("Image"), icon='image.png') data, filename, title = self._get_image_data(data, filename, title, to_grayscale=False) assert data.ndim == 3, "RGB data must have 3 dimensions" if pixel_size is None: assert center_on is None, "Ambiguous parameters: both `center_on`"\ " and `xdata`/`ydata` were specified" xmin, xmax = xdata ymin, ymax = ydata else: xmin, xmax, ymin, ymax = self.compute_bounds(data, pixel_size, center_on) self.__set_image_param(param, title, alpha_mask, alpha, interpolation, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) image = RGBImageItem(data, param) image.set_filename(filename) return image
def draw_image(self, painter, canvasRect, srcRect, dstRect, xMap, yMap): # normally we use this method indirectly from quiqwt which takes the burden of constructing # the right parameters. if we want to call this method manually, eg for painting on on a # QPixmap for saving the image, we just use the last set of parmeters passed to this # method, this is much easier than constructing the params seperatly, and so we get the # exact same result as we see on screen: self.last_canvas_rect = canvasRect self.last_src_rect = srcRect self.last_dst_rect = dstRect self.last_xmap = xMap self.last_ymap = yMap rtmin, mzmax, rtmax, mzmin = srcRect x1, y1 = canvasRect.left(), canvasRect.top() x2, y2 = canvasRect.right(), canvasRect.bottom() NX = x2 - x1 NY = y2 - y1 rtmin, mzmax, rtmax, mzmin = srcRect image = self.compute_image(0, NX, NY, rtmin, rtmax, mzmin, mzmax)[::-1, :] image2 = self.compute_image(1, NX, NY, rtmin, rtmax, mzmin, mzmax)[::-1, :] dilated = dilate(image.astype(np.int32), mzmax, mzmin) dilated2 = dilate(image2.astype(np.int32), mzmax, mzmin) self.data = np.zeros_like(dilated, dtype=np.uint32)[::-1, :] # add image as rgb(255, 255, 0): first we add red, then green which yields yellow: self.data += dilated * 256 * 256 # plus red: self.data += dilated * 256 # add image2 as rgb(0, 0, 256) which is blue: self.data += dilated2 self.data |= 255 << 24 self.bounds = QRectF(rtmin, mzmin, rtmax - rtmin, mzmax - mzmin) RGBImageItem.draw_image(self, painter, canvasRect, srcRect, dstRect, xMap, yMap)
def set_data(self, data, lut_range=None, **kwargs): '''dummy reimplementation to accept the lut_range kwarg (just ignoring it)''' return RGBImageItem.set_data(self, data, **kwargs)
def __init__(self, param=None): RGBImageItem.__init__(self, numpy.zeros((1, 1, 3)), param=param) TaurusEncodedBaseImageItem.__init__(self, self.__class__.__name__)