from pluginsystem import object_feature_computation_plugin
import vigra
from vigra import numpy as np

class StandardObjectFeatures(object_feature_computation_plugin.ObjectFeatureComputationPlugin):
    """
    Computes the standard vigra region features
    """
    worksForDimensions = [2, 3]
    omittedFeatures = ["Global<Maximum >", "Global<Minimum >", 'Histogram', 'Weighted<RegionCenter>']

    def computeFeatures(self, rawImage, labelImage, frameNumber):
        return vigra.analysis.extractRegionFeatures(rawImage.astype('float32'),
                                                    labelImage.astype('uint32'),
                                                    ignoreLabel=0)


from pluginsystem import object_feature_computation_plugin
import vigra
from vigra import numpy as np

class StandardObjectFeatures(object_feature_computation_plugin.ObjectFeatureComputationPlugin):
    """
    Computes the standard vigra region features
    """
    worksForDimensions = [2, 3]
    omittedFeatures = ["Global<Maximum >", "Global<Minimum >", 'Histogram', 'Weighted<RegionCenter>']

    def computeFeatures(self, rawImage, labelImage, frameNumber):
        return vigra.analysis.extractRegionFeatures(rawImage.squeeze().astype('float32'),
                                                    labelImage.squeeze().astype('uint32'),
                                                    ignoreLabel=0)


Fix default region feature computation plugin
Fix default region feature computation plugin

  from pluginsystem import object_feature_computation_plugin
  import vigra
  from vigra import numpy as np
  
  class StandardObjectFeatures(object_feature_computation_plugin.ObjectFeatureComputationPlugin):
      """
      Computes the standard vigra region features
      """
      worksForDimensions = [2, 3]
      omittedFeatures = ["Global<Maximum >", "Global<Minimum >", 'Histogram', 'Weighted<RegionCenter>']
  
      def computeFeatures(self, rawImage, labelImage, frameNumber):
-         return vigra.analysis.extractRegionFeatures(rawImage.astype('float32'),
+         return vigra.analysis.extractRegionFeatures(rawImage.squeeze().astype('float32'),
-                                                     labelImage.astype('uint32'),
+                                                     labelImage.squeeze().astype('uint32'),
                                                      ignoreLabel=0)
  
  
Fix default region feature computation plugin
## Code Before:
from pluginsystem import object_feature_computation_plugin
import vigra
from vigra import numpy as np

class StandardObjectFeatures(object_feature_computation_plugin.ObjectFeatureComputationPlugin):
    """
    Computes the standard vigra region features
    """
    worksForDimensions = [2, 3]
    omittedFeatures = ["Global<Maximum >", "Global<Minimum >", 'Histogram', 'Weighted<RegionCenter>']

    def computeFeatures(self, rawImage, labelImage, frameNumber):
        return vigra.analysis.extractRegionFeatures(rawImage.astype('float32'),
                                                    labelImage.astype('uint32'),
                                                    ignoreLabel=0)


## Instruction:
Fix default region feature computation plugin
## Code After:
from pluginsystem import object_feature_computation_plugin
import vigra
from vigra import numpy as np

class StandardObjectFeatures(object_feature_computation_plugin.ObjectFeatureComputationPlugin):
    """
    Computes the standard vigra region features
    """
    worksForDimensions = [2, 3]
    omittedFeatures = ["Global<Maximum >", "Global<Minimum >", 'Histogram', 'Weighted<RegionCenter>']

    def computeFeatures(self, rawImage, labelImage, frameNumber):
        return vigra.analysis.extractRegionFeatures(rawImage.squeeze().astype('float32'),
                                                    labelImage.squeeze().astype('uint32'),
                                                    ignoreLabel=0)

