hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en
MIT License
13.03k stars 677 forks source link

Prevent interpolation in textures #1915

Open wlwatkins opened 1 year ago

wlwatkins commented 1 year ago

Version of Dear PyGui

Version: 1.7.2 Operating System: win 11

My Issue/Question

How to prevent pixel interpolation when using add_image_series ? I have a rgba numpy array, but when showing the image the pixels are blended, but i need theme to be shown clearly (like matplotlib would)

To Reproduce

Expected behaviour

get neat pixel separation without interpolation

Screenshots/Video

This is what i get image

this is what i expect

image

Standalone, minimal, complete and verifiable example

# Here's some code anyone can copy and paste to reproduce your issue
import dearpygui.dearpygui as dpg
import numpy as np
from matplotlib import cm
dpg.create_context()

dpg.show_tool(dpg.mvTool_Metrics)
with dpg.window(label="Tutorial", width=400, height=400):

    values: np.ndarray = np.random.rand(100, 100)

    colmap = cm.get_cmap('viridis', 256)
    lut = (colmap.colors[...,0:4]*255).astype(np.uint8)
    rescaled = ((values.astype(float) - values.min())*255/(values.max() - values.min())).astype(np.uint8)
    result = np.ones((*rescaled.shape,4), dtype=np.uint8)
    np.take(lut, rescaled, axis=0, out=result)
    result = result.flatten()/255

    with dpg.group(horizontal=True):
        with dpg.texture_registry(show=False):
            dpg.add_raw_texture(width=100, height=100, default_value=np.asarray(result, dtype=np.float32), tag=f"texture_tag", format=dpg.mvFormat_Float_rgba)

        dpg.add_colormap_scale(min_scale=values.min(), max_scale=values.max(), colormap=dpg.mvPlotColormap_Jet, tag=f"_legend")
        with dpg.plot(label="title", height=-1, width=-1, crosshairs=True, anti_aliased =False, delay_search=True, tag=f"_plot_with"):
            dpg.bind_colormap(dpg.last_item(), dpg.mvPlotColormap_Jet)
            dpg.add_plot_axis(dpg.mvXAxis, tag=f"_x_axis", no_tick_marks=False, no_gridlines=False)
            dpg.add_plot_axis(dpg.mvYAxis, tag=f"_y_axis", no_tick_marks=False, no_gridlines=False)
            dpg.add_image_series(f"texture_tag", parent =f"_y_axis", bounds_max=[100, 100], bounds_min=[0, 0], )
                # dpg.add_heat_series(values.flatten().tolist(), values.shape[0], values.shape[1], parent =f"_y_axis",  scale_min=values.min(), scale_max=values.max(), format="", tag=f"{self.uuid}_plot", bounds_max=[values.shape[0]-0.5, values.shape[1]-0.5], bounds_min=[-0.5, -0.5])

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
wlwatkins commented 1 year ago

i see this as been discussed in https://github.com/hoffstadt/DearPyGui/issues/773 but i can't find the solution yet

wlwatkins commented 7 months ago

Hi, just want to know how the project was going. I know dpg2 was in the pipe, but it seems to have changes direction. Is there any plan to push on with dpg? thanks