DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
228 stars 50 forks source link

Gradient throws "Image is not protected" at sigma < 0.8 #170

Closed vis-florum closed 1 week ago

vis-florum commented 1 week ago

Component PyDip 3.5.1

Describe the bug When using Gradient in PyDip, and any other function built on Gradient (e.g. StructureTensor), with a sigma < 0.8, then the following error occurs: diplib.PyDIP_bin.ParameterError: Image is protected

This behaviour was not observed in version 3.4.x on the same system (I am rerunning existing code with 3.5)

To Reproduce This works:

import diplib as dip
import numpy as np

img = np.random.rand(100,100)
dip.Gradient(img, sigmas=.8)

but:

import diplib as dip
import numpy as np

img = np.random.rand(100,100)
dip.Gradient(img, sigmas=.79)

results in:

Traceback (most recent call last): File "", line 1, in diplib.PyDIP_bin.ParameterError: Image is protected in function: void dip::Image::Strip() (/io/include/diplib/library/image.h at line number 1283) in function: void dip::FourierTransform(const dip::Image&, dip::Image&, const StringSet&, dip::BooleanArray) (/io/src/transform/fourier.cpp at line number 613) in function: void dip::GaussFT(const dip::Image&, dip::Image&, dip::FloatArray, dip::UnsignedArray, dip::dfloat, const String&, const String&, const StringArray&) (/io/src/linear/gauss.cpp at line number 444) in function: void dip::Gauss(const dip::Image&, dip::Image&, dip::FloatArray, dip::UnsignedArray, const String&, const StringArray&, dip::dfloat) (/io/src/linear/derivative.cpp at line number 80) in function: void dip::Derivative(const dip::Image&, dip::Image&, dip::UnsignedArray, dip::FloatArray, const String&, const StringArray&, dip::dfloat) (/io/src/linear/derivative.cpp at line number 112) in function: void dip::Gradient(const dip::Image&, dip::Image&, dip::FloatArray, const String&, const StringArray&, dip::BooleanArray, dip::dfloat) (/io/src/linear/derivative.cpp at line number 167)

System information: Ubuntu Linux: LSB Version: core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch Distributor ID: Ubuntu Description: Ubuntu 22.04.5 LTS Release: 22.04 Codename: jammy Kernel: 5.15.0-126-generic

Python: Python 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 16:05:46) [GCC 13.3.0] on linux Diplib installed via pip

crisluengo commented 1 week ago

Thank you for reporting this!

crisluengo commented 1 week ago

Complete in c4ba3c5b