Unfortunately one does not know the condition in advance. I'd better post the case.
for(i in seq_along(images)[-1]){
seg<-segment(images[i], display=FALSE, filter = myfilter)
quartz()
regi<-registration(images[i], coordinate=coord[i], display=TRUE, filter = myfilter)
dev.copy(pdf, paste0(tools::file_path_sans_ext(basename(images[i])), 'regi.pdf'))
}
I need the loop to stop before saving regi as pdf (I skipped the following commands of the loop for simplicity), because regi itself is likely to be modified with
regi<-change.corrpoints()
before running again
regi<-registration(images[i], coordinate=coord[i], display=TRUE, filter = myfilter, correspondance = regi)
Only now one would need to save produce a pdf file.
Thanks for replying!