scikit-image

Extracting the elements matching the filter

爱⌒轻易说出口 提交于 2019-12-08 15:26:35
问题 I want to filter the indices whose footprint (3,3) consists of 1s. import numpy as np data = np.array([[1, 1 , 0 , 0 , 0 , 0 , 1 , 0], [1, 1 , 1 , 0 , 0 , 1 , 1 , 0], [1, 1 , 1 , 1 , 1 , 0 , 0 , 0], [0, 0 , 1 , 1 , 1 , 0 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 1], [1, 1 , 0 , 0 , 0 , 1 , 1 , 1], [1, 1 , 0 , 0 , 0 , 1 , 1 , 1]]) The expected answer is below, unwanted positions are set to 0s: answer = np.array([[0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 1 , 1 , 1 , 0

Save bounding box as image

旧巷老猫 提交于 2019-12-08 11:19:10
问题 I have some python code that takes in an image of an A4 letter, then draws bounding boxes around each character. I want to know how to save each bounding box as an image, so essentially it's taking every character it detects and saving it. Preferable as a .png resized to 20x20 (A similar question was asked here but the answer is quite vague and don't know how to implement it in my code) Here is my code: import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as mpatches

Get blue colored contours using scikit-image/opencv

好久不见. 提交于 2019-12-08 05:23:26
问题 I'm trying to get blue colored contours using scikit-image. I'm sure there are functions in opencv that are also available in scikit-image. I am aware of the find_contours method which works well however it gets ALL colors of contours. I just wnat to get the blue contours. http://scikit-image.org/docs/dev/api/skimage.measure.find_contours.html Any ideas of how to do this? My guess is to preprocess the image somehow to remove every color other than blue. 回答1: Your suggestion of first

The kernel appears to have died. It will restart automatically

时光毁灭记忆、已成空白 提交于 2019-12-07 18:24:28
问题 When running: from skimage import data in jupyter notebook I always get the error : "The kernel appears to have died. It will restart automatically" I use: Anaconda 4.2.0 (64-bit) Python 3.5.2 scikit-image 0.12.3 np111py35_1 When I run a notebook with python 2.7 kernel it goes fine with no error. So I guess there is a compatibility issue? But I need to use python 3.5, any suggestion? 回答1: Problem solved with: conda update mkl working versions: mkl 2017.0.1 0 mkl-service 1.1.2 py35_2 来源: https

How to extract skimage skeleton information to NetworkX nodes and edges in python for further advanced analysis

强颜欢笑 提交于 2019-12-07 15:46:46
问题 Currently, I use skimage in python to extract the skeleton of open space from some a binarized map as following pictures, With following python codes: from skimage.morphology import skeletonize from skimage import draw from skimage.io import imread, imshow from skimage.color import rgb2gray # load image from file img_fname=os.path.join('images','mall1_2F_schema.png') image=imread(img_fname) # Change RGB color to gray image=rgb2gray(image) # Change gray image to binary image=np.where(image>np

Skimage - Weird results of resize function

拜拜、爱过 提交于 2019-12-07 06:55:01
问题 I am trying to resize a .jpg image with skimage.transform.resize function . Function returns me weird result (see image below). I am not sure if it is a bug or just wrong use of the function. import numpy as np from skimage import io, color from skimage.transform import resize rgb = io.imread("../../small_dataset/" + file) # show original image img = Image.fromarray(rgb, 'RGB') img.show() rgb = resize(rgb, (256, 256)) # show resized image img = Image.fromarray(rgb, 'RGB') img.show() Original

Convert boolean numpy array to pillow image

北慕城南 提交于 2019-12-07 05:19:51
问题 I'm currently working with image processing in python using the scikit-image library. I'm trying to make a binary image using sauvola thresholding with the following code: from PIL import Image import numpy from skimage.color import rgb2gray from skimage.filters import threshold_sauvola im = Image.open("test.jpg") pix = numpy.array(im) img = rgb2gray(pix) window_size = 25 thresh_sauvola = threshold_sauvola(img, window_size=window_size) binary_sauvola = img > thresh_sauvola Which gives the

Unexpected output while converting RGB image to LAB image

不想你离开。 提交于 2019-12-06 16:48:18
I am trying to extract the LAB a-channel of a 32-bit RGB image. However I fail to read the image correctly and I get unexpected results. import cv2 org = cv2.imread('42.png', -1) print org.dtype # print uint8 lab_image = cv2.cvtColor(org, cv2.COLOR_RGB2LAB) l,a,b = cv2.split(lab_image) cv2.imshow('', a) cv2.waitKey(0) Original image: http://labtools.ipk-gatersleben.de/images/42.png Expected output (ImageJ): http://labtools.ipk-gatersleben.de/images/imagej_out.png OpenCV output: http://labtools.ipk-gatersleben.de/images/python_out.png I also tried to read/convert the image with skimage but the

Trouble importing filters using skimage

五迷三道 提交于 2019-12-06 14:02:39
I have been using the Skimage package for quite a while in Python 2.7. Recently I upgrade my Ubuntu to 14.10 And now I can not import filters (used to be filter) from the Skimage package. Python 2.7.9 (default, Apr 2 2015, 15:33:21) [GCC 4.9.2] on linux2 Type "copyright", "credits" or "license()" for more information. >>> from skimage import filters Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from skimage import filters File "/usr/local/lib/python2.7/dist-packages/skimage/filters/__init__.py", line 17, in <module> from .. import restoration File "/usr/local/lib

How can I get a full medial-axis line with its perpendicular lines crossing it?

不想你离开。 提交于 2019-12-06 13:17:06
问题 I have an image and I want to get the pixels that cross through its medial axis. I tried to use skeletonize and medial axis methods in order to get them but both methods return one dimensional line which is shorter than the corresponding object. Here's the code with a sample image:- >>> import skimage.filter >>> import skimage.morphology >>> import numpy as np >>> import scipy.misc >>> im=scipy.misc.imread('img.jpg') >>> thr=skimage.filter.threshold_otsu(im) >>> im=im > thr # Threshold the