I'm working to setup boundaries around 4 distinct regions of interest in an image - the image & data are in 0-1 normalized space, with four equally sized quadrants. It is easy to setup square boundaries:
df.all$ROI <- ifelse(df.all$x_pred_normalised > 0 & df.all$x_pred_normalised <= .5 &
df.all$y_pred_normalised > 0 & df.all$y_pred_normalised <= .5, c("lower_left"),
ifelse(df.all$x_pred_normalised > 0 & df.all$x_pred_normalised <= .5 &
df.all$y_pred_normalised > .5 & df.all$y_pred_normalised <= 1, c("upper_left"),
ifelse(df.all$x_pred_normalised > .5 & df.all$x_pred_normalised <= 1 &
df.all$y_pred_normalised > 0 & df.all$y_pred_normalised <= .5, c("lower_right"),
ifelse(df.all$x_pred_normalised > .5 & df.all$x_pred_normalised <= 1 &
df.all$y_pred_normalised > .5 & df.all$y_pred_normalised <= 1, c("upper_right"),
c("other")))))
However, I would like to setup a circular boundary (radius of .15 as an example) at the center of each quadrant (.25, .25; .25, .75; .75, .25; .75, .75) that provides the same output.
sample data:
x_pred_normalized <- rnorm(1000, mean=.5, sd=.5)
y_pred_normalized <- rnorm(1000, mean=.5, sd=.5)
df.all <- as.data.frame(cbind(x_pred_normalized, y_pred_normalized))
df.all$ROI_square <- ifelse(df.all$x_pred_normalised > 0 & df.all$x_pred_normalised <= .5 &
df.all$y_pred_normalised > 0 & df.all$y_pred_normalised <= .5, c("lower_left"),
ifelse(df.all$x_pred_normalised > 0 & df.all$x_pred_normalised <= .5 &
df.all$y_pred_normalised > .5 & df.all$y_pred_normalised <= 1, c("upper_left"),
ifelse(df.all$x_pred_normalised > .5 & df.all$x_pred_normalised <= 1 &
df.all$y_pred_normalised > 0 & df.all$y_pred_normalised <= .5, c("lower_right"),
ifelse(df.all$x_pred_normalised > .5 & df.all$x_pred_normalised <= 1 &
df.all$y_pred_normalised > .5 & df.all$y_pred_normalised <= 1, c("upper_right"),
c("other")))))
desired output:
x_pred_normalized y_pred_normalized ROI_square ROI_circle
.99 .99 upper_right other
.51 .51 upper_right other
.25 .25 lower_left lower_left