【问题标题】:How can I create a condition to delete the files?如何创建删除文件的条件?
【发布时间】:2021-01-08 13:00:57
【问题描述】:

我正在尝试从我的数据文件夹中获取每个图像的像素方差,并在其低于 800 时将其删除。我曾尝试删除数据框中的行或列,但这不适用于列表。 有人可以帮我解决我在这里做错了什么吗?

library(magick)
library(tidyverse)

Folder <- "......."
images <- list.files(path = Folder, pattern = "*.JPG", full.names = TRUE)

images <- map(images, image_read)




images[$image_variance <= 800.0000,]

【问题讨论】:

    标签: r rmagick


    【解决方案1】:

    您可以使用purrr::keep

    result <- purrr::keep(images, ~image_variance(.x) > 800)
    

    或以 R Filter 为基础,仅保留方差大于 800 的图像。

    result <- Filter(function(x) image_variance(x) > 800, images)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 2012-01-29
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 2012-03-12
      • 1970-01-01
      相关资源
      最近更新 更多