向一系列.jpg图像添加中心线

问题描述 投票:1回答:1

有人对程序或代码添加任何永久性的中心线或矩形添加到一系列.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 rmagick
1个回答
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")
}
© www.soinside.com 2019 - 2024. All rights reserved.