Проблема с размером памяти при обработке кадров данных из изображений - PullRequest
0 голосов
/ 01 апреля 2019

Я новичок в R, и мне нужно разработать инструмент для этого:

1-й Нарисуйте область интереса (ROI) из разностного изображения

2nd. Проанализируйте интенсивность пикселей в ROI, сформируйте множество изображений в формате «.pgm» (взятых с течением времени) и составьте таблицу со временем / ROI / интенсивностью

У меня проблемы со второй частью. Мой код хорошо работает для максимум 50 изображений. Существует проблема обработки размера массива фреймов данных для большего количества изображений. Проблема возникает, когда я соединяю интенсивность пикселей данных из n изображений и данные пикселей ROI (см. Obj seqlabs1 из кода)

У вас есть предложения по упрощению процесса обработки всех изображений?

Спасибо !!!

#Analysis .PGM images by the region of interest(ROI)
#Libraries required
library(imager)
library(magick)
library(dplyr) 
library(purrr)
library(reshape)
#select the folder that contains the images
setwd("...")
#make a list with the names of the files that contains a pattern
imfiles<-list.files("...",pattern = ".pgm")
# load all the images from the listl1
im<-map(imfiles,image_read)
#join all images in a sequence
seq<- image_join(im)
#transform seq to imager format
seqmgr<-magick2cimg(seq)
#transform the image to df
dfseqmgr<-as.data.frame(seqmgr)
#"labs" is an array that contains the info for one image about which 
#pixels are the ones selected as ROI. It cames from the 1st part of the 
#code not shown .I replicate it n times for n images that I have to 
#analyze in order to be able to mutate it witht he array from the sequence 
#data frame. 
#replicate n times the data frame with values selected ROI
seqlabs<-labs%>%slice(rep(row_number(),(nrow(dfseqmgr)/nrow(labs))))
#join data pixel intensity from n images and ROI data pixels data 
seqlabs1<- mutate(seqlabs,index=as.data.frame(seqmgr)$value)
#Add column with number of stacks (z)
seqlabs2<-cbind(seqlabs1,z=dfseqmgr[,3])
#group by columns with ROI pixels
roiset<- dplyr::group_by(seqlabs2,value,z) %>% 
dplyr::summarise(mx=mean(x),my=mean(y),signal=mean(index))
#remove x and y coordinates of the pixels from the ROI
drops<-c("mx","my")
roiset1<-roiset[ , !(names(roiset) %in% drops)]
#add colnames for ROI and time column
colnames(roiset1)<-c("ROI","time","signal")
#reorganize the data as time/ROI/signal
roiset2<-melt(roiset1, id = c('ROI', 'time'))
result<-cast(roiset2,time ~ ROI)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...