Image processing


In [1]:
from skimage import io, color, feature, transform
import numpy as np
from skimage.filters import rank
import plotly.plotly as py
import cufflinks as cf # this is necessary to link pandas to plotly
import plotly.graph_objs as go
cf.go_offline()
from plotly.offline import plot, iplot
from skimage.morphology import disk
from matplotlib import pyplot as PLT



In [2]:
rgbImg = io.imread("/Users/sreejithmenon/Dropbox/Social_Media_Wildlife_Census/All_Zebra_Count_Images/8598.jpeg")

In [ ]:
hsvImg = color.rgb2hsv(rgbImg)

In [ ]:
red = np.array([pix[0] for row in rgbImg for pix in row])
green = np.array([pix[1] for row in rgbImg for pix in row])
blue = np.array([pix[2] for row in rgbImg for pix in row])

hue = np.array([pix[0] for row in hsvImg for pix in row])
saturation = np.array([pix[1] for row in hsvImg for pix in row])
value = np.array([pix[2] for row in hsvImg for pix in row])

In [ ]:
y = 0.299 * red + 0.587 * green + 0.114 * blue
(np.max(y) - np.min(y))/np.mean(y)

In [ ]:
a = np.array(rgbImg)

In [ ]:
a

In [ ]:
hue

In [ ]:
data = [
    go.Histogram(
    x = hue,
    nbinsx = 12
    )
]

plot(data)

In [ ]:
a, _ = np.histogram(saturation, bins=5)
np.std(a)

In [3]:
gray = color.rgb2gray(rgbImg)

In [ ]:
gray.shape

In [ ]:
glcm = feature.greycomatrix(gray, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4])
glcm.shape

In [ ]:
entropy = rank.entropy(gray, disk(5))

In [ ]:
entropy.shape

In [ ]:
feature.hog(resized_img, orientations=8)

In [4]:
resized_img = transform.resize(gray, (600,600))

In [ ]:
resized_img.shape

In [ ]:
PLT.imshow(flipped)
PLT.show()

In [5]:
left = resized_img.transpose()[:300].transpose()
right = resized_img.transpose()[300:].transpose()

In [ ]:
left.shape, right.shape

In [15]:
I = np.identity(600)[::-1]

In [16]:
flipped = I.dot(right)

In [17]:
inner = feature.hog(left) - feature.hog(flipped)

In [18]:
np.linalg.norm(inner)


Out[18]:
7.4599010338301044

In [13]:
inner


Out[13]:
array([-0.00700603, -0.00796074, -0.00081415, ...,  0.00238143,
        0.0120759 , -0.00081522])

In [ ]: