Questions tagged [scipy.ndimage]

23 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,407
  • 2
  • 29
  • 52
2
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
  • 120
  • 1
  • 2
  • 11
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
  • 79
  • 4
1
vote
1 answer

Why does find_objects give a bunch of Nones and then range of the whole image?

I am trying to find all objects detected in difference of frames, I thougt this would give a list of each area detected in the threshold, but find_objects is giving a bunch of "None"s and a range of the whole…
NoBugs
  • 8,418
  • 10
  • 72
  • 132
1
vote
0 answers

Any recommendation to resize 3d image array which consists of only 0 and 1?

I want to resize(downscale) the ground truth 3d images of brain tumor segmentation. Here are some g.t. + brain images: G.t. images are 3d numpy array and consist of only 0 and 1 value(only green voxel and black voxel, brain is not included in g.t.…
Crispy13
  • 181
  • 1
  • 11
0
votes
0 answers

Resampling/Interpolation of 3D Multi-class Mask without changing label values/scipy.ndimage.interpolation or RegularGridInterpolator

I have a 3D mask volume L with the following: print(L.shape) (170, 256, 256) print("L: ", np.unique(L)) L: [0 1 2 3 4 5 6 7 8] I want to downsample and then upsample the mask to its original size keeping the label values the same. Failed…
banikr
  • 11
  • 4
0
votes
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
  • 13
  • 3
0
votes
0 answers

to use scipy.ndimage.gaussian_filter for 2d array of prmsl data and plot without breaking near 0 meridian

Good Day! I have a problem with ploting prmsl data after scipy.ndimage.gaussian_filter (sigma=2) near the 0 meridian. I have my longitude data like a np.arange(0,359.5,0.5) - after addcyclic np.arange(0,360,0.5), and when i try plot isobars i get…
0
votes
0 answers

How to perform labelling with ndimage without running out of memory?

For Geospatial analysis I created a clump function that will identify patches of deforestation in a .tif file. The deforestation events are labelled as 1 the rest is background (0) I created the following function : import rasterio as rio from…
Pierrick Rambaud
  • 870
  • 9
  • 31
0
votes
0 answers

Reshape changes the range of scipy.ndimage.rotate

import scipy.ndimage as snd np.max(snd.rotate(roi_old, Rotangle)) Out[166]: 1.642610287502076 np.max(snd.rotate(roi_old, Rotangle,reshape=False)) Out[167]: 1.6771061860083012 Note that the smaller image yields greater max value, meaning that it is…
Leon
  • 3
  • 3
0
votes
1 answer

Librosa ModuleNotFoundError: No module named 'scipy.ndimage'

I am trying to use librosa library but whatever I do I take the following massage (Using Python 3.8 and PyCharm on Anaconda) What I am trying: import librosa import IPython.display as ipd sr = 22050 # sample rate T = 5.0 # seconds t =…
UIAT
  • 1
0
votes
2 answers

Use a custom kernel / image filter to find a specific pattern in a 2d array

Given an image im, >>> np.random.seed(0) >>> im = np.random.randint(0, 100, (10,5)) >>> im array([[44, 47, 64, 67, 67], [ 9, 83, 21, 36, 87], [70, 88, 88, 12, 58], [65, 39, 87, 46, 88], [81, 37, 25, 77, 72], [ 9,…
0
votes
0 answers

scipy.ndimage RuntimeError: coordinate array data type not supported

I was using the method scipy.ndimage.map_coordinates, and it seemed to work fine in my code. However, when I called it from another method, it gave me a RuntimeError: coordinate array data type not supported. Here is the traceback: Traceback (most…
Eboyer
  • 23
  • 5
0
votes
1 answer

How to set different stride with uniform filter in scipy?

I am using the following code to run uniform filter on my data: from scipy.ndimage.filters import uniform_filter a = np.arange(1000) b = uniform_filter(a, size=10) The filter right now semms to work as if a stride was set to size // 2. How to…
JAV
  • 259
  • 2
  • 8
0
votes
1 answer

How to get the list of values of scipy.ndimage gaussian_filter?

I'm trying to get a list of values when I use a gaussian_filter. I read a file with a column and float values. Example: 0.8457 0.0 0.505 etc... My script is this: #!/usr/bin/env python import numpy as np from scipy.ndimage.filters import…
Hdez
  • 129
  • 6
1
2