Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature.peak_local_max changes input image #5410

Closed
odoublewen opened this issue May 26, 2021 · 4 comments
Closed

feature.peak_local_max changes input image #5410

odoublewen opened this issue May 26, 2021 · 4 comments

Comments

@odoublewen
Copy link
Contributor

Description

Under certain conditions, the input image changes after calling feature.peak_local_max. This behavior is evident in scikit-image 0.18.0 and 0.18.1. It is not present in 0.17.2

Way to reproduce

Input data files attached:
im_int.txt
labels_int.txt

Script:

import skimage
from skimage import feature
import numpy as np

print("skimage version")
print(skimage.__version__)

im = np.genfromtxt('im_int.txt')
labels = np.genfromtxt('labels_int.txt', dtype=int)

print("image before calling feature.peak_local_max")
print(im)
print(np.min(im))

peaks = feature.peak_local_max(im, labels=labels, num_peaks_per_label=1, exclude_border=False)

print("image after calling feature.peak_local_max")
print(im)
print(np.min(im))

Output from both 0.17.2 and 0.18.1:

$ python find_peaks.py 
skimage version
0.17.2
image before calling feature.peak_local_max
[[1145. 1136. 1041. ... 1055.  999. 1153.]
 [1115. 1107. 1073. ... 1001. 1060. 1114.]
 [1091. 1065. 1069. ...  927. 1124. 1109.]
 ...
 [1110. 1168.  908. ... 1149.  917.  953.]
 [1045. 1104.  937. ... 1057. 1094.  916.]
 [ 793.  954. 1128. ... 1013. 1018.  983.]]
793.0
image after calling feature.peak_local_max
[[1145. 1136. 1041. ... 1055.  999. 1153.]
 [1115. 1107. 1073. ... 1001. 1060. 1114.]
 [1091. 1065. 1069. ...  927. 1124. 1109.]
 ...
 [1110. 1168.  908. ... 1149.  917.  953.]
 [1045. 1104.  937. ... 1057. 1094.  916.]
 [ 793.  954. 1128. ... 1013. 1018.  983.]]
793.0


$ python find_peaks.py 
skimage version
0.18.1
image before calling feature.peak_local_max
[[1145. 1136. 1041. ... 1055.  999. 1153.]
 [1115. 1107. 1073. ... 1001. 1060. 1114.]
 [1091. 1065. 1069. ...  927. 1124. 1109.]
 ...
 [1110. 1168.  908. ... 1149.  917.  953.]
 [1045. 1104.  937. ... 1057. 1094.  916.]
 [ 793.  954. 1128. ... 1013. 1018.  983.]]
793.0
image after calling feature.peak_local_max
[[ 1.14500000e+003  1.13600000e+003 -1.79769313e+308 ...  1.05500000e+003
   9.99000000e+002  1.15300000e+003]
 [ 1.11500000e+003  1.10700000e+003 -1.79769313e+308 ...  1.00100000e+003
   1.06000000e+003  1.11400000e+003]
 [ 1.09100000e+003  1.06500000e+003  1.06900000e+003 ...  9.27000000e+002
   1.12400000e+003  1.10900000e+003]
 ...
 [ 1.11000000e+003  1.16800000e+003 -1.79769313e+308 ...  1.14900000e+003
   9.17000000e+002  9.53000000e+002]
 [ 1.04500000e+003 -1.79769313e+308 -1.79769313e+308 ...  1.05700000e+003
   1.09400000e+003  9.16000000e+002]
 [ 7.93000000e+002 -1.79769313e+308 -1.79769313e+308 ...  1.01300000e+003
   1.01800000e+003  9.83000000e+002]]
-1.7976931348623157e+308

Version information

# Paste the output of the following python commands
from __future__ import print_function
import sys; print(sys.version)
import platform; print(platform.platform())
import skimage; print("scikit-image version: {}".format(skimage.__version__))
import numpy; print("numpy version: {}".format(numpy.__version__))
# your output here

3.8.6 (default, Nov  5 2020, 15:37:44) 
[Clang 11.0.0 (clang-1100.0.33.16)]
macOS-10.15.7-x86_64-i386-64bit
scikit-image version: 0.18.1
numpy version: 1.20.2

FYI @rfezzani - Somewhat similar to #5047

@rfezzani
Copy link
Member

Thank you @odoublewen for reporting, I will investigate ASAP 😉

@memoryleine
Copy link

memoryleine commented May 28, 2021

This seems similar to #5235 as well? I remember because I ran into the same problem recently and discovered that issue when I was trying to figure it out.

@rfezzani
Copy link
Member

rfezzani commented Jun 7, 2021

@memoryleine, I can't reproduce the bug with current skimage dev version:

>>> import skimage
>>> from skimage import feature
>>> import numpy as np
>>> 
>>> print("skimage version")
skimage version
>>> print(skimage.__version__)
0.19.0.dev0
>>> 
>>> im = np.genfromtxt('im_int.txt')
>>> labels = np.genfromtxt('labels_int.txt', dtype=int)
>>> 
>>> print("image before calling feature.peak_local_max")
image before calling feature.peak_local_max
>>> print(im)
[[1145. 1136. 1041. ... 1055.  999. 1153.]
 [1115. 1107. 1073. ... 1001. 1060. 1114.]
 [1091. 1065. 1069. ...  927. 1124. 1109.]
 ...
 [1110. 1168.  908. ... 1149.  917.  953.]
 [1045. 1104.  937. ... 1057. 1094.  916.]
 [ 793.  954. 1128. ... 1013. 1018.  983.]]
>>> print(np.min(im))
793.0
>>> 
>>> peaks = feature.peak_local_max(im, labels=labels, num_peaks_per_label=1, exclude_border=False)
>>> 
>>> print("image after calling feature.peak_local_max")
image after calling feature.peak_local_max
>>> print(im)
[[1145. 1136. 1041. ... 1055.  999. 1153.]
 [1115. 1107. 1073. ... 1001. 1060. 1114.]
 [1091. 1065. 1069. ...  927. 1124. 1109.]
 ...
 [1110. 1168.  908. ... 1149.  917.  953.]
 [1045. 1104.  937. ... 1057. 1094.  916.]
 [ 793.  954. 1128. ... 1013. 1018.  983.]]
>>> print(np.min(im))
793.0

I will investigate more concerning v18 😉 .

@rfezzani
Copy link
Member

rfezzani commented Jun 7, 2021

OK, as @memoryleine pointed out 👏, this bug is already reported in #5235 and it is fixed by #5236 😉. I will close this issue as it is already fixed. Thank you again @odoublewen for reporting.

@rfezzani rfezzani closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants