Skip to main content

Posts

Showing posts from January, 2021

Image Editing Software | Applying Color Filters on Image

 Hello friends! Welcome to the last post on Image Editing Software. In this post, you will be learning how to apply color filters to an image. We will be doing this using the OpenCV library package. You can also check out the video below.  So let's get started. We will start by importing Opencv and Numpy to our code.  import cv2 import numpy as np And now we will start writing the callback methods for applying filters. Let us start with the  yellowButton_callback() method.  def yellowButton_callback (): opencvImage = cv2.cvtColor(np.array(originalImage) , cv2.COLOR_RGB2BGR) opencvImage[: , : , 0 ] = 20 global outputImage outputImage = Image.fromarray(cv2.cvtColor(opencvImage , cv2.COLOR_BGR2RGB)) dispayImage(outputImage) Alright. Let us understand the above code line by line. To apply a color filter I have to manipulate the image array. So I need the image in an array form. np.array(originalImage) converts the image that we read using the PI...

Image Editing Software | Changing Brightness And Contrast

 Hello! In this post, you will be learning how to change the brightness and contrast of an image using the PIL library package. You can check out the video below to learn more.  We will continue to build out previous code. Let us start by importing the required library package. from PIL import ImageEnhance The ImageEnhance package will be used to change the brightness and contrast of an image. Now, we will be writing a few lines to the brightness_callback() method.  def brightness_callback (brightness_pos): brightness_pos = float (brightness_pos) global outputImage enhancer = ImageEnhance.Brightness(originalImage) outputImage = enhancer.enhance(brightness_pos) dispayImage(outputImage) brightness_callback() method requires an argument to be passed. This argument holds the current position of the slider and is of string type. The ImageEnhance library package needs a variable of float type. So that is why in the first line we have converted the brightne...

Image Editing Software | Importing And Saving Images

 Hello friends! Welcome back. This is going to be a single post where you will be learning about importing images, displaying images, and saving the images on the image editing GUI window. So let's get started. We will continue to build our previous code. First, we will add the required library packages to our code.  from PIL import Image from PIL import ImageTk from tkinter import filedialog The Image and ImageTk library packages will be used for opening and displaying the image on the window. The filedialog library will be used for browsing the images from the computer directory that you want to import. Let us now jump to writing the code. For importing a new image you will have to add the following code to the import button callback method . def importButton_callback(): global originalImage filename = filedialog.askopenfilename() originalImage = Image.open(filename) dispayImage(originalImage) We have defined originalImage as a global variable. This is becaus...

Image Editing Software | GUI Designing | Creating Radio Buttons

Hello Friends! Let us continue our development of Image editing software. In this tutorial, we will add radio buttons to our GUI. These radio buttons will be used to apply different types of color filters to the image. Check out the video below. Let us start by creating a new frame for radio buttons and let us anchor it to the north side. Frame3 = tk.Frame(window , height = 20 ) Frame3.pack( anchor =tk.N) Now, let's add radio buttons to this frame. We will be creating 5 radio buttons (pink, orange, blue, yellow, none) and pack them using the grid. yellowButton = tk.Radiobutton(Frame3 , text = "Yellow" , width = 20 , value = 1 , command =yellowButton_callback) yellowButton.grid( row = 0 , column = 0 ) blueButton = tk.Radiobutton(Frame3 , text = "Blue" , width = 20 , value = 2 , command =blueButton_callback) blueButton.grid( row = 0 , column = 1 ) orangeButton = tk.Radiobutton(Frame3 , text = "Orange" , width = 20 , value = 3 , command =orangeButton_call...