forked from pgriffin17/cameraControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplayimageitem.py
More file actions
26 lines (21 loc) · 821 Bytes
/
displayimageitem.py
File metadata and controls
26 lines (21 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtWidgets, QtGui
import numpy as np
from scipy.ndimage import center_of_mass
class Display_Imi(pg.ImageItem):
def __init__(self, image=None, axisOrder = "row-major"):
super().__init__(image, axisOrder=axisOrder)
def dims(self) -> tuple:
if np.any(self.image):
shape = np.shape(self.image)
return (shape[1], shape[0])
else:
print("There is no image assigned to the Display Image Item.")
def setNewImage(self, frame: np.ndarray) -> None:
self.setImage(frame)
def com(self) -> tuple:
if self.image:
com = center_of_mass(self.image)
return (com[1], com[0])
else:
print("There is no image assigned to the Display Image Item")