1什么是Gist特征
(1) 一種宏觀意義的場景特征描述
(2) 只識別“大街上有一些行人”這個場景,無需知道圖像中在那些位置有多少人,或者有其他什么對象。
(3) Gist特征向量可以一定程度表征這種宏觀場景特征
GIST定義下列五種對空間包絡的描述方法
| 空間包絡名 | 闡釋 |
|---|---|
| 自然度(Degree of Naturalness) | 場景如果包含高度的水平和垂直線,這表明該場景有明顯的人工痕跡,通常自然景象具有紋理區域和起伏的輪廓。所以,邊緣具有高度垂直於水平傾向的自然度低,反之自然度高。 |
| 開放度(Degree of Openness) | 空間包絡是否是封閉(或圍繞)的。封閉的,例如:森林、山、城市中心。或者是廣闊的,開放的,例如:海岸、高速公路。 |
| 粗糙度(Degree of Roughness) | 主要指主要構成成分的顆粒大小。這取決於每個空間中元素的尺寸,他們構建更加復雜的元素的可能性,以及構建的元素之間的結構關系等等。粗糙度與場景的分形維度有關,所以可以叫復雜度。 |
| 膨脹度(Degree of Expansion) | 平行線收斂,給出了空間梯度的深度特點。例如平面視圖中的建築物,具有低膨脹度。相反,非常長的街道則具有高膨脹度。 |
| 險峻度(Degree of Ruggedness) | 即相對於水平線的偏移。(例如,平坦的水平地面上的山地景觀與陡峭的地面)。險峻的環境下在圖片中生產傾斜的輪廓,並隱藏了地平線線。大多數的人造環境建立了平坦地面。因此,險峻的環境大多是自然的。 |
2 Gist的實現--LMgist
-
LMgist的Matlab代碼 LMgist Matlab代碼
-
LMgist Matlab代碼的使用
% 讀取圖片
img = imread('demo2.jpg');
% 設置GIST參數
clear param
param.orientationsPerScale = [8 8 8 8]; % number of orientations per scale (from HF to LF)
param.numberBlocks = 4;
param.fc_prefilt = 4;
% 計算GIST
[gist, param] = LMgist(img, '', param);
3 LMgist原理
3.1 LMgist算法主流程
- G1:對輸入圖片進行預處理 (RGB或RGBA轉128x128灰度圖)
- G2:對輸入圖片進行Prefilt處理
- G3:計算圖片的Gist向量
3.2 G2 對輸入圖片進行Prefilt處理
3.2.1 Pad images to reduce boundary artifacts (擴邊+去偽影)
圖1 sympading操作
3.2.2 Filter (構造濾波器)
3.2.3 Whitening (白化)
3.2.4 Local contrast normalization (局部對比度歸一化)
3.2.5 Local contrast normalization (局部對比度歸一化)
3.3 計算圖片的Gist向量
3.3.1 Pading
3.3.2 FFT
3.3.3 遍歷每個Gabor核函數
圖2 全局Gist特征的提取
4 LMgist的Python實現
GitHub代碼 https://github.com/Kalafinaian/python-img_gist_feature
4.1 提取Gist特征
import cv2
from img_gist_feature.utils_gist import *
s_img_url = "./test/A.jpg"
gist_helper = GistUtils()
np_img = cv2.imread(s_img_url, -1)
print("default: rgb")
np_gist = gist_helper.get_gist_vec(np_img)
print("shape ", np_gist.shape)
print("noly show 10dim", np_gist[0,:10], "...")
print()
print("convert rgb image")
np_gist = gist_helper.get_gist_vec(np_img, mode="rgb")
print("shape ", np_gist.shape)
print("noly show 10dim", np_gist[0,:10], "...")
print()
print("convert gray image")
np_gist = gist_helper.get_gist_vec(np_img, mode="gray")
print("shape ", np_gist.shape)
print("noly show 10dim", np_gist[0,:10], "...")
print()
運行得到的gist特征為
default: rgb
shape (1, 1536)
noly show 10dim [0.02520592 0.05272802 0.05941689 0.05476999 0.13110509 0.13333975
0.29072759 0.16522023 0.25032277 0.36850457] ...
convert rgb image
shape (1, 1536)
noly show 10dim [0.02520592 0.05272802 0.05941689 0.05476999 0.13110509 0.13333975
0.29072759 0.16522023 0.25032277 0.36850457] ...
convert gray image
shape (1, 512)
noly show 10dim [0.10004389 0.20628179 0.17682694 0.16277722 0.10557428 0.14448622
0.29214159 0.11260066 0.16488087 0.28381876] ...
4.2 Gist特征余弦相似距離
下載好github中的代碼項目,運行python _test_get_cossim.py
5 LMgist的效果
