splitChannels.Rd
split a multichannel antsImage into a list of scalar antsImages
splitChannels(image)
list of scalar antsImages
r <- floor(seq(1:(64 * 64)) / (64 * 64) * 255)
dim(r) <- c(64, 64)
r <- as.antsImage(r)
g <- r * 0
b <- r * 0
testthat::expect_error(splitChannels(r))
rgbImage <- mergeChannels(list(r, g, b))
imgList <- splitChannels(rgbImage)
testthat::expect_length(imgList, 3)
sapply(imgList, function(x) {
testthat::expect_s4_class(x, class = "antsImage")
})
#> [[1]]
#> antsImage
#> Pixel Type : float
#> Components Per Pixel: 1
#> Dimensions : 64x64
#> Voxel Spacing : 1x1
#> Origin : 0 0
#> Direction : 1 0 0 1
#>
#>
#> [[2]]
#> antsImage
#> Pixel Type : float
#> Components Per Pixel: 1
#> Dimensions : 64x64
#> Voxel Spacing : 1x1
#> Origin : 0 0
#> Direction : 1 0 0 1
#>
#>
#> [[3]]
#> antsImage
#> Pixel Type : float
#> Components Per Pixel: 1
#> Dimensions : 64x64
#> Voxel Spacing : 1x1
#> Origin : 0 0
#> Direction : 1 0 0 1
#>
#>
testthat::expect_error(splitChannels("hey"))