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
2 answers

ndimage map_coordinates with masked arrays

I am using ndimage to interpolate as follows: ndimage.map_coordinates(input_data, coords, output, 2, prefilter=False) Now, the problem is that I do not have valid measurements over my whole input data. So, I have a masked array which tells me which…
Luca
  • 10,458
  • 24
  • 107
  • 234
1
vote
1 answer

How to get area of image with boundary conditions?

Many functions in scipy.ndimage accept an optional mode=nearest|wrap|reflect|constant argument which determines how to handle cases in which the function needs some data from outside the area of the image (padding). The padding is handled…
Alex I
  • 19,689
  • 9
  • 86
  • 158
0
votes
0 answers

how to calculate a masked distance transform with ndimage.distance_transform_edt?

I have a 512^3 boolean array. I am currently calculating a distance transform using scipy.ndimage.distance_transform_edt. The calculation is taking quite a while (tens of seconds). I only need to know the distances for a small set of pixels (a few…
tomerg
  • 353
  • 2
  • 12
0
votes
0 answers

Scipy.ndimage.rotate on 3D image gives a different result if spline_filter is applied before

The scipy.ndimage.rotate is supposed to apply a spline filter before rotation. But with images of at least 3 dimensions, when I apply scipy.ndimage.prefilter before and I then call rotate with prefilter=False, the result is very different in…
vincent59
  • 81
  • 2
  • 7
0
votes
0 answers

Anaconda Scipy shift import issues even though Scipy is installed

----> 7 from scipy.ndimage.interpolation import shift ModuleNotFoundError: No module named 'scipy.ndimage.interpolation' It gives me this error even though Numpy and Scipy are all installed. I perused this site and other online forums and for the…
0
votes
1 answer

How to apply convolution in-place on GPU (in Python)

I need to perform a convolution on an image in-place, and by in-place I mean such that as the structuring element gets applied to different pixels, I want the result of the previous steps to overwrite the image. To put it in context, this is useful…
Blademaster
  • 324
  • 2
  • 15
0
votes
2 answers

Performing ndimage.convolve on big numpy.memmap: Unable to allocate 56.0 GiB for an array

While trying to do ndimage.convolve on big numpy.memmap, exception occurs: Exception has occurred: _ArrayMemoryError Unable to allocate 56.0 GiB for an array with shape (3710, 1056, 3838) and data type float32 Seems that convolve creates a regular…
aaxx
  • 55
  • 1
  • 5
0
votes
2 answers

Remove all pixels with all-zero neighbors

Is there a way to perform a process similar to erosion in OpenCV that retains a given pixel if ANY of its neighbors are non-zero, instead of requiring all of its neighbors to be non-zero? Here, by neighbors, I mean any pixel with…
Michael Sohnen
  • 953
  • 7
  • 15
0
votes
1 answer

How to rotate the image without changing the shape of array?

I'm working on rotating the image. However, when I'm using the scipy.ndimage.rotate() function I can rotate the full image (reshape=True), but the shape of array will be changed. For instance, as the example of scipy.ndimage.rotate(), the result I'm…
Happier
  • 71
  • 1
  • 5
0
votes
1 answer

Getting array of zeros when using Python cupyx.scipy.ndimage map_coordinates

I'm trying to map pixels values from one image to another on the gpu with Python cupyx.scipy.ndimage map_coordinates function. The output cupy-array is all zeros. When I'm using scipy.ndimage to run its map_coordinates I'm getting the interpolated…
rotemp
  • 11
  • 1
0
votes
1 answer

Using sp.ndimage.label on Xarray DataArray with apply_ufunc

Lets say I have the simple array: data = [1,1,0,0,1,1,1] I can apply labeling to this data with the scipy ndimage module with: groups, _ = sp.ndimage.label(data) Resulting in In [68]: print(groups) [1 1 0 0 2 2 2] Now, I would like to do the same…
hm8
  • 1,381
  • 3
  • 21
  • 41
0
votes
1 answer

Testing if a point lies within a labeled object with scipys ndi.label()

Above is an image that has been put through ndi.label()and displayed with matplotlib with each coloured region representing a different feature. Plotted on top of the image are red points that represent a pair of coordinates each. All coordinates…
0
votes
0 answers

How to add a gaussian blur with a real gaussian shape on an image with Python

Let's say I have an image as the following 2D arrays: img = np.array([ [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0], [0,…
Lionel
  • 331
  • 1
  • 2
  • 14
0
votes
1 answer

What can I use to measure some properties in a 3D (x,y,z) ?Regionprops docu says it's only for (N, M) but I found information of a 3D regionprops PR

Link to regionprops documentation: https://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops PR of Regionprops info: https://github.com/scikit-image/scikit-image/pull/1505
Juan I.
  • 5
  • 2
0
votes
2 answers

Isolating the head in a grayscale CT image using Python

I am dealing with CT images that contain the head of the patient but also 'shadows' of the metalic cylinder. These 'shadows' can appear down, left or right. In the image above it appears only on the lower side of the image. In the image below it…
user8270077
  • 4,621
  • 17
  • 75
  • 140