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
1
vote
1 answer

numba ctype matching with ndfilter

I am trying to use Numba cfunc as scipy.LowLevelCallable inside ndi.generic_filter however I am facing signature matching issue. If I set return type to int16 it recognize as short if I set to int32 or intc it says long. Both signatures cannot be…
tayyab
  • 78
  • 1
  • 6
1
vote
2 answers

How to find the diameter of input image objects using image processing in Python?

Given an input image for example a jpg with some circular objects (coins for example), I want to find their individual diameters. Thanks to this question (How to find the diameter of objects using image processing in Python?) , I know how to…
1
vote
1 answer

Conditional logic with Python ndimage generic_filter

I am trying to write a python function to remove hot-pixels in 2D image data. I am trying to make function that will take the mean for the neighbors around each element in the 2D array and conditionally overwrite that element if its value exceeds…
Matt
  • 75
  • 1
  • 6
1
vote
1 answer

How to resize N-d numpy image?

How to resize N-d numpy image? I don't just want to subsample it, but to interpolate / average the pixels. For example, if I start with array([[[3, 1, 3, 1], [3, 1, 3, 1], [3, 1, 3, 1], [3, 1, 3, 1]], [[3, 1, 3, 1], …
MWB
  • 11,740
  • 6
  • 46
  • 91
1
vote
0 answers

sum filter with ndimage with special footprint

I would like to write an algorithm that calculates the sum of the elements in a 3*3-window of a 3D array without the value of the center of my window For instance, for the input A : A1 = np.array([[1,1,0],[0,0,0],[0,0,0]]) A2 =…
1
vote
1 answer

Faster index computation from Scipy labelled array apart from np.where

I am working on a large array (3000 x 3000) over which I use scipy.ndimage.label. The return is 3403 labels and the labelled array. I would like to know the indices of these labels for e.g. for label 1 I should know the rows and columns in the…
Gargantua89
  • 13
  • 1
  • 3
1
vote
0 answers

ROI augmentation in keras: scipy.ndimage transformations

I've got an image with regions of interest. I would like to apply random transformations to this image, while keeping the regions of interest correct. My code is taking a list of boxes in this format [x_min, y_min, x_max, y_max]. It then converts…
lhk
  • 27,458
  • 30
  • 122
  • 201
1
vote
1 answer

np.roll vs scipy.interpolation.shift--discrepancy for integer shift values

I wrote some code to shift an array, and was trying to generalize it to handle non-integer shifts using the "shift" function in scipy.ndimage. The data is circular and so the result should wrap around, exactly as the np.roll command does…
Mike
  • 1,727
  • 3
  • 15
  • 25
1
vote
1 answer

How to produce a 2D cut through a 3D image?

I have a 3D array with some data (a raster 3D image). I would like to get a 2D cut through that array, using some suitable interpolation (preferably linear - that's probably "trilinear" in this case). The plane of the cut can be described however…
Alex I
  • 19,689
  • 9
  • 86
  • 158
1
vote
1 answer

ndimage.label: Displaying patches of a certain size

Context: I utilize an SVM to analyze an image and find pixels of interest. After filtering out pixels of low interest (full code below), the resulting binary mask is stored to be displayed later. At the same time, I use ndimage.label to go through…
DeeWBee
  • 695
  • 4
  • 13
  • 38
1
vote
1 answer

label 3d numpy array with scipy.ndimage.label

I've got a large 3d numpy array which consists of ones and zeros. I would like to use the scipy.ndimage.label tool to label the features in each sub-array (2d). A subset of the 3d-array looks like: import numpy as np from scipy.ndimage import…
Wilmar van Ommeren
  • 7,469
  • 6
  • 34
  • 65
1
vote
1 answer

Objects' sizes along dimension?

I have a 3D label matrix. Using ndimage.sum I can get the labeled objects sizes, which is great for filtering based on volume. My question is : can I easily get objects sizes along each axis, to eliminate those that are only in one plane, for…
nicoco
  • 1,421
  • 9
  • 30
1
vote
1 answer

How to return multiple values using scipy ndimage.generic_filter in Python?

I'm looking for a way to output multiple values using the generic_filter module in scipy.ndimage like so: import numpy as np from scipy import ndimage a = np.array([range(1,5),range(5,9),range(9,13),range(13,17)]) def summary(a): …
kika
  • 21
  • 2
1
vote
1 answer

python, dimension subset of ndimage using indices stored in another image

I have two images with the following dimensions, x, y, z: img_a: 50, 50, 100 img_b: 50, 50 I'd like to reduce the z-dim of img_a from 100 to 1, grabbing just the value coincide with the indices stored in img_b, pixel by pixel, as indices vary…
peter
  • 25
  • 4
1
vote
1 answer

How to smooth / filter a function in a n-dimensional space using python?

I have function defined in an n-dimensional space which I represent with (X,Y), where X is an array of size mxn containing the input features and Y an array of size mx1 containing the output. So there are m points in an d-dimensional space with m >>…
Mannaggia
  • 4,559
  • 12
  • 34
  • 47