oeyh / NN

MIT License
1 stars 0 forks source link

Assignment 7 use K-means to compress image #4

Closed oeyh closed 5 years ago

oeyh commented 6 years ago

If using scipy.misc.imread the png, it will return RGB values in the range of 0-255, and if you use this data matrix for learning and then plot, the image looks weird and changes a lot every time you run it again.

Need feature scaling?

oeyh commented 5 years ago

Root cause found: If data A is 0-255 with type uint8, the result matrix must be of type uint8, too. If it is in range of 0-255, but of type float, it will get clipped to range 0-1 and result in weird color map.

Matplotlib.pyplot.imshow() doc clearly says: All values should be in the range [0 .. 1] for floats or [0 .. 255] for integers. Out-of-range values will be clipped to these bounds.