简单的图像显著性区域特征提取方法-----opencv实现LC,AC,FT
时间: 2023-10-06 14:12:25 浏览: 175
LC(Local Contrast)、AC(Adaptive Contrast)和FT(Frequency-Tuned)是三种常见的图像显著性区域特征提取方法。下面是它们的OpenCV实现方法:
LC特征提取:
```python
import cv2
def lc_feature(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
lc = cv2.addWeighted(gray, 2, blurred, -1, 0)
return lc
```
AC特征提取:
```python
import cv2
def ac_feature(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
ac = cv2.addWeighted(gray, 1.5, blurred, -0.5, 0)
return ac
```
FT特征提取:
```python
import cv2
import numpy as np
def ft_feature(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
dx = cv2.Sobel(blurred, cv2.CV_64F, 1, 0)
dy = cv2.Sobel(blurred, cv2.CV_64F, 0, 1)
gradient = cv2.magnitude(dx, dy)
gradient = np.uint8(gradient)
ft = cv2.addWeighted(gray, 0.5, gradient, 0.5, 0)
return ft
```
以上三个方法都是先将彩色图像转为灰度图像,然后使用高斯滤波进行模糊处理,最后得到特定的显著性区域特征图。其中,LC特征提取通过计算图像的局部对比度得到,AC特征提取通过计算图像的自适应对比度得到,FT特征提取通过计算图像的梯度幅值得到。
阅读全文