将图像中的单行或平均线/边缘组合成单线

发布于 2025-01-20 00:50:49 字数 1325 浏览 3 评论 0 原文

我使用Magick从R中的Magick中提取了一系列图像。 单个结果如下:

“单个边缘”

我要做的是将类似的行组合到一条线中。 例如,前两行在它们所包含的区域中相当相似​​,并且可以在两者之间进行类似“平均值”之类的东西。 第三和第四张图像之间也有一些明显的相似之处。 我有数百个。

如果我只是将所有图像添加在一起(只需求和代表它们的矩阵),我会得到很多混乱:

“组合边缘”

,但我仍然可以分辨一些区域。

理想情况下,我正在寻找与R的解决方案。

编辑:

目标。因此,我在这里拥有的是一些基于某些人群的LAT和LON的空间模型的结果。我有数百个二进制功能,大约90个位置。我为每个功能安装了一个2维的GP,并计算了覆盖所有点的正方形区域的点网格的预测。目的是找到分开分组的一般分界线。 这就是原始预测的样子:

”在此处输入图像描述

编辑2:

以下是一些RDS格式的矩阵:

原始GP预测:

提取的边缘:

I have extracted from a series of images their edges using magick in R.
Individual results look as follows:

individual edges

What I am trying to do, is combine similar lines, into a single line.
For example, the first two lines are fairly similar in the region that they encompase, and one could take something like 'the average' between both.
There are also some clear similarities between the third and fourth image.
I have hundreds of these.

If I just add all images together (simply summing the matrices that represent them), I get a lot of clutter:

combined edges

But I can still make out some regions.

Ideally, I am looking for a solution with R.

Edit:

Goal. So, what I have here are the results from some spatial models based on the lat and lon of some populations. I have hundreds of binary features for some 90 places. I fitted a 2 dimensional GP for each feature, and the calculated the predictions for a grid of points covering a square area encompassing all points. The goal is to find general dividing lines that separate groups of points.
This is what the original predictions look like:

enter image description here

Edit 2:

Here are some matrices in rds format:

Original GP predictions:
https://drive.google.com/file/d/1785BBcGKZ2TMLBKbcXKLlcrLue_VJl0O/view?usp=sharing

Extracted edges: https://drive.google.com/file/d/1OUQy6rsP5Mxmf18TXwvoZ8O7MS7Hom3t/view?usp=sharing

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

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

发布评论

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

评论(1

南城旧梦 2025-01-27 00:50:49

我认为这完全取决于你如何定义混乱以及你期望看到什么。

让我们制作一些具有 2 个“颜色”的“图像”矩阵的非常小的示例

m1 <- matrix(c(1, 1, 1, 0, 0, 0, 1, 0, 1), 3, 3)
m2 <- t(apply(m1, 2, rev))
m3 <- t(apply(m2, 2, rev))

让我们看看它们是什么样子

image(m1)

< img src="https://i.sstatic.net/dwVot.png" alt="在此处输入图像描述">

image(m2)

在此处输入图像描述

image(m3)

在此输入图片描述

然后就是您必须对您定义的混乱与否进行调用,但让我们将矩阵中的值相加

all <- m1+m2+m3

image(all)

在此处输入图像描述

我们现在看到 3 种颜色,所有图像(大多数图像)中存在最暗的颜色,最亮的颜色没有颜色图像数(最少图像)。

要消除噪声,需要将低于某个阈值的矩阵值设置为零以消除混乱,如果您愿意,可以将其(基于阈值)转换回二进制矩阵

It is I think all on how you define clutter and what you expect to see.

Lets make some very small example of "image" matrixes having 2 "colors"

m1 <- matrix(c(1, 1, 1, 0, 0, 0, 1, 0, 1), 3, 3)
m2 <- t(apply(m1, 2, rev))
m3 <- t(apply(m2, 2, rev))

Let us see how they look like

image(m1)

enter image description here

image(m2)

enter image description here

image(m3)

enter image description here

Then it is the call you have to make on what you define clutter or not, but let us add up the values in the matrices

all <- m1+m2+m3

image(all)

enter image description here

We see now 3 colors, darkest was present in all images (most images) and lightest color in none of the images (least images).

To remove noise it would be a matter of setting matrix values below a certain threshold to zero to remove the clutter and if you prefer you could convert it (based on thresholds) back to a binary matrix

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