Description Usage Arguments Examples
This function randomizes the trajectories from an object of class Traj within the white area (intensity = 1) of a binary image.Trajectories are first randomly rotated around their point of origin and then their origin is randomly assigned to a xy coordinate with the mask area. Trajectory points that fall out of the mask are then pruned out.
1 | randomize(trajectory, mask)
|
trajectory |
An object of class Traj |
mask |
An object of class Image. The image should be a binary mask. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Upload mask and trajectories
data(cellmask)
data(trajectory)
## Randomize trajectories
randtraj <- randomize(trajectory, mask = cellmask)
## Plot trajectories
EBImage::display(cellmask, method = "raster")
## Overlay trajectories in black
ntraj = nlevels(trajectory["trajectory"])
for (i in 1:ntraj) {
traj_i <- subset(trajectory["data"], trajectory == i)
lines(traj_i$x, traj_i$y, type="l", col = "black")
}
## Overlay randomized trajectories in blue
nrandtraj = nlevels(randtraj["trajectory"])
for (i in 1:nrandtraj) {
traj_i <- subset(randtraj["data"], trajectory == i)
lines(traj_i$x, traj_i$y, type="l", col = "blue")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.