0

I have multiple images in a folder (over 70,000 images) and I don't want to read in all of them.

I have written these scripts to filter out the files I need, there are roughly 5000 selective images I need. I filtered out the files through a CSV file which has filenames of the images in the rows.

install.packages("dplyr")
library(dplyr)

ClassifyLeison = read.csv('C:#The file path......)

Melanoma <- ClassifyLeison[1:2]
Melanoma <- filter(Melanoma, MEL == 1 )

Below is a the first 6 image files I need, there are 5000 image files that I need to read in (but I could only display the 6 rows, but there are more rows)

               image         MEL
1.             ISIC_0000002   1

2.             ISIC_0000004   1

3.             ISIC_0000013   1

4. ISIC_0000022_downsampled   1

5. ISIC_0000026_downsampled   1

6. ISIC_0000029_downsampled   1

Below I have written scripts which reads in all of the files in the folder, but I can't read in all of the files because of the memory constraints with R Studio, so for now I only need the selective files.

library(keras)
library(EBImage)
library(imager)

SkinImages <- "C:\\Users\\user\\Documents\\Final Year Proj\\DATA\\ISIC_2019_Training_Input"

SkinLeison <- list.files(path = SkinImages, pattern = "*.jpg", full.names = T)

 for (i in seq_along(SkinLeison)) {
      assign(paste("T_0_low_000", i, sep = "."),load.image(SkinLeison[i]))
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
A-Kay
  • 53
  • 5
  • Where are `readImage`, `resize`, and `array_reshape` defined? Please don't include `install.packages` in your sample code. Have you tried the [`magick`](https://cran.r-project.org/web/packages/magick/index.html) package? – r2evans Jan 20 '20 at 17:25
  • array_reshape and resize are apart of the EBImage package. The readImage function is used to read the different file types, i dont think im meant to declare them. Okay ill try not to include them next time sorry...... Let me check out the magik package i read about that breifly but i didnt really understand it – A-Kay Jan 21 '20 at 09:56
  • One point from this, A-Kay, is that questions on SO should be fairly *reproducible*. In this case, always list non-base packages (`library(EBImage)` along with `dplyr`), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and expected output. Because you are working on images, it is realistic to upload (via SO and it's tie with imgur) a couple of images directly to the question (which you *can* [edit](https://stackoverflow.com/posts/59828117/edit)). Refs: https://stackoverflow.com/questions/5963269 and https://stackoverflow.com/help/mcve, for starters. Thanks! – r2evans Jan 21 '20 at 14:44
  • Okay i understan, but i have copied all of the code i have written, ill try to rephrase the questions better next time thanks and sorry. – A-Kay Jan 22 '20 at 18:00
  • I understand, but while you've copied code, we do not have access to your images nor have an idea of what they look like. That's why I suggested that you can embed 2-3 images (or give good examples of what to use) with file names that match what you've provided in your `head(Melanoma)`. While it might be as easy as me grabbing a 1 byte gif and naming it `ISIC_0000000.jpg`, I don't know if that gif would have the properties your code expects/needs. Really, if all it needs is a small jpeg, then perhaps all you need to do is embed one or say "any jpeg will do". (What does "reshape" do for you?) – r2evans Jan 22 '20 at 18:11
  • Okay hold on i dont think i have phrased my question and description properly let me re-edit it sorry – A-Kay Jan 22 '20 at 18:19
  • 1
    Big confusion: what does your `Melanoma` subset have to do with `SkinLesion`? It is not clear to me how the two relate. BTW: I strongly discourage use of `assign`; if you're going to load "2 or more" of something and do the same thing to all of them, then something like `allimgs <- lapply(filelist, load.image)` and then `all_results <- lapply(allimgs, somefunc)` for doing reduction/reshaping/whatever. – r2evans Jan 22 '20 at 19:10
  • 1
    ahh i see, Melanoma and SkinLeison variables are from two different programs, I was meant to put the programs together when i figure out how to link the images to the data frame.... ohh okayy i seee ill try to amend that... – A-Kay Jan 22 '20 at 22:23

0 Answers0