import cv2 import numpy as np import matplotlib.pyplot as plt # Membaca gambar img = cv2.imread('D:/Skripsi/ekstraksi fitur/Mycobacterium Tuberculosis/mt17.jpg') if img is None: print("Gambar tidak ditemukan atau path salah.") else: # Memisahkan channel warna blue, green, red = cv2.split(img) # Menampilkan channel hijau plt.figure(figsize=(12, 6)) plt.subplot(1, 2, 1) plt.imshow(green, cmap='gray') plt.title("Green Channel") plt.axis('off') # Menyembunyikan axis # Menghitung histogram dari channel hijau histogram, bin_edges = np.histogram(green, bins=256, range=(0, 255)) # Menampilkan histogram dari channel hijau plt.subplot(1, 2, 2) plt.plot(bin_edges[0:-1], histogram, color='green') plt.title("Histogram of Green Channel") plt.xlabel("Pixel value") plt.ylabel("Frequency") plt.tight_layout() plt.show()