In [1]:
#loading the standard header files 
import numpy as np
import pandas as pd
import os
import sys
import cv2
from matplotlib import pyplot as plt
from skimage.feature import hog

#loading the python file 
#link->
import image_feature_extraction
In [2]:
def loadFilePaths(image_directory):
    
    files=os.listdir(image_directory)
    files_path=[os.path.join(image_directory,file) for file in files ]
    return files_path
In [47]:
files_path=loadFilePaths('D://Himani-work/gsoc2020/dataset/ideology_extra200ms/ideology_image_dataset/')

Original image

In [60]:
img=cv2.imread(files_path[0])
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(img_gray,cmap="gray")
Out[60]:
<matplotlib.image.AxesImage at 0x2497e3e18c8>

Gray-scale-Gaussian-filter-resized Image

In [4]:
features=image_feature_extraction.getGrayScaleFeatures(['hims.jpg'])
img=features[0].reshape(120,120)
plt.imshow(img,cmap="gray")
 Status: 0 / 1
Out[4]:
<matplotlib.image.AxesImage at 0x28eddd33708>
In [57]:
features=image_feature_extraction.getGrayScaleFeatures(files_path[0:1])
img=features[0].reshape(120,120)
plt.imshow(img,cmap="gray")
 Status: 0 / 1
Out[57]:
<matplotlib.image.AxesImage at 0x2497e292ac8>

Canny Edge features

In [7]:
features=image_feature_extraction.getCannyFeatures(['hims.jpg'])
img=features[0].reshape(120,120)
plt.imshow(img,cmap="gray")
 Status: 0 / 1
Out[7]:
<matplotlib.image.AxesImage at 0x28edde9f1c8>
In [17]:
img=cv2.imread('hims.jpg')


width = 164
height = 128
dim = (width, height)

resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)


fd, hog_image = hog(resized, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(2, 2), visualize=True,multichannel=True)
plt.imshow(hog_image,cmap="gray")
Out[17]:
<matplotlib.image.AxesImage at 0x28ede7961c8>
In [56]:
features=image_feature_extraction.getCannyFeatures(files_path[0:1])
img=features[0].reshape(120,120)
plt.imshow(img,cmap="gray")
 Status: 0 / 1
Out[56]:
<matplotlib.image.AxesImage at 0x2497e22ec08>

Prewitt-y Edge Features

In [61]:
features=image_feature_extraction.getPrewittyFeatures(files_path[0:1])
img=features[0].reshape(120,120)
plt.imshow(img,cmap="gray")
 Status: 0 / 1
Out[61]:
<matplotlib.image.AxesImage at 0x2497e451dc8>

Sobel Edge features

In [63]:
features=image_feature_extraction.getSobelyFeatures(files_path[0:1])
img=features[0].reshape(120,120)
plt.imshow(img,cmap="gray")
 Status: 0 / 1
Out[63]:
<matplotlib.image.AxesImage at 0x2497e4badc8>

HOG Features

In [68]:
img=cv2.imread(files_path[0])


width = 164
height = 128
dim = (width, height)

resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)


fd, hog_image = hog(resized, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(2, 2), visualize=True,multichannel=True)
plt.imshow(hog_image,cmap="gray")
Out[68]:
<matplotlib.image.AxesImage at 0x2497e541f88>

FAST Features

In [71]:
img=cv2.imread(files_path[0],0)
fast = cv2.FastFeatureDetector_create()
# find and draw the keypoints
width = 164
height = 128
dim = (width, height)

resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)

kp = fast.detect(resized,None)
img2 = cv.drawKeypoints(resized, kp, None, color=(255,0,0))
plt.imshow(img2)
Out[71]:
<matplotlib.image.AxesImage at 0x2497e660f48>

BRIEF Features

In [73]:
img=cv2.imread('Briefdetector.png')


plt.imshow(img)
Out[73]:
<matplotlib.image.AxesImage at 0x2497e7014c8>

ORB Features

In [74]:
img=cv2.imread('orbdetector.png')


plt.imshow(img)
Out[74]:
<matplotlib.image.AxesImage at 0x2497e7921c8>
In [ ]: