Exemple #1
0
    def __init__(self, hdulist, figure, rect):
        self.hdulist = hdulist
        self.figure = figure
        self.axes = self._create_axes(rect)
        #self.figure.add_axes(self.axes)

        self.marker = None

        self.display_changed = Signal()
        self.xy_changed = Signal()
        self.focus_released = Signal()

        self._colormap = GrayscaleColorMap()
        self._mpl_event_handlers = {}
        self._interaction_context = None
        self.number_of_images_displayed = 0
        self.frame_number = None
Exemple #2
0
def main():
    img = create_test_image()
    colormap = GrayscaleColorMap()

    plt.subplot(1, 1, 1)
    plt.subplots_adjust(left=0.15, bottom=0.25)

    axcolor = 'lightgoldenrodyellow'
    contrast_ax = plt.axes([0.15, 0.15, 0.65, 0.03], axisbg=axcolor)
    bias_ax = plt.axes([0.15, 0.1, 0.65, 0.03], axisbg=axcolor)

    contrast_slider = Slider(contrast_ax, "Contrast", 0.0, 1.0, valinit=0.5)
    bias_slider = Slider(bias_ax, "Bias", 0.0, 1.0, valinit=0.5)

    cmap = colormap.as_mpl_cmap()
    plt.subplot(1, 1, 1)
    img_ax = plt.imshow(img, cmap=cmap)
    plt.colorbar(orientation="horizontal")

    def update_colormap():
        cmap = colormap.as_mpl_cmap()
        img_ax.set_cmap(cmap)

    def update_contrast(contrast):
        print("Setting contrast to %f" % contrast)
        colormap.set_contrast(contrast)
        update_colormap()

    def update_bias(bias):
        print("Setting bias to %f" % bias)
        colormap.set_bias(bias)
        update_colormap()

    contrast_slider.on_changed(update_contrast)
    bias_slider.on_changed(update_bias)

    plt.show()