Questions tagged [scipy.ndimage]

50 questions
0
votes
1 answer

how to implement scipy.ndimage.convolve1d

I have a code on python I like to convert it to c++. I have a probleme in this line how can I implement it in cpp. y = scipy.ndimage.convolve1d(x1, x2, mode="constant")
0
votes
0 answers

Implement "SAGA Majority Filter" with ndimage

I am looking for a way to implement that QGIS Filter to smooth agriculture zones within a field. Right now I have many artifacts. I want to smooth and eliminate artifacts smaller than specified number of pixels and instead pick neighboring max. I…
0
votes
2 answers

Is there a way to add two filter together as one filter in edge detection?

When I do an edge detection, I normally first use a Gaussian filter: img_blur = scipy.ndimage.gaussian_filter(img,2,truncate = 2.25) Then a gradient filter: Ix= scipy.ndimage.convolve(im, dx) Iy = scipy.ndimage.convolve(im, dy) Where dx and dy…
0
votes
1 answer

How to remove CT bed/shadows in a CT image with python?

I am working with 3D CT images and trying to remove the lines from the bed. A slice from the original Image: Following is my code to generate the mask: segmentation = morphology.dilation(image_norm, np.ones((1, 1, 1))) labels, label_nb =…
0
votes
0 answers

Sigma parameter for scipy.ndimage.gaussian_filter function I don't understand the concept of axes

I have simple example that is not working as expected import numpy as np from PIL import Image from scipy import ndimage def gaussian_smoothing(image, sigma = 1): im = np.array(image) sim = ndimage.gaussian_filter(im, sigma=sigma) …
0
votes
0 answers

ndimage.rotate for rotating a live video makes it very slow (python)

My objective is to have the webcam transmitting live feed and I could rotate the image feed by some degries (this part would be controlled by the values of a gyroscope). The problem is although the image rotates when using ndimage.rotate by the…
0
votes
1 answer

Reduce artifacts when resampling a Brain MRI scan using scipy affine_transform

I have a Brain MRI. It is gray scale with 20 slices. I put it into a numpy array with shape (20,256,256). I use scipy.ndimage affine_transform to rotate and resample the array as below. The dark stipes in the image is the artifact that I want…
John Henckel
  • 10,274
  • 3
  • 79
  • 79
0
votes
1 answer

Scipy Median Filter Which Ignores Zero-Valued Datapoints?

I have been using the median_filter function from scipy.ndimage. I would like to use this in a way that discards any data that isn't positively valued. That is, suppose one iteration of the filter acts over: [40, 50, 0, 90] If I simply run the…
0
votes
0 answers

How do I find rectangular areas in a matrix

I have a matrix with different labels. How do I find all rectangles with identical values? I tried: import numpy as np import scipy.ndimage as nd a= np.zeros((120, 120), dtype=np.uint16) a[:100, :100] = 5 a[10:100, 10:100] = 6 a[12:100, 12:100] =…
Ruediger Jungbeck
  • 2,836
  • 5
  • 36
  • 59
0
votes
1 answer

How to grow a labeled feature in an scipy ndimage

Is there a way to grow a labeled feature in an ndimage? Ideally with a way to specify how the growth should happen by using a structure. I'm using scipy.ndimage.label() for feature detection in an n-dimensional binary image like so: import numpy as…
nieswand
  • 33
  • 7
0
votes
1 answer

How to find coordinate of polygon shape from binary image?

The image is below, where dark area is 0, bright area is 255. I want to find 4 coordinates [(x1, y1),(x2, y2),(x3, y3),(x4, y4)] of bright area from this image. This bright area would be polygon shape (pentagon, hexagon, triangle etc.). I have…
Md. Rezwanul Haque
  • 2,882
  • 7
  • 28
  • 45
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
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
  • 279
  • 2
  • 9
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
  • 151
  • 7