如何计算“绿点”的数量?在图像中?

发布于 2024-10-03 03:00:46 字数 115 浏览 9 评论 0原文

你好 我有一堆图像。让我们假设它们都具有相同的大小。 图像有黑色背景和一些准圆形绿点 代表荧光。我必须计算金额(百分比) 每个图像的荧光。即绿点的面积。

知道如何做到这一点,例如在 Java 中吗?

Hi
I have a bunch of images. Let's assume all of them of the same size.
The images have a black background and some quasi round green spots
which represent fluorescence. I have to calculate the amount (in percentage)
of fluorescence of each image. I.e. the area of green spots.

Any idea how to do this, for example in Java?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酷炫老祖宗 2024-10-10 03:00:46

这是图像处理中的标准问题,称为图像分割。您将能够找到大量有关它的信息。

特别是,这是显微图像处理中的常见问题,而这正是您正在做的事情。我认为 ImageJ 中可能有预装操作来执行此操作;如果没有,这将是 ImageJ 中的一个相当简单的宏,并且由于 ImageJ 是在 java 中,因此如果您愿意,您可以使用 ImageJ 的库编写 java 代码。

我建议您采用一种方法:

  1. 预处理图像以清理它 - 通过减去中值滤波器或邻域大于细胞的高斯卷积来减去背景,或滚球算法(在 ImageJ 源中查找)或类似的东西,也许随后进行少量模糊(例如,具有 3x3 邻域的中值滤波器)以消除斑点。
  2. 计算图像的直方图
  3. 在直方图中搜索两个峰值,一个对应于黑色像素,一个对应于绿色
  4. 使用两个峰值的值作为两簇 K 均值(我想是 2 均值!)​​分割

的 种子在执行 K 均值步骤时,您可以从直方图中选择一个阈值(例如,查找两个峰值之间的山谷),然后对其进行分段。或者使用某种自适应分割(例如,将像素与其邻域的中值进行比较),但这需要一些调整。

This is a standard problem in image processing, and is called image segmentation. You will be able to find vast quantities of information about it.

In particular, this is a common problem in microscopic image processing, which is what you're doing. I think there might be canned operations to do it in ImageJ; if not, it would be a fairly simple macro in ImageJ, and since ImageJ is in java, you could write java code using ImageJ's libraries if you like.

I would suggest an approach in which you:

  1. Preprocess the image to clean it up - background subtraction by subtracting a median filter or a gaussian convolution with a neighbourhood larger than your cells, or the rolling ball algorithm (look in the ImageJ source for that), or something similar, perhaps followed by a small amount of blurring (say, a median filter with a 3x3 neighbourhood) to remove speckles.
  2. Calculate a histogram of the image
  3. Search for two peaks in the histogram, one corresponding to black pixels, one to green
  4. Use the values of the two peaks to seed a two-cluster K-means (2-means, i suppose!) segmentation

Instead of doing the K-means step, you could just pick a threshold from the histogram (look for the valley between the two peaks, say), and segment on that. Or use some sort of adaptive segmentation (comparing pixels to the median in their neighbourhood, say), but that will require some tuning.

驱逐舰岛风号 2024-10-10 03:00:46

一些想法:

  • 您可以进行边缘检测,然后执行 霍夫圆变换。如果您已经知道圆的半径,这应该很有效。
  • 比较颜色时,您可以使用更适合模糊比较的颜色空间。例如 HSV 颜色空间
  • 由于您的背景是黑色,因此计算亮度和应用阈值。然后计算高于阈值的像素。
  • 在发布计算机视觉问题时,查看输入材料总是有帮助的。

A few thoughts:

  • You could do an edge detection and then perform a hough circle transform. This should work well if you already know the radius of the circles.
  • When comparing colors you could use a color space that is better suited for fuzzy comparison. For example the HSV color space
  • Since your background is black, it is probably easiest to calculate the luminance and apply a threshold. Then count the pixels above the threshold.
  • When posting a computer-vision problem, it is always helpful to see the input material.
从此见与不见 2024-10-10 03:00:46

我现在没有时间详细介绍,但我可以为您概述该过程:

循环遍历图像

  1. 将每个图像加载到 BufferedImage 中(http://download.oracle.com/javase/6/docs/api /java/awt/image/BufferedImage.html)
  2. 循环遍历每个像素 (x,y) 并获取该像素的颜色 (int getRGB(int x, int y))
  3. 将此颜色与参考颜色进行比较(例如 0x7FFF00 表示绿色) )或定义一系列可接受的颜色。
  4. 如果匹配,则增加一个计数器
  5. 循环运行后,将计数器与像素总数进行比较,瞧,您就得到了百分比

(注意:这可能是一种非常幼稚的方法,并且可以进行大量优化,但这应该是一个开始)

I don't have the time to go into detail now, but I can outline the process for you:

Loop through the images

  1. Load each image into a BufferedImage (http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html)
  2. Loop through each pixel (x,y) and get the colour for that pixel (int getRGB(int x, int y))
  3. Compare this colour to your reference colour (e.g. 0x7FFF00 for green) or define a range of accepted colours.
  4. If it matches, increment a counter
  5. After the loop ran, compare the counter to the total number of pixels and et voila, you got your percentage

(NB: this is probably a very naive way to do it and there is loads of optimisation possible, but it should be a start)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文