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 modifies input image #5235

Closed
simone-codeluppi opened this issue Feb 12, 2021 · 1 comment · Fixed by #5236
Closed

feature.peak_local_max modifies input image #5235

simone-codeluppi opened this issue Feb 12, 2021 · 1 comment · Fixed by #5236

Comments

@simone-codeluppi
Copy link

Description

Hi
I am processing a float image (linked below) to detect peaks.
When i call feature.peak_local_max without defining labels everything is fine. If I define labels the call to feature.peak_local_max causes a change in the intensity values (adding/changing the value of some pixels to 1.7976931348623157e+308) of the image processed. I can replicate the issue with skimage 0.18.0 and 0.18.1 however everything works fine with skimage 0.17.2. Please let me know if I missed anything because I cannot wrap my head around the issue. Thanks!

File to reproduce the issue

img_path_dropbox = get image from here

Way to reproduce

from skimage import feature, measure
from scipy import ndimage as nd

def test(img):
    print(f'min value original: {img.min()}')
    thr = 2.208
    img_mask = img>thr
        
    labels = nd.label(img_mask)[0]
            
    properties = measure.regionprops(labels)
                
    for ob in properties:
        if ob.area< 10 or ob.area>600:
            img_mask[ob.coords[:,0],ob.coords[:,1]]=0

    labels = nd.label(img_mask)[0]
    properties = measure.regionprops(labels,intensity_image=img)

    selected_peaks = feature.peak_local_max(img, min_distance=5, 
                            threshold_abs=thr, exclude_border=True, 
                            footprint=None,num_peaks_per_label=1)

    print(f'min value after peak calling no labels: {img.min()}')

    selected_peaks = feature.peak_local_max(img, min_distance=5, 
                            threshold_abs=thr, exclude_border=True, 
                            footprint=None, labels=labels,num_peaks_per_label=1)
    
    print(f'min value after peak calling using labels: {img.min()}')
    return selected_peaks


img, meta = pickle.load(open(path-to-img ,'rb'))
pk = test(img, thr)

# RESULT 
# min value original: 0.2976309153266585
# min value after peak calling no labels: 0.2976309153266585
# min value after peak calling using labels: -1.7976931348623157e+308

Version information

3.8.2 (default, May  7 2020, 20:00:49)
[GCC 7.3.0]
Linux-3.10.0-957.1.3.el7.x86_64-x86_64-with-glibc2.10
scikit-image version: 0.18.0
# same error in scikit-image version: 0.18.1
# everything works fine in version 0.17.2
numpy version: 1.19.4
@rfezzani
Copy link
Member

Thank you @simone-codeluppi for the report. I confirm the bug, I can reproduce 😖

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

Successfully merging a pull request may close this issue.

2 participants