r - R 中的图像平滑

标签 r image-processing filtering smoothing

如何在 R 中平滑这张图片,以便只保留两个峰值?

如果这是一维数据,我会对其进行运行均值或拟合回归函数。但我没有找到有关在二维矩阵上应用这些方法的非常具体的信息。例如,我尝试使用 stats 包中的 filter()

我也考虑过克里金法,但这更多的是插值,是吗?

spectrogram

最佳答案

spatstat 包包含一个应用高斯模糊的函数 blur()。这在某种程度上使图像变得平滑,大部分噪声消失并且两个主峰清晰可辨。

效果如下图所示,相当显着,尤其是在3d图中。

effects of blurring

生成图片的代码是:

library(jpeg)
library(fields)
library(spatstat)

picture <- readJPEG("~/Downloads/spectrogram.png.jpeg")
picture2 <- as.matrix(blur(as.im(picture), sigma=6))

layout(matrix(c(1:4), nrow=2))
image.plot(picture, col=gray.colors(50), main="original image", asp=1)
image.plot(picture2, col=gray.colors(50), main="blurred with sigma = 6", asp=1)
drape.plot(1:nrow(picture), 1:ncol(picture), picture, border=NA, theta=0, phi=45, main="original spectrogram")
drape.plot(1:nrow(picture), 1:ncol(picture), picture2, border=NA, theta=0, phi=45, main="blurred with sigma = 6")

关于r - R 中的图像平滑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17022379/

相关文章:

matlab - MATLAB 教程中的 SIFT 实现

Python Image.open() 给出 'object has no attribute' 错误

css - 从事件日志 4720 中筛选详细信息

r - 在多个日期范围之间过滤

r - 使用 SendMailR 将电子邮件数据框作为电子邮件正文中的表格

r - 如何将函数应用于一系列数据表列而无需指定新列名?

python - 我如何在 python opencv GUI 中打印一些功能?

javascript - 没有子节点的对象数组的递归过滤

r - Rstudio 的 'find in files' 有 R 版本吗?

r - 使用R Shiny整合时间序列图和传单 map