Skip to content

Commit f4d5ad7

Browse files
committed
Added RGBHistogram vector to FeatureVectors
1 parent f938509 commit f4d5ad7

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

FeatureVectors.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import cv2
12
import numpy as np
23

34

@@ -22,10 +23,20 @@ def __getStdIntensity(self):
2223

2324
return stdIntensity
2425

26+
def __getRGBHistogramVector(self):
27+
histogram_3d = cv2.calcHist([self.image], [0, 1, 2], None,
28+
[8, 8, 8], [0, 256, 0, 256, 0, 256])
29+
histogram_3d = histogram_3d.ravel()
30+
RGBHistogram = list(histogram_3d)
31+
32+
return RGBHistogram
33+
2534
def getFeatureVector(self):
2635
featureVectors = []
2736
meanIntensity = self.__getMeanIntensity()
2837
stdIntensity = self.__getStdIntensity()
38+
rgbHistogram = self.__getRGBHistogramVector()
2939

30-
featureVectors = meanIntensity+stdIntensity
40+
colorVectors = meanIntensity+stdIntensity+rgbHistogram
41+
featureVectors = colorVectors
3142
return featureVectors

ImageSearch.ipynb

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

ImageSearch_Serial.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ def extractFeatureVectors(image_path):
1919

2020
def ImageSearch(queryImage):
2121

22-
start = time.perf_counter()
23-
2422
image_db_path = "Image_Database/"
2523
image_paths = []
2624
for img in os.listdir(image_db_path):
2725
image_paths.append(image_db_path+img)
2826

29-
lists = [image_paths, image_paths, image_paths, image_paths]
30-
3127
features = {}
3228
for image in image_paths:
3329
imageName, vector = extractFeatureVectors(image)
@@ -44,13 +40,8 @@ def ImageSearch(queryImage):
4440
search = QuerySearch(queryVector, features)
4541
results = search.performSearch()
4642

47-
results.sort(key=lambda res: res[1])
48-
print(results)
49-
43+
results.sort(key=lambda res: res[1], reverse=True)
5044
# for res in results:
5145
# print(res)
5246

5347
return results
54-
55-
end = time.perf_counter()
56-
print(f"Time : {end-start}")

0 commit comments

Comments
 (0)