INNER CODE UNIT · Python

U_temp

AllAlgorithms/python · classification/fcm.py:19

        U_temp = numpy.power(U_temp, 2/(self.m - 1))
        denominator_ = U_temp.reshape(
            (data.shape[0], 1, -1)).repeat(U_temp.shape[-1], axis=1)
        denominator_ = U_temp[:, :, numpy.newaxis] / denominator_
        return 1 / denominator_.sum(2)

    def Centers(self, data, U):
        um = U ** self.m
        return (data.T @ um / numpy.sum(um, axis=0)).T

    def newImage(self, U, centers, im):
        best = numpy.argmax(self.U, axis=-1)
        # print(best)
        # numpy.round()
        image = im.astype(int)
        for i in range(256):
            image = numpy.where(image == float(i), centers[best[i]][0], image)
        return image

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…