# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ## Proof of concept using Imviz to display RGB layers

# We start off by silencing warnings that can happen when loading data as well as deprecation warnings, for clarity:

import warnings
warnings.simplefilter('ignore')

# Import modules needed for this notebook.

# +
from glue.core.component_link import ComponentLink
from skimage.io import imread

from jdaviz import Imviz
# -

# Read in the RGB layers as different Numpy arrays.

# +
# Point filename to your RGB file (e.g., JPEG)
filename = 'ogle_galaxy_in_color.jpg'

im = imread(filename)
im_r = im[:, :, 0][::-1, :]
im_g = im[:, :, 1][::-1, :]
im_b = im[:, :, 2][::-1, :]
# -

# Start Imviz app and load RGB channels into different data layers.

# +
imviz = Imviz()
imviz.load_data(im_r, data_label='Red')
imviz.load_data(im_g, data_label='Green')
imviz.load_data(im_b, data_label='Blue')

viewer = imviz.default_viewer

imviz.app
# -

# Assign the different RGB layers.

viewer.state.color_mode = 'One color per layer'
viewer.state.layers[0].color = 'red'
viewer.state.layers[1].color = 'green'
viewer.state.layers[2].color = 'blue'

# **Note:** If you blink, you need to run this again. Don't blink!



StarcoderdataJupyterScriptsDedupFiltered