-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
floodFill in place #21
Comments
Thanks for your feedback! Your performance issues could be probably addressed by allowing the argument |
That's close. For my application I would need the |
- allow multiple points and colors to be passed to `floodFill` (#21)
I've enabled filling of multiple objects with possibly different labels/colors across the whole image stack, feel free to test. For details and examples see the documentation I'm looking forward to hearing from you whether this helped to address the bottleneck. If you feel up to it, it would be really great if you could perform some before/after benchmark and provide the results. |
Not working for me because of #23 :-( |
Figured it out. The parameters for For an 1868 x 1400 image, filling 417 regions using the new method is about 500 times faster than the old method - 12 milliseconds vs 6+ seconds!! > library(microbenchmark)
> dim(image)
[1] 1868 1400
> length(nuc_locations)
[1] 417
> microbenchmark(EBImage::floodFill(image, list(nuc_locations),
+ list(as.list(cell_ids))), times=10)
Unit: milliseconds
expr min lq
EBImage::floodFill(image, list(nuc_locations), list(as.list(cell_ids))) 9.122525 9.279515
mean median uq max neval
11.87673 9.622194 11.1117 21.07505 10
>
> microbenchmark({y=image
+ for (i in seq_len(length(nuc_locations)))
+ y = EBImage::floodFill(y, nuc_locations[i], cell_ids[i])},
+ times=10)
Unit: seconds
expr
{ y = image for (i in seq_len(length(nuc_locations))) y = EBImage::floodFill(y, nuc_locations[i], cell_ids[i]) }
min lq mean median uq max neval
6.230726 6.255482 6.350389 6.341448 6.431667 6.524966 10 |
- allow multiple points and colors to be passed to `floodFill` (#21) From: aoles <[email protected]> git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/EBImage@131904 bc3139a8-67e5-0310-9ffc-ced21a209358
Thanks for getting back to me with the benchmark results. Indeed, the performance boost is impressive! Also, thank you for your feedback on the interface to
The following example illustrates the different but equivalent ways of specifying the starting points. library(EBImage)
x = readImage(system.file("images", "shapes.png", package="EBImage"))
y = combine(x, x)
p1 = c(67, 146)
p2 = c(466, 72)
p3 = c(155, 66)
# points provided as a vector of coordinates
pts = c(p1, p2)
refx = floodFill(x, pts, 0.5)
refy = floodFill(y, list(pts, p3), 0.5)
# points provided as a list of coordinates
pts = list(p1, p2)
identical(refx, floodFill(x, pts, 0.5))
## [1] TRUE
identical(refy, floodFill(y, list(pts, p3), 0.5))
## [1] TRUE
# points provided in a matrix
pts = rbind(p1, p2)
identical(refx, floodFill(x, pts, 0.5))
## [1] TRUE
identical(refy, floodFill(y, list(pts, p3), 0.5))
## [1] TRUE
# points provided as a data frame
pts = data.frame(pts)
identical(refx, floodFill(x, pts, 0.5))
## [1] TRUE
identical(refy, floodFill(y, list(pts, p3), 0.5))
## [1] TRUE |
Thanks for the change! You might want to include the code in your comment above as either example code for |
- allow multiple points and colors to be passed to `floodFill` (#21) From: aoles <[email protected]> git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/EBImage@131904 bc3139a8-67e5-0310-9ffc-ced21a209358
Would it be possible to add a version of
floodFill
that performs the operation in place?I have images roughly 1500x1000 to 1800x1400 with hundreds of regions I want to fill with different values. Using
EBImage::floodFill
, the runtime seems to be dominated by the GC as each fill operation allocates a new copy of the image.Would it be possible make a version of
floodFill
that copies the source image only if there are multiple references to it, otherwise modifying it in place?The text was updated successfully, but these errors were encountered: