检测灰度图像中黑色区域的存在 [英] Detecting the presence of a black areas in a grayscale image

查看:346
本文介绍了检测灰度图像中黑色区域的存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是一个模糊的目标,因此我没有相同的可复制代码。

My objective is a vague one, and as such I don't have any reproducible code for the same.

我想建立一个训练网络某些类型的灰度图像可以检测到超出特定灰度强度阈值的区域。

I want to develop a network that I train with certain types of grey scale images that will detect the areas which are above a certain grayscale intensity threshold.

我该如何进一步进行?我需要神经网络吗?

How should I proceed further with this? Do I need a neural network for this?

下面是一些示例图像。最左边的是它的外观,中间的是发现有一些黑线(不是完全是黑色的,但在灰度强度的某个阈值之上),而最右端的是

Below are some sample images. The one on the extreme left is what it should look like, the one in the middle is when it finds out that there are some black lines (not exactly black, but above some threshold of a grayscale intensity) and the one on the extreme right is what I expect the output of my code to be.

PS这一点在检测CT扫描中的裂缝时特别有用,这些裂缝在其中显示为深黑色斑点/线条其他灰度背景

PS This is particularly of interest when detecting cracks in CT scans, which show up as dark black blobs/lines among the other grayscale background

推荐答案

这很简单,您绝对不需要神经网络来解决这个问题。如果您正在处理灰度图像并且知道您感兴趣的强度阈值(例如,允许的强度值最大为3),则只需执行简单的阈值操作即可识别黑色区域。

This is very trivial and you will definitely not need a neural network to solve this. If you are working with grayscale images and know the intensity threshold you are interested in (e.g you allow an intensity value up to 3) you can just do a simple threshold operation to identify the black regions.

这可能也可以在您的ct扫描应用程序上使用,前提是这些裂缝的强度总是很低。

This would probably also work on your ct scan application, presupposed these "cracks" are always of very low intensity.

例如对于在示例图像中应用了裂缝的ct图像,将这些裂缝阈值设置得很好(您只会得到一些背景噪声/伪像)。请参见以下OpenCV片段:

E.g. for a ct-image where I applied your "cracks" in your example image, threshold these cracks would work pretty well (you only get some background noise/artifacts). See the following OpenCV snipped:

import numpy as np
import cv2

# Load an color image in grayscale
img = cv2.imread('chest-ct-lungs.jpg',0)
ret,thresh = cv2.threshold(img,3,255,cv2.THRESH_BINARY)
cv2.imwrite('output.png',thresh)

输入:

原始图片来源:www.radiologyinfo .org

original image source: www.radiologyinfo.org

输出:

如您所见,这实际上只是三行代码,所以不要总是假设您必须使用神经网络进行所有操作,有时最好只解决图片问题-处理问题的老式方式。尤其是如果问题很简单。

As you see this is literally just 3 lines of code, don't always assume you have to use neural networks for everything, sometimes its best to just solve a image-processing problem the "old fashioned way". Especially if the problem is a trivial one.

这篇关于检测灰度图像中黑色区域的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆