Last active
November 14, 2023 17:49
-
-
Save aishwarya-singh25/06ed2f7978882b76636e4bbf2353a095 to your computer and use it in GitHub Desktop.
Image features
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) | |
#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') |
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) | |
#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') |
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
image = imread('puppy.jpeg') | |
feature_matrix = np.zeros((660,450)) | |
feature_matrix.shape |
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
features = np.reshape(feature_matrix, (660*450)) | |
features.shape |
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
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) |
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
image = imread('puppy.jpeg', as_gray=True) | |
image.shape, imshow(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
image = imread('puppy.jpeg') | |
image.shape |
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
#checking image shape | |
image.shape, 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
#pixel features | |
features = np.reshape(image, (660*450)) | |
features.shape, features |
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 | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where to save image? whether path should be written in imread function?