【问题标题】:the image processing areas to segment the regions based on their corresponding level of brightness图像处理区域根据相应的亮度级别对区域进行分割
【发布时间】:2020-01-06 17:23:37
【问题描述】:

对于下面显示的图像,存在不同亮度级别的区域。例如,我用红色圆圈标记了两个区域,即 3 和 4;并用箭头指向两个小区域,即1和2。有哪些图像处理算法可以根据各自的亮度水平分割区域,我也想计算这些不同区域的面积。

【问题讨论】:

  • 到目前为止你尝试了什么?
  • 您可以添加没有红色图纸的原始图像吗?一种做法是进行高斯模糊、阈值、形态学运算,然后进行轮廓滤波

标签: opencv image-processing computer-vision


【解决方案1】:

您只能在图像区域上使用 Otsu 阈值。 首先,您可以通过阈值仅获得图像的前景(没有黑色背景)。然后您可以使用 Otsu 算法计算非 0 值的阈值。然后用这个值对图像进行阈值处理。

src = cv.imread(image_path)

#convert to gray scale
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY) 

#thresholding to find only white region of image, without black backgorund
ret3, th3 = cv.threshold(gray, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)

#erosion to delet some noises
cv.erode(th3, np.ones((5, 5), np.uint8), 1)

#get all values from image that are not equal 0 (are not background)
tempThresImg = gray[th3 != 0]

#get threshold value only for not black pixels
threshold, temp = cv.threshold(tempThresImg, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)  # using otsu threshold

#use threshold value on whole image
ret, thresh = cv.threshold(gray, threshold, 255, cv.THRESH_BINARY)

我的结果(带有你的箭头):

阈值化后获得前景:

结果:

您可以根据算法检测到的过多或过少来更改阈值以获得结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-18
    • 1970-01-01
    • 2016-10-08
    • 2011-11-24
    • 1970-01-01
    • 2016-05-13
    相关资源
    最近更新 更多