Problem solved! - List element set as parameter to

2019-08-16 15:06发布

I've loaded images with load.image() function to a list, and when I wanted to add the index from the list as the parameter to a function called grayscale(), I've got the following error:

Error in if (spectrum(im) == 1) { : argument is of length zero

Could someone please help me in this problem?

filenames <- list.files("~/Downloads/project", pattern="*.jpg", full.names = T)
if(!is.null(filenames)){
  for(idx in filenames) {
    im <- idx
    print(im)
    load.image(im)

    im1=grayscale(im);

Problem is solved now:

load.image(im) should be saved to a variable, and this one should be added as the parameter for the grayscale() function

filenames <- list.files("~/Downloads/project", pattern="*.jpg", full.names = T)
if(!is.null(filenames)){
  for(idx in filenames) {
    im <- idx
    print(im)
    loaded_image <- load.image(im)

    im1=grayscale(loaded_image);

0条回答
登录 后发表回答