Questions tagged [scipy.ndimage]
50 questions
4
votes
1 answer
2D local maxima and minima in Python
I have a data frame, df, representing a correlation matrix, with this heatmap with example extrema. Every point has, obviously, (x,y,value):
I am looking into getting the local extrema. I looked into argrelextrema, I tried it on individual rows and…

Adam
- 3,872
- 6
- 36
- 66
3
votes
2 answers
Using regionprops in Python
I am trying to analyze greyscale TIFF stacks, in which a given frame will look like this. I filter it (using Gaussian blur), and then binarize it (using Otsu's method for threshold).
MATLAB code, which works great:
image_conncomp =…

oofin
- 160
- 1
- 2
- 12
2
votes
2 answers
Using Scipy.ndimage to iterate over Elevation Array
I have an elevation array from a .tif LiDAR surface. Example array below.
Existing_example_arrayV0 = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 1, 1, 0, 0, 0],
[ 0, 1, 1, 1, 1, 0, 0],
…

Patstro
- 69
- 6
2
votes
1 answer
What is the fastest way to rotate image in python?
I needed to know what is the fastest way to rotate an Image in Python.
There is no such question asked or answered to my knowledge in Stack Overflow, so I decided to run an experiment and find out the answer. That is why I would like to share the…

shahab daiani
- 79
- 7
1
vote
1 answer
Alignment of a 3D volume to its principal axes
I'm trying to align a rectangular prism contained in a 3D numpy array to the principal axes of the array. Specifically, I need to accomplish this alignment by rotating the full array, as opposed to extracting the coordinates of the object and then…

Pete
- 504
- 4
- 15
1
vote
1 answer
Using Scipy.ndimage to Rotate an Array within Np.Nan Values
I have an elevation array from a .tif LiDAR surface. Example array below.
from scipy.ndimage import rotate
import numpy as np
test_surface_nan = [[np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan],
[np.nan, np.nan,…

Patstro
- 69
- 6
1
vote
1 answer
Erosion and Dilation of Image in one direction using Scipy
I have an elevation array from a .tif LiDAR surface. Example array below.
Existing_example_arrayV0 = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 1, 1, 0, 0, 0],
[ 0, 1, 1, 1, 1, 0, 0],
…

Patstro
- 69
- 6
1
vote
1 answer
reverse or invertible ndimage.map_coordinates mapping based on planar homography
Suppose I have an image that I want to warp as part of a forward model of a system. In the reverse model, I need to be able to undo the warp. Consider the following:
import numpy as np
from scipy.ndimage import map_coordinates
from matplotlib…

Brandon Dube
- 428
- 1
- 10
- 26
1
vote
1 answer
What is the best way to pass an extra argument to a scipy.LowLevelCallable function?
I have a python script that creates a set of ctype input arguments to pass to scipy.LowLevelCallable(see the notes section) and uses it to make a call to scipy.generic_filter that only executes a single iteration for testing purposes. I also define…

Yes
- 339
- 3
- 19
1
vote
1 answer
How to make dotted line in a binary array
how to create the dotted line in the below NumPy array
import NumPy as np
from matplotlib import pyplot as plt
from matplotlib.colors import ListedColormap
x=np.array( [ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0, 0,…

raja
- 123
- 7
1
vote
1 answer
How to access range of indices of an array where specific conditions match
I have an array for a example:
import NumPy as np
a=np.array( [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0],
…

raja
- 123
- 7
1
vote
1 answer
Rotation of 3d array and point cloud not matching
I have the following problem: I have a 3d numpy array representing a stack of images. I also have a point cloud (n,3) of some relevant locations in the 3d array, which I have plotted in there. I want to rotate both by an angle around the x-axis. I…

Cristian Soitu
- 23
- 3
1
vote
1 answer
cv2.Filter2D vs ndimage.convolve?
I am new to image processing, please forgive me if you find the question too simple.
I was trying to replace ndimage.convolve() with cv2.filter2D() function for convolution.
Here is the original code
ndimage.convolve(Gxx,f,origin=0)
Here is the…

user976385
- 117
- 1
- 10
1
vote
1 answer
How does maximum_filter1d work in scipy? How does cval, origin, mode parameter affect it?
Documentation link:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.maximum_filter1d.html#r4df4f294a847-2
The example given in the documentation is,
>>> maximum_filter1d([2, 8, 0, 4, 1, 9, 9, 0,1], size=3)
array([8, 8, 8, 4, 9, 9,…

Sanjay S
- 51
- 5
1
vote
1 answer
Using shift() on MNIST data. Getting strange results
I am trying to use the shift() function on MNIST images.
Somehow, though, when I look at the original data and the shifted data, it looks like the shifted values that were exactly zero are becoming really small nonzero values instead of zero. An…

THill3
- 87
- 6