Skip to content

Instantly share code, notes, and snippets.

@FilipeMaia
Created November 26, 2020 11:46
Show Gist options
  • Save FilipeMaia/8ead6f8289ae76229c3c31620cc8477a to your computer and use it in GitHub Desktop.
Save FilipeMaia/8ead6f8289ae76229c3c31620cc8477a to your computer and use it in GitHub Desktop.
# Create n noisy images
n = 10
nclasses = 2
images = [io.imread('ellipse.png',pilmode="L"), io.imread('rectangle.png',pilmode="L")]
# Store the noise in 3D matrices
noisy_images = np.zeros((n,images[0].shape[0], images[0].shape[1]))
classes = np.zeros((n))
# Calculate noisy images the noise
for i in range(n):
c = np.random.randint(0,nclasses)
noisy_images[i] = np.random.poisson(images[c])
classes[i] = c
np.save('classes.npy',classes)
# Calculate correlation coefficient matrix
# You should put all images in one matrix and call corrcoef on it.
cc_matrix = numpy.corrcoef(noisy_images.reshape(n,-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment