【问题标题】:Add a centerline to a series of .jpg images为一系列 .jpg 图像添加中心线
【发布时间】:2020-03-13 09:22:58
【问题描述】:

是否有人对在一系列 .jpg 图像中添加永久虚线中心线或矩形的程序或代码有任何建议。使用 ImageJ 或 IrfanView 或 R

编辑。 在 R 中使用 ImageMagick 包的建议很棒,一张图片使用下面的代码效果很好。但目前尚不清楚如何对文件夹中的多个图像进行批处理。

> test <- image_read('F:/11_Cairns/Data/2_Barron_Richter_Thomatis/FRAMES/2017_4_665_20171206083500_6.jpg')
> img <- image_draw(test)
> rect(600,0, 680, 720, border = "yellow", lty = "dashed", lwd = 2)

【问题讨论】:

标签: r image-processing imagemagick jpeg


【解决方案1】:

以下将起作用...

# Return a vector of all file paths that end with "jpg":
files <- list.files("F:/11_Cairns/Data/2_Barron_Richter_Thomatis/FRAMES/", pattern = "jpg$", ignore.case = TRUE, full.names = TRUE)

# Loop over each image and add a dashed yellow lines.
for(i in files){
    test <- image_read(i)
    img <- image_draw(test)
    rect(600, 0, 680, 720, border = "yellow", lty = "dashed", lwd = 2)
    dev.off()
    # And if you want to save it, but not overwrite the original file:
    file_loc <- gsub("\\.jpg", "_new.jpg", i, ignore.case = TRUE)
    image_write(img, path = file_loc, format = "jpg")
}

【讨论】:

  • 我认为您可以包含一行来保存生成的图像。我敢打赌,如果约翰正在寻找处理一批图像,他希望保存这些图像。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-15
相关资源
最近更新 更多