I am trying to apply NMF to a particular image that is loaded in grayscale mode. I have tried several links but my image after application of NMF remains almost the same and cannot be distinguished with the grayscale image initially loaded.
However, when i come across the scikit-learn's code on implementing decomposition on a dataset, i see that the faces there have been transformed into ghost - like faces. Here is the link:
And here is the code I am using:
import cv2
from sklearn import decomposition
import matplotlib.pyplot as plt
img = cv2.imread('test1.jpeg',0)
estimator = decomposition.NMF(n_components = 2, init = 'nndsvda', tol = 5e-3)
estimator.fit(img)
vmax = max(img.max(), -img.min())
plt.imshow(img, cmap=plt.cm.gray, interpolation = 'nearest',vmin=-vmax,vmax=vmax)
plt.show()
I am new to the techniques of NMF on matrices espicially such a large image numpy array.
My image is test1.jpeg that is 225 * 224 .jpeg image.
Can someone please help me on implementing the code for a single image? Thanks a lot in advance.