-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonOp.py
More file actions
30 lines (23 loc) · 1.02 KB
/
commonOp.py
File metadata and controls
30 lines (23 loc) · 1.02 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
from tkinter import *
from tkinter import filedialog as fd
from PIL import Image, ImageTk
import cv2 as cv
def savePath(file_path):
global image
image = file_path
def getIm():
return image
def saveImage(file, noise_img,noise_type_added):
cv.imwrite(changeName(file,noise_type_added),noise_img)
def showImage(img, frameIm2):
img = cv.cvtColor(img, cv.COLOR_BGR2RGB) # Convert the image from BGR to RGB format
img_pil = Image.fromarray(img) # Convert the processed image back to a PIL image
imgObg = ImageTk.PhotoImage(img_pil) # Convert the processed image to a Tkinter PhotoImage object
label = Label(frameIm2 ,image=imgObg, background= "lightgray", height= 300, width =300)
label.image = imgObg
label.grid( column = 0, row = 0, columnspan = 2, rowspan = 2, sticky = "NSEW")
def changeName(file,noise_type):
newfilename = file.split(".")[0]
newfilename = newfilename+noise_type +".jpg"
print(newfilename)
return newfilename