def getUniformityFeatureValue(self): r""" **19. Uniformity** .. math:: \textit{uniformity} = \displaystyle\sum^{N_g}_{i=1}{p(i)^2} Uniformity is a measure of the sum of the squares of each intensity value. This is a measure of the heterogeneity of the image array, where a greater uniformity implies a greater heterogeneity or a greater range of discrete intensity values. .. note:: Defined by IBSI as Intensity Histogram Uniformity. """ eps = numpy.spacing(1) binEdges = imageoperations.getBinEdges(self.binWidth, self.targetVoxelArray) bins = numpy.histogram(self.targetVoxelArray, binEdges)[0] sumBins = bins.sum() if sumBins == 0: # No segmented voxels return 0 bins = bins / (float(sumBins + eps)) return numpy.sum(bins**2)
def getEntropyFeatureValue(self): r""" **3. Entropy** .. math:: \textit{entropy} = -\displaystyle\sum^{N_g}_{i=1}{p(i)\log_2\big(p(i)+\epsilon\big)} Here, :math:`\epsilon` is an arbitrarily small positive number (:math:`\approx 2.2\times10^{-16}`). Entropy specifies the uncertainty/randomness in the image values. It measures the average amount of information required to encode the image values. .. note:: Defined by IBSI as Intensity Histogram Entropy. """ eps = numpy.spacing(1) binEdges = imageoperations.getBinEdges(self.binWidth, self.targetVoxelArray) bins = numpy.histogram(self.targetVoxelArray, binEdges)[0] sumBins = bins.sum() if sumBins == 0: # No segmented voxels return 0 bins = bins + eps bins = bins / float(sumBins) return -1.0 * numpy.sum(bins * numpy.log2(bins))
def _getDiscretizedTargetVoxelArray(self): if self.discretizedTargetVoxelArray is None: binEdges = imageoperations.getBinEdges(self.targetVoxelArray, **self.settings) self.discretizedTargetVoxelArray = numpy.histogram(self.targetVoxelArray, binEdges)[0] return self.discretizedTargetVoxelArray
def _getDiscretizedTargetVoxelArray(self): if self.discretizedTargetVoxelArray is None: if self.binCount is not None: binEdges = self.binCount else: binEdges = imageoperations.getBinEdges(self.binWidth, self.targetVoxelArray) self.discretizedTargetVoxelArray = numpy.histogram( self.targetVoxelArray, binEdges)[0] return self.discretizedTargetVoxelArray
def getUniformityFeatureValue(self): r""" Calculate the Uniformity of the image array. :math:`uniformity = \displaystyle\sum^{N_l}_{i=1}{p(i)^2}` Uniformity is a measure of the sum of the squares of each intensity value. This is a measure of the heterogeneity of the image array, where a greater uniformity implies a greater heterogeneity or a greater range of discrete intensity values. """ eps = numpy.spacing(1) binEdges = imageoperations.getBinEdges(self.binWidth, self.targetVoxelArray) bins = numpy.histogram(self.targetVoxelArray, binEdges)[0] try: bins = bins / (float(bins.sum() + eps)) return (numpy.sum(bins ** 2)) except ZeroDivisionError: return numpy.core.nan
def getEntropyFeatureValue(self): r""" Calculate the Entropy of the image array. :math:`entropy = -\displaystyle\sum^{N_l}_{i=1}{p(i)\log_2\big(p(i)+\epsilon\big)}` Here, :math:`\epsilon` is an arbitrarily small positive number (:math:`\approx 2.2\times10^{-16}`). Entropy specifies the uncertainty/randomness in the image values. It measures the average amount of information required to encode the image values. """ eps = numpy.spacing(1) binEdges = imageoperations.getBinEdges(self.binWidth, self.targetVoxelArray) bins = numpy.histogram(self.targetVoxelArray, binEdges)[0] try: bins = bins + eps bins = bins / float(bins.sum()) return (-1.0 * numpy.sum(bins * numpy.log2(bins))) except ZeroDivisionError: return numpy.core.nan