Skip main navigation

Practical: Getting and setting image pixel values using Python OpenCV

A practical on getting and setting pixel values in an image using Python OpenCV

It’s common to process and analyse images purely using Python, rather than through via Fiji. The OpenCV library is one way to do this.

This practical shows you how to install OpenCV if you haven’t already, then how to open images and manipulate pixel values within them.

All the instructions are in the attached pdf in the Downloads section below.

The example image used in the practical that you should save as ‘roots.jpg’ is below:

Image of roots on blue paper for use in the practical

The sample script ‘open_image.py’ can be downloaded from our Github repository at https://github.com/nlmellor/PhenoDataCampp/tree/main/ImageAnalysis/code.

Please let us know how you get on in the comments below.

This article is from the free online

Introduction to Image Analysis for Plant Phenotyping

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now