2019/04/10 10:10

# 1什么是Gist特征

(1) 一种宏观意义的场景特征描述        (2) 只识别“大街上有一些行人”这个场景，无需知道图像中在那些位置有多少人，或者有其他什么对象。        (3) Gist特征向量可以一定程度表征这种宏观场景特征 GIST定义下列五种对空间包络的描述方法

# 2 Gist的实现--LMgist

% 读取图片

% 设置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 (扩边+去伪影)

${\bf{matlog}} = \log \left( {{\bf{mat}} + 1} \right)$ ${\bf{matPad}} = {\mathop{\rm sympading}\nolimits} \left( {{\bf{matlog}},\left[ {5,5,5,5} \right]} \right)$

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200208104955368-1473334664.jpg"><br> 图1 sympading操作 </center>

### 3.2.2 Filter (构造滤波器)

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200208105012668-1585339058.jpg"><br> </center>

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200208105028753-319814328.jpg"><br> </center>

${\bf{matGf}} = {\mathop{\rm FFTSHITF}\nolimits} \left( {\exp \left( { - \frac{{{\bf{matF}}{{\bf{x}}^2} + {\bf{matF}}{{\bf{y}}^2}}}{{{{\left( {\frac{{fc}}{{\sqrt {\log \left( 2 \right)} }}} \right)}^2}}}} \right)} \right)$

### 3.2.3 Whitening (白化)

${\bf{matRes}} = {\bf{matPad}} - {\mathop{\rm Real}\nolimits} \left( {{\mathop{\rm IFFT}\nolimits} \left( {{\mathop{\rm FFT}\nolimits} \left( {{\bf{matPad}}} \right){\bf{matGf}}} \right)} \right)$

### 3.2.4 Local contrast normalization (局部对比度归一化）

${\bf{matLocal}} = \sqrt {\left| {{\mathop{\rm IFFT}\nolimits} \left( {{\mathop{\rm FFT}\nolimits} \left( {{\bf{matRes}} \cdot {\bf{matRes}}} \right) \cdot {\bf{matGf}}} \right)} \right|}$

${\bf{matRes}} = \frac{{{\bf{matRes}}}}{{0.2 + {\bf{matLocal}}}}$

### 3.2.5 Local contrast normalization (局部对比度归一化）

${\bf{matPrefilt = matRes}}\left[ {5:64 + 5,5:64 + 5} \right]$

## 3.3 计算图片的Gist向量

${\bf{matPad}} = {\mathop{\rm sympading}\nolimits} \left( {{\bf{matPrefilt}},\left[ {32,32,32,32} \right]} \right)$

### 3.3.2 FFT

${\bf{matLocal}} = {\mathop{\rm FFT}\nolimits} \left( {{\bf{matPad}}} \right)$

### 3.3.3 遍历每个Gabor核函数

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200208105052721-807272724.jpg"><br> </center>

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200208105112432-653713443.jpg"><br> 图2 全局Gist特征的提取 </center>

# 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()

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()


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特征余弦相似距离

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200213164528658-1951493200.jpg"><br> </center>

# 5 LMgist的效果

<center> <img src="https://img2018.cnblogs.com/blog/1180694/202002/1180694-20200208105155266-1856892565.jpg"><br> </center>

0
0 收藏

0 评论
0 收藏
0