if(interactive() && ants_available()) {
ants <- load_ants()
scale <- (0.1 + outer(
seq(0, 1, length.out = 256)^6,
seq(0, 1, length.out = 256)^2,
FUN = "+"
)) / 6
img = ants$image_read(ants$get_ants_data('r16')) * scale
corrected <- correct_intensity(img)
pal <- gray.colors(255, start = 0)
par(mfrow = c(1, 2), mar = c(0.1, 0.1, 2.1, 0.1),
bg = "black", fg = "white")
image(img[], asp = 1, axes = FALSE,
col = pal, ylim = c(1, 0),
main = "Original", col.main = "white")
image(corrected[], asp = 1, axes = FALSE,
col = pal, ylim = c(1, 0),
main = "Corrected", col.main = "white")
}
Run the code above in your browser using DataLab