Questions tagged [ndimage]

Multi-dimensional image processing module within Scipy.

Scipy contains modules for a variety of scientific computing tasks.

ndimage is used for multi-dimensional image processing and contains the following submodules,

  • Filters scipy.ndimage.filters
  • Fourier filters scipy.ndimage.fourier
  • Interpolation scipy.ndimage.interpolation
  • Measurements scipy.ndimage.measurements
  • Morphology scipy.ndimage.morphology
  • Utility
108 questions
3
votes
1 answer

Scipy NDimage correlate: unbearably slow

I'm running code using Python 3.3. The goal is to correlate data_3d (a 1000x1000x1000 Boolean ndarray) with kernel (a 35x35x35 float ndarray). I then perform another correlation to sum over the previous result. As such, I am correlating another…
3
votes
0 answers

problems with footprint in scipy.ndimage.filters.maximum_filter

I am using scipy.ndimage.filters.maximum_filter to find out the local maxima with the code like this: neighborhood = ndimage.morphology.generate_binary_structure(2,2) fore_ground=scipy.ndimage.filters.maximum_filter(iobrcbr,neighborhood) However,…
user30985
  • 573
  • 1
  • 6
  • 19
3
votes
1 answer

How to remove some connected components in python?

Consider a binarized image, I use scipy.ndimage.label() on it and then apply the find_objects() on the result. Now I've got a tuple list consists of N tuples, each of them is two slice, like: index value 0 (slice(0, 21, None) slice(0, 12, None))…
Lancelod Liu
  • 290
  • 5
  • 19
2
votes
1 answer

Why is my manual convolution different to scipy.ndimage.convolve

I apologise in advance, I may just not understand convolution. I'm struggling to reconcile the results using scipy.ndimage.convolve with what I get attempting to do it by hand. For the example in the documentation: import numpy as np a =…
2
votes
2 answers

How scipy.ndimage.median_filter works for even sizes

Has someone found/understood how works scipy.ndimage.median_filter for even sizes? Because I tested a lot of theories and tried to read the source code, but I haven't an explanation (Of course it's better to use odd sizes to avoid shifts, but it's…
2
votes
2 answers

Getting the coordinates of elements in clusters without a loop in numpy

I have a 2D array, where I label clusters using the ndimage.label() function like this: import numpy as np from scipy.ndimage import label input_array = np.array([[0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0,…
Canol Gökel
  • 1,168
  • 2
  • 13
  • 29
2
votes
1 answer

Adaptive Gaussian filtering with NumPy

Running a Gaussian filter over image with static sigma value is easy: scipy.ndimage.gaussian_filter(input, sigma) But how to do this with a sigma value that is different for each pixel? For example, I might have another NumPy array of the same size…
Jachym
  • 309
  • 1
  • 10
2
votes
1 answer

Rotate an image without averaging pixel values

Is it possible to rotate an image and keep the true values? When I rotate a black and white image I get back grey values. Can I rotate without averaging the pixel values? I can almost do it manually by using np.where() but it gets difficult when…
rzaratx
  • 756
  • 3
  • 9
  • 29
2
votes
2 answers

Unexpected behavior of `scipy.ndimage.zoom()` for `order=0`

I have difficulties understanding the behavior of scipy.ndimage.zoom() when order=0. Consider the following code: import numpy as np import scipy as sp import scipy.ndimage arr = np.arange(3) + 1 print(arr) for order in range(5): zoomed =…
norok2
  • 25,683
  • 4
  • 73
  • 99
2
votes
0 answers

Find the weights or kernel used by gaussian_filter of scipy.ndimage

I am having an image consisting of {0,1,2} values and I am trying to run gaussian_filter from scipy.ndimage over it. Though it was very easy to use but I haven't understood the things properly yet. Few things that I understood are : sigma is the…
Mayan19
  • 113
  • 1
  • 9
2
votes
2 answers

How to broadcast or vectorize a linear interpolation of a 2D array that uses scipy.ndimage map_coordinates?

I have recently hit a roadblock when it comes to performance. I know how to manually loop and do the interpolation from the origin cell to all the other cells by brute-forcing/looping each row and column in 2d array. however when I process a 2D…
dfresh22
  • 961
  • 1
  • 15
  • 23
2
votes
1 answer

How to find the largest connected region using scipy.ndimage?

I have a binary image. The binary image has some isolate regions like noise. I know that the expected region much larger than these isolate regions. Hence, I used the connected components to remove the isolate regions by finding the largest…
Jame
  • 3,746
  • 6
  • 52
  • 101
2
votes
2 answers

Python ndimage: Converting an existing ndarray into greyscale

During my python 2.7 exploration trying to use scipy I have made the following simple script: #!/usr/bin/env python # coding=utf-8 # -*- Mode: python; c-basic-offset: 4 -*- from scipy import ndimage import numpy as np from scipy import misc import…
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
2
votes
1 answer

Speed up scipy ndimage measurements applied on a numpy 3-d

I have multiple large labeled numpy 2d array (10 000x10 000). For each label (connected cells with the same number) I want to calculate multiple measurements based on the values of another numpy 3-d array (mean, std., max, etc.). This is possible…
Wilmar van Ommeren
  • 7,469
  • 6
  • 34
  • 65
2
votes
1 answer

Scipy.generic_filter - window translation to 1D

I am trying to use scipy.generic_filter to process an image. However, I need to further subset the window within the function I am applying. In another words I need to know the process (function) used to convert the 2D window to 1D array within the…
Tereza_S
  • 21
  • 1