Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
OpenCV with Python By Example

You're reading from  OpenCV with Python By Example

Product type Book
Published in Sep 2015
Publisher Packt
ISBN-13 9781785283932
Pages 296 pages
Edition 1st Edition
Languages
Author (1):
Prateek Joshi Prateek Joshi
Profile icon Prateek Joshi

Table of Contents (19) Chapters

OpenCV with Python By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Applying Geometric Transformations to Images Detecting Edges and Applying Image Filters Cartoonizing an Image Detecting and Tracking Different Body Parts Extracting Features from an Image Creating a Panoramic Image Seam Carving Detecting Shapes and Segmenting an Image Object Tracking Object Recognition Stereo Vision and 3D Reconstruction Augmented Reality Index

Embossing


An embossing filter will take an image and convert it into an embossed image. We basically take each pixel and replace it with a shadow or a highlight. Let's say we are dealing with a relatively plain region in the image. Here, we need to replace it with plain gray color because there's not much information there. If there is a lot of contrast in a particular region, we will replace it with a white pixel (highlight), or a dark pixel (shadow), depending on the direction in which we are embossing.

This is what it will look like:

Let's take a look at the code and see how to do this:

import cv2
import numpy as np

img_emboss_input = cv2.imread('input.jpg')

# generating the kernels
kernel_emboss_1 = np.array([[0,-1,-1],
                            [1,0,-1],
                            [1,1,0]])
kernel_emboss_2 = np.array([[-1,-1,0],
                            [-1,0,1],
                            [0,1,1]])
kernel_emboss_3 = np.array([[1,0,0],
                            [0,0,0],
   ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}