seantronsen / pvt

GNU General Public License v3.0
0 stars 0 forks source link

Feature: Allow users to add an optional border to the image pane display #42

Closed seantrons closed 5 months ago

seantrons commented 5 months ago

When viewing images whose background mirrors that of the panel background (e.g. black on black), it's impossible to tell where the image begins and ends. Sure, we can just say this is the user responsibility to use their favorite drawing method to add a border to the images, but PyQtGraph provides this out of the box.

Noting this issue down just for documentation purposes. I'm going to go add a convenience method and have this implemented in just a moment.

seantrons commented 5 months ago

For an example of what I'm referring to, check out this image:

image

seantrons commented 5 months ago

Issue resolved as of: 4931166c

Example image: image

from qtviewer import *
import numpy as np

def mask_circle(radius: int):
    l, r = -radius, radius + 1
    kvec = np.arange(l, r, 1, np.intp)
    grid = np.meshgrid(kvec, kvec, "xy")
    gridx, gridy = np.square(grid[0]), np.square(grid[1])
    euclid = np.sqrt(gridx + gridy)
    result = np.where(euclid <= radius, 255, 0)
    return result.astype(np.uint8)

def show():

    v = Viewer()
    ip = ImagePane(lambda **_: mask_circle(10), border="red")
    v.add_panes(ip)
    v.run()

if __name__ == "__main__":
    show()

Side note: This is with numpy=1.26.*

Closing issue.