question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Labels layer with autogenerated pyramid levels shows artifacts

See original GitHub issue

🐛 Bug

When loading a label layer with multiscale pyramids (e.g. from ome-zarr), randomly colored pixels can occur at the contours of labeled regions. This indicates additional label values differing from the labeled region’s value, which might be caused by downsampling with interpolation or antialiasing.

image

In my case I originally used skimage.transform.rescale(array, scale=0.5, order=0, anti_aliasing=False, preserve_range=True).astype(np.uint). I could confirm that all my multiscale levels were all uint images with the same set of values.

This seems to be caused when Napari autogenerates additional multiscale levels (the ome-zarr file might contain just as many levels as considered sufficient by the generator, but may still be valid). The downscaling method does maybe not visually impact normal image layers, but for labels layers it does, since arbitrary colors can be assigned to regions.

To Reproduce

Steps to reproduce the behavior:

import napari
import numpy as np
from skimage.draw import circle

# Draw a curved segmentation with a label value greater 1. Due to varying boundary 
# direction, incorrect downsampling will produce a range of intensity values.
label_image_0 = np.zeros((2048, 2048), dtype=np.uint)
label_image_0[circle(r=1024, c=1024, radius=1000)] = 10
label_image_1 = np.zeros((1024, 1024), dtype=np.uint)
label_image_1[circle(r=512, c=512, radius=500)] = 10
pyramid = [label_image_0, label_image_1]

viewer = napari.Viewer()
viewer.add_labels(pyramid, name="label_image")
napari.run()

Expected behavior

When zooming in and out, a each region should be displayed with a single color without that boundary pixels change color.

Environment

napari: 0.4.9 Platform: Linux-5.4.0-74-generic-x86_64-with-glibc2.10 System: Ubuntu 18.04.5 LTS Python: 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0] Qt: 5.15.2 PyQt5: 5.15.2 NumPy: 1.20.1 SciPy: 1.6.1 Dask: 2021.01.1 VisPy: 0.6.6

OpenGL:

  • GL version: 4.6.0 NVIDIA 390.143
  • MAX_TEXTURE_SIZE: 16384

Screens:

  • screen 1: resolution 1920x1200, scale 1.0
  • screen 2: resolution 1920x1200, scale 1.0

Plugins:

  • console: 0.0.3
  • napari-ome-zarr: 0.1.1
  • scikit-image: 0.4.9
  • svg: 0.1.4

Additional context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nclackcommented, Jul 9, 2021

ah. I’ll take a look.

1reaction
aeisenbarthcommented, Jul 9, 2021

I tried again and I noticed that an environment variable was set, namely NAPARI_OCTREE=1 as workaround for https://github.com/napari/napari/issues/1942.

When set to 0, the issue does not occur. So it seems not to be a bug in the default code, but probably only in the octree code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SMART Art Pyramid - YouTube
Video showing how to create a pyramid with graphics using SMART Art in PowerPoint.
Read more >
Inside the Archaeology Lab: Labeling Artifacts - YouTube
This analytical work is done in an archaeology lab, where it is vital to keep the artifacts organized. This video shows how artifacts...
Read more >
Working With the Artifact Labels Grid - Oracle Help Center
Click Tools, and then click Artifact Labels. To filter: Click filter icon , and then select the artifacts you want to work with....
Read more >
Label-Conditioned Next-Frame Video Generation with Neural ...
work, we propose using a state-of-the-art neural flow generator ... ReLU layer in the pyramid halves the width and height while.
Read more >
US11074478B2 - Image classification and labeling - Google Patents
Some IP registration systems may use single level (non-hierarchical) systems ... maps—intermediate network layers and/or auto generated semantic labels).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found