本篇博文分享一篇寻找图像中灯光亮点(图像中最亮点)的教程,例如,检测图像中五个灯光的亮点并标记,项目效果如下所示:
第1步:导入并打开原图像,实现代码如下所示:
# import the necessary packages
from imutils import contours
from skimage import measure
import numpy as np
import argparse
import imutils
import cv2
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="path to the image file")
args = vars(ap.parse_args())
第2步:开始检测图像中最亮的区域,首先需要从磁盘加载图像,然后将其转换为灰度图并进行平滑滤波,以减少高频噪声,实现代码如下所示:
#load the image, convert it to grayscale, and blur it
image = cv2.imread(args["image"])