Skip to content

Instantly share code, notes, and snippets.

@aishwarya-singh25
Last active November 14, 2023 17:49
Show Gist options
  • Save aishwarya-singh25/06ed2f7978882b76636e4bbf2353a095 to your computer and use it in GitHub Desktop.
Save aishwarya-singh25/06ed2f7978882b76636e4bbf2353a095 to your computer and use it in GitHub Desktop.
Image features
#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)
#calculating horizontal edges using prewitt kernel
edges_prewitt_horizontal = prewitt_h(image)
#calculating vertical edges using prewitt kernel
edges_prewitt_vertical = prewitt_v(image)
imshow(edges_prewitt_vertical, cmap='gray')
#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)
#calculating horizontal edges using prewitt kernel
edges_prewitt_horizontal = prewitt_h(image)
#calculating vertical edges using prewitt kernel
edges_prewitt_vertical = prewitt_v(image)
imshow(edges_prewitt_vertical, cmap='gray')
image = imread('puppy.jpeg')
feature_matrix = np.zeros((660,450))
feature_matrix.shape
features = np.reshape(feature_matrix, (660*450))
features.shape
for i in range(0,iimage.shape[0]):
for j in range(0,image.shape[1]):
feature_matrix[i][j] = ((int(image[i,j,0]) + int(image[i,j,1]) + int(image[i,j,2]))/3)
image = imread('puppy.jpeg', as_gray=True)
image.shape, imshow(image)
image = imread('puppy.jpeg')
image.shape
#checking image shape
image.shape, image
#pixel features
features = np.reshape(image, (660*450))
features.shape, features
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from skimage.io import imread, imshow
image = imread('image_8_original.png', as_gray=True)
imshow(image)
@rupalikale-prog
Copy link

where to save image? whether path should be written in imread function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment