I have to count and differentiate viable cells from dead cells in an image. I tried to clean the image with the following code and RStudio crashes. Anytime I run the code, I am prompted to start a new session.
Has anyone encounter similar problem?
cols <- rainbow(3, alpha=0.3)[2] # Initialize the green color
pred <- ifelse(mask1, cols, "#00000000")
fixed.pred <- fillHull(mask1)
fixed.pred <- bwlabel(fixed.pred)
temp.rm <- names(which(table(fixed.pred)<2000))
fixed.pred <- rmObjects(fixed.pred, temp.rm)
fixed.pred2 <- ifelse(fixed.pred, cols, "#00000000")
squares.x <- c(4, 4, 4, 5, 4, 5)-1
squares.y <- c(2, 3, 6, 6, 7, 7)-1
mask2 <- matrix("#00000000", dim(pic1)[1], dim(pic1)[2])
for(i in 1:length(squares.x)){
mask2[(squares.y[i]*240+24):(squares.y[i]*240+240+24), (squares.x[i]*240+258):(squares.x[i]*240 + 240 + 258)] <- cols
}
disjoint.grid.x <- seq(258, 1698, by=240)/dim(pic1)[2]+1
disjoint.grid.y <- seq(24, 2184, by=240)/dim(pic1)[1]+1