-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_processor.py
More file actions
40 lines (29 loc) · 1.18 KB
/
image_processor.py
File metadata and controls
40 lines (29 loc) · 1.18 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 27 11:28:38 2024
@author: courtand
"""
import cv2
import numpy as np
def gamma_LUT(gamma):
invGamma = 1.0 / gamma
table = np.array([((i / 255.0) ** invGamma) * 255
for i in np.arange(0, 256)]).astype("uint8")
# apply gamma correction using the lookup table
return table
def convert_imageToPyqtgraph(img,vid):
#conversion de l'image pour affichage dans le plotview
if len(img.shape)>2 : #image couleur (3e terme pour le nombre de canaux)
#image.currentGrayFrame=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#l'image affichée est l'image couleur
cframe=cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
gaframe=cv2.LUT(cframe, vid.LUT)
else :
#image.currentGrayFrame = img.copy()
#gaframe=cv2.LUT(image.currentGrayFrame, video.LUT)
gaframe=cv2.LUT(img, vid.LUT)
#rotation de l'image à 90° : cv2.transpose
#[::-1,:] et .T pour orienter l'image correctement
#self.img.setImage(self.frame[::-1,:].T)
vid.currentTFrame=cv2.transpose(gaframe[::-1,:])
return vid.currentTFrame