0% found this document useful (0 votes)
9 views1 page

HOG Feature Extraction in OpenCV

The document contains Python functions for extracting HOG and SIFT features from images, converting them to grayscale before processing. It also includes a function to plot accuracy graphs over epochs, displaying the relationship between epochs and accuracy. The functions utilize libraries such as OpenCV and Matplotlib for image processing and visualization.

Uploaded by

bobamexxaa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

HOG Feature Extraction in OpenCV

The document contains Python functions for extracting HOG and SIFT features from images, converting them to grayscale before processing. It also includes a function to plot accuracy graphs over epochs, displaying the relationship between epochs and accuracy. The functions utilize libraries such as OpenCV and Matplotlib for image processing and visualization.

Uploaded by

bobamexxaa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

def extract_hog_features(images):

hog_features = []
for img in images:
gray = [Link](img, cv2.COLOR_BGR2GRAY)
feature = hog(
gray,
orientations=9,
pixels_per_cell=(8, 8),
cells_per_block=(2, 2),
block_norm="L2-Hys",
)
hog_features.append(feature)
return [Link](hog_features)

def extract_sift_features(images):
sift = cv2.SIFT_create()
sift_features = []
for img in images:
gray = [Link](img, cv2.COLOR_BGR2GRAY)
keypoints, descriptors = [Link](gray, None)
if descriptors is not None:
sift_features.append([Link](descriptors, axis=0))
else:
sift_features.append([Link](128))
return [Link](sift_features)

def plot_accuracy_graph(epochs, accuracies, title):


[Link](epochs, accuracies, marker="o", label=title)
[Link]("Epoch")
[Link]("Accuracy")
[Link](f"Epoch vs Accuracy ({title})")
[Link]()
[Link](True)

You might also like