To separate a particular portion from the image, we have to locate the area first. Then we have to copy that area from the main image to another matrix. This is how the ROI in OpenCV works.In this example, two matrices have been declared at the beginning. After that, an image named 'image_name.jpg' has been loaded into the 'image1' matrix. The next line 'image2=image1 (Rect(100, 100, 120, 120));' requires special attention. This line is cropping out the defined region of the image and storing it in the 'image2' matrix.The figure shows what we have done here with the 'Rect(100, 100, ... Read More
We have declared three variables named-'blue_Channel', 'green_channel' and 'red_channel'. The goals of these variables is to save the pixel values. We have used these variables inside the 'for loops'. Then we declared a matrix named 'color_Image_Matrix'.The syntax of this method is:blue_Channel = color_image_Matrix.at(i, j)[0];We used a BGR image. It has three channels. These channels maintain specific sequence, color_image_Matrix.at (i, j) represents the pixel values located at (i, i) and [0] represents the first channel. For example, if we write the line as follows:blue_Channel=color_image_Matrix.at (30, 35) [0];It means the variable 'blue_Channel' will have the first channel's pixel value located at(30, 35). ... Read More
Tkinter Button widgets are very useful in terms of handling events and performing actions during the execution of an application. We can create Tkinter Buttons using the Button(parent, text, option..) constructor. Using the constructor, we can create multiple buttons within the loop.ExampleIn this example, we will create multiple buttons in the range using a Python for loop.#import required libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win= Tk() #Set the geometry of the window win.geometry("750x250") #Create a LabelFrame labelframe= LabelFrame(win) #Define a canvas in the window canvas= Canvas(labelframe) canvas.pack(side=RIGHT, fill=BOTH, ... Read More
Tkinter functions can be created with the help of threading concept where we define, when a function should run or stop. A Tkinter function can be scheduled using the after(time, callback) function.Let us suppose that we have created a callback function that forces the main window to be closed after some time. There might be times when we need to stop the scheduling of the function. In order to cancel or stop a particular schedule of a callback function, we can use after_cancel(widget) function.ExampleIn the given example, the script will close the main window after 3 seconds but after initializing ... Read More
Tkinter has an Entry widget to accept single-line user input. It has many properties and attributes that can be used to configure the Entry widget. To change the size (width or height of the Entry widget), we can use Internal Padding Properties – ipadx and ipady. By defining the value of internal padding, we can actually change the width and height of the Entry widget.Example#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter frame win.geometry("750x350") #Define a function to submit the validate the ... Read More
To active the focus on a particular widget during the execution of a Tkinter program, we can use focus_set() method. Adding the focus creates a gray line around the widget and makes it visible to the user.There might be some cases when we need to remove the focus from the desired widget.This can be done either by removing the focus_set() property or switching the focus from one widget to another.Example#Import the required Libraries from tkinter import * from tkinter import ttk from tkinter import messagebox #Create an instance of Tkinter frame win = Tk() #Set the geometry of Tkinter ... Read More
Popup window in Tkinter can be created by defining the Toplevel(win) window. A Toplevel window manages to create a child window along with the parent window. It always opens above all the other windows defined in any application. We can create a top-level window or a child window by initializing the object of Toplevel(parent). It inherits all the property of its parent window, such as geometry, title, and width or height.ExampleIn this example, we will create a button that will open a Popup window above all the other windows.#Import the required Libraries from tkinter import * from tkinter import ttk ... Read More
To find the minimum height and width of canvas items, we can use the bounding box property of Canvas. Basically, a bounding box property enables the canvas item to return the position inside the canvas. Initially, every item in the bbox(item) method defines the minimum and maximum width and height of the item.Example#Import required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Define the geometry of the window win.geometry("750x250") #Initialize a Canvas canvas= Canvas(win, width= 600, height= 200) #Add a text inside the Canvas text= canvas.create_text(300, 20, text= "This is a New Line Text", font=16, ... Read More
Popup window in Tkinter can be created by defining the Toplevel(win) window. A Toplevel window manages to create a child window along with the parent window. It always opens above all the other windows defined in any application. We can create a top-level window or child window by initializing the object of Toplevel(parent). It inherits all the property of its parent window such as geometry, title, and width or height.ExampleIn this example, we will create a button that will open a Popup window above all the other windows.#Import the required Libraries from tkinter import * from tkinter import ttk #Create ... Read More
Tkinter Scale Widgets are used to provide the visual representation of data items where we can modify or change the value of data items. In order to change the state of data or select multiple data in the field, we can use the Scale widget.The Scale Widget can be created by initializing a Scale(parent, from_, to, orient, options) constructor.However, sometimes we need to set the default value of the Tkinter Scale widget, which can be set by using the set(numeric_value) method.ExampleIn this example, we will create a scale widget that sets a default value for the slider.#Import the required Libraries ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP