Python Articles

Page 136 of 855

Dividing Images Into Equal Parts Using OpenCV Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 8K+ Views

The Python OpenCV library enables us to utilize a variety of image-processing tools, like image classification, face/object detection, tracking, and more. In this article, we will use Python list slicing or NumPy array slicing techniques to divide an image into equal parts, since OpenCV-Python uses NumPy arrays to store image data and pixel values. Input Output Scenarios Assuming we have an input image, in the output we will see the equally divided parts of the given image. Approach We will follow the below steps to divide the images into equal parts ? ...

Read More

White and black dot detection using OpenCV Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 4K+ Views

OpenCV Python is a powerful image processing library that uses NumPy arrays to store image data. This allows us to efficiently detect and count objects like white and black dots in images. The cv2.findContours() method is used for detecting objects in binary images. We'll use this method along with thresholding techniques to detect white and black dots ? Syntax cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) Parameters: image − 8-bit single-channel binary image mode − Contour retrieval mode method − Contour approximation method Approach Follow these steps to detect white and ...

Read More

Check if the image is empty using OpenCV Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 3K+ Views

OpenCV is an Open Source Computer Vision Library in Python. It is one of the most popular image processing libraries and uses NumPy arrays to represent images. In this article, we will explore different methods to check if an image is empty or blank using OpenCV Python. Input-Output Scenarios We'll work with a blank input image and demonstrate how to programmatically detect whether an image is empty ? Input Image Expected Output Image is empty Method 1: Using Unique Pixel Count An empty image typically has very few unique ...

Read More

Splitting and Merging Channels with OpenCV Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 5K+ Views

A standard digital color image is represented by pixels, where each pixel is a combination of primary colors. A channel is a grayscale image that represents only one primary color component of a colored image. For example, an RGB image has three channels: red, green, and blue. Observe the below colored images to see how each channel looks separately: Below grayscale images are the representation of each channel of the RGB image. In this article, we will discuss how to split and merge channels of an image using Python OpenCV library. Splitting ...

Read More

Top Hat and Black Hat Transform using OpenCV Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 3K+ Views

Top Hat and Black Hat Transforms are morphological operations used for feature extraction and enhancement in image processing. These operations help extract small details from images by analyzing structural differences between the original image and its morphological transformations. Top Hat Transform extracts bright small elements by computing the difference between the original image and its opening (top hat = image - opening). It highlights small bright features that are smaller than the structuring element. Black Hat Transform extracts dark small elements by computing the difference between the image's closing and the original image (black hat = closing - ...

Read More

Conversion between binary, hexadecimal and decimal numbers using Coden module

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 284 Views

The coden is a Python library developed by Tanmay Earappa for handling secret codes and number base conversions. This module provides convenient functions to convert between binary, hexadecimal, and decimal number systems. Installation Install the coden module using pip − pip install coden Key Conversion Functions The coden module provides the following conversion functions − hex_to_bin(): Converts hexadecimal to binary hex_to_int(): Converts hexadecimal to decimal bin_to_hex(): Converts binary to hexadecimal bin_to_int(): Converts binary to decimal int_to_bin(): Converts decimal to binary int_to_hex(): Converts decimal to hexadecimal Hexadecimal to Binary Conversion ...

Read More

Convert a nested for loop to a map equivalent in Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 889 Views

Nested for loops execute repetitive code blocks, where an inner loop runs completely for each iteration of the outer loop. Python's map() function provides a functional programming approach to achieve similar results by applying functions to iterables. Understanding Nested For Loops A nested for loop structure contains one loop inside another ? for x in sequence: for y in sequence: # inner loop code # outer loop code Map Function Syntax map(function, iterable) Where: function: Function applied ...

Read More

Convert \"unknown format\" strings to datetime objects in Python

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 2K+ Views

Dates can be in many formats like "2009/05/13 19:19:30", "May 13 2009 07:19PM", and "2009-05-13 19:19". Python provides several approaches to convert these unknown format strings into datetime objects using the datetime and dateutil modules. A Python datetime object contains complete information about date and time including year, month, day, hours, minutes, seconds, and time zones. This article shows how to convert unknown format date strings to datetime objects. Input-Output Example Here's what we want to achieve ? Input string (unknown format): 20050607T090650 Output Datetime object: 2005-06-07 09:06:50 Data type: Using datetime.strptime() ...

Read More

Python Program to insert multiple elements into the array from the specified index

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 2K+ Views

An array is a collection of homogeneous data elements stored in an organized way. Each data element in the array is identified by an index value. In Python, we can insert multiple elements at a specific index position using various approaches. Arrays in Python Python does not have a native array data structure, so we use the list data structure as an alternative ? # Python list example my_list = [10, 4, 11, 76, 99] print(my_list) [10, 4, 11, 76, 99] We can also use the NumPy module to work with ...

Read More

Python Program to find the distinct elements from two arrays

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 3K+ Views

In programming, an array is a data structure used to store a collection of homogeneous data elements. Each element is identified by a key or index value. In Python, we use lists to represent arrays. Finding distinct elements from two arrays means identifying unique elements that exist in one array but not in the other − this is also known as the symmetric difference. Input Output Scenarios Let's look at example inputs and expected outputs ? Input arrays: A = [1, 2, 3, 4, 5] B = [5, 2, 6, 3, 9] Output array: [1, ...

Read More
Showing 1351–1360 of 8,549 articles
« Prev 1 134 135 136 137 138 855 Next »
Advertisements