[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73HBZ997Z17CTHVR2GVCQ97":3,"skill-same:01M73HBZ997Z17CTHVR2GVCQ97":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73HBZ997Z17CTHVR2GVCQ97","napari-image-viewer",null,"Interactive viewer for microscopy. Displays 2D\u002F3D\u002F4D arrays as Image, Labels, Points, Shapes, Tracks layers; supports annotation, plugin analysis, headless screenshots. Core visualization for Python bioimage workflows. Use ImageJ\u002FFIJI for macro processing; napari for Python-native interactive visualization and DL segmentation review.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"BSD-3-Clause","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fnapari-image-viewer\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"napari-image-viewer\"\ndescription: \"Interactive viewer for microscopy. Displays 2D\u002F3D\u002F4D arrays as Image, Labels, Points, Shapes, Tracks layers; supports annotation, plugin analysis, headless screenshots. Core visualization for Python bioimage workflows. Use ImageJ\u002FFIJI for macro processing; napari for Python-native interactive visualization and DL segmentation review.\"\nlicense: \"BSD-3-Clause\"\n---\n\n# napari — Multi-dimensional Image Viewer\n\n## Overview\n\nnapari is a fast, interactive multi-dimensional viewer for scientific data built on PyQt5 and VisPy. It displays NumPy arrays and zarr arrays as layered visualizations — Image layers for raw data, Labels layers for segmentation masks, Points layers for cell centroids, and Shapes layers for ROI annotations. napari integrates with scikit-image, Cellpose, and StarDist via plugins, making it the standard visualization and annotation tool in Python bioimage analysis pipelines. For headless environments (HPC, CI), napari supports offscreen rendering and `viewer.screenshot()` for automated figure generation.\n\n## When to Use\n\n- Visually inspecting and quality-checking microscopy images and segmentation masks before quantitative analysis\n- Annotating training data for deep learning segmentation models (Cellpose, StarDist)\n- Overlaying multiple image channels (DAPI, GFP, mCherry) with independent contrast and colormap control\n- Reviewing 3D z-stacks and 4D time-lapse experiments with slider-based navigation\n- Exporting annotated screenshots or label masks from GUI for publication figures\n- Running plugin-based analysis (Cellpose napari plugin, StarDist plugin, n2v denoising) interactively\n- Use **ImageJ\u002FFIJI** for macro\u002Fbatch scripting with minimal Python dependency\n- Use **ITK-SNAP** as an alternative for medical imaging (DICOM, NIfTI) segmentation\n\n## Prerequisites\n\n- **Python packages**: `napari`, `numpy`, `scikit-image`\n- **Qt backend**: requires display server; for headless use `QT_QPA_PLATFORM=offscreen`\n- **Optional plugins**: `napari-cellpose`, `napari-stardist`, `napari-animation`\n\n```bash\n# Install with all backends\npip install \"napari[all]\"\n\n# Or minimal install\npip install napari pyqt5\n\n# Verify\npython -c \"import napari; print(napari.__version__)\"\n# 0.5.5\n\n# Install useful plugins\npip install napari-cellpose napari-animation\n```\n\n## Quick Start\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import data\n\n# Open viewer with a sample image\nviewer = napari.Viewer()\nviewer.add_image(data.cells3d()[:, 1, :, :], name=\"DAPI\", colormap=\"blue\")\nnapari.run()   # blocks until viewer closed (use in scripts)\n```\n\n## Core API\n\n### Module 1: Image Layer — Display Raw Images\n\nAdd and configure multi-channel image layers.\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import io\n\nviewer = napari.Viewer()\n\n# Add single grayscale image\nimg = io.imread(\"cells.tif\")  # shape: (H, W)\nviewer.add_image(img, name=\"phase contrast\", colormap=\"gray\",\n                 contrast_limits=[0, img.max()])\n\n# Add multichannel image (3 channels)\nimg_mc = io.imread(\"multichannel.tif\")  # shape: (H, W, 3)\nviewer.add_image(img_mc[..., 0], name=\"DAPI\", colormap=\"blue\", blending=\"additive\")\nviewer.add_image(img_mc[..., 1], name=\"GFP\", colormap=\"green\", blending=\"additive\")\nviewer.add_image(img_mc[..., 2], name=\"mCherry\", colormap=\"red\", blending=\"additive\")\n\nprint(f\"Layers: {[l.name for l in viewer.layers]}\")\n```\n\n### Module 2: Labels Layer — Visualize Segmentation Masks\n\nDisplay and edit integer label masks from Cellpose, StarDist, or scikit-image.\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import io\n\nviewer = napari.Viewer()\n\nimg = io.imread(\"cells.tif\")\nmasks = np.load(\"masks.npy\")  # integer label array: 0=background, 1..N=cells\n\n# Add raw image\nviewer.add_image(img, name=\"raw\", colormap=\"gray\")\n\n# Add label mask (each cell gets a unique random color)\nlabel_layer = viewer.add_labels(masks, name=\"cell_masks\", opacity=0.5)\n\n# Access labels for editing\nprint(f\"Unique cells: {len(np.unique(masks)) - 1}\")\nprint(f\"Label layer data shape: {label_layer.data.shape}\")\n```\n\n### Module 3: Points Layer — Mark Cell Centroids\n\nAdd and style point markers for centroids, landmarks, or detected features.\n\n```python\nimport napari\nimport numpy as np\nimport pandas as pd\nfrom skimage.measure import regionprops_table\n\nviewer = napari.Viewer()\n\n# Compute centroids from label mask\nmasks = np.load(\"masks.npy\")\nprops = regionprops_table(masks, properties=[\"centroid\", \"label\"])\ncentroids = np.column_stack([props[\"centroid-0\"], props[\"centroid-1\"]])\n\n# Add centroids as Points layer\nviewer.add_points(\n    centroids,\n    name=f\"centroids ({len(centroids)} cells)\",\n    size=8,\n    face_color=\"yellow\",\n    edge_color=\"black\",\n    edge_width=0.5,\n)\nprint(f\"Cells marked: {len(centroids)}\")\n```\n\n### Module 4: Shapes Layer — Draw ROIs and Annotations\n\nAdd bounding boxes, polygons, and line annotations.\n\n```python\nimport napari\nimport numpy as np\n\nviewer = napari.Viewer()\n\n# Add rectangles as ROIs (format: [[y1, x1], [y2, x2]])\nrois = [\n    np.array([[50, 100], [200, 300]]),   # ROI 1\n    np.array([[300, 150], [450, 350]]),  # ROI 2\n]\n\nshapes_layer = viewer.add_shapes(\n    rois,\n    shape_type=\"rectangle\",\n    name=\"ROIs\",\n    edge_color=\"cyan\",\n    face_color=\"transparent\",\n    edge_width=2,\n)\n\n# Retrieve shapes data for analysis\nfor i, shape in enumerate(shapes_layer.data):\n    y_min, x_min = shape.min(axis=0)\n    y_max, x_max = shape.max(axis=0)\n    print(f\"ROI {i+1}: y={y_min:.0f}-{y_max:.0f}, x={x_min:.0f}-{x_max:.0f}\")\n```\n\n### Module 5: 3D and Time-lapse Visualization\n\nDisplay z-stacks and time series with sliders.\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import data\n\nviewer = napari.Viewer()\n\n# 3D z-stack: shape (Z, H, W)\nzstack = data.cells3d()[:, 1, :, :]   # nuclei channel\nviewer.add_image(zstack, name=\"z-stack nuclei\",\n                 colormap=\"cyan\", blending=\"additive\")\n\n# 4D time-lapse: shape (T, H, W) or (T, Z, H, W)\ntimelapse = np.random.randint(0, 65535, (10, 256, 256), dtype=np.uint16)\nviewer.add_image(timelapse, name=\"timelapse\", colormap=\"gray\")\n\n# napari shows axis sliders automatically for ndim > 2\nprint(f\"z-stack shape: {zstack.shape} → slider for Z axis\")\nprint(f\"timelapse shape: {timelapse.shape} → sliders for T axis\")\n```\n\n### Module 6: Headless Screenshot Export\n\nExport screenshots without a display (for HPC and CI environments).\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"  # must be set BEFORE importing napari\n\nimport napari\nimport numpy as np\nfrom skimage import io, data\nimport matplotlib\nmatplotlib.use(\"Agg\")  # also set matplotlib backend\n\nviewer = napari.Viewer(show=False)\n\nimg = data.cells3d()[30, 1, :, :]  # single z-slice\nmasks = (img > img.mean()).astype(int)  # simple threshold mask\n\nviewer.add_image(img, name=\"DAPI\", colormap=\"blue\", blending=\"additive\")\nviewer.add_labels(masks.astype(np.int32), name=\"masks\", opacity=0.5)\n\n# Export screenshot\nscreenshot = viewer.screenshot(path=\"napari_export.png\", canvas_only=True)\nprint(f\"Screenshot saved: napari_export.png ({screenshot.shape})\")\nviewer.close()\n```\n\n## Key Parameters\n\n| Parameter | Module | Default | Effect |\n|-----------|--------|---------|--------|\n| `colormap` | `add_image` | `\"gray\"` | Colormap name (matplotlib cmaps + napari built-ins: \"green\", \"blue\", \"cyan\") |\n| `contrast_limits` | `add_image` | auto | `[min, max]` intensity clipping for display |\n| `blending` | `add_image` | `\"translucent\"` | `\"additive\"` for multichannel overlay; `\"opaque\"` for solid |\n| `opacity` | `add_labels` | `0.7` | 0–1 transparency of label layer over image |\n| `face_color` | `add_points` | `\"white\"` | Point fill color (name, hex, or RGBA) |\n| `size` | `add_points` | `10` | Point radius in data coordinates (pixels) |\n| `edge_width` | `add_shapes` | `1` | Shape outline width in pixels |\n| `show` | `Viewer()` | `True` | `False` for headless\u002Foffscreen mode |\n| `ndisplay` | `Viewer()` | `2` | `3` for 3D OpenGL rendering mode |\n| `canvas_only` | `screenshot()` | `False` | `True` to exclude the napari toolbar from export |\n\n## Common Workflows\n\n### Workflow 1: Review Cellpose Segmentation Quality\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n\nimport napari\nimport numpy as np\nfrom cellpose import models\nfrom skimage import io\nfrom skimage.measure import regionprops_table\n\n# Segment with Cellpose\nimg = io.imread(\"cells.tif\")\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\nmasks, _, _, diams = model.eval(img, diameter=0, channels=[0, 0])\n\n# Visualize in napari (headless for export)\nviewer = napari.Viewer(show=False)\nviewer.add_image(img, name=\"raw\", colormap=\"gray\")\nviewer.add_labels(masks, name=f\"masks ({masks.max()} cells)\", opacity=0.6)\n\n# Add centroids\nprops = regionprops_table(masks, properties=[\"centroid\"])\ncentroids = np.column_stack([props[\"centroid-0\"], props[\"centroid-1\"]])\nviewer.add_points(centroids, name=\"centroids\", size=6, face_color=\"yellow\")\n\nviewer.screenshot(path=\"segmentation_review.png\", canvas_only=True)\nviewer.close()\nprint(f\"QC export: segmentation_review.png — {masks.max()} cells detected\")\n```\n\n### Workflow 2: Multi-channel FISH Image Analysis\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import io\n\n# Load 4-channel FISH image: DAPI + 3 RNA probes\nimg = io.imread(\"fish_4channel.tif\")  # shape: (H, W, 4)\n\nviewer = napari.Viewer()\nchannels = [\n    (\"DAPI\", \"blue\", img[..., 0]),\n    (\"probe_A_cy3\", \"yellow\", img[..., 1]),\n    (\"probe_B_cy5\", \"red\", img[..., 2]),\n    (\"probe_C_gfp\", \"green\", img[..., 3]),\n]\n\nfor name, colormap, channel in channels:\n    viewer.add_image(channel, name=name, colormap=colormap,\n                     blending=\"additive\",\n                     contrast_limits=[channel.min(), np.percentile(channel, 99.5)])\n\nnapari.run()\n```\n\n## Common Recipes\n\n### Recipe 1: Export All Layers as Annotated Figure\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n\nimport napari\nimport numpy as np\nfrom skimage import io\nimport matplotlib.pyplot as plt\n\nviewer = napari.Viewer(show=False)\n\nimg = io.imread(\"cells.tif\")\nmasks = np.load(\"masks.npy\")\n\nviewer.add_image(img, name=\"raw\", colormap=\"gray\")\nviewer.add_labels(masks, name=\"segmentation\", opacity=0.5)\n\n# Set camera zoom and position\nviewer.camera.zoom = 1.5\nviewer.camera.center = (img.shape[0] \u002F\u002F 2, img.shape[1] \u002F\u002F 2)\n\nscreenshot = viewer.screenshot(path=\"figure_panel.png\", canvas_only=True)\nviewer.close()\n\n# Add scalebar with matplotlib\nfig, ax = plt.subplots(figsize=(6, 6))\nax.imshow(screenshot)\nax.axis(\"off\")\nplt.tight_layout()\nplt.savefig(\"figure_final.pdf\", dpi=300, bbox_inches=\"tight\")\nprint(\"Exported: figure_final.pdf\")\n```\n\n### Recipe 2: Batch Export Z-stack Projections\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n\nimport napari\nimport numpy as np\nfrom skimage import io\nfrom pathlib import Path\n\noutput_dir = Path(\"projections\")\noutput_dir.mkdir(exist_ok=True)\n\nfor img_path in sorted(Path(\"zstacks\").glob(\"*.tif\")):\n    zstack = io.imread(img_path)  # shape: (Z, H, W)\n    max_proj = zstack.max(axis=0)\n    \n    viewer = napari.Viewer(show=False)\n    viewer.add_image(max_proj, name=\"max_projection\", colormap=\"gray\")\n    viewer.screenshot(path=str(output_dir \u002F f\"{img_path.stem}_maxproj.png\"), canvas_only=True)\n    viewer.close()\n    print(f\"Exported: {img_path.stem}_maxproj.png\")\n\nprint(\"All z-stack projections exported.\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `qt.qpa.plugin: Could not load the Qt platform plugin \"xcb\"` | Missing display or Qt platform plugin | Set `QT_QPA_PLATFORM=offscreen` before importing napari; install `libxcb-util-dev` |\n| napari window does not open | Running in SSH without X forwarding | Use `viewer = napari.Viewer(show=False)` and export via `screenshot()` |\n| Slow rendering of large images | Image too large for GPU VRAM | Use `viewer.add_image(img, multiscale=True)` for pyramidal rendering |\n| Labels layer shows wrong colors | Mask dtype overflow | Ensure masks are `int32` not `uint8` (overflow at 255 cells) |\n| `napari.run()` blocks Jupyter notebook | Qt event loop conflict | Use `%gui qt` magic in Jupyter; or use `viewer.show()` without `napari.run()` |\n| Screenshot is black\u002Fempty | Viewer not fully rendered before screenshot | Add `viewer.update()` or slight delay before `screenshot()` |\n| Plugin not appearing in menu | Plugin not installed or wrong napari version | `pip install napari-\u003Cplugin>`; check napari version compatibility on napari-hub |\n| 3D rendering slow | Complex geometry or large volume | Switch `viewer.dims.ndisplay = 2`; reduce z-stack depth |\n\n## References\n\n- [napari documentation](https:\u002F\u002Fnapari.org\u002Fstable\u002F) — official API reference and tutorials\n- [napari GitHub: napari\u002Fnapari](https:\u002F\u002Fgithub.com\u002Fnapari\u002Fnapari) — source code and plugin development guide\n- Sofroniew N et al. (2022) \"napari: a multi-dimensional image viewer for Python\" — *Zenodo*. [DOI:10.5281\u002Fzenodo.3555620](https:\u002F\u002Fdoi.org\u002F10.5281\u002Fzenodo.3555620)\n- [napari-hub](https:\u002F\u002Fwww.napari-hub.org\u002F) — plugin registry with 300+ community analysis plugins\n","# napari — Multi-dimensional Image Viewer\n\n## Overview\n\nnapari is a fast, interactive multi-dimensional viewer for scientific data built on PyQt5 and VisPy. It displays NumPy arrays and zarr arrays as layered visualizations — Image layers for raw data, Labels layers for segmentation masks, Points layers for cell centroids, and Shapes layers for ROI annotations. napari integrates with scikit-image, Cellpose, and StarDist via plugins, making it the standard visualization and annotation tool in Python bioimage analysis pipelines. For headless environments (HPC, CI), napari supports offscreen rendering and `viewer.screenshot()` for automated figure generation.\n\n## When to Use\n\n- Visually inspecting and quality-checking microscopy images and segmentation masks before quantitative analysis\n- Annotating training data for deep learning segmentation models (Cellpose, StarDist)\n- Overlaying multiple image channels (DAPI, GFP, mCherry) with independent contrast and colormap control\n- Reviewing 3D z-stacks and 4D time-lapse experiments with slider-based navigation\n- Exporting annotated screenshots or label masks from GUI for publication figures\n- Running plugin-based analysis (Cellpose napari plugin, StarDist plugin, n2v denoising) interactively\n- Use **ImageJ\u002FFIJI** for macro\u002Fbatch scripting with minimal Python dependency\n- Use **ITK-SNAP** as an alternative for medical imaging (DICOM, NIfTI) segmentation\n\n## Prerequisites\n\n- **Python packages**: `napari`, `numpy`, `scikit-image`\n- **Qt backend**: requires display server; for headless use `QT_QPA_PLATFORM=offscreen`\n- **Optional plugins**: `napari-cellpose`, `napari-stardist`, `napari-animation`\n\n```bash\n# Install with all backends\npip install \"napari[all]\"\n\n# Or minimal install\npip install napari pyqt5\n\n# Verify\npython -c \"import napari; print(napari.__version__)\"\n# 0.5.5\n\n# Install useful plugins\npip install napari-cellpose napari-animation\n```\n\n## Quick Start\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import data\n\n# Open viewer with a sample image\nviewer = napari.Viewer()\nviewer.add_image(data.cells3d()[:, 1, :, :], name=\"DAPI\", colormap=\"blue\")\nnapari.run()   # blocks until viewer closed (use in scripts)\n```\n\n## Core API\n\n### Module 1: Image Layer — Display Raw Images\n\nAdd and configure multi-channel image layers.\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import io\n\nviewer = napari.Viewer()\n\n# Add single grayscale image\nimg = io.imread(\"cells.tif\")  # shape: (H, W)\nviewer.add_image(img, name=\"phase contrast\", colormap=\"gray\",\n                 contrast_limits=[0, img.max()])\n\n# Add multichannel image (3 channels)\nimg_mc = io.imread(\"multichannel.tif\")  # shape: (H, W, 3)\nviewer.add_image(img_mc[..., 0], name=\"DAPI\", colormap=\"blue\", blending=\"additive\")\nviewer.add_image(img_mc[..., 1], name=\"GFP\", colormap=\"green\", blending=\"additive\")\nviewer.add_image(img_mc[..., 2], name=\"mCherry\", colormap=\"red\", blending=\"additive\")\n\nprint(f\"Layers: {[l.name for l in viewer.layers]}\")\n```\n\n### Module 2: Labels Layer — Visualize Segmentation Masks\n\nDisplay and edit integer label masks from Cellpose, StarDist, or scikit-image.\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import io\n\nviewer = napari.Viewer()\n\nimg = io.imread(\"cells.tif\")\nmasks = np.load(\"masks.npy\")  # integer label array: 0=background, 1..N=cells\n\n# Add raw image\nviewer.add_image(img, name=\"raw\", colormap=\"gray\")\n\n# Add label mask (each cell gets a unique random color)\nlabel_layer = viewer.add_labels(masks, name=\"cell_masks\", opacity=0.5)\n\n# Access labels for editing\nprint(f\"Unique cells: {len(np.unique(masks)) - 1}\")\nprint(f\"Label layer data shape: {label_layer.data.shape}\")\n```\n\n### Module 3: Points Layer — Mark Cell Centroids\n\nAdd and style point markers for centroids, landmarks, or detected features.\n\n```python\nimport napari\nimport numpy as np\nimport pandas as pd\nfrom skimage.measure import regionprops_table\n\nviewer = napari.Viewer()\n\n# Compute centroids from label mask\nmasks = np.load(\"masks.npy\")\nprops = regionprops_table(masks, properties=[\"centroid\", \"label\"])\ncentroids = np.column_stack([props[\"centroid-0\"], props[\"centroid-1\"]])\n\n# Add centroids as Points layer\nviewer.add_points(\n    centroids,\n    name=f\"centroids ({len(centroids)} cells)\",\n    size=8,\n    face_color=\"yellow\",\n    edge_color=\"black\",\n    edge_width=0.5,\n)\nprint(f\"Cells marked: {len(centroids)}\")\n```\n\n### Module 4: Shapes Layer — Draw ROIs and Annotations\n\nAdd bounding boxes, polygons, and line annotations.\n\n```python\nimport napari\nimport numpy as np\n\nviewer = napari.Viewer()\n\n# Add rectangles as ROIs (format: [[y1, x1], [y2, x2]])\nrois = [\n    np.array([[50, 100], [200, 300]]),   # ROI 1\n    np.array([[300, 150], [450, 350]]),  # ROI 2\n]\n\nshapes_layer = viewer.add_shapes(\n    rois,\n    shape_type=\"rectangle\",\n    name=\"ROIs\",\n    edge_color=\"cyan\",\n    face_color=\"transparent\",\n    edge_width=2,\n)\n\n# Retrieve shapes data for analysis\nfor i, shape in enumerate(shapes_layer.data):\n    y_min, x_min = shape.min(axis=0)\n    y_max, x_max = shape.max(axis=0)\n    print(f\"ROI {i+1}: y={y_min:.0f}-{y_max:.0f}, x={x_min:.0f}-{x_max:.0f}\")\n```\n\n### Module 5: 3D and Time-lapse Visualization\n\nDisplay z-stacks and time series with sliders.\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import data\n\nviewer = napari.Viewer()\n\n# 3D z-stack: shape (Z, H, W)\nzstack = data.cells3d()[:, 1, :, :]   # nuclei channel\nviewer.add_image(zstack, name=\"z-stack nuclei\",\n                 colormap=\"cyan\", blending=\"additive\")\n\n# 4D time-lapse: shape (T, H, W) or (T, Z, H, W)\ntimelapse = np.random.randint(0, 65535, (10, 256, 256), dtype=np.uint16)\nviewer.add_image(timelapse, name=\"timelapse\", colormap=\"gray\")\n\n# napari shows axis sliders automatically for ndim > 2\nprint(f\"z-stack shape: {zstack.shape} → slider for Z axis\")\nprint(f\"timelapse shape: {timelapse.shape} → sliders for T axis\")\n```\n\n### Module 6: Headless Screenshot Export\n\nExport screenshots without a display (for HPC and CI environments).\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"  # must be set BEFORE importing napari\n\nimport napari\nimport numpy as np\nfrom skimage import io, data\nimport matplotlib\nmatplotlib.use(\"Agg\")  # also set matplotlib backend\n\nviewer = napari.Viewer(show=False)\n\nimg = data.cells3d()[30, 1, :, :]  # single z-slice\nmasks = (img > img.mean()).astype(int)  # simple threshold mask\n\nviewer.add_image(img, name=\"DAPI\", colormap=\"blue\", blending=\"additive\")\nviewer.add_labels(masks.astype(np.int32), name=\"masks\", opacity=0.5)\n\n# Export screenshot\nscreenshot = viewer.screenshot(path=\"napari_export.png\", canvas_only=True)\nprint(f\"Screenshot saved: napari_export.png ({screenshot.shape})\")\nviewer.close()\n```\n\n## Key Parameters\n\n| Parameter | Module | Default | Effect |\n|-----------|--------|---------|--------|\n| `colormap` | `add_image` | `\"gray\"` | Colormap name (matplotlib cmaps + napari built-ins: \"green\", \"blue\", \"cyan\") |\n| `contrast_limits` | `add_image` | auto | `[min, max]` intensity clipping for display |\n| `blending` | `add_image` | `\"translucent\"` | `\"additive\"` for multichannel overlay; `\"opaque\"` for solid |\n| `opacity` | `add_labels` | `0.7` | 0–1 transparency of label layer over image |\n| `face_color` | `add_points` | `\"white\"` | Point fill color (name, hex, or RGBA) |\n| `size` | `add_points` | `10` | Point radius in data coordinates (pixels) |\n| `edge_width` | `add_shapes` | `1` | Shape outline width in pixels |\n| `show` | `Viewer()` | `True` | `False` for headless\u002Foffscreen mode |\n| `ndisplay` | `Viewer()` | `2` | `3` for 3D OpenGL rendering mode |\n| `canvas_only` | `screenshot()` | `False` | `True` to exclude the napari toolbar from export |\n\n## Common Workflows\n\n### Workflow 1: Review Cellpose Segmentation Quality\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n\nimport napari\nimport numpy as np\nfrom cellpose import models\nfrom skimage import io\nfrom skimage.measure import regionprops_table\n\n# Segment with Cellpose\nimg = io.imread(\"cells.tif\")\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\nmasks, _, _, diams = model.eval(img, diameter=0, channels=[0, 0])\n\n# Visualize in napari (headless for export)\nviewer = napari.Viewer(show=False)\nviewer.add_image(img, name=\"raw\", colormap=\"gray\")\nviewer.add_labels(masks, name=f\"masks ({masks.max()} cells)\", opacity=0.6)\n\n# Add centroids\nprops = regionprops_table(masks, properties=[\"centroid\"])\ncentroids = np.column_stack([props[\"centroid-0\"], props[\"centroid-1\"]])\nviewer.add_points(centroids, name=\"centroids\", size=6, face_color=\"yellow\")\n\nviewer.screenshot(path=\"segmentation_review.png\", canvas_only=True)\nviewer.close()\nprint(f\"QC export: segmentation_review.png — {masks.max()} cells detected\")\n```\n\n### Workflow 2: Multi-channel FISH Image Analysis\n\n```python\nimport napari\nimport numpy as np\nfrom skimage import io\n\n# Load 4-channel FISH image: DAPI + 3 RNA probes\nimg = io.imread(\"fish_4channel.tif\")  # shape: (H, W, 4)\n\nviewer = napari.Viewer()\nchannels = [\n    (\"DAPI\", \"blue\", img[..., 0]),\n    (\"probe_A_cy3\", \"yellow\", img[..., 1]),\n    (\"probe_B_cy5\", \"red\", img[..., 2]),\n    (\"probe_C_gfp\", \"green\", img[..., 3]),\n]\n\nfor name, colormap, channel in channels:\n    viewer.add_image(channel, name=name, colormap=colormap,\n                     blending=\"additive\",\n                     contrast_limits=[channel.min(), np.percentile(channel, 99.5)])\n\nnapari.run()\n```\n\n## Common Recipes\n\n### Recipe 1: Export All Layers as Annotated Figure\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n\nimport napari\nimport numpy as np\nfrom skimage import io\nimport matplotlib.pyplot as plt\n\nviewer = napari.Viewer(show=False)\n\nimg = io.imread(\"cells.tif\")\nmasks = np.load(\"masks.npy\")\n\nviewer.add_image(img, name=\"raw\", colormap=\"gray\")\nviewer.add_labels(masks, name=\"segmentation\", opacity=0.5)\n\n# Set camera zoom and position\nviewer.camera.zoom = 1.5\nviewer.camera.center = (img.shape[0] \u002F\u002F 2, img.shape[1] \u002F\u002F 2)\n\nscreenshot = viewer.screenshot(path=\"figure_panel.png\", canvas_only=True)\nviewer.close()\n\n# Add scalebar with matplotlib\nfig, ax = plt.subplots(figsize=(6, 6))\nax.imshow(screenshot)\nax.axis(\"off\")\nplt.tight_layout()\nplt.savefig(\"figure_final.pdf\", dpi=300, bbox_inches=\"tight\")\nprint(\"Exported: figure_final.pdf\")\n```\n\n### Recipe 2: Batch Export Z-stack Projections\n\n```python\nimport os\nos.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n\nimport napari\nimport numpy as np\nfrom skimage import io\nfrom pathlib import Path\n\noutput_dir = Path(\"projections\")\noutput_dir.mkdir(exist_ok=True)\n\nfor img_path in sorted(Path(\"zstacks\").glob(\"*.tif\")):\n    zstack = io.imread(img_path)  # shape: (Z, H, W)\n    max_proj = zstack.max(axis=0)\n    \n    viewer = napari.Viewer(show=False)\n    viewer.add_image(max_proj, name=\"max_projection\", colormap=\"gray\")\n    viewer.screenshot(path=str(output_dir \u002F f\"{img_path.stem}_maxproj.png\"), canvas_only=True)\n    viewer.close()\n    print(f\"Exported: {img_path.stem}_maxproj.png\")\n\nprint(\"All z-stack projections exported.\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `qt.qpa.plugin: Could not load the Qt platform plugin \"xcb\"` | Missing display or Qt platform plugin | Set `QT_QPA_PLATFORM=offscreen` before importing napari; install `libxcb-util-dev` |\n| napari window does not open | Running in SSH without X forwarding | Use `viewer = napari.Viewer(show=False)` and export via `screenshot()` |\n| Slow rendering of large images | Image too large for GPU VRAM | Use `viewer.add_image(img, multiscale=True)` for pyramidal rendering |\n| Labels layer shows wrong colors | Mask dtype overflow | Ensure masks are `int32` not `uint8` (overflow at 255 cells) |\n| `napari.run()` blocks Jupyter notebook | Qt event loop conflict | Use `%gui qt` magic in Jupyter; or use `viewer.show()` without `napari.run()` |\n| Screenshot is black\u002Fempty | Viewer not fully rendered before screenshot | Add `viewer.update()` or slight delay before `screenshot()` |\n| Plugin not appearing in menu | Plugin not installed or wrong napari version | `pip install napari-\u003Cplugin>`; check napari version compatibility on napari-hub |\n| 3D rendering slow | Complex geometry or large volume | Switch `viewer.dims.ndisplay = 2`; reduce z-stack depth |\n\n## References\n\n- [napari documentation](https:\u002F\u002Fnapari.org\u002Fstable\u002F) — official API reference and tutorials\n- [napari GitHub: napari\u002Fnapari](https:\u002F\u002Fgithub.com\u002Fnapari\u002Fnapari) — source code and plugin development guide\n- Sofroniew N et al. (2022) \"napari: a multi-dimensional image viewer for Python\" — *Zenodo*. [DOI:10.5281\u002Fzenodo.3555620](https:\u002F\u002Fdoi.org\u002F10.5281\u002Fzenodo.3555620)\n- [napari-hub](https:\u002F\u002Fwww.napari-hub.org\u002F) — plugin registry with 300+ community analysis plugins\n",{"name":5,"license":15,"description":7},"master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fawesome-skills\u002Fnapari-image-viewer",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill napari-image-viewer",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill napari-image-viewer",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill napari-image-viewer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fnapari-image-viewer\u002FSKILL.md",true,[],[49,58,65,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]