- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Calculating the mean of all pixels for each band in an image using the Pillow library
In this program, we will calculate the mean of all the pixels in each channel using the Pillow library. There are a total three channels in an image and therefore, we will get a list of three values.
Original Image
Algorithm
Step 1: Import the Image and ImageStat libraries. Step 2: Open the image. Step 3: Pass the image to the stat function of the imagestat class. Step 4: Print the mean of the pixels.
Example Code
from PIL import Image, ImageStat im = Image.open('image_test.jpg') stat = ImageStat.Stat(im) print(stat.mean)
Output
[76.00257724463832, 69.6674300254453, 64.38017448200654]
- Related Articles
- Calculating the root mean square of all pixels for each band in an image using the Pillow library
- Calculating the median of all pixels for each band in an image using the Pillow library
- Calculating the variance of all pixels for each band in an image using the Pillow library
- Calculating the standard deviation of all pixels for each band in an image using the Pillow library
- Cropping an image using the Pillow library
- Rotating an image using Pillow library
- Loading and displaying an image using the Pillow library
- Applying Gaussian Blur to an image using the Pillow library
- Applying Box Blur to an image using the Pillow library
- Applying rank filter to an image using the Pillow library
- Applying MinFilter on an image using Pillow library
- Applying MaxFilter on an image using Pillow library
- Applying ModeFilter on an image using Pillow library
- Applying MedianFilter on an image using Pillow library
- How to Set/modify the pixels(RGB values) of an image using Java OpenCV Library?

Advertisements