当前位置: 首页>>代码示例>>Python>>正文


Python roi.RectangularROI类代码示例

本文整理汇总了Python中glue.core.roi.RectangularROI的典型用法代码示例。如果您正苦于以下问题:Python RectangularROI类的具体用法?Python RectangularROI怎么用?Python RectangularROI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RectangularROI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_mouse_release

    def on_mouse_release(self, event):

        # Get the visible datasets
        if event.button == 1 and self.mode is not None:
            visible_data, visual = self.get_visible_data()
            data = self.get_map_data()

            if len(self.line_pos) == 0:
                self.lasso_reset()
                return

            elif self.mode is 'lasso':
                selection_path = path.Path(self.line_pos, closed=True)
                mask = selection_path.contains_points(data)

            elif self.mode is 'ellipse':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                c = CircularROI((xmax + xmin) / 2., (ymax + ymin) / 2., (xmax - xmin) / 2.)  # (xc, yc, radius)
                mask = c.contains(data[:, 0], data[:, 1])

            elif self.mode is 'rectangle':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                r = RectangularROI(xmin, xmax, ymin, ymax)
                mask = r.contains(data[:, 0], data[:, 1])

            else:
                raise ValueError("Unknown mode: {0}".format(self.mode))

            self.mark_selected(mask, visible_data)

            self.lasso_reset()
开发者ID:pllim,项目名称:glue-3d-viewer,代码行数:33,代码来源:scatter_toolbar.py

示例2: test_spectrum

    def test_spectrum(self):
        roi = RectangularROI()
        roi.update_limits(0, 0, 3, 3)

        expected = self.x[:, :3, :3].mean(axis=1).mean(axis=1)
        _, actual = Extractor.spectrum(self.data, self.data.id["x"], roi, (0, "x", "y"), 0)
        np.testing.assert_array_almost_equal(expected, actual)
开发者ID:rguter,项目名称:glue,代码行数:7,代码来源:test_spectrum_tool.py

示例3: test_apply_roi

 def test_apply_roi(self):
     data = self.add_data_and_attributes()
     roi = RectangularROI()
     roi.update_limits(*self.roi_limits)
     x, y = self.roi_points
     self.client.apply_roi(roi)
     assert self.layer_data_correct(data.edit_subset, x, y)
开发者ID:antonl,项目名称:glue,代码行数:7,代码来源:test_scatter_client.py

示例4: test_collapse

    def test_collapse(self, tmpdir):

        roi = RectangularROI()
        roi.update_limits(0, 2, 0, 2)
        self.tool._update_profile()

        self._save(tmpdir)
开发者ID:antonl,项目名称:glue,代码行数:7,代码来源:test_spectrum_tool.py

示例5: test_spectrum

    def test_spectrum(self):
        roi = RectangularROI()
        roi.update_limits(0.5, 1.5, 2.5, 2.5)

        expected = self.x[:, 1:3, 2:3].mean(axis=1).mean(axis=1)
        _, actual = Extractor.spectrum(
            self.data, self.data.id['x'], roi, (0, 'x', 'y'), 0)
        np.testing.assert_array_almost_equal(expected, actual)
开发者ID:stscieisenhamer,项目名称:glue,代码行数:8,代码来源:test_spectrum_tool.py

示例6: test_apply_roi_results

 def test_apply_roi_results(self, roi_limits, mask):
     # Regression test for glue-viz/glue#718
     data = self.add_data_and_attributes()
     roi = RectangularROI()
     roi.update_limits(*roi_limits)
     x, y = self.roi_points
     self.client.apply_roi(roi)
     np.testing.assert_equal(data.edit_subset.to_mask(), mask)
开发者ID:antonl,项目名称:glue,代码行数:8,代码来源:test_scatter_client.py

示例7: test_apply_roi_adds_on_empty

 def test_apply_roi_adds_on_empty(self):
     data = self.add_data_and_attributes()
     data._subsets = []
     data.edit_subset = None
     roi = RectangularROI()
     roi.update_limits(*self.roi_limits)
     x, y = self.roi_points
     self.client.apply_roi(roi)
     assert data.edit_subset is not None
开发者ID:antonl,项目名称:glue,代码行数:9,代码来源:test_scatter_client.py

示例8: test_extract

    def test_extract(self):

        roi = RectangularROI()
        roi.update_limits(0, 0, 2, 3)

        expected = self.data['x'][:, :2, :3, 1].mean(axis=1).mean(axis=1)
        _, actual = Extractor.spectrum(self.data, self.data.id['x'],
                                       roi, (0, 'x', 'y', 1), 0)

        np.testing.assert_array_equal(expected, actual)
开发者ID:antonl,项目名称:glue,代码行数:10,代码来源:test_spectrum_tool.py

示例9: test_visibility_sticky

 def test_visibility_sticky(self):
     data = self.add_data_and_attributes()
     roi = RectangularROI()
     roi.update_limits(*self.roi_limits)
     assert self.client.is_visible(data.edit_subset)
     self.client.apply_roi(roi)
     self.client.set_visible(data.edit_subset, False)
     assert not self.client.is_visible(data.edit_subset)
     self.client.apply_roi(roi)
     assert not self.client.is_visible(data.edit_subset)
开发者ID:antonl,项目名称:glue,代码行数:10,代码来源:test_scatter_client.py

示例10: test_apply_roi_doesnt_add_if_any_selection

 def test_apply_roi_doesnt_add_if_any_selection(self):
     d1 = self.add_data_and_attributes()
     d2 = self.add_data()
     d1.edit_subset = None
     d2.edit_subset = d2.new_subset()
     ct = len(d1.subsets)
     roi = RectangularROI()
     roi.update_limits(*self.roi_limits)
     x, y = self.roi_points
     self.client.apply_roi(roi)
     assert len(d1.subsets) == ct
开发者ID:antonl,项目名称:glue,代码行数:11,代码来源:test_scatter_client.py

示例11: test_apply_roi_applies_to_all_editable_subsets

 def test_apply_roi_applies_to_all_editable_subsets(self):
     d1 = self.add_data_and_attributes()
     d2 = self.add_data()
     state1 = d1.edit_subset.subset_state
     state2 = d2.edit_subset.subset_state
     roi = RectangularROI()
     roi.update_limits(*self.roi_limits)
     x, y = self.roi_points
     self.client.apply_roi(roi)
     assert d1.edit_subset.subset_state is not state1
     assert d1.edit_subset.subset_state is not state2
开发者ID:antonl,项目名称:glue,代码行数:11,代码来源:test_scatter_client.py

示例12: test_4d_single_channel

def test_4d_single_channel():

    x = np.random.random((1, 7, 5, 9))
    d = Data(x=x)
    slc = (0, 0, 'x', 'y')
    zaxis = 1
    expected = x[0, :, :, :].mean(axis=1).mean(axis=1)
    roi = RectangularROI()
    roi.update_limits(0, 0, 10, 10)

    _, actual = Extractor.spectrum(d, d.id['x'], roi, slc, zaxis)

    np.testing.assert_array_almost_equal(expected, actual)
开发者ID:antonl,项目名称:glue,代码行数:13,代码来源:test_spectrum_tool.py

示例13: test_collapse

    def test_collapse(self, tmpdir):

        roi = RectangularROI()
        roi.update_limits(0, 2, 0, 2)
        self.tool._update_profile()

        self._save(tmpdir)

        # For some reason we need to close and dereference the image and tool
        # here (and not in teardown_method) otherwise we are left with
        # references to the image viewer.
        self.image.close()
        self.image = None
        self.tool.close()
        self.tool = None
开发者ID:stscieisenhamer,项目名称:glue,代码行数:15,代码来源:test_spectrum_tool.py

示例14: on_mouse_release

    def on_mouse_release(self, event):

        visible_data, visual = self.get_visible_data()

        # Get the visible datasets
        if event.button == 1 and self.mode is not None:

            visible_data, visual = self.get_visible_data()
            data = self.get_map_data()
            if len(self.line_pos) == 0:
                self.lasso_reset()
                return

            elif self.mode is 'lasso':
                # Note, we use points_inside_poly here instead of calling e.g.
                # matplotlib directly, because we include some optimizations
                # in points_inside_poly
                vx, vy = np.array(self.line_pos).transpose()
                x, y = data.transpose()
                mask = points_inside_poly(x, y, vx, vy)

            elif self.mode is 'ellipse':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                c = CircularROI((xmax + xmin) / 2., (ymax + ymin) / 2., (xmax - xmin) / 2.)  # (xc, yc, radius)
                mask = c.contains(data[:, 0], data[:, 1])

            elif self.mode is 'rectangle':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                r = RectangularROI(xmin, xmax, ymin, ymax)
                mask = r.contains(data[:, 0], data[:, 1])

            else:
                raise ValueError("Unknown mode: {0}".format(self.mode))

            # Mask matches transposed volume data set rather than the original one.
            # The ravel here is to make mask compatible with ElementSubsetState input.
            new_mask = np.reshape(mask, self.trans_ones_data.shape)
            new_mask = np.ravel(np.transpose(new_mask))
            self.mark_selected(new_mask, visible_data)

            self.lasso_reset()
开发者ID:pllim,项目名称:glue-3d-viewer,代码行数:43,代码来源:volume_toolbar.py

示例15: release

    def release(self, event):

        if event.button == 1:

            if self.corner2 is not None:

                r = RectangularROI(*self.bounds)

                indices_dict = {}

                for layer_artist in self.iter_data_layer_artists():

                    data = get_map_data(layer_artist, self.viewer)
                    mask = r.contains(data[:, 0], data[:, 1])

                    shape_mask = np.reshape(mask, layer_artist.layer.shape[::-1])
                    shape_mask = np.ravel(np.transpose(shape_mask))

                    indices_dict[layer_artist.layer] = np.where(shape_mask)[0]

                self.mark_selected_dict(indices_dict)

            self.reset()
开发者ID:PennyQ,项目名称:glue-3d-viewer,代码行数:23,代码来源:selection_tools.py


注:本文中的glue.core.roi.RectangularROI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。