Images and masks splitting into multiple pieces in Python

Images and masks splitting into multiple pieces in Python

A practical example of images and masks splitting into smaller parts. Data labelers use special annotation tools for objects annotation. For example, the Computer Vision Annotation Tool (CVAT) is widely known in computer vision.

mages and masks splitting into multiple pieces in Python with Google Colab.

Data labelers use special annotation tools for objects annotation. For example, the Computer Vision Annotation Tool (CVAT) is widely known in computer vision. Naturally, it is more convenient for labelers to work with high-resolution images. This is especially true when you need to mark a large number of objects.

In one of the roof segmentation tasks that I participated in, it was necessary to highlight triangular segments, quadrangular segments, other segments and edges of the roof. An example of such markup is shown in the following figure (white color for edges, red color for triangles, green color for quadrangles, blue color for other polygons):

Image for post

Image for post

Image is created by Oleksii Sheremet with matplotlib module

The original images were obtained from Google Earth at 2048x1208 pixels. The masks were annotated by data labelers using CVAT at the same resolution. To train the model, images and masks should be in a lower resolution (from 128x128 to 512x512 pixels). It is well known that image splitting is a technique most often used to slice a large image into smaller parts. Thus, the logical solution was to split the images and their corresponding masks into the parts with the same resolution.

All code for splitting was implemented in Google Colab. Let’s take a closer look. Import libraries:

import os
import sys
import shutil
import glob
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from PIL import Image

Mount the Google Drive (with images and masks) to Google Colab:

from google.colab import drive
%cd "gdrive/My Drive/File Folder"

splitting masks annotation-tools image-segmentation computer-vision

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction To Image Segmentation

Clustering parts of an image together which belong to the same object class. In the research and application of images, people are often only interested in certain parts of the images.

Computer Vision and 5 Main Types of Image Annotation

Image annotation is an integral part of the machine learning process for numerous computer vision models. This video will introduce five of the most common t...

Major Image Recognition And Annotation Trends

Image recognition and annotation technologies are evolving. New techniques that allow you to solve a wide variety of tasks quickly appear. We are happy to present five major trends in image recognition and annotation.

Solving Some Image Processing,Computer Vision Problems With Python Libraries

In this article, a few image processing/computer vision problems and their solutions with python libraries (scikit-image, PIL, opencv-python) will be discussed. Some of the problems are from the exercises from this book (available on Amazon).

All about images -Types of Images:

Everything we see around its nothing but an Image. we capture them using our mobile camera. Image is nothing but a signal which conveys.