Esempio n. 1
0
    def OnChangeFeatures(self, event):
    #---------------------------------------------------------------------------
        from gamera import plugin
        from gamera.core import ONEBIT
        from gamera.core import ImageBase
        from gamera.args import Args, Check

        if self.classifier is None:
            gui.message("No classifier loaded")
            return

        allFeatures = [x[0] for x in plugin.methods_flat_category("Features", ONEBIT)]
        allFeatures.sort()

        existingFeatures = [x[0] for x in ImageBase.get_feature_functions(self.classifier.features)[0]]

        featureControls = []
        for f in allFeatures:
            featureControls.append(Check('', f, default=(f in existingFeatures)))

        dialog = Args(featureControls, name = "Feature selection",
            title="Select the features you want to use for optimization")

        result = dialog.show(self)

        if result is None:
            gui_util.message("No change applied")
            return

        selectedFeatures = [name for check, name in zip(result, allFeatures) if check]
        self.classifier.change_feature_set(selectedFeatures)

        self.UpdatePanels()
Esempio n. 2
0
    def OnChangeFeatures(self, event):
        # ---------------------------------------------------------------------------
        from gamera import plugin
        from gamera.core import ONEBIT
        from gamera.core import ImageBase
        from gamera.args import Args, Check

        if self.classifier == None:
            gui.message("No classifier loaded")
            return

        allFeatures = [x[0] for x in plugin.methods_flat_category("Features", ONEBIT)]
        allFeatures.sort()

        existingFeatures = [x[0] for x in ImageBase.get_feature_functions(self.classifier.features)[0]]

        featureControls = []
        for f in allFeatures:
            featureControls.append(Check("", f, default=(f in existingFeatures)))

        dialog = Args(
            featureControls, name="Feature selection", title="Select the features you want to use for optimization"
        )

        result = dialog.show(self)

        if result == None:
            gui_util.message("No change applied")
            return

        selectedFeatures = [name for check, name in zip(result, allFeatures) if check]
        self.classifier.change_feature_set(selectedFeatures)

        self.UpdatePanels()
Esempio n. 3
0
    def OnOpenClassifier(self, event):
    #---------------------------------------------------------------------------
        from gamera.args import Args, Class
        from gamera.gui import gui
        from gamera import knn

        dialog = Args(
            [Class("Classifier", knn._kNNBase)],
             name="Select an existing classifier...")
        results = dialog.show(
            self, gui.main_win.shell.locals,
            docstring="""Choose an already created classifier for optimization.""")

        if results is None:
            return

        self.classifier = results[0]

        if isinstance(self.classifier, knn.kNNInteractive):
            gui_util.message("Given interactive classifier will be converted"\
                " to noninteractive classifier for optimization (internal)")
            self.classifier = self.CopyClassifier(self.classifier)

        self.SetClassifiers()
        self.UpdatePanels()
        self.EnableControls(True)
Esempio n. 4
0
    def OnOpenClassifier(self, event):
        # ---------------------------------------------------------------------------
        from gamera.args import Args, Class
        from gamera.gui import gui
        from gamera import knn

        dialog = Args([Class("Classifier", knn._kNNBase)], name="Select an existing classifier...")
        results = dialog.show(
            self, gui.main_win.shell.locals, docstring="""Choose an already created classifier for optimization."""
        )

        if results == None:
            return

        self.classifier = results[0]

        if isinstance(self.classifier, knn.kNNInteractive):
            gui_util.message(
                "Given interactive classifier will be converted"
                " to noninteractive classifier for optimization (internal)"
            )
            self.classifier = self.CopyClassifier(self.classifier)

        self.SetClassifiers()
        self.UpdatePanels()
        self.EnableControls(True)