Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use KMeans in Sklearn to do clustering and find the nearest cluster centroid for each SIFT feature; Use cv 2 . xfeatures 2 d .

Use KMeans in Sklearn to do clustering and find the nearest cluster centroid for each SIFT feature;
Use cv2.xfeatures2d.SIFT_create() to create a SIFT object;
Use cv2.Keypoint() to generate key points;
Use sift.compute() to compute SIFT descriptors given densely sampled keypoints.
Be mindful of RAM usage. Try to make the code more memory efficient, otherwise it could easily exceed RAM limits in Colab, at which point your session will crash.
If your RAM is going to run out of space, use gc.collect() for the garbage collector to collect unused objects in memory to free some space.
Store data or features as NumPy arrays instead of lists. Computation on NumPy arrays is much more efficient than lists.
from sklearn import neighbors
np.random.seed(65)
##########--WRITE YOUR CODE HERE--##########
# The following steps are just for your reference
# You can write in your own way
#
# # densely sample keypoints
# def sample_kp(shape, stride, size):
# return kp
#
# # extract vocabulary of SIFT features
# def extract_vocabulary(raw_data, key_point):
# return vocabulary
#
# # extract Bag of SIFT Representation of images
# def extract_feat(raw_data, vocabulary, key_point):
# return feat
#
# # sample dense keypoints
# skp = sample_kp((train_data[0].shape[0],train_data[0].shape[1]),(64,64),8)
# vocabulary = extract_vocabulary(train_data, skp)
# train_feat = extract_feat(train_data, vocabulary, skp)
# test_feat = extract_feat(test_data, vocabulary, skp)
train_feat =
test_feat =
##########-------END OF CODE-------##########
# this block should generate
# train_feat and test_feat corresponding to train_data and test_data
In python please and thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions