Skip to content
Snippets Groups Projects
Commit 46c5b83e authored by LexvanGastel's avatar LexvanGastel
Browse files

vraag 20 2-4

parent b3446797
Branches
No related tags found
No related merge requests found
import cv2
import matplotlib.pyplot as plt
class ImageProcessor: class ImageProcessor:
def __init__(self, image_path): def __init__(self, image_path):
self.image self.image = cv2.imread(image_path)
self.image_rgb self.image_rgb = cv2.cvtColor(self.image, cv2.COLOR_BGR2RGB)
self.image_hsv
def apply_median_filter(self, kernel_size): def apply_median_filter(self, kernel_size):
return filterd_image return filterd_image
def get_color_channels(self): def get_color_channels(self):
red_channel = self.image_rgb[:, :, 0]
green_channel = self.image_rgb[:, :, 1]
blue_channel = self.image_rgb[:, :, 2]
return red_channel, green_channel, blue_channel return red_channel, green_channel, blue_channel
def convert_to_hsv(self): def convert_to_hsv(self):
return hsv_image return hsv_image
class Plotter: class Plotter:
@staticmethod
def __init__(self): def __init__(self):
pass pass
def plot_image_channels(self, image): def plot_image_channels(image, red, green, blue):
return None fig, axes = plt.subplots(2, 2, figsize=(12,8))
axes[0,0].imshow(image)
axes[0,0].set_title("Original picture")
axes[0,0].axis("off")
axes[0,1].imshow(red,cmap = "Reds")
axes[0,1].set_title("Red channel")
axes[0,1].axis("off")
axes[1,0].imshow(green, cmap = "Greens")
axes[1,0].set_title("Green channel")
axes[1,0].axis("off")
axes[1,1].imshow(blue, cmap = "Blues")
axes[1,1].set_title("blue channel")
axes[1,1].axis("off")
plt.show()
def plot_histograms(self, image): def plot_histograms(self, image):
return None return None
\ No newline at end of file image_path = "traffic_light_image_1.png"
processor = ImageProcessor(image_path)
red, green, blue = processor.get_color_channels()
Plotter.plot_image_channels(processor.image_rgb,red,green,blue)
\ No newline at end of file
Image diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment