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
4
votes
0 answers

tensorflow equivalent for scipy.ndimage and skimage.measure

I have a script that takes a label image, where each pixel represent the class of the original pixel in a given image. Using scipy.ndimage and skimage.measure I create a list of bounding boxes that contain each object. I'd like to do the same…
Tal
  • 127
  • 1
  • 7
4
votes
1 answer

Intensity-weighted minimal path between 2 points in grayscale image

I want to determine minimum path between two specific points in an image, i.e. the path for which sum of distances between adjacent pixels weighted by pixel intensity (greyscale) will be minimized. For instance, this picture shows the input…
eudoxos
  • 18,545
  • 10
  • 61
  • 110
4
votes
2 answers

create 3D binary image

I have a 2D array, a, comprising a set of 100 x,y,z coordinates: [[ 0.81 0.23 0.52] [ 0.63 0.45 0.13] ... [ 0.51 0.41 0.65]] I would like to create a 3D binary image, b, with 101 pixels in each of the x,y,z dimensions, of coordinates…
MyCarta
  • 808
  • 2
  • 12
  • 37
4
votes
1 answer

Scipy ndimage median_filter origin

I have a binary array, say, a = np.random.binomial(n=1, p=1/2, size=(9, 9)). I perform median filtering on it using a 3 x 3 kernel on it, like say, b = nd.median_filter(a, 3). I would expect that this should perform median filter based on the pixel…
rakesh a
  • 537
  • 2
  • 5
  • 15
4
votes
1 answer

Numpy/Scipy Connected Components

I am writing a program in python to find "islands" of 1s, 0s or -1s in a L*L matrix. I need It to find these "regions" of connected components, label each one of them, and be capable of returning, for a given element of the matrix m[x][y] , the size…
albertociarr
  • 41
  • 1
  • 2
4
votes
3 answers

Read an image pixel by pixel (ndimage/ndarray)

I have an image that is stored as an ndarray. I would like to iterate over each pixel in this array. I can iterate over each element of the array like this: from scipy import ndimage import numpy as np l = ndimage.imread('sample.gif',…
Juicy
  • 11,840
  • 35
  • 123
  • 212
3
votes
1 answer

How to make ndimage.filters.maximum_filter work like MATLAB's imregionalmax function?

After reading this post, and play also with SciKit-image I found a difference in Python compared to MATLAB's function imregionalmax. I have these lines of code: from skimage.feature import peak_local_max manos = np.ones([5,5]) manos[2,2] =…
3
votes
1 answer

How to specify a periodic connection for features of scipy.ndimage.label?

Given an N*N array of 0 and 1, I want to build the list of clusters (a cluster being a set of connected points labeled by 1). scipy.ndimage.label is very useful because it tells you which points are connected. But I would like also to have periodic…
Njha
  • 73
  • 8
3
votes
1 answer

Get path of boundaries of contiguous regions in 2D array

Say I have an array like this: import numpy as np arr = np.array([ [1, 1, 3, 3, 1], [1, 3, 3, 1, 1], [4, 4, 3, 1, 1], [4, 4, 1, 1, 1] ]) There are 4 distinct regions: The top left 1s, 3s, 4s and right 1s. How would I get the paths for…
Artyer
  • 31,034
  • 3
  • 47
  • 75
3
votes
2 answers

How to down sample image array, without changing pixel values

I have image segmentation project, and ground truth labels given as images where pixel value stands for the label. I need to resize the images and labels, while keeping the labels in the same value set. I tried many things, All change the value…
3
votes
0 answers

How to solve...ValueError: cannot convert float NaN to integer

I'm running quite a complex code so I won't bother with details as I've had it working before but now im getting this error. Particle is a 3D tuple filled with 0 or 255, and I am using the scipy centre of mass function and then trying to turn the…
Scott Alistair
  • 161
  • 4
  • 12
3
votes
1 answer

How to align principal axes of 3D density map in numpy with Cartesian axes?

I have an n x n x n numpy array that contains density values on a cubic grid. I'm trying to align the principal axes of inertia of the density map with the cartesian x,y,z axes of the grid. I have the following so far: import numpy as np from scipy…
tomerg
  • 353
  • 2
  • 12
3
votes
1 answer

Want to detect edge and corner parts in a jigsaw puzzle, but can't find the 4 corners of each piece

I have a jigsaw puzzle and want to automatically distinguish between "normal", "edge", and "corner" pieces in that puzzle (I hope that the definition of those words is obvious for anyone who has ever done jigsaw puzzle) To make things easier, I…
tfv
  • 6,016
  • 4
  • 36
  • 67
3
votes
1 answer

Select size filtered elements in a large array (raster)

I could need help on this: On a large boolean numpy array (imported raster) (2000x2000), I try to select only elements that are greater than 800 units. (number of total elements > 1000) I tried a loop: labeled_array, num_features =…
Nono
  • 133
  • 4
3
votes
1 answer

Directly "plot" line segments to numpy array

One of my first projects realized in python does Monte Carlo simulation of stick percolation. The code grew continually. The first part was the visualization of the stick percolation. In an area of width*length a defined density (sticks/area) of…
MrCyclophil
  • 162
  • 3
  • 13