hoffstadt / hoffstadt/DearPyGui

Prevent interpolation in textures

Open
#1,915 2 comments 1 reaction 0 assignees View on GitHub
category: textures priority: high type: bug type: improvement
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## 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](https://user-images.githubusercontent.com/8661949/196894090-d471e298-b54e-433f-b666-e85baca55b2d.png)

this is what i expect

![image](https://user-images.githubusercontent.com/8661949/196894457-2b9ba285-ccb8-4221-8a52-15a3a0a27261.png)

## Standalone, minimal, complete and verifiable example

```python
# 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()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.