スタートアップから大手まで。
調達・受発注をAIで標準化。

相見積比較も進捗管理もAIが下支え。取引先は招待で完全無料。

14日間 無料で試すクレカ不要・1分/招待企業は完全無料

投稿日:2025年2月12日

Basic and applied practical course on image processing using Python

Introduction to Image Processing

💡 こうした調達・受発注の属人化、newji なら「ひとつの画面」で解決。見積依頼から発注・進捗・承認までAIが下支えします。
14日間 無料で試す →

Image processing is an essential technique used in various fields like computer vision, machine learning, and artificial intelligence.
It involves the manipulation of images to improve their quality or to extract important information.
Python, with its rich libraries and ease of use, is a popular programming language for image processing tasks.

In this article, we will explore the basics and applied concepts of image processing using Python.
We will also discuss some practical applications to help you understand how image processing can be a valuable tool in solving real-world problems.

Understanding Image Processing

Image processing refers to a set of techniques used to enhance, analyze, and manipulate images.
It involves operations that transform an image into another image to achieve desired results.

Some common image processing tasks include noise removal, image enhancement, edge detection, and image segmentation.
These tasks are performed to improve the visual quality of images or to prepare data for further analysis.

Types of Image Processing

There are two main types of image processing: analog and digital.
Analog image processing is used for hard copies, such as printed photographs.
Digital image processing involves manipulating images with a computer and is the focus of this article.
With digital image processing, images are converted into a set of numbers that correspond to pixels.

Python Libraries for Image Processing

Python offers a variety of libraries to perform image processing tasks effectively.
These libraries provide functions that make it easy to manipulate and analyze images.

OpenCV

OpenCV (Open Source Computer Vision Library) is an open-source library with a comprehensive set of tools for image and video processing.
It offers various algorithms for image manipulation, such as resizing, cropping, and rotating images.
OpenCV is frequently used in real-time applications and has support for a wide range of image formats.

PIL/Pillow

Pillow, the friendly fork of the Python Imaging Library (PIL), is a simple and easy-to-use library for image manipulation.
It supports opening, cropping, saving, and displaying various image formats.
Pillow is ideal for small tasks, such as image resizing, format conversion, and applying basic image effects.

scikit-image

scikit-image is a collection of algorithms for image processing in Python.
Built on top of SciPy, it provides tools for basic and advanced image processing tasks.
This library is designed for use in scientific computing and offers capabilities for tasks such as image filtering, segmentation, and transformation.

Basic Image Processing Operations

In this section, we will cover some fundamental image processing operations and how to perform them using Python libraries.

Reading and Displaying Images

The first step in image processing is reading an image file and displaying it.
Using OpenCV, you can read an image with the `cv2.imread()` function and display it using `cv2.imshow()`.

“`python
import cv2

# Read the image
image = cv2.imread(‘image.jpg’)

# Display the image
cv2.imshow(‘Displayed Image’, image)

# Wait for a key event, then close the window
cv2.waitKey(0)
cv2.destroyAllWindows()
“`

Image Resizing

Resizing is a common operation in image processing when you want to scale the image to a specific size.
In OpenCV, the `cv2.resize()` function lets you resize an image.

“`python
# Resize the image to 200×200 pixels
resized_image = cv2.resize(image, (200, 200))

# Display the resized image
cv2.imshow(‘Resized Image’, resized_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
“`

Image Rotation

Rotating an image is useful for aligning images or changing their orientation.
You can use the `cv2.getRotationMatrix2D()` and `cv2.warpAffine()` functions to rotate an image.

“`python
# Get the rotation matrix for a 45-degree rotation
rotation_matrix = cv2.getRotationMatrix2D((image.shape[1] / 2, image.shape[0] / 2), 45, 1)

# Rotate the image
rotated_image = cv2.warpAffine(image, rotation_matrix, (image.shape[1], image.shape[0]))

# Display the rotated image
cv2.imshow(‘Rotated Image’, rotated_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
“`

Image Filtering

Image filtering is used to enhance images, such as sharpening or blurring.
This can be done using OpenCV’s filtering functions.

“`python
# Apply a Gaussian blur filter
blurred_image = cv2.GaussianBlur(image, (5, 5), 0)

# Display the blurred image
cv2.imshow(‘Blurred Image’, blurred_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
“`

Advanced Image Processing Concepts

Once you are comfortable with basic image processing techniques, you can explore more advanced topics.

Edge Detection

Edge detection is an important image processing technique used to identify the boundaries within an image.
The Canny edge detection algorithm is a popular method implemented in the `cv2.Canny()` function.

“`python
# Perform Canny edge detection
edges = cv2.Canny(image, 100, 200)

# Display the edge-detected image
cv2.imshow(‘Edges’, edges)
cv2.waitKey(0)
cv2.destroyAllWindows()
“`

Image Segmentation

Image segmentation is the process of dividing an image into different regions for easier analysis.
OpenCV provides several algorithms for segmentation, such as thresholding and contour detection.

“`python
# Convert the image to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Apply thresholding
_, thresholded = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)

# Display the segmented image
cv2.imshow(‘Segmented Image’, thresholded)
cv2.waitKey(0)
cv2.destroyAllWindows()
“`

Practical Applications of Image Processing

Image processing has countless practical applications in our daily lives.
Some of the common applications include:

– **Medical Imaging:** Enhancing X-rays, MRIs, and other medical scans for better diagnosis.
– **Facial Recognition:** Identifying and verifying individuals based on facial features.
– **Autonomous Vehicles:** Analyzing the surrounding environment to navigate safely.
– **Augmented Reality:** Overlaying computer-generated images on the real-world view.

Conclusion

Image processing is a powerful tool in the hands of developers and scientists.
Mastering its basics and practical applications can dramatically enhance your problem-solving capabilities.
With Python’s extensive libraries and resources, you can easily start experimenting and implementing image processing techniques in your projects.
Whether in academia or industry, the skills you gain will prove invaluable in a world increasingly reliant on digital imagery and machine vision.

WHITE PAPER

この記事の理解を深める
無料ホワイトペーパーをプレゼント

製造業の現場で使える実務資料(PDF)を無料でお届けします。"こんな資料が届きます" ↓ 下のボタンからどうぞ。

PRODUCT — 製造業向け 調達・受発注クラウド

この記事の課題、
newji で解決しませんか?

newji は、製造業の調達・受発注に特化したクラウド/AIエージェント。見積依頼・発注書作成・進捗管理・承認をひとつの画面に集約し、AIが比較と異常検知を担当。最後の「GO」だけ人が押す仕組みです。

  • 見積〜発注〜納期を一元管理。催促・転記のムダをゼロに
  • AIが相見積もり比較と異常検知。あなたは判断だけに集中
  • 取引先は「招待」で完全無料。自社コストだけで取引先ごとデジタル化

※ 取引先から招待された企業様は完全無料でご利用いただけます

調達購買アウトソーシング

調達購買アウトソーシング

調達が回らない、手が足りない。
その悩みを、外部リソースで“今すぐ解消“しませんか。
サプライヤー調査から見積・納期・品質管理まで一括支援します。

対応範囲を確認する

OEM/ODM 生産委託

アイデアはある。作れる工場が見つからない。
試作1個から量産まで、加工条件に合わせて最適提案します。
短納期・高精度案件もご相談ください。

加工可否を相談する

NEWJI DX

現場のExcel・紙・属人化を、止めずに改善。業務効率化・自動化・AI化まで一気通貫で設計します。
まずは課題整理からお任せください。

DXプランを見る

受発注AIエージェント

受発注が増えるほど、入力・確認・催促が重くなる。
受発注管理を“仕組み化“して、ミスと工数を削減しませんか。
見積・発注・納期まで一元管理できます。

機能を確認する

You cannot copy content of this page