A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 101
Backtrace:
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Router::$uri is deprecated
Filename: core/Router.php
Line Number: 127
Backtrace:
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$benchmark is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$hooks is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$config is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$log is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$utf8 is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$uri is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$exceptions is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$router is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$output is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$security is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$input is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$lang is deprecated
Filename: core/Controller.php
Line Number: 75
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$load is deprecated
Filename: core/Controller.php
Line Number: 78
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$db is deprecated
Filename: core/Loader.php
Line Number: 396
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_DB_mysqli_driver::$failover is deprecated
Filename: database/DB_driver.php
Line Number: 371
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 132
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 292
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 166
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 235
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 315
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 356
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 289
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: drivers/Session_files_driver.php
Line Number: 108
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Session cannot be started after headers have already been sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$session is deprecated
Filename: core/Loader.php
Line Number: 1283
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$form_validation is deprecated
Filename: core/Loader.php
Line Number: 1283
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 8
Function: __construct
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Welcome::$m_data is deprecated
Filename: core/Loader.php
Line Number: 358
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 11
Function: model
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$benchmark is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$hooks is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$config is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$log is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$utf8 is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$uri is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$exceptions is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$router is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$output is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$security is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$input is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$lang is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$load is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$db is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$session is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$form_validation is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$m_data is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home/alfe6346/public_html/application/controllers/Welcome.php
Line: 187
Function: view
File: /home/alfe6346/public_html/index.php
Line: 315
Function: require_once
alf-printing Digital-Printing dan Media Pembelajaran
Cepat, Berkualitas, dan Terjangkau
Indonesia
Penjelasan Kode Python — Basic Image Ops (Tkinter + OpenCV)
Ringkas: Aplikasi GUI untuk operasi citra dasar: tampilkan citra asli, konversi grayscale, histogram equalization, serta penyesuaian brightness/contrast (α, β) dengan slider. Histogram (grayscale/RGB) diperbarui setiap kali gambar dirender.Daftar Isi Import Modul Setup Path & Impor Utilitas Fungsi adjust_bc Kelas BasicOpsGUI Constructor __init__ Method open_image Method _ensure_image Method Operasi: show_original, op_gray, op_hist_eq, op_bc_apply Rendering & Histogram: _render, _update_hist, _fit_image Blok Main Dependensi & Cara Menjalankan FAQ 1) Import Modul import os, sys
import cv2
import numpy as np
import tkinter as tk
from tkinter import filedialog, messagebox
from PIL import Image, ImageTk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.pyplot as pltos, sys : manipulasi path & sys.path untuk impor relatif.cv2 (OpenCV): operasi citra—konversi warna, equalization, dan transformasi intensitas.numpy : representasi citra sebagai ndarray.tkinter : GUI native; filedialog untuk memilih berkas, messagebox untuk dialog.Pillow (Image, ImageTk): konversi array ke objek gambar yang bisa ditampilkan di Tkinter.matplotlib + FigureCanvasTkAgg: menggambar histogram langsung di jendela Tkinter.2) Setup Path & Impor Utilitas _FILE_DIR = os.path.dirname(__file__)
_ROOT_DIR = os.path.abspath(os.path.join(_FILE_DIR, ".."))
if _ROOT_DIR not in sys.path:
sys.path.insert(0, _ROOT_DIR)
from common.io import read_imageMenjamin modul common.io dapat diimpor saat skrip dijalankan langsung. Fungsi read_image diasumsikan membaca gambar dan mengembalikannya sebagai array RGB numpy.
3) Fungsi adjust_bc(img, alpha=1.2, beta=20) def adjust_bc(img, alpha=1.2, beta=20):
return cv2.convertScaleAbs(img, alpha=alpha, beta=beta)Tujuan: Mengatur contrast (α) dan brightness (β) dengan transformasi linier img' = α·img + β lalu diklip 0..255.Parameter: img (RGB uint8), alpha (float), beta (int).Return: citra hasil dalam tipe uint8.4) Kelas BasicOpsGUI 4.1 __init__(self, root) self.root = root
self.root.title("Basic Ops - Gray, HistEq, Brightness/Contrast")
# State
self.img_rgb: np.ndarray | None = None
self.photo: ImageTk.PhotoImage | None = NoneState utama: img_rgb menyimpan citra saat ini (RGB); photo adalah objek ImageTk untuk Label Tkinter.# Bar atas: tombol buka, label status
# Frame kontrol: tombol operasi (asli, gray, equalization)
# Frame B/C: slider alpha (kontras) & beta (kecerahan) + tombol terapkan
# Area tampilan: label judul + label gambar
# Area histogram: Figure Matplotlib tertanam via FigureCanvasTkAgg4.2 open_image(self) path = filedialog.askopenfilename(...)
self.img_rgb = read_image(path)
self.status.config(text=path)
self.show_original()Membuka dialog pilih berkas, membaca citra (RGB), memperbarui status, dan merender citra asli. Penanganan error: kegagalan baca ditampilkan via messagebox.showerror.4.3 _ensure_image(self) → bool if self.img_rgb is None:
messagebox.showinfo("Info", "Silakan buka gambar terlebih dahulu.")
return False
return TrueValidasi ketersediaan citra sebelum menjalankan operasi.
4.4 Method Operasi show_original(self)self._render(self.img_rgb, title="Citra Asli (RGB)")op_gray(self)gray = cv2.cvtColor(self.img_rgb, cv2.COLOR_RGB2GRAY)
self._render(gray, title="Grayscale")op_hist_eq(self)gray = cv2.cvtColor(self.img_rgb, cv2.COLOR_RGB2GRAY)
hist_eq = cv2.equalizeHist(gray)
self._render(hist_eq, title="Histogram Equalization (Gray)")op_bc_apply(self)alpha = float(self.alpha_var.get())
beta = int(self.beta_var.get())
out = adjust_bc(self.img_rgb, alpha=alpha, beta=beta)
self._render(out, title=f"Brightness/Contrast (α={alpha:.2f}, β={beta})")Catatan: HistEq dilakukan di domain grayscale satu kanal, sedangkan B/C diterapkan pada citra RGB 3‑kanal.
4.5 Rendering & Histogram _render(self, img, title="")if img.ndim == 2:
pil = Image.fromarray(img.astype(np.uint8), mode="L")
else:
pil = Image.fromarray(img.astype(np.uint8))
pil = self._fit_image(pil, 960, 600)
self.photo = ImageTk.PhotoImage(pil)
self.img_label.configure(image=self.photo)
self.title_label.configure(text=title)
self._update_hist(img)Konversi ndarray ke PIL.Image (mode L untuk grayscale). Penskalaan proporsional agar muat di area tampilan (_fit_image). Perbarui label gambar & judul, lalu gambar histogram. _update_hist(self, img)self.ax.clear()
if img.ndim == 2:
data = img.ravel().astype(np.uint8)
self.ax.hist(data, bins=256, range=(0,255), color='black', alpha=0.8)
self.ax.set_title('Histogram (Grayscale)')
else:
for i, c in enumerate(['r','g','b']):
data = img[:,:,i].ravel().astype(np.uint8)
self.ax.hist(data, bins=256, range=(0,255), color=c, alpha=0.5, label=['R','G','B'][i])
self.ax.legend(loc='upper right', fontsize=8)
self.ax.set_xlim(0,255); self.ax.set_xlabel('Intensitas'); self.ax.set_ylabel('Frekuensi')
self.fig.tight_layout(); self.canvas.draw_idle()Histogram 256 bin untuk intensitas 0–255. Grayscale: satu histogram; RGB: tiga histogram bertumpuk (R,G,B). _fit_image(im, max_w, max_h) (static)w, h = im.size
scale = min(max_w / w, max_h / h, 1.0)
new_size = (int(w * scale), int(h * scale))
return im.resize(new_size, Image.Resampling.LANCZOS)Menghitung skala agar gambar tidak melebihi area tampilan; menggunakan filter LANCZOS untuk kualitas tinggi.
5) Blok Main if __name__ == "__main__":
root = tk.Tk()
app = BasicOpsGUI(root)
root.mainloop()Menjalankan aplikasi hanya saat file dieksekusi langsung; membuat root Tk, menginstansiasi GUI, lalu memulai mainloop().
6) Dependensi & Cara Menjalankan Paket Peran opencv-python Operasi citra (konversi, equalization, skala intensitas) numpy Representasi data piksel Pillow Konversi ndarray → gambar Tkinter matplotlib Plot histogram
Instal cepat (venv disarankan) pip install opencv-python numpy pillow matplotlibSimpan file sebagai basic_ops.py dalam struktur yang berisi modul common/io.py. Jalankan: python basic_ops.py Klik Buka Gambar... → pilih gambar → coba tombol operasi dan slider. 7) FAQ Mengapa histogram untuk RGB dibuat per‑kanal? Agar distribusi intensitas masing‑masing kanal terlihat jelas; penyesuaian B/C dapat memengaruhi kanal secara berbeda.
HistEq menghasilkan artefak, normal? Pada citra berisik atau rentang dinamis sempit, equalization bisa menonjolkan noise; pertimbangkan CLAHE bila diperlukan.
Apa bedanya α (kontras) dan β (kecerahan)? α mengatur kemiringan (sebaran kontras), β menggeser intensitas rata‑rata ke atas/bawah.