<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by shashika dilhani on Medium]]></title>
        <description><![CDATA[Stories by shashika dilhani on Medium]]></description>
        <link>https://medium.com/@shashikadilhani97?source=rss-231202168af4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*q2eEYq0Q-YlPAT7We-ucdg.jpeg</url>
            <title>Stories by shashika dilhani on Medium</title>
            <link>https://medium.com/@shashikadilhani97?source=rss-231202168af4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:56:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shashikadilhani97/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Digital Image Thresholding Techniques…]]></title>
            <link>https://medium.com/@shashikadilhani97/digital-image-thresholding-techniques-969b006c9e07?source=rss-231202168af4------2</link>
            <guid isPermaLink="false">https://medium.com/p/969b006c9e07</guid>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[shashika dilhani]]></dc:creator>
            <pubDate>Fri, 06 Aug 2021 09:27:38 GMT</pubDate>
            <atom:updated>2021-08-06T09:27:38.994Z</atom:updated>
            <content:encoded><![CDATA[<p>Types of image thresholding techniques…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FeLEP9XvqY-DAnecV3cTCQ.png" /></figure><p>Image thresholding is the easiest way to separate image background and foreground. Also, this image thresholding can be identify as image segmentation. To apply thresholding techniques, we should use a gray scale image. When thresholding, that grayscale image will be converted to a binary image. In this article, we will discuss about different types of digital image thresholding techniques.</p><h3>Simple Thresholding…</h3><blockquote>In simple thresholding, all pixel values those are greater than the specific threshold value, assign to standard value. It compares pixel values with special threshold value. After separating the pixel, we can see the segmented images according to threshold values. Threshold techniques are mainly divided in to 3 categories based on the threshold operator.</blockquote><ul><li>Global → threshold operator depends on the gray values of the pixel</li><li>Local → threshold operator depends on the gray values of the pixel and local properties</li><li>Dynamic → threshold operator depends on the gray values of the pixel and local properties and it’s position</li></ul><h3>Basic Global Thresholding …</h3><p>Global thresholding depends on the histogram of the image. This section again divides in to 2 categories : <strong><em>histogram improvement</em></strong> method and <strong><em>threshold computing</em></strong> method.</p><h4>Histogram Improvement …</h4><p>Using this method, we can easily separate the image segments. But this method will fail when using images with complex backgrounds. Also, this method sensitive to noises.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*xw8FCZabVjamEQraGrNNLw.png" /></figure><h4>Threshold Computing…</h4><p>Threshold computing methods can be use for complex backgrounds and multiple objects. It uses local both properties and gray level information for the thresholding process. Therefore , threshold computing methods is most effective than histogram improvement method. There are several threshold computing methods such as Adaptive thresholding, Otsu thresholding and Binary thresholding.</p><h3>Adaptive Thresholding …</h3><blockquote>In this technique, input image will be segmented in to small areas. These areas are non overlapping areas. Different threshold values are use to each image segment. Threshold values are depends on the locations of pixel values. Because, each image segment has different light areas.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*EcfRrMQw0WRKxeSL1JxedA.png" /></figure><h3>Binary Thresholding…</h3><blockquote>In binary thresholding technique, pixels above the threshold value will be turned on, those below the threshold will be turned off. This is a simple thresholding technique and most common technique. Pixel values compares with 255 and 0. According to that margin, pixel colors will be black or white.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*9VMxUazMx8S9lzdDaE_Yqw.png" /></figure><h3>Threshold to Zero …</h3><blockquote>In this technique, pixel value compares with the threshold value. If the value is grater than threshold value, then corresponding value will be assign. Otherwise, pixel value will be set to Zero.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*5cCkoVd7vvFtooCeM9fhHw.png" /></figure><h3>Otsu Thresholding …</h3><blockquote>This “Automatic Optimal Threshold Detection” technique finds optimum global threshold value from histogram of the image. When image histogram has 2 peaks, optimal threshold value should be in the middle of those values. Image will be separated in to foreground and background according to threshold value. There are 2 categories in Otsu method called 1-D and 2-D. 2-D method is more effective than 1-D technique.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*m9X-vKizGMZxaqQrzzvU2Q.jpeg" /></figure><h3>Truncate Thresholding …</h3><p>In this method, the destination pixel will be set to the threshold value. Pixel values which are greater than the threshold value will be set to threshold value. Other values are remaining same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ewdNxR7w0NhyXt4InHImHQ.jpeg" /></figure><h3><strong><em>Implementation ..</em></strong></h3><pre>#include &quot;opencv2/opencv.hpp&quot;<br>#include &quot;opencv2/highgui.hpp&quot;<br>#include &quot;opencv2/core.hpp&quot;<br></pre><pre>using namespace std;<br>using namespace cv;<br>int main(int argc, char* argv[]) {</pre><pre>Mat img = imread(argv[1],CV_LOAD_IMAGE_GRAYSCALE);</pre><pre>if (!img.data) {<br>cout &lt;&lt; &quot;Could not fnd the image!&quot; &lt;&lt; endl;<br>return -1;}</pre><pre>int height = img.rows;<br>int width = img.cols;<br>int widthstep = img.step;<br>int ch = img.channels();</pre><pre>Mat avgFilter = img.clone();<br>Mat medianFilter = img.clone();<br>Mat gaussianFilter = img.clone();<br>Mat bThreshbold = img.clone();<br>Mat oThreshbold = img.clone();<br>Mat aThreshbold = img.clone();</pre><pre>blur(img, avgFilter,Size(3, 3), Point(-1,-1), 4);<br>medianBlur(img, medianFilter,3);<br>GaussianBlur(img, gaussianFilter, Size(3,3),(0,0), 4);</pre><pre>//====================Thresholding==================================</pre><pre>////////////////   Binary Thresholding   /////////////////////////<br>//foreground white, bachgroud white<br>threshold(medianFilter, bThreshbold, 130, 255, CV_THRESH_BINARY );<br>//forground black background white<br>threshold(medianFilter, bThreshbold, 130, 255,CV_THRESH_BINARY_INV);</pre><pre>/////////////////   OTSU Threshold  ///////////////////////////////<br>threshold(medianFilter, oThreshbold, 0, 255, CV_THRESH_OTSU CV_THRESH_BINARY);</pre><pre>////////////////   Aduptive Treshold   /////////////////////////////<br>adaptiveThreshold(medianFilter, aThreshbold, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 11, 2 );</pre><pre>namedWindow(&quot;Image&quot;);<br>imshow(&quot;Image&quot;, img);<br>namedWindow(&quot;Average Filter&quot;);<br>imshow(&quot;Average Filter&quot;, avgFilter);<br>namedWindow(&quot;Median Filter&quot;);<br>imshow(&quot;Median Filter&quot;, medianFilter);<br>namedWindow(&quot;Gaussian Filter&quot;);<br>imshow(&quot;Gaussian Filter&quot;, gaussianFilter);<br>namedWindow(&quot;Binary Threshold&quot;);<br>imshow(&quot;Binary Threshold&quot;, bThreshbold);<br>namedWindow(&quot;OTSU Threshold&quot;);<br>imshow(&quot;OTSU Threshold&quot;, oThreshbold);<br>namedWindow(&quot;AD Threshold&quot;);<br>imshow(&quot;AD Threshold&quot;, aThreshbold);<br>imwrite(&quot;bthresh.jpg&quot;,bThreshbold );<br>imwrite(&quot;othresh.jpg&quot;,oThreshbold );<br>imwrite(&quot;adthhresh.jpg&quot;,aThreshbold );</pre><pre>cvWaitKey(0);<br>return 0;<br>}</pre><h3>Conclusion …</h3><p>Image thresholding techniques are the simplest and cost effective way for image segmentation. The output images will be different according to the threshold operators and image properties.</p><h3>References …</h3><p><a href="https://ukdiss.com/examples/global-thresholding-image-segmentation-techniques.php">https://ukdiss.com/examples/global-thresholding-image-segmentation-techniques.php</a></p><p><a href="https://learnopencv.com/opencv-threshold-python-cpp/">https://learnopencv.com/opencv-threshold-python-cpp/</a></p><p><a href="https://www.tutorialspoint.com/performing-truncate-thresholding-on-an-image-using-opencv">https://www.tutorialspoint.com/performing-truncate-thresholding-on-an-image-using-opencv</a></p><p><a href="https://docs.opencv.org/4.5.1/d7/d4d/tutorial_py_thresholding.html">https://docs.opencv.org/4.5.1/d7/d4d/tutorial_py_thresholding.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=969b006c9e07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital Image Processing Filters]]></title>
            <link>https://medium.com/@shashikadilhani97/digital-image-processing-filters-832ec6d18a73?source=rss-231202168af4------2</link>
            <guid isPermaLink="false">https://medium.com/p/832ec6d18a73</guid>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[shashika dilhani]]></dc:creator>
            <pubDate>Thu, 05 Aug 2021 19:29:23 GMT</pubDate>
            <atom:updated>2021-08-05T19:29:23.050Z</atom:updated>
            <content:encoded><![CDATA[<p>Types of images filters and smoothing techniques….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLNQnZiJ_11TZnSuqU-nZQ.png" /></figure><blockquote>In digital image processing, smoothing operations are use to remove noises. Image filtering is a most important part of the smoothing process. In this article, we will discuss about different types of image filters and their characteristics.</blockquote><h3>Image Filtering…</h3><p>Filtering techniques are use to enhance and modify digital images. Also, images filters are use to blurring and noise reduction , sharpening and edge detection. Image filters are mainly use for suppress high (smoothing techniques) and low frequencies(image enhancement, edge detection). Classification of image filters is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*t_PNwIx_9U8RHTa2bFA_pw.png" /><figcaption>source:<a href="https://www.researchgate.net/publication/328619526"> </a>https://www.researchgate.net/publication/328619526</figcaption></figure><blockquote>Simple Adaptive Median filter (AMF) , Decision Based Median Filter (DBMF) , Decision Based Untrimmed Median Filter (DBUTM)</blockquote><p>According to this classification, image filters can be divide in to two main categories. Spatial filtering is the traditional method of image filtering. it is use directly on the image pixels. Frequency domain filters are use to remove high and low frequencies and smoothing.</p><p>Non linear filters are use to detect edges. Those filtering techniques are more effective than linear filters. In linear filtering, image details and edges are tend to blur. Gaussian filter, Laplacian filter and Neighborhood Average (Mean) filter can be identify as examples for linear filters. Median filters are non linear filters. The next part of this article is the discussion about different linear and non linear filters.</p><h3><strong>Median Filter…</strong></h3><blockquote>Median filter is a non-linear filter. It replaces each pixel values by the median values of it’s neighbor pixels. This is the efficient way for remove salt-and-pepper noise. The calculation of the median value is given below.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*-NVjiEYLFVOdRbxkihA8Qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*rb_JjH49u0MUTZs-0ncB7w.png" /></figure><h3>Laplacian Filter…</h3><blockquote>Laplace smoothing technique is mainly use to detect image edges. It highlights gray level discontinuities. It is based on second spatial derivation of an image. To define Laplacian operator, below equation has been used.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*UT31K134wXnZ8SM07GBZQA.png" /></figure><blockquote>Laplace edge detector use only one kernel. To detect the edges of an image, this kernel detects 2nd order derivatives of image’s intensity levels by using only single pass. We can use “kernel 2&quot; for detects edges with diagonals. It will give better approximation. Also, Laplace method gives faster calculations than others.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*H5cP-t6IEDFUeFAn3YX-Fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*o_was4oP7irQ06dNecz1KA.png" /></figure><h3>Gaussian Filter…</h3><blockquote>This filter is a 2-D convolutional operator. It use to blur images. Also, it removes details and noises. Gaussian filter is similar to mean filter. But main difference is, Gaussian filter use a kernel. That kernel has a shape of gaussian hump. Gaussian kernel weights pixels at its center much more strongly than its boundaries. There are different gaussian kernels. Based on the kernel size, output image will be different.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*I4rHGuGpVmxT_3x84UfcvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*rShy1GuFKnBHwG18newGag.png" /></figure><h3>Neighbourhood Average Filter…</h3><blockquote>This filter is also called as mean filter. In average filtering, pixel values will be replace by average values of neighbour pixels. The calculation of average value is as follows.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*U8tDH9dcvmAyuJhp2fnj7Q.png" /></figure><h3>BOX Filter…</h3><blockquote>Box filter is a spatial domain linear image filter. Also, this box filter is a low-pass filter. It’s operations are similar to average filtering technique.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*DfL8FZFCVYl6AL95_czu6A.png" /></figure><h3>Conclusion…</h3><blockquote>From this article, we discussed about digital image filters and classification of those filters. Mainly there are 2 types of filters and user those topics, there are different types of filtering techniques. Image filters are widely use for remove noises and image enhancement processes. Using filters, we can remove or emphasize image details.</blockquote><h3><strong><em>References…</em></strong></h3><blockquote><a href="https://www.researchgate.net/publication/328619526">https://www.researchgate.net/publication/328619526</a></blockquote><blockquote><a href="https://www.researchgate.net/publication/328619526_Comparative_Analysis_of_Fixed_Valued_Impulse_Noise_Removal_Techniques_for_Image_Enhancement_Second_International_Conference_ICACDS_2018_Dehradun_India_April_20-21_2018_Revised_Selected_Papers_Part_I">https://www.researchgate.net/publication/328619526_Comparative_Analysis_of_Fixed_Valued_Impulse_Noise_Removal_Techniques_for_Image_Enhancement_Second_International_Conference_ICACDS_2018_Dehradun_India_April_20-21_2018_Revised_Selected_Papers_Part_I</a></blockquote><ul><li><a href="https://www.programmersought.com/article/48905351349/">MATLAB image processing-Gaussian low-pass filter, Gaussian high-pass filter (code and examples) - Programmer Sought</a></li><li><a href="https://homepages.inf.ed.ac.uk/rbf/HIPR2/filtops.htm">Digital Filters</a></li><li><a href="https://docs.opencv.org/4.5.2/dd/d6a/tutorial_js_filtering.html">OpenCV: Smoothing Images</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=832ec6d18a73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hidden Markov Models with Viterbi Algorithm…]]></title>
            <link>https://medium.com/@shashikadilhani97/hidden-markov-models-with-viterbi-algorithm-226fa4b5777d?source=rss-231202168af4------2</link>
            <guid isPermaLink="false">https://medium.com/p/226fa4b5777d</guid>
            <category><![CDATA[hidden-markov-models]]></category>
            <category><![CDATA[viterbi-algorithm]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[shashika dilhani]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 12:10:19 GMT</pubDate>
            <atom:updated>2021-11-09T17:16:55.733Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How to optimize Hidden Markov Models using Viterbi Algorithm.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*o4IHA6h-QMwchXNJLik5fw.jpeg" /></figure><p>In the previous article (You can find it <a href="https://medium.com/@shashikadilhani97/hidden-markov-models-with-forward-algorithm-d6d4f6fa7214"><em>here</em></a>), we discussed about what are the Hidden Markov Models and how to optimize Hidden Markov Models with forward algorithm. In HMM, there are 3 types of problems. “Decoding” is the second type of HMM problems.</p><p><strong><em>Decoding</em></strong><em> → O observation sequence and λ = (A,B) Hidden Markov Model, find best hidden state sequence Q</em></p><p>In decoding tasks, we can find what is the most suitable hidden state sequence for given Hidden Markov Model. Therefore, we can use Viterbi algorithm for this task. Viterbi algorithm is the most common decoding algorithm for HMM.</p><p>This is the main 3 states of Viterbi Algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*qnh-zOLOvce48zDMPnuUPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*r9MQRuVL-oiNSPBGJXM5GA.png" /></figure><p>Let’s consider an example (from speech and language processing by Daniel Jurafsky and James H. Martin)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*_uQNxhwio3fC0DCwb4pf2Q.jpeg" /></figure><p>This is the diagram for Hidden Markov Model for ice cream task. (<em>same as the previous article</em>). HOT and COLD are the hidden states. Observations (O = {1,2,3}) are the no of ice cream eating results of a given day. In the ice-cream domain, observation sequence is <strong>(3 1 3 )</strong>. Here is the solution for best hidden weather sequence using Viterbi decoding algorithm.</p><p>Viterbi algorithm is identical for the forward algorithm. But in the Viterbi algorithm, it selects <strong>maximum</strong> value from the previous path probabilities. Also Viterbi algorithm has backpointers. Because, this algorithm makes probabilities and most likely state sequence.</p><p>Here is the graphical representation of the solution. In this graph, circles represent the hidden states and squares represent the observations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*qnczISP3_nsD6gnIESjqbw.jpeg" /></figure><p>From this representation, <em>v</em> values can be calculate as follows.</p><p><em>v1(1) = P(C |start).P(3|C)</em></p><p><em>v1(2) = P(H |start).P(3|H)</em></p><p>From <em>v1(1) and v1(2) ;</em></p><p><em>v1(2) = 0.8 * 0.4 = 0.32</em></p><p><em>v1(1) = 0.2 * 0.1 = 0.02</em></p><p>So, <em>v1(2) is the suitable answer for first observation. Because it is the maximum answer. Let’s consider v2(1) and v2(2).</em></p><p><em>v2(1) = v1(2) .P(C|H).P(1|C)</em></p><p><em>v2(2) = v1(2) .P(H|H).P(1|H)</em></p><p><em>v2(1) = 0.32*0.4*0.5 = 0.064</em></p><p><em>v2(2) = 0.32*0.6*0.2 = 0.0384</em></p><p>According to this result, the maximum value is 0.064. then, <em>v2(1) is the answer for second observation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*BzXCDhJGPmtt5gvOkybf1Q.jpeg" /></figure><p>As seen above, we can calculate full hidden pattern using Viterbi decoding algorithm for final answer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=226fa4b5777d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hidden Markov Models with Forward Algorithm]]></title>
            <link>https://medium.com/@shashikadilhani97/hidden-markov-models-with-forward-algorithm-d6d4f6fa7214?source=rss-231202168af4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6d4f6fa7214</guid>
            <dc:creator><![CDATA[shashika dilhani]]></dc:creator>
            <pubDate>Wed, 07 Jul 2021 15:46:14 GMT</pubDate>
            <atom:updated>2021-07-07T15:46:14.441Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What are the Hidden Markov Models ,how to apply Hidden Marko Models to part of speech tagging and how to optimize HMM with forward algorithm…..</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*BGYc0XF3JuykME2sNBtXlg.png" /></figure><h3>What are the Hidden Markov Models ?</h3><p>In part of speech tagging, there are Markov chains for calculate probabilities for sequential observable events.</p><p><em>ex : For given Markov chain representation about weather conditions, predict the probability of the weather for the next seven days will be “sun-rain-rain-sun-rain-sun-rain” .</em></p><p>In this example, observations are visible. But there are some events which are hidden events. Those events are not observed. Hidden Markov Models are the solutions for these kind of POS tagging. HMM contains with 5 parts.</p><ul><li><em>Q = q1 q2 q3 ….. qN → set of N states</em></li><li><em>A = a11, a12, a13,……aNN → Transition Probability Matrix (aij is Probability for moving from one state to another state)</em></li><li><em>O = o1 o2 o3 ….oT → Observation sequence</em></li><li><em>B = bi(ot) → Observation likelihoods (emission probabilities)</em></li><li><em>π = π1,π2,…,πN → Initial probability distributions</em></li></ul><p><strong>There are 2 assumptions for first order HMM;</strong></p><p>The probability of particular state depends only on the previous state <em>P(qi|q1,…,qi−1) = P(qi|qi−1)</em></p><p>The probability of an observation <em>Oi </em>depends on the state that produced the observation<em> qi </em>and not on any other states or any other observation.</p><p><em>P(Oi | q1,..qT,O1,…OT) = P(Oi |qi)</em></p><p>In Hidden Markov Models, There are 3 types of problems</p><ul><li><strong><em>Likelihood</em></strong><em> → λ = (A,B) Hidden Markov Model and O observation sequence, calculate Likelihood P(O|λ)</em></li><li><strong><em>Decoding</em></strong><em> → O observation sequence and λ = (A,B) Hidden Markov Model, find best hidden state sequence Q</em></li><li><strong><em>Learning</em></strong><em> → O observation sequence and given HMM states, learn the Hidden Markov Model parameters A and B.</em></li></ul><p>in this article, we will discuss about likelihood computations (Forward Algorithm)</p><h3>Optimize HMM with Forward Algorithm…</h3><p>There are 3 states in the forward algorithm,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*xEsri8DQ4FWUBnsQd8SwUg.png" /></figure><p>In forward algorithm, initialization is probability of being in state <em>j </em>after seeing the first t observations in given <em>λ </em>automation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*7gxTdO9unmISQ4rXotZukQ.png" /></figure><p>Let’s consider an example (from speech and language processing by Daniel Jurafsky and James H. Martin)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*TqI66ccobpHqj7lPPBb5Ig.png" /></figure><p>This diagram shows the here is the Hidden Markov Model for ice cream task. HOT and COLD are the hidden states. Observations (O = {1,2,3}) are the no of ice cream eating results of a given day. Here is the solution for ice cream observation sequence <strong>(3 1 3 )</strong>.</p><p>let’s calculate the forward probability of observation <em>3 1 3</em> for hidden weather sequence <em>hot hot cold.</em></p><p><em>P (3 1 3 | hot hot cold)</em></p><p><em>= P(hot |start) . P(3|hot).P(hot |hot).P(1|hot).P(cold |hot).P(3|cold)</em></p><p><em>= 0.8 * 0.4 *0.6 *0.2 * 0.4* 0.1 = 0.00153</em></p><p>For this examples, there are 8 different states. When we calculate total probability of observation, we should calculate probabilities for all hidden weather sequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*uRPkIsEWOxsEO7rjfLGnpg.png" /></figure><p>Then we can calculate total probability as follows</p><p><strong>Total Probability </strong>=<em> p(3 1 3 | hot hot hot) + P(3 1 3 | hot hot cold) + P(3 1 3 | hot cold hot) + …..</em></p><p>This is the graphical representation of the solution. In this graph, circles represent the hidden states and squares represent the observations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*_XaX-JTF8uYqUlP1dANlLQ.png" /></figure><p>This graph represent the calculating values of all single elements by summing all previous states. From this representation, α values can be calculate as follows.</p><p><em>α1(1) = P(C |start).P(3|C)</em></p><p><em>α1(2) = P(H |start).P(3|H)</em></p><p><em>α2(1) = α1(1) .P(C|C).P(1|C) + α1(2) .P(C|H).P(1|C)</em></p><p><em>α2(2) = α1(1) .P(H|C).P(1|H) + α1(2) .P(H|H).P(1|H)</em></p><p><em>α3(1) = α2(1) .P(C|C).P(3|C) + α2(2) .P(C|H).P(3|C)</em></p><p><em>α3(2) = α2(1) .P(H|C).P(3|H) + α2(2) .P(H|H).P(3|H)</em></p><p>As seen above, we can calculate total probability by using forward algorithm for Hidden Markov Models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6d4f6fa7214" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>