Commit e50c1d1b authored by Valentin Valls's avatar Valentin Valls
Browse files

Make sure RGB images are displayable

parent 9bef586c
......@@ -269,6 +269,21 @@ def plot_image(data=None, name=None, existing_id=None, selected=True, closeable=
selected: If true the plot will be selected when created
closeable: If true the plot will be closeable
"""
if data is not None and data.ndim == 3 and data.shape[2] in (3, 4):
# FIXME: silx 0.15 do not support RGB in ImageView
# So here we use Plot2D
# This can be removed when https://github.com/silx-kit/silx/pull/3487 is merged
flint = flint_proxy.get_flint()
p = flint.get_plot(
"plot2d",
name=name,
unique_name=existing_id,
selected=selected,
closeable=closeable,
)
p.add_image(data, legend="image")
return p
flint = flint_proxy.get_flint()
p = flint.get_plot(
"image",
......
......@@ -11,7 +11,7 @@ def test_plot_list(flint_session):
assert vrange[0:2] == [[0, 5], [0, 2]]
def test_scatter_plot(flint_session):
def test_plot_scatter(flint_session):
x = numpy.array([0, 1, 2, 0, 1, 2, 0, 1, 2])
y = numpy.array([0, 0, 0, 1, 1, 1, 2, 2, 2])
value = numpy.array([0, 1, 0, 1, 2, 1, 0, 1, 0])
......@@ -52,6 +52,13 @@ def test_plot_numpy_2d(flint_session):
assert vrange[0:2] == [[0, 10], [0, 10]]
def test_plot_numpy_2d_rgb(flint_session):
data = numpy.array([[[0, 255, 255], [0, 0, 255]], [[255, 0, 255], [255, 255, 0]]])
p = plot.plot(data)
vrange = p.get_data_range()
assert vrange[0:2] == [[0, 2], [0, 2]]
def test_plot_numpy_3d(flint_session):
data = numpy.arange(10 * 10 * 10)
data.shape = 10, 10, 10
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment