Example #1
0
def build_items():
    x = np.linspace(-10, 10, 200)
    y = np.sin(np.sin(np.sin(x)))
    filename = osp.join(osp.dirname(__file__), "brain.png")
    items = [ 
              make.curve(x, y, color="b"),
              make.image(filename=filename),
              make.trimage(filename=filename),
              make.maskedimage(filename=filename, colormap='gray',
                               show_mask=True, xdata=[0, 40], ydata=[0, 50]),
              make.label("Relative position <b>outside</b>",
                         (x[0], y[0]), (-10, -10), "BR"),
              make.label("Relative position <i>inside</i>",
                         (x[0], y[0]), (10, 10), "TL"),
              make.label("Absolute position", "R", (0, 0), "R"),
              make.legend("TR"),
              make.rectangle(-3, -0.8, -0.5, -1., "rc1"),
              make.segment(-3, -0.8, -0.5, -1., "se1"),
              make.ellipse(-10, 0.0, 0, 0, "el1"),
              make.annotated_rectangle(0.5, 0.8, 3, 1., "rc1", "tutu"),
              make.annotated_segment(-1, -1, 1, 1., "rc1", "tutu"),
              Axes( (0, 0), (1, 0), (0, 1) ),
              PolygonShape(np.array([[150., 330.],
                                     [270., 520.],
                                     [470., 480.],
                                     [520., 360.],
                                     [460., 200.],
                                     [250., 240.]])),
              ]
    return items
Example #2
0
def build_items():
    x = np.linspace(-10, 10, 200)
    y = np.sin(np.sin(np.sin(x)))
    filename = osp.join(osp.dirname(__file__), "brain.png")
    items = [
        make.curve(x, y, color="b"),
        make.image(filename=filename),
        make.trimage(filename=filename),
        make.maskedimage(filename=filename,
                         colormap='gray',
                         show_mask=True,
                         xdata=[0, 40],
                         ydata=[0, 50]),
        make.label("Relative position <b>outside</b>", (x[0], y[0]),
                   (-10, -10), "BR"),
        make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10),
                   "TL"),
        make.label("Absolute position", "R", (0, 0), "R"),
        make.legend("TR"),
        make.rectangle(-3, -0.8, -0.5, -1., "rc1"),
        make.segment(-3, -0.8, -0.5, -1., "se1"),
        make.ellipse(-10, 0.0, 0, 0, "el1"),
        make.annotated_rectangle(0.5, 0.8, 3, 1., "rc1", "tutu"),
        make.annotated_segment(-1, -1, 1, 1., "rc1", "tutu"),
        Axes((0, 0), (1, 0), (0, 1)),
        PolygonShape(
            np.array([[150., 330.], [270., 520.], [470., 480.], [520., 360.],
                      [460., 200.], [250., 240.]])),
    ]
    return items
Example #3
0
    def update(self, img_data):
        """Update the image plot and other information."""
        # Apply image transformations if necessary.
        img_data = np.rot90(img_data, -self.rotation)
        if self.mirror[0]:
            img_data = np.flipud(img_data)
        if self.mirror[1]:
            img_data = np.fliplr(img_data)

        # Configure plot
        plot = self.imageWidget.get_plot()
        img = get_image_item(self.imageWidget)
        roi_rect = get_rect_item(self.imageWidget)
        if img is None:
            img = make.image(img_data, colormap=str(self.colormapBox.currentText()))
            plot.add_item(img)
        else:
            img.set_data(img_data)
        #img.select()
        #plot.replot()
            
        # Display ROI if requested.
        # TODO: make mirroring work
        roi = np.array(self.cam.roi)
        center = np.array(img_data.shape)/2
        roi = rotate_rect_cw(roi, center, self.rotation)
        if self.showROIBox.isChecked():
            if roi_rect is None:
                roi_rect = make.rectangle(roi[0], roi[1], roi[2], roi[3])
                roi_rect.set_resizable(False)
                roi_rect.set_selectable(False)
                plot.add_item(roi_rect)
            else:
                roi_rect.set_rect(roi[0], roi[1], roi[2], roi[3])
        else:
            if roi_rect is not None:
                plot.del_item(roi_rect)

        # Update plot
        if self.autoscaleButton.isChecked():
            self.rescale()
        self.set_lut_range()
        plot.set_plot_limits(0, img_data.shape[1], 0, img_data.shape[0])
        plot.set_aspect_ratio(img_data.shape[0]/img_data.shape[1], lock=True)
        plot.replot()
    def update(self):
        """Show the currently selected image from the ring buffer."""
        # Get the specified image data and ROI
        img_data = self.rbuffer.read(self.indexBox.value())
        roi = self.rbuffer.get_roi(self.indexBox.value())

        # Update the viewer
        plot = self.imageWidget.get_plot()
        img = get_image_item(self.imageWidget)
        rect = get_rect_item(self.imageWidget)
        if img is None:
            img = make.image(img_data,
                             colormap=str(
                                 self.parent().colormapBox.currentText()))
            plot.add_item(img)
        else:
            img.set_data(img_data)
        if rect is None:
            rect = make.rectangle(roi[0], roi[1], roi[2], roi[3])
            plot.add_item(rect)
        else:
            rect.set_rect(roi[0], roi[1], roi[2], roi[3])
        plot.replot()
Example #5
0
 def addRoi(self, x0=0, y0=0, x1=1, y1=1):
     self.roi = make.rectangle(x0, y0, x1, y1, "ROI")
     self.plot.add_item(self.roi)