Skip to content

fft() failed: “index -2 is out of bounds for axis 0 with size 1” #117

@timiil

Description

@timiil

test.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Emgu.CV" Version="4.6.0.5131" />
    <PackageReference Include="Emgu.CV.runtime.windows" Version="4.6.0.5131" />
    <PackageReference Include="Numpy" Version="3.11.1.33" />
  </ItemGroup>

</Project>

Program.cs:

using Emgu.CV;
using Emgu.CV.Structure;
using Numpy;


Image<Gray, byte> img = new Image<Gray, byte>(args[0]);

var data = img.Mat.GetRawData();
var ndasrc = np.asfarray(data);
var ndaFFT = np.fft.fft2(ndasrc);    //failed here ->

Console.WriteLine(ndaFFT.len);

dotnet run ..\green.tif

failed:

Could not find platform dependent libraries <exec_prefix>
Unhandled exception. Python.Runtime.PythonException: index -2 is out of bounds for axis 0 with size 1
  File "C:\Users\timiil\AppData\Local\python-3.11.0-embed-amd64\Lib\numpy\core\fromnumeric.py", line 43, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\timiil\AppData\Local\python-3.11.0-embed-amd64\Lib\numpy\core\fromnumeric.py", line 54, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\timiil\AppData\Local\python-3.11.0-embed-amd64\Lib\numpy\core\fromnumeric.py", line 190, in take
    return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<__array_function__ internals>", line 180, in take
  File "C:\Users\timiil\AppData\Local\python-3.11.0-embed-amd64\Lib\numpy\fft\_pocketfft.py", line 688, in _cook_nd_args
    s = take(a.shape, axes)
        ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\timiil\AppData\Local\python-3.11.0-embed-amd64\Lib\numpy\fft\_pocketfft.py", line 703, in _raw_fftnd
    s, axes = _cook_nd_args(a, s, axes)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\timiil\AppData\Local\python-3.11.0-embed-amd64\Lib\numpy\fft\_pocketfft.py", line 1014, in fft2
    return _raw_fftnd(a, s, axes, fft, norm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<__array_function__ internals>", line 180, in fft2
   at Python.Runtime.PythonException.ThrowLastAsClrException()
   at Python.Runtime.PyObject.Invoke(PyTuple args, PyDict kw)
   at Python.Runtime.PyObject.InvokeMethod(String name, PyTuple args, PyDict kw)
   at Numpy.np.fft.fft2(NDarray a, Int32[] s, Int32[] axes, String norm)
   at Program.<Main>$(String[] args) in D:\code\bandpass\app\bandpassdemo\Program.cs:line 13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions