Replies: 2 comments 2 replies
-
A combination of row and column profiles (https://www.libvips.org/API/current/libvips-arithmetic.html#vips-profile) may give you enough information to deduce it. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Ooop! Sorry, this dropped off my to-do list. As well as @andreas-kupries excellent profile suggestion, you can threshold and search a low-res image. For example (untested!): # higher levels get smaller images from the pyramid -- this one is
# 2875x2057, 16x smaller, so we can search quickly
image = pyvips.Image.new_from_file("CMU-1.svs", level=2)
# make a one-band mask image, with TRUE for pixels over 240
# this should detect a white background
# blur first, so we only detect large areas above 240
mask = image.gaussblur(20) > 240
# label connected regions in the mask image
# each connected block will be given a unique index
# the background will be label 1, each black blob will
# be 2, 3, .. etc.
index = mask.labelregions()
# make an xy image, so each pixel contains its own coordinate
xy = pyvips.Image.xyz(width=mask.width, height=mask.height)
# now histogram the xy image, but use the index image to pick the
# histogram bins
# don't sum the xy, instead find the min of each bin
lefttop = xy.hist_find_indexed(index, combine="min")
# now lefttop is an array where pixel (1, 0) is two ints for left/top of blob 1,
# pixel (2, 0) is the position of blob 1, etc.
# scale up by x16 to get coordinates in the WSI image You can use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to see if it is possible to do a poor mans tissue detection. Trying to see if there is a method or methods to determine the first non blank pixel of a whole slide image.
Also libvips is awesome!
Beta Was this translation helpful? Give feedback.
All reactions