This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import matplotlib.patches as patches | |
image = plt.imread('index.jpg') | |
# draw emtpy figure | |
fig = plt.figure() | |
# define axis | |
ax = fig.add_axes([0, 0, 1, 1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter_update = [] | |
for i in range(f.shape[2]): | |
for j in range(f.shape[0]): | |
for k in range(f.shape[1]): | |
temp = 0 | |
spos_row = j | |
spos_col = k | |
epos_row = spos_row + s_row | |
epos_col = spos_col + s_col | |
for l in range(X.shape[2]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#loading data | |
import pandas as pd | |
data = pd.read_csv('train_LZdllcl.csv') | |
#data summary | |
data.info() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data.dtypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#training k-means model | |
from sklearn.cluster import KMeans | |
kmeans = KMeans(n_clusters=4) | |
kmeans.fit(data) | |
#predictions from kmeans | |
pred = kmeans.predict(data) | |
frame = pd.DataFrame(data) | |
frame['cluster'] = pred | |
frame.columns = ['Weight', 'Height', 'cluster'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
# read images | |
img1 = cv2.imread('eiffel_2.jpeg') | |
img2 = cv2.imread('eiffel_1.jpg') | |
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) | |
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from skimage import exposure | |
#adjusting brightness | |
image = imread('images.jpeg') | |
image_bright = exposure.adjust_gamma(image, gamma=0.5,gain=1) | |
image_dark = exposure.adjust_gamma(image, gamma=1.5,gain=1) | |
# plotting images | |
plt.subplot(131), imshow(image) | |
plt.title('Original Image') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#creating hog features | |
fd, hog_image = hog(resized_img, orientations=9, pixels_per_cell=(8, 8), | |
cells_per_block=(2, 2), visualize=True, multichannel=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#importing the required libraries | |
import numpy as np | |
from skimage.io import imread, imshow | |
from skimage.filters import prewitt_h,prewitt_v | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
#reading the image | |
image = imread('puppy.jpeg',as_gray=True) |