Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
OpenCL Programming by Example

You're reading from   OpenCL Programming by Example A comprehensive guide on OpenCL programming with examples with this book and ebook

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781849692342
Length 304 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Banger Banger
Author Profile Icon Banger
Banger
Koushik Bhattacharyya Koushik Bhattacharyya
Author Profile Icon Koushik Bhattacharyya
Koushik Bhattacharyya
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Hello OpenCL FREE CHAPTER 2. OpenCL Architecture 3. OpenCL Buffer Objects 4. OpenCL Images 5. OpenCL Program and Kernel Objects 6. Events and Synchronization 7. OpenCL C Programming 8. Basic Optimization Techniques with Case Studies 9. Image Processing and OpenCL 10. OpenCL-OpenGL Interoperation 11. Case studies – Regressions, Sort, and KNN Index

Histogram calculation


Histogram is a graphical representation of tonal distribution of a digital image. It plots the number of pixels for each tonal value. In this example we find the histogram of each of the RGB color components in the color image.

In this section, we will discuss the histogram sample. The sample code has two parts the host code and the device code which is defined as a const char *histogram_kernel. For understanding purpose, we will discuss the OpenCL kernel code that follows. For an OpenCL application programmer most of the effort goes in writing the OpenCL kernel. The majority of the host code is that of setting up the OpenCL platform to run that kernel. We now start with the discussion of the kernel code.

Algorithm

The input image of size X height and Y width is divided into the small linear chunks of size BIN_SIZE=256. Each thread shall process 256 pixel values and compute the RGB histogram. Also the total number of threads in a work group which we have selected is 16...

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
OpenCL Programming by Example
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 £16.99/month. Cancel anytime
Modal Close icon
Modal Close icon