scikit-image

Merging non-overlapping array blocks

China☆狼群 提交于 2019-11-30 04:08:43
问题 I divided a (512x512) 2-dimensional array to 2x2 blocks using this function. skimage.util.view_as_blocks (arr_in, block_shape) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> B = view_as_blocks(A, block_shape=(2, 2)) >>> B[0, 0] array([[0, 1], [4, 5]]) >>> B[0, 1] array([[2, 3], [6, 7]]) Now I need to put the same blocks to their original places after manipulation but I couldn't see any function in skimage for that. What's the best way to merge the non-overlapping

How to crop or remove white background from an image

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 04:04:07
I am trying to compare images using OpenCV and Python. Consider these images: Both feature an identical pair of shoes, set to a white background. The only difference being that the first has a taller background than the second. I want to know how to programmatically crop the white backgrounds of both so that I'm left with only the pair of shoes. I must add that it won't be possible for me to manually crop the backgrounds. You requirement in the comment: The shoes are on a white background. I would like to completely get rid of the border; as in be left with a rectangular box with either a

inline images have low quality

旧城冷巷雨未停 提交于 2019-11-29 22:57:37
I'm loading a TIF file with scikit-image and displaying it inline in an ipython notebook (version 2.2.0). This works, however, the image is quite small when first displayed, and when I resize it using the draggable handle on the bottom right of the image, it just rescales the image while retaining the resolution of the original, so it's very blurry when enlarged. It's basically as if ipython is converting my image into a thumbnail on the fly. I've tried using matplotlib's plt.imshow() as well, which has the exact same result. I'm starting the notebook with ipython notebook --pylab inline .

How to read mp4 video to be processed by scikit-image?

白昼怎懂夜的黑 提交于 2019-11-29 21:36:02
I would like to apply a scikit-image function (specifically the template matching function match_template ) to the frames of a mp4 video, h264 encoding. It's important for my application to track the time of each frame, but I know the framerate so I can easily calculate from the frame number. Please note that I'm running on low resources, and I would like to keep dependencies as slim as possible: numpy is needed anyway, and since I'm planning to use scikit-image , I would avoid importing (and compiling) openCV just to read the video. I see at the bottom of this page that scikit-image can

Python: taking the GLCM of a non-rectangular region

跟風遠走 提交于 2019-11-29 17:42:15
I have been using the SLIC implementation of skimage to segment images in superpixels. I would like to use GLCMs to extract additional features from these superpixels for a classification problem. These superpixels are not rectangular. In MATLAB you can set pixels to NaN and they will be ignored by the algorithm ( link ). I could use this to make bounding boxes around the superpixels and then just setting the unused pixels to NaN. The greycomatrix function in skimage does not work entirely the same as the MATLAB implementation however. When setting pixels to NaN the function fails on an assert

reshaping a view of a n-dimensional array without using reshape

萝らか妹 提交于 2019-11-29 15:20:20
tl;dr Can I reshape a view of a numpy array from 5x5x5x3x3x3 to 125x1x1x3x3x3 without using numpy.reshape? I would like to perform a sliding window operation (with different strides) to a volume (size of MxMxM). The sliding window array can be generated with the use of numpy.lib.stride_tricks.as_strided , as previously suggested by Benjamin and Eickenberg , and demonstrated in the below code snippet, which uses a helper method from skimage that uses as_strided . The output from this helper method gives me a shape of NxNxNxnxnxn, but I'd prefer the shape to be N^3x1xnxnxn. While I can use np

Import error No module named skimage

泪湿孤枕 提交于 2019-11-29 10:42:14
问题 I am building code on python using skimage. But I am getting import errors while using skimage.segmentation. Traceback (most recent call last): File "superpixel.py", line 5, in from skimage.segmentation import slic ImportError: No module named skimage.segmentation 回答1: You can use pip install scikit-image . Also see the recommended procedure. 回答2: As per the official installation page of skimage (skimage Installation) : python-skimage package depends on matplotlib, scipy, pil, numpy and six.

How to identify incomplete rectangles in openCV

℡╲_俬逩灬. 提交于 2019-11-29 08:02:14
How would I go around identifying and extracting rectangles from an image such as the one shown below. Note that my rectangles might be incomplete and have some missing edges and some sides might be partial lines. Thanks ! This can be solved using morphological operations such as eroding and dilating . This two operations will help creating closed rectangles. After that you can use the tutorial from this page to detect simple shapes such as rectangles. I implemented a quick demo which worked for the image you provided. main.py: import cv2 import numpy as np from shapeDetector import

Calculating percentage of Bounding box overlap, for image detector evaluation

谁都会走 提交于 2019-11-29 00:02:57
In testing an object detection algorithm in large images, we check our detected bounding boxes against the coordinates given for the ground truth rectangles. According to the Pascal VOC challenges, there's this: A predicted bounding box is considered correct if it overlaps more than 50% with a ground-truth bounding box, otherwise the bounding box is considered a false positive detection. Multiple detections are penalized. If a system predicts several bounding boxes that overlap with a single ground-truth bounding box, only one prediction is considered correct, the others are considered false

inline images have low quality

坚强是说给别人听的谎言 提交于 2019-11-28 19:52:38
问题 I'm loading a TIF file with scikit-image and displaying it inline in an ipython notebook (version 2.2.0). This works, however, the image is quite small when first displayed, and when I resize it using the draggable handle on the bottom right of the image, it just rescales the image while retaining the resolution of the original, so it's very blurry when enlarged. It's basically as if ipython is converting my image into a thumbnail on the fly. I've tried using matplotlib's plt.imshow() as well