C++CodeDelphiLearn PythonPython GUIRAD Studio

Easily Perform Powerful Computer Vision Functions In Python GUI App With Mahotas Library

Do you want to perform some Image Processing tasks in your Delphi GUI App? This post will get to understand how to use Mahotas Python Library using Python4Delphi in Delphi/C++ application. Mahotas is a computer vision and image processing library for Python.

Mahotas contains traditional image processing functions such as filtering and morphological operations as well as more modern computer vision functions for feature computation, including interest point detection and local descriptors.

Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi. They let you easily execute Python scripts, create new Python modules and new Python types. You can use Python4Delphi a number of different ways such as:

  • Create a Windows GUI around your existing Python app.
  • Add Python scripting to your Delphi Windows apps.
  • Add parallel processing to your Python apps through Delphi threads.
  • Enhance your speed-sensitive Python apps with functions from Delphi for more speed.

Prerequisites.

  • If not python and Python4Delphi is not installed on your machine, Check this how to run a simple python script in Delphi application using Python4Delphi sample app
  • Open windows open command prompt, and type pip install -U mahotas to install Mahotas. For more info for Installing Python Modules check here
  • First, run the Demo1 project for executing Python script in Python for Delphi. Then load the Texblob sample script in the Memo1 field and press the Execute Script button to see the result. On Clicking Execute Button the script strings are executed using the below code. Go to GitHub to download the Demo1 source.

Mahotas Python Library sample script details:

  • How to label a region in an image. Labeled images are integer images where the values correspond to different regions. I.e., region 1 is all of the pixels which have value 1, region two is the pixels with value 2, and so on. By convention, region 0 is the background and often handled differently.
  • Thresholding is a type of image segmentation, where we change the pixels of an image to make the image easier to analyze. In thresholding, we convert an image from color or grayscale into a binary image, i.e., one that is simply black and white. A well-known thresholding method is Otsu’s method which is demonstrated below.
  • Color space conversion is the translation of the representation of a color from one basis to another. An RGB image is represented as a 3-dimensional array of shape (h,w,3), where each pixel is represented by three values, red/green/blue. Image color space conversion using rgb2grey,rgb2sepia method were shown below.
labelling-8458696
Labeling Images
luis2-1426133
Thresholding Otsu’s Method
mahotas-7642088
Mahotas Color Space conversions Demo

Note: Samples used for demonstration were picked from here with only the difference of printing the outputs. You can check the APIs and some more samples from the same place.

You have read the quick overview of Mahotas library, download this library from here, and perform image processing fuctions such as watershed, filtering regions, morphological processing, in your applications. Check out Python4Delphi and easily build Python GUIs for Windows using Delphi.

close
Related posts
DelphiPythonPython GUIWindows

Learn To Work With Real-World Graphics Using The Python Matplotlib Library In A Delphi Windows App

DelphiPythonPython GUIWindows

Learn To Build A Python GUI For Easily Processing Images With Pillow Library In A Delphi Windows App

DelphiPythonPython GUIWindows

Learn To Build A Python GUI For Computer Vision Tasks With Powerful OpenCV Library In A Delphi Windows App

DelphiPythonPython GUIWindows

Learn To Work With HTTP Requests Using Python Requests Library In A Delphi Windows App

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

fr_FRFrench