Book Image

OpenCV Computer Vision Application Programming Cookbook Second Edition

By : Robert Laganiere
Book Image

OpenCV Computer Vision Application Programming Cookbook Second Edition

By: Robert Laganiere

Overview of this book

OpenCV 3 Computer Vision Application Programming Cookbook is appropriate for novice C++ programmers who want to learn how to use the OpenCV library to build computer vision applications. It is also suitable for professional software developers wishing to be introduced to the concepts of computer vision programming. It can also be used as a companion book in a university-level computer vision courses. It constitutes an excellent reference for graduate students and researchers in image processing and computer vision.
Table of Contents (18 chapters)
OpenCV Computer Vision Application Programming Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Applying look-up tables to modify the image appearance


Image histograms capture the way a scene is rendered using the available pixel intensity values. By analyzing the distribution of the pixel values over an image, it is possible to use this information to modify and possibly improve an image. This recipe explains how we can use a simple mapping function, represented by a look-up table, to modify the pixel values of an image. As we will see, look-up tables are often defined from histogram distributions.

How to do it...

A look-up table is a simple one-to-one (or many-to-one) function that defines how pixel values are transformed into new values. It is a 1D array with, in the case of regular gray-level images, 256 entries. Entry i of the table gives you the new intensity value of the corresponding gray level, which is as follows:

         newIntensity= lookup[oldIntensity];

The cv::LUT function in OpenCV applies a look-up table to an image in order to produce a new image. We can add this function...