示例#1
0
def plot_eigenvectors(eigenvectors,
                      num_components,
                      sz,
                      filename=None,
                      start_component=0,
                      rows=None,
                      cols=None,
                      title="Subplot",
                      color=True):
    if (rows is None) or (cols is None):
        rows = cols = int(math.ceil(np.sqrt(num_components)))
    num_components = np.min(num_components, eigenvectors.shape[1])
    fig = plt.figure()
    for i in range(start_component, num_components):
        vi = eigenvectors[0:, i].copy()
        vi = minmax(np.asarray(vi), 0, 255, dtype=np.uint8)
        vi = vi.reshape(sz)

        ax0 = fig.add_subplot(rows, cols, (i - start_component) + 1)

        plt.setp(ax0.get_xticklabels(), visible=False)
        plt.setp(ax0.get_yticklabels(), visible=False)
        plt.title("%s #%d" % (title, i), create_font('Tahoma', 10))
        if color:
            implot = plt.imshow(np.asarray(vi))
        else:
            implot = plt.imshow(np.asarray(vi), cmap=cm.grey)
    if filename is None:
        fig.show()
    else:
        fig.savefig(filename, format="png", transparent=False)
示例#2
0
def plot_gray(X,  sz=None, filename=None):
    if not sz is None:
        X = X.reshape(sz)
    X = minmax(I, 0, 255)
    fig = plt.figure()
    implot = plt.imshow(np.asarray(Ig), cmap=cm.gray)
    if filename is None:
        plt.show()
    else:
        fig.savefig(filename, format="png", transparent=False)
示例#3
0
def plot_gray(X, sz=None, filename=None):
    if not sz is None:
        X = X.reshape(sz)
    X = minmax(I, 0, 255)
    fig = plt.figure()
    implot = plt.imshow(np.asarray(Ig), cmap=cm.gray)
    if filename is None:
        plt.show()
    else:
        fig.savefig(filename, format="png", transparent=False)
示例#4
0
def plot_eigenvectors(eigenvectors, num_components, sz, filename=None, start_component=0, rows = None, cols = None, title="Subplot", color=True):
        if (rows is None) or (cols is None):
            rows = cols = int(math.ceil(np.sqrt(num_components)))
        num_components = np.min(num_components, eigenvectors.shape[1])
        fig = plt.figure()
        for i in range(start_component, num_components):
            vi = eigenvectors[0:,i].copy()
            vi = minmax(np.asarray(vi), 0, 255, dtype=np.uint8)
            vi = vi.reshape(sz)
            
            ax0 = fig.add_subplot(rows,cols,(i-start_component)+1)
            
            plt.setp(ax0.get_xticklabels(), visible=False)
            plt.setp(ax0.get_yticklabels(), visible=False)
            plt.title("%s #%d" % (title, i), create_font('Tahoma',10))
            if color:
                implot = plt.imshow(np.asarray(vi))
            else:
                implot = plt.imshow(np.asarray(vi), cmap=cm.grey)
        if filename is None:
            fig.show()
        else:
            fig.savefig(filename, format="png", transparent=False)
示例#5
0
import normalization as n

datastring = '10 12 3 6 5 25 17 100 1000 98 11 27 78 33 9 18 23 44 690 200'
datastringarray = datastring.split(' ')
data = []
normalizeddata = []

for i in datastringarray:
    data.append(float(i))

oldmin = min(data)
oldmax = max(data)

for i in data:
    normalizeddata.append(n.minmax(i, oldmin, oldmax, 0, 1))

print(normalizeddata)
示例#6
0
 def extract(self, X):
     return minmax(X, self._low, self._high, self._min, self._max)