Praveen Chougale
Praveen Chougale

Reputation: 383

How to get all the values of the matrix in a single row?

I have 40 images of size 480*640 (jpeg IMAGES),For each images I need to put the whole matrix in a single row...so for 40 images I need 40 rows of observations.

filenames <- list.files("C:/Users/Desktop/PatternRecognition/texture/T1", 
pattern = "*.jpg", full.names = TRUE)
result={}
for (i in 1:length(filenames)){
 x <- readJPEG(filenames[i])
 y <- getChannels(x)
 y <- as.vector(y)
 result <- rbind(result,y)
}

x=matrix(x)
x

In The above code getChannels is not working.

Upvotes: 0

Views: 304

Answers (1)

cirofdo
cirofdo

Reputation: 1074

You didn't give a reproducible example, neither your output, but the idea is to use as.vector(t(DATA_FRAME)) to put a df in one row.

So I guess your code would be:

for (i in 1:length(filenames)){
  x <- readJPEG(filenames[i])
  y <- as.vector(t(y))

  result <- rbind(result,y)
}

Upvotes: 0

Related Questions