scikit-image

How to Correctly mask 3D Array with numpy

蹲街弑〆低调 提交于 2020-08-18 17:55:39
问题 I'm trying to mask a 3D array (RGB image) with numpy. However, my current approach is reshaping the masked array (output below). I have tried to follow the approach described on the SciKit-Image crash course. Crash Course I have looked in the Stackoverflow and a similar question has been asked, but with no accepted answer (similar question here) What is the best way to accomplish masking like this? Here is my attempt: # create some random numbers to fill array tmp = np.random.random((10, 10))

skimage.io.imread Versus cv2.imread

半城伤御伤魂 提交于 2020-08-08 06:18:19
问题 I am using and familiar with cv2 , today I was giving a try with skimage . I was trying to read an image using skimage and cv2 . It seems that they both read the image perfectly. But when I plot histograms of the image but read through different libraries ( skimage and cv2 ), the histogram shows a significant difference. Would anyone help me by explaining the difference between the histograms? My code: import cv2 import skimage.io as sk import numpy as np import matplotlib.pyplot as plt path

bins must increase monotonically

℡╲_俬逩灬. 提交于 2020-08-02 07:06:28
问题 I just want to draw Matplotlib histograms from skimage.exposure but I get a ValueError: bins must increase monotonically. The original image comes from here and here my code: from skimage import io, exposure import matplotlib.pyplot as plt img = io.imread('img/coins_black_small.jpg', as_grey=True) hist,bins=exposure.histogram(img) plt.hist(bins,hist) ValueError: bins must increase monotonically. But the same error arises when I sort the bins values: import numpy as np sorted_bins = np.sort

How can I read an image from an Internet URL in Python cv2, scikit image and mahotas?

生来就可爱ヽ(ⅴ<●) 提交于 2020-08-02 05:39:25
问题 How can I read an image from an Internet URL in Python cv2? This Stack Overflow answer, import cv2.cv as cv import urllib2 from cStringIO import StringIO import PIL.Image as pil url="some_url" img_file = urllib2.urlopen(url) im = StringIO(img_file.read()) is not good because Python reported to me: TypeError: object.__new__(cStringIO.StringI) is not safe, use cStringIO.StringI.__new__ 回答1: Since a cv2 image is not a string (save a Unicode one, yucc), but a NumPy array, - use cv2 and NumPy to

Problem installing scikit-image probably due to blosc

回眸只為那壹抹淺笑 提交于 2020-05-28 14:18:54
问题 Hi I am trying to install scikit image in a virtual environment on ubuntu 18.04. It fails when it tries to install imagecodecs, I tried to install imagecodecs separately but it gives the same error which is something due to blosc. I installed blosc separately but somehow this still fails. /usr/include/python3.6m/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] #warning "Using

Extract polygon coordinates from image (map)

纵然是瞬间 提交于 2020-05-17 05:49:06
问题 I have the following map: I want to extract the polygon coordinates (pixls), I am using the following code snipt, but the inteverted labeled image is all 0's (False): import numpy as np from skimage import io, measure, morphology from skimage.io import imsave, imread img = io.imread('map.png', as_gray=True) imsave("test.png", img) img = morphology.binary_dilation(img, selem=np.ones((5,5))) img_inverted = np.invert(img) img_inverted_labeled = measure.label(img_inverted) n_lbls = np.unique(img

scikit-image saves binary image as completely black image

蓝咒 提交于 2020-05-15 04:12:30
问题 So, I am trying to get binary image with scikit-image and save it on disk with the following code: gray = color.rgb2gray(img) thresh = filters.threshold_otsu(gray) binary = gray >= thresh io.imsave("./testout/" + img_name, binary) When I do io.imshow(binary), I get what I expected. But the imsave() return to me completely black image, as if it turn both True and False values into (0,0,0) in rgb or something. So what is the right way to do it? 回答1: from skimage import img_as_uint # ... io

scikit-image saves binary image as completely black image

心已入冬 提交于 2020-05-15 04:09:08
问题 So, I am trying to get binary image with scikit-image and save it on disk with the following code: gray = color.rgb2gray(img) thresh = filters.threshold_otsu(gray) binary = gray >= thresh io.imsave("./testout/" + img_name, binary) When I do io.imshow(binary), I get what I expected. But the imsave() return to me completely black image, as if it turn both True and False values into (0,0,0) in rgb or something. So what is the right way to do it? 回答1: from skimage import img_as_uint # ... io