[scikit-image] filtering image entry values based on a threshold
Stefan van der Walt
stefanv at berkeley.edu
Tue Nov 22 20:30:02 EST 2016
On Mon, Nov 21, 2016, at 19:49, wine lover wrote:
> In one code segment, I once saw an approach of filtering image values
> as follows using cv2. In Scikit image, if I want to realize the same
> functionality, how to do it?
>
> import cv2 img = cv2.threshold(img, 0.5, 1.,
> cv2.THRESH_BINARY)[1].astype(np.uint8
How about:
from skimage import img_as_float, img_as_ubyte
img = img_as_float(img)
img_thresholded = img_as_ubyte(img < 0.5)
Stéfan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20161122/cc26dab3/attachment.html>
More information about the scikit-image
mailing list