Today, we will be doing the third post in our series <em>Image editing using ArrayFire</em>. References to old posts are available below.
* <a href="http://sandbox.arrayfire.com/image-editing-using-arrayfire/">Part 1</a>
* <a href="http://sandbox.arrayfire.com/image-editing-using-arrayfire-part-2/">Part 2</a>

In this post, we will be looking at the following operations.
<ul>
<li>Image Histogram</li>
<li>Simple Binary Thesholding</li>
<li>Otsu's Thresholding</li>
<li>Iterative Thresholding</li>
<li>Adaptive Binary Thresholding</li>
<li>Emboss Filter</li>
</ul>

Today's post will be mostly dominated by different types of thresholding operations we can achieve using ArrayFire.

<h4>Image Histogram</h4>
We have built-in function in ArrayFire that creates a <a href="http://www.sandbox.arrayfire.com/docs/group__image__func__cpp__histogram.htm">histogram</a>.
<div style = "text-align:center">
 <div style="vertical-align: top">
[caption id="attachment_6311" align="alignnone" width="300"]<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/07/arrow.jpg"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2014/07/arrow-300x168.jpg" alt="Input" width="300" height="168" class="size-medium wp-image-6311" /></a> Input[/caption]
 </div>
 <div style="vertical-align: bottom">
<iframe height=371 width=600 src="//docs.google.com/a/sandbox.arrayfire.com/spreadsheets/d/1mWvh5XftcIF4hkcf2gwe_7K0kKWngiayhqA7NOIKAPA/gviz/chartiframe?oid=928171252" seamless frameborder=0 scrolling=no></iframe>
 </div>
</div>

<h4>Simple Binary Thesholding</h4>

<p><code>c
binary threshold
</code></p>

<h4>Otsu's Thresholding</h4>

<p>The famous Otus's thersholding method is very reliable in the case of images with bi-modal histograms. Below given is a comparision of simple binary thresholding and Otus's thresholding for your reference.
<code>c
Otsu
</code></p>

<h4>Iterative Thresholding</h4>

<p>This is another type of global thresholing method where the input image is repetitively thresholded. In each iteration, threshold value is calculated from the previous step's result. In the first iteratation, the threshold value is selected randomly. When the difference between two succesive steps threshold is less than certain value, the algorithm exits the iterative loop and the last iteration's threshold value is used to threshold the original input image.
<code>c
Iterative thresholing
</code></p>

<h4>Adaptive Binary Thresholding</h4>

<p>Thresholding methods are usually categorized into two types: global and variable. Global thresholding methods have a single threshold value that helps classify the image pixels into two classes. Variable thresholding is where local neighbor-hood properties of the current pixel are usedf to threshold that very pixel. Adaptive binary threshold is where every pixel is thresholded using a threshold value that is computed using the pixel intensities from the spatial neighborhood of the current pixel. In the below implemenation, we used the local operators such as Mean, Median and Minimum &amp; Maximum to calculate the pixel threshold from local neighborhood. Thresholding output for each local operator mentioned above are provided below for your reference.
<code>c
</code></p>

<h4>Emboss Filter</h4>

<p>The emboss function is tailored after the emboss filter provided in GIMP, image editing software. The final outcome of emboss function is based on it's three input parameters: azimuth, elevation &amp; depth. The code and the sample outputs of emboss function are provided below.
<code>c
emnboss code
</code></p>