%pylab inline --no-import-all
Populating the interactive namespace from numpy and matplotlib
import scipy
import scipy.misc
from scipy import stats
import numpy as np
import urllib
import skimage
import skimage.color
import skimage.io
import skimage.exposure
import skimage.data
import matplotlib.pyplot as plt
from skimage import data
from skimage import transform as tf
# URL = "http://uc452cam01-kky.fav.zcu.cz/snapshot.jpg"
URL = "http://www.chmi.cz/files/portal/docs/meteo/kam/pribram.jpg"
# URL = "http://plzen.cz/kamera.php?0.8989779513794929"
img = skimage.io.imread(URL, as_gray=False)
plt.imshow(img)
img.shape
(1200, 1600, 3)
img.shape
(1200, 1600, 3)
type(img)
numpy.ndarray
img.dtype
dtype('uint8')
dir(img)
['T', '__abs__', '__add__', '__and__', '__array__', '__array_finalize__', '__array_function__', '__array_interface__', '__array_prepare__', '__array_priority__', '__array_struct__', '__array_ufunc__', '__array_wrap__', '__bool__', '__class__', '__complex__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__lshift__', '__lt__', '__matmul__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__xor__', 'all', 'any', 'argmax', 'argmin', 'argpartition', 'argsort', 'astype', 'base', 'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 'copy', 'ctypes', 'cumprod', 'cumsum', 'data', 'diagonal', 'dot', 'dtype', 'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getfield', 'imag', 'item', 'itemset', 'itemsize', 'max', 'mean', 'min', 'nbytes', 'ndim', 'newbyteorder', 'nonzero', 'partition', 'prod', 'ptp', 'put', 'ravel', 'real', 'repeat', 'reshape', 'resize', 'round', 'searchsorted', 'setfield', 'setflags', 'shape', 'size', 'sort', 'squeeze', 'std', 'strides', 'sum', 'swapaxes', 'take', 'tobytes', 'tofile', 'tolist', 'tostring', 'trace', 'transpose', 'var', 'view']
np.min(img)
0
# from skimage import color
imggray = skimage.color.rgb2gray(img)
plt.imshow(imggray, cmap='gray')
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x218c420f6d8>
plt.imshow(imggray, vmin=0, vmax=1, cmap="Spectral")
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x218c53a8ba8>
data = np.random.random([3,2])
print(data)
print(' ')
print(data.ravel())
[[0.36861496 0.08497248] [0.22922652 0.26559663] [0.70683073 0.20412185]] [0.36861496 0.08497248 0.22922652 0.26559663 0.70683073 0.20412185]
np.min(img)
img.shape
(1200, 1600, 3)
a, b, c = plt.hist(img.ravel(), 40, density=False)
a, b, c = plt.hist(img.ravel(), 40, cumulative=True, density=False)
a, b, c = plt.hist(img[::2,::2].ravel(), bins=[0,50,100,110,120,130,200,255],
# normed=False
)
a, b, c = plt.hist(img[::2,::2].ravel(), 10)
img.flatten()
img[::2,::2].ravel()
import timeit
timeit.timeit('import numpy as np; img = np.random.random([640,480]); img.ravel()', number=100)
# timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit()
0.4349804000000006
timeit.timeit('import numpy as np; img = np.random.random([640,480]); img.flatten()', number=100)
0.5586205000000035
print(a.shape)
print(b.shape)
plt.plot(b[:-1], a, '*g--')
(10,) (11,)
[<matplotlib.lines.Line2D at 0x218c3cd5c50>]
# import cv2
import numpy as np
from matplotlib import pyplot as plt
import scipy
import scipy.misc
import urllib
import matplotlib.pyplot as plt
# scipy.misc.imread(
URL = "http://uc452cam01-kky.fav.zcu.cz/snapshot.jpg"
img = skimage.io.imread(URL)
imgg = skimage.color.rgb2gray(img)
plt.imshow(imggray, cmap='gray')
plt.show()
a, b, c = plt.hist(imgg.ravel(),255)
plt.figure()
plt.imshow(imgg, cmap='gray', clim=(0.0, 1.0))
plt.figure()
plt.imshow(imgg + 0.5, cmap='gray', clim=(0.0, 1.0))
# plt.colorbar()
plt.show()