<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SHIVAY Development House</title>
	<atom:link href="https://www.shivay.co.il/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.shivay.co.il</link>
	<description>Shivay is a pioneering software, engineering, and algorithms company dedicated to crafting bespoke solutions tailored to our clients’ specific hardware needs</description>
	<lastBuildDate>Tue, 10 Feb 2026 08:52:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://www.shivay.co.il/wp-content/uploads/2024/03/shivay-fav-web-65x65.png</url>
	<title>SHIVAY Development House</title>
	<link>https://www.shivay.co.il</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Python itertools and color palettes</title>
		<link>https://www.shivay.co.il/2019/12/24/python-itertools-and-color-palettes/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Tue, 24 Dec 2019 05:39:11 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://www.shivay.co.il/?p=2737</guid>

					<description><![CDATA[The RGB color scheme uses values of 0-255 for each color channel in the format (R, G, B). So the color red is (255, 0, 0), the color green is (0, 255, 0) and the color blue is (0, 0, 255). The colors yellow (255, 255, 0), magenta (255, 0, 255) and cyan (0, 255, [&#8230;]]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2737" class="elementor elementor-2737" data-elementor-post-type="post">
				<div class="elementor-element elementor-element-25fc033e e-flex e-con-boxed e-con e-parent" data-id="25fc033e" data-element_type="container" data-e-type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-6e4445ba elementor-widget elementor-widget-text-editor" data-id="6e4445ba" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><span style="color: #dfdfdf;">The RGB color scheme uses values of 0-255 for each color channel in the format (R, G, B). So the color red is (255, 0, 0), the color green is (0, 255, 0) and the color blue is (0, 0, 255). The colors yellow (255, 255, 0), magenta (255, 0, 255) and cyan (0, 255, 255) are combinations of 2 values equaling 255 and the remaining one is zero. Other basic colors such as orange, brown, gray, and many more are combinations of the values 0, 128 and 255 for various red, green and blue channels. Orange for example is (255, 128, 0).<br /></span></p><center><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-2748" src="https://www.shivay.co.il/wp-content/uploads/2019/12/2019-12-24-07_36_35-Figure-1.png" alt="" width="506" height="258" srcset="https://www.shivay.co.il/wp-content/uploads/2019/12/2019-12-24-07_36_35-Figure-1.png 506w, https://www.shivay.co.il/wp-content/uploads/2019/12/2019-12-24-07_36_35-Figure-1-300x153.png 300w, https://www.shivay.co.il/wp-content/uploads/2019/12/2019-12-24-07_36_35-Figure-1-500x255.png 500w" sizes="(max-width: 506px) 100vw, 506px" /></center><p><span style="color: #dfdfdf;"><br />A common task is to create the entire palette of colors using 0 and 255. These will include red, green, blue, yellow, magenta, cyan, white (255, 255, 255) and black (0, 0, 0). Instead of manually typing all the combinations we can use Python&#8217;s itertools module to do this:</span></p><pre class="EnlighterJSRAW" data-enlighter-language="python">import itertools
for color in itertools.product([0, 255], repeat=3):
    print(color)
</pre><p>The result is:</p><pre>(0, 0, 0)      
(0, 0, 255)    
(0, 255, 0)    
(0, 255, 255)  
(255, 0, 0)    
(255, 0, 255)  
(255, 255, 0)  
(255, 255, 255)
</pre><p>To further generate the colors with the value 128 as well, you can use this code:</p><pre class="EnlighterJSRAW" data-enlighter-language="python">import itertools
for color in itertools.product([0, 128, 255], repeat=3):
    print(color)
</pre><p>And the result:</p><pre>(0, 0, 0)       
(0, 0, 128)     
(0, 0, 255)     
(0, 128, 0)     
(0, 128, 128)   
(0, 128, 255)   
(0, 255, 0)     
(0, 255, 128)   
(0, 255, 255)   
(128, 0, 0)     
(128, 0, 128)   
(128, 0, 255)   
(128, 128, 0)   
(128, 128, 128) 
(128, 128, 255) 
(128, 255, 0)   
(128, 255, 128) 
(128, 255, 255) 
(255, 0, 0)     
(255, 0, 128)   
(255, 0, 255)   
(255, 128, 0)   
(255, 128, 128) 
(255, 128, 255) 
(255, 255, 0)   
(255, 255, 128) 
(255, 255, 255) 
</pre><p>The image in the beginning of this post was generated using this code:</p><pre class="EnlighterJSRAW" data-enlighter-language="python">import itertools, numpy
from matplotlib.pylab import imshow, show, xticks, yticks

colors = list(itertools.product([0, 255], repeat=3))
m = numpy.array(colors).reshape(2, 4, 3)
xticks([])
yticks([])
imshow(m)
show()
</pre><p> </p>								</div>
				</div>
					</div>
				</div>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Thumbnail Graphs</title>
		<link>https://www.shivay.co.il/2019/12/15/thumbnails/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Sun, 15 Dec 2019 06:06:21 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://www.shivay.co.il/?p=2698</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Thumbnail Graphs</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div>
<div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h4 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >// Shai Vaingast, December 2019</h4></div></div></div></div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693293457" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><br />
A reoccurring task I do quite a lot is plot a lot of graphs:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">
from matplotlib import pyplot
import numpy

t = numpy.arange(0, 2 * numpy.pi, 0.1)
data = { 'sin' : numpy.sin(t), 'cos': numpy.cos(t), 't' : t, 't**2' : t ** 2, 
    'abs(t-pi)' : abs(t - numpy.pi), '-t' : -t }

for function in data:
    pyplot.figure()
    pyplot.plot(t, data[function])
    pyplot.title(function)

pyplot.show()
</pre>
<p>Now if you open a figure for every graph, once you get to a twenty or so, this becomes too much for Python and Matplotlib. So instead, I use subplots. Using subplots does require a bit of maintenance: what figure are we currently on? do we need to open a new figure? So I wrote a class to handle the thumbnails overhead:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">
# a class to encapsulate automatic subplots
# Shai Vaingast, 2019-12-03

from matplotlib import pyplot as plt

class Thumbnails():
    def __init__(self, n=2, m=2):
        self._i = 1
        self._n = n
        self._m = m

    def _next(self):
        if self._i == 1:
            plt.figure()
        plt.subplot(self._n, self._m, self._i)
        self._i += 1
        if self._i == self._n * self._m + 1:
            self._i = 1

    def _text(self, title=None, xlabel=None, ylabel=None):
        if title is not None: plt.title(title)
        if xlabel is not None: plt.xlabel(xlabel)
        if ylabel is not None: plt.ylabel(ylabel)

    def imshow(self, img, title=None, xlabel=None, ylabel=None):
        self._next()
        plt.imshow(img)
        self._text(title, xlabel, ylabel)

    def scatter(self, x, y, title=None, xlabel=None, ylabel=None):
        self._next()
        plt.scatter(x, y)
        self._text(title, xlabel, ylabel)

    def plot(self, x, y, title=None, xlabel=None, ylabel=None):
        self._next()
        plt.plot(x, y)
        self._text(title, xlabel, ylabel)

    def show(self):
        plt.show()
        
if __name__ == '__main__':
    import numpy

    t = numpy.arange(0, 2 * numpy.pi, 0.1)
    data = { 'sin' : numpy.sin(t), 'cos': numpy.cos(t), 't' : t, 't**2' : t ** 2, 
        'abs(t-pi)' : abs(t - numpy.pi), '-t' : -t }
    
    thumb = Thumbnails()
    for function in data:
        thumb.plot(t, data[function], title=function)

    plt.show()
</pre>
<p>Here&#8217;s what it looks like (first figure):<br />
<figure id="attachment_2713" aria-describedby="caption-attachment-2713" style="width: 640px" class="wp-caption aligncenter"><img decoding="async" src="https://www.shivay.co.il/wp-content/uploads/2019/12/thumbnails_Figure_1.png" alt="Thumbnails figure" width="640" height="480" class="size-full wp-image-2713" srcset="https://www.shivay.co.il/wp-content/uploads/2019/12/thumbnails_Figure_1.png 640w, https://www.shivay.co.il/wp-content/uploads/2019/12/thumbnails_Figure_1-300x225.png 300w, https://www.shivay.co.il/wp-content/uploads/2019/12/thumbnails_Figure_1-500x375.png 500w" sizes="(max-width: 640px) 100vw, 640px" /><figcaption id="caption-attachment-2713" class="wp-caption-text">A thumbnails figure implemented with subplots</figcaption></figure><br />
To see it in action, run the following:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="bash">
python thumbnails.py</pre>
<p>Copy and save it as thumbnails.py. The usage is quite straightforward. Create a Thumbnails object and then call the plot(), scatter() or imshow() methods. The default subplot size is 2&#215;2 but you can override it, for example, 3&#215;1:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">
from thumbnails import Thumbnails
thumb = Thumbnails(3, 1)
</pre>
<p>The Thumbnails class also supports graphs of the following types:</p>
<ul>
<li>scatter plots</li>
<li>regular plots</li>
<li>images</li>
</ul>
<p>You can easily extend it to support additional graph types.</p>
<p>I&#8217;ve also added support for titles. To add a title, add title=&#8217;graph title&#8217; as a parameter to the plot function. Similarly, to add a xlabel or ylabel, pass them as parameters to the plot function.</p>
<p>A fuller example is provided in the script itself:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">
import numpy
from matplotlib import pyplot as plt
from thumbnails import Thumbnails

t = numpy.arange(0, 2 * numpy.pi, 0.1)
data = { 'sin' : numpy.sin(t), 'cos': numpy.cos(t), 't' : t, 't**2' : t ** 2,
    'abs(t-pi)' : abs(t - numpy.pi), '-t' : -t }

thumb = Thumbnails()
for function in data:
    thumb.plot(t, data[function], title=function)

plt.show()
</pre>
<p></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compiling with Visual Studio and OpenCV</title>
		<link>https://www.shivay.co.il/2016/02/02/compiling-with-visual-studio-and-opencv/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Tue, 02 Feb 2016 17:55:03 +0000</pubDate>
				<category><![CDATA[OpenCV]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=1478</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Compiling with Visual Studio and OpenCV</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Download and Unzip OpenCV4.0</u></a></strong></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>Setting an Environment Variable</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#3"><u>Setting up Visual Studio</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#4"><strong><u>Testing the Application</u></strong></a></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#5"><strong><u>Streaming Realtime Image Processing in C++</u></strong></a></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#6"><strong><u>Streaming Realtime Image Processing in Python</u></strong></a></span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="" class="vc_custom_heading vc_do_custom_heading" >Download and Unzip OpenCV4.0</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1562153930710" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">Either through <a style="color: #dfdfdf;" href="https://www.opencv.org/"><span style="text-decoration: none;">https://www.opencv.org</span></a> or direct link: <a style="color: #dfdfdf;" href="https://sourceforge.net/projects/opencvlibrary/files/4.0.0/opencv-4.0.0-vc14_vc15.exe/download"><span style="text-decoration: none;">https://sourceforge.net/projects/opencvlibrary/files/4.0.0/opencv-4.0.0-vc14_vc15.exe/download</span></a></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">Unzip to to c:\opencv40</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">Your directory should look like this:</span></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img decoding="async" width="300" height="101" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Download-and-Unzip-OpenCV4.0-1.jpg" class="vc_single_image-img attachment-full" alt="Download and Unzip OpenCV4.0" title="Download and Unzip OpenCV4.0" /></div>
		</figure>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Setting an Environment Variable</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1562154605209" >
		<div class="wpb_wrapper">
			<ol>
<li><span style="color: #dfdfdf;">From Windows start menu, run &#8220;Edit the System Environment Variables”</span></li>
<li><span style="color: #dfdfdf;">Click on Environment Variables and click New. Define a new environment variable named OPENCV_DIR and set it to the location of the OpenCV directory (usually</span><br />
<span style="color: #dfdfdf;">c:\Opencv40\build where 40 means OpenCV 4.0). Exit the dialog box.</span></li>
</ol>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="501" height="284" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-an-Environment-Variable-3.jpg" class="vc_single_image-img attachment-full" alt="Setting an Environment Variable" title="Setting an Environment Variable" srcset="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-an-Environment-Variable-3.jpg 501w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-an-Environment-Variable-3-300x170.jpg 300w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-an-Environment-Variable-3-500x283.jpg 500w" sizes="(max-width: 501px) 100vw, 501px" /></div>
		</figure>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="185" height="265" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-an-Environment-Variable-2.jpg" class="vc_single_image-img attachment-full" alt="Setting an Environment Variable" title="Setting an Environment Variable" /></div>
		</figure>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="3" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Setting up Visual Studio</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1562154710836" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 3. Install Visual Studio 2017<br />
4. Create a simple console application (ConsoleApplication1).<br />
5. Go to Project | ConsoleApplication1 Properties… and select the configuration All Configurations. Platform should be x64. Select C/C++, General and click on the Additional Include Directories, and select Edit.<br />
6. Add the directory $(OPENCV_DIR)\include and ensure it is properly evaluated</span></p>
<p>&nbsp;</p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="524" height="371" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4.jpg" class="vc_single_image-img attachment-full" alt="Setting up Visual Studio" title="Setting up Visual Studio" srcset="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4.jpg 524w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4-300x212.jpg 300w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4-500x354.jpg 500w" sizes="(max-width: 524px) 100vw, 524px" /></div>
		</figure>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1562154818788" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 7. Do the same in Linker, General and Additional Library Directories:<br />
$(OPENCV_DIR)\x64\vc15\lib</span></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="478" height="335" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4-7.jpg" class="vc_single_image-img attachment-full" alt="Setting up Visual Studio" title="Setting up Visual Studio" srcset="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4-7.jpg 478w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-4-7-300x210.jpg 300w" sizes="(max-width: 478px) 100vw, 478px" /></div>
		</figure>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1562154871796" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 8. In Debugging, add the command: PATH=$(OPENCV_DIR)\x64\vc15\bin;%PATH%</p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="493" height="347" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-8.jpg" class="vc_single_image-img attachment-full" alt="Setting up Visual Studio" title="Setting up Visual Studio" srcset="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-8.jpg 493w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-8-300x211.jpg 300w" sizes="(max-width: 493px) 100vw, 493px" /></div>
		</figure>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1562154926188" >
		<div class="wpb_wrapper">
			<p></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 9. Add the entry $(OPENCV_DIR)\x64\vc15\lib\opencv_world400d.lib to the Debug configuration<br />
</span></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="453" height="322" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-9.jpg" class="vc_single_image-img attachment-full" alt="Setting up Visual Studio" title="Setting up Visual Studio" srcset="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-9.jpg 453w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-9-300x213.jpg 300w" sizes="(max-width: 453px) 100vw, 453px" /></div>
		</figure>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1562155003413" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 10. Repeat the same with the Release dll: Add the entry $(OPENCV_DIR)\x64\vc15\lib\opencv_world400.lib to the Release configuration (notice that the ending is 400.dll and not 400d.dll)<br />
</span></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="540" height="379" src="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-10.jpg" class="vc_single_image-img attachment-full" alt="Setting up Visual Studio" title="Setting up Visual Studio" srcset="https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-10.jpg 540w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-10-300x211.jpg 300w, https://www.shivay.co.il/wp-content/uploads/2016/02/Setting-up-Visual-Studio-7-10-500x351.jpg 500w" sizes="(max-width: 540px) 100vw, 540px" /></div>
		</figure>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="4" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Testing the Application</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1562156230780" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 11. Create an image named test.png in ConsoleApplication directory<br />
12. Write the following code<br />
13. Run and see that it works<br />
</span></p>

		</div>
	</div>
</div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element vc_custom_1574614965054" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="cpp">// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include "pch.h"
#include &lt;iostream&gt;
#include &lt;opencv2/opencv.hpp&gt;

using namespace cv;
int main()
{
  Mat img=cv::imread("test.png");
  cv::imshow("Test", img);
  cv::waitKey();
}
</pre>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#0600df;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#0600df;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="5" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Streaming Realtime Image Processing in C++</h3></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element vc_custom_1574615197277" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="cpp">#include "pch.h"
#include &lt;iostream&gt;
#include &lt;opencv2/opencv.hpp&gt;

int main()
{
    cv::VideoCapture cap(0); // open the default camera
    if (!cap.isOpened())  // check if we succeeded
        return -1;

    cv::Mat edges;
    cv::namedWindow("edges", 1);
    for (;;)
    {
 		cv::Mat frame;
        cap &gt;&gt; frame; // get a new frame from camera
        cv::cvtColor(frame, edges, cv::COLOR_BGR2GRAY);
        cv::GaussianBlur(edges, edges, cv::Size(7, 7), 1.5, 1.5);
        cv::Canny(edges, edges, 0, 30, 3);
        cv::imshow("edges", edges);
        if (cv::waitKey(30) &gt;= 0) break;
    }
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;
}

</pre>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#0600df;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#0600df;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="6" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Streaming Realtime Image Processing in Python</h3>
	<div class="wpb_text_column wpb_content_element vc_custom_1574614080197" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="enlighter">import numpy as np
import cv2
cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY):
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) &amp; 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
</pre>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Debugging OpenCV Source Code with Python</title>
		<link>https://www.shivay.co.il/2016/01/22/debugging-opencv-source-code-with-python/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Fri, 22 Jan 2016 17:20:50 +0000</pubDate>
				<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Debugging OpenCV]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=192</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" > Debugging OpenCV Source Code with Python</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Operating System</u></a></strong></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>Development Environment</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#3"><u>OpenCV</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#4"><strong><u>Python and OpenCV</u></strong></a></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#5"><strong><u>C/C++ Integrated Development Environment</u></strong></a></span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Operating System</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567675656996" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">1. Install Oracle VM VirtualBox latest version 5.2.20 from https://www.virtualbox.org/wiki/Downloads. Username: sightec, password: sightex</span></p>
<p><span style="color: #dfdfdf;">2. Generate a 64 bit Ubuntu machine (20GB HD, 8GB RAM) with clipboard sharing</span></p>
<p><span style="color: #dfdfdf;">3. Install Ubuntu 18.04 LTS from https://www.ubuntu.com/#download</span></p>
<p><span style="color: #dfdfdf;">4. Upgrad and update all packages to the latest version</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">pip sudo apt-get update</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo apt-get upgrade</span></p>
<p><span style="color: #dfdfdf;">5. Run Software Updater (Ubuntu)</span></p>
<p><span style="color: #dfdfdf;">6. Install Guest additions on Ubuntu (From VirtualBox, Devices|Insert Guest Additions CD Image…) and reboot. This will enable clipboard sharing and file sharing between the host and the virtual machine<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Development Environment</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567675969305" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">7. In Ubuntu, set up the tool chain (compilers and libraries, see Required Packages in https://docs.opencv.org/3.4/d7/d9f/tutorial_linux_install.html)</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo apt-get install build-essential</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev</span></p>
<p><span style="color: #dfdfdf;">8. Set Python and related libraries</span><br />
<span style="color: #dfdfdf;">1. To get the most out of python, install the suite: ipython (interactive python development environment with shell and code completion), numpy (numerical librarie) and matplotlib (graphs and MATLAB feel)</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo apt-get install python-dev python-numpy python-dbg ipython python-matplotlib</span></p>
<p><span style="color: #dfdfdf;">9. Some additional libraries for OpenCV:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo apt-get install libgtk-3-dev</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="3" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >OpenCV</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567676683976" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">10. Get the latest version of OpenCV as source code (zipped file) from https://opencv.org/releases.html</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">unzip Downloads/opencv-3.4.3.zip</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">11. Create a temporary directory to compile OpenCV:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">mkdir -p ~/temp_opencv_compile/build</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">12. Configure cmake-gui</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">◦ If cmake-gui is not insalled, sudo apt install cmake-qt-gui<br />
◦ run cmake-gui from the command line<br />
◦ Make sure to configure cmake-gui with CodeBlocks &#8211; Unix Makefiles so we can later edit/view the source code in Code::Blocks C/C++ IDE<br />
◦ Where is the source code: /home/sightec/opencv-3.4.3.<br />
◦ Where to build binaries: /home/sightec/temp_opencv_compile/build.<br />
◦ Click configure. Use default compile settings.<br />
◦ Ensure to select BUILD_WITH_DEBUG_INFO, CMAKE_CONFIGURATION_TYPES only Debug (make sure to delete the Release configurations), CMAKE_BUILD_TYPE=Debug, ENABLE_GNU_STL_DEBUG (support for standard template library structures debug such as vectors and maps). This will enable debugging OpenCV C/C++ code.<br />
◦ Click Generate<br />
◦ View the results and ensure support for the modules you wish. If, for example, you want Cuda support and the configuration result shows no Cuda support, install Cuda using apt-get and re-run cmake-gui<br />
◦ Exit cmake-gui</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">13. Make OpenCV</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">make -j4 (or simply make)</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">14. Install OpenCV</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">sudo make install </span></p>
<p><em><span style="color: #dfdfdf;">(note: you must sudo)</span></em></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Scroll back and ensure the the Debug version was installed (and not the Release). It should read: &#8212; Install configuration: &#8220;Debug&#8221;</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="4" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Python and OpenCV</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1574690707659" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"><br />
15. Test OpenCV from Python</span></p>
<p align="left"><span style="color: #dfdfdf;">Code:</span></p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">import cv2
from pylab import *
n = randn(100,100)
thr, n = cv2.threshold(n, 0.5, 1, cv2.THRESH_BINARY)
ion()
imshow(n)</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="5" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >C/C++ Integrated Development Environment</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567677261501" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">16. Note: I’ve covered Code::Blocks (C/C++ compiled/debugger); it’s possible to use Eclipse as well.</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">17. Install Code::Blocks (http://codeblocks.org/): sudo apt-get install codeblocks</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">18. Launch codeblocks and open the existing project from ~/temp_opencv_compile/build named OpenCV.cbp</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">19. From Code::Blocks main bar, select the click on the drop down box and select opencv_features2d.</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">20. Click on Project||Set programs’ arguments| Set and type in the host application text box<br />
/usr/bin/python. Also check the Run host in terminal checkbox.</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">21. Add breakpoints in the C/C++ code as you see fit.</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">22. In Code::Blocks, click on Debug/Continue button. This will do a fast compilation (pre-compiled headers check) and launch a terminal.</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">23. You will be presented with a terminal and Python running inside. Issue the following (example):</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">import cv2</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">img =cv2.imread(‘/home/sightec/index.png’)</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;"> orb=cv2.ORB_create()</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">orb.detect(img)</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">24. You might experience throws from OpenCL so either disable them in the compilation phase of OpenCV or continue and keep debugging (it is only thrown once).</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">25. Add watches/breakpoints as you see fit and continue.</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">26. If you have ipython installed (highly recommended) you can run it from the debugger instead of the python console as follows</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">1. Host application: /bin/bash<br />
2. Program arguments: /usr/bin/ipython</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Getting Started with Machine Learning in Python</title>
		<link>https://www.shivay.co.il/2016/01/19/getting-started-with-machine-learning-in-python/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Tue, 19 Jan 2016 14:51:26 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[machine learning]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=46</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Getting Started with Machine Learning in Python</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Development Environment</u></a></strong></span></p>
<p><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>Ipython</u></a></strong></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#3"><u>MATLAB functionality</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#4"><u>Graphs with Matplotlib</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#5"><strong><u>Numpy</u></strong></a></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#6"><strong><u>Scipy</u></strong></a></span></p>
<p align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#7"><strong><u>Scikit-learn</u></strong></a></span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Development Environment</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563347808358" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 1. To get MATLAB-like functionality, install the suite:</span></p>
<p class="Standard" style="text-align: left; padding-left: 40px;" align="left"><span style="color: #dfdfdf;">a) Ipython, an interactive python development environment with shell and code completion, see https://ipython.org/<br />
b) Numpy, a numerical library, see http://www.numpy.org/<br />
c) matplotlib, a powerful package for plotting, https://matplotlib.org/<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 7px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567685922203" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left; padding-left: 40px;"><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">sudo apt install ipython python-matplotlib/ </span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563347973338" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 2. If you’re also interested in image processing, install OpenCV and bindings. Note that there are two ways to install OpenCV; this method will install compiled OpenCV with Python bindings. If you wish to install the source code so you can edit OpenCV, see https://opencv.org/<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 7px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567685931978" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left; padding-left: 40px;"><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">sudo apt install python-opencv </span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563346221311" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 3. For additional MATLAB toolboxes such as signal processing, special functions, integration and interpolation, optimization, sparse matrices and more, install SciPy, https://www.scipy.org/:<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 7px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567685940243" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left; padding-left: 40px;"><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">sudo apt install python-scipy </span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563346204141" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 4. For machine learning capabilities, install scikit-learn, https://scikit-learn.org/stable/<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 7px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567685947963" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left; padding-left: 40px;"><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">sudo apt install python-sklearn </span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563346259259" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> 5. For additional Python packages no covered in this document, consult with PyPI, the Python Package Index, at https://pypi.org/<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Ipython</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563348050737" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Ipython is an enhanced interactive python environment with command completion and syntax highlghting. Some useful commands to get you started are: <span style="font-family: Consolas, Monaco, monospace;">ls, cd, help, reset</span> and <span style="font-family: Consolas, Monaco, monospace;">run.</span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="3" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >MATLAB functionality</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563348142602" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Start Ipython and import MATLAB functionality</span></p>
<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">$ ipython –pylab</span></span></p>
<p><span style="color: #dfdfdf;">Alternatively, you can start python/ipython and then import pylab:</span></p>
<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">$ ipython</span></span></p>
<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">from pylab import *</span></span></p>
<p><span style="color: #dfdfdf;">Pylab combines the functionality of Numpy, Scipy, Ipython and matplotlib.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="4" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Graphs with Matplotlib</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567687371795" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">See that you can plot a simple graph:</span></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">t=arange(0, 100, 0.01)
plot(t, sin(t))
title('Sin(t)')
xlabel('time [sec]')
grid()
show()</pre>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1563348527005" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">By default, graphs are not shown until you issue the command <span style="font-family: Consolas, Monaco, monospace;">show()</span>. You can override this by calling the command </span><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">ion()</span> or <span style="font-family: Consolas, Monaco, monospace;">ioff()</span>.</span></p>
<p><span style="color: #dfdfdf;">Matplotlib supports a wide range of graphs. See this gallery (including code) for its capabilities, see https://matplotlib.org/gallery/index.html</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="5" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Numpy</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563348890028" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">As a general rule, use only Numpy’s <span style="font-family: Consolas, Monaco, monospace;">ndarray</span> data structure and not the <span style="font-family: Consolas, Monaco, monospace;">mat</span> data structure. The mat data structure is not supported by all packages (whereas <span style="font-family: Consolas, Monaco, monospace;">ndarray</span> is). This is the building block for all numerical operations and packages on Python. See https://docs.scipy.org/doc/numpy-1.15.0/user/basics.creation.html. If you’re using pylab, you can drop the leading <span style="font-family: Consolas, Monaco, monospace;">np..</span> If you want to manually use Numpy, issue <span style="font-family: Consolas, Monaco, monospace;">import numpy as np. </span></span></p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1563348918167" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Examples:<br />
</span><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">arange(10)<br />
zeros((2,2,3)) </span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="6" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Scipy</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563348938346" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">See the link above. To use, <span style="font-family: Consolas, Monaco, monospace;">import scipy.</span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="7" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Scikit-learn</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563348963914" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">Scikit-learn (or sklearn for short), supports a great deal of machine learning methodologies and algorithms including: classification, regression, clustering, and dimensionality reduction. It also provides analysis and validation tools.<br />
The scikit-learn.org has a great deal of information available. Start with the tutorials https://scikit-learn.org/stable/tutorial/index.html and move on to explore the examples in https://scikit-learn.org/stable/auto_examples/index.html.<br />
To use sklearn: </span><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">import sklearn</span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Everyday Python part 1</title>
		<link>https://www.shivay.co.il/2016/01/14/everyday-python-part-1-shai-vaingast-2019/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Thu, 14 Jan 2016 17:21:37 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=412</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Everyday Python part 1</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h4 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >// Shai Vaingast, 2019</h4></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Development environment – Installing Python</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>Development environment – Testing Python</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#3"><strong><u>Interactive Python</u></strong></a></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#4"><strong><u>DOS for non interactive Python</u></strong></a></span></p>
<p align="left"><span style="color: #f9f9f9;"><a style="color: #f9f9f9;" href="#5"><strong><u>Modules and Packages</u></strong></a></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#6"><u>Data Types</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#7"><u>Flow Control</u></a></strong></span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Development environment – Installing Python</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563365503955" >
		<div class="wpb_wrapper">
			<ol>
<li><span style="color: #dfdfdf;">Install the latest <u>Python 2</u> release (notice, 2, not 3), from <a style="color: #dfdfdf;" href="https://www.python.org/downloads/windows/">https://www.python.org/downloads/windows/</a>. Please make sure you download the 64 bit install version (quite important when doing machine learning with Scikit-learn), named <em>Windows x86-64 MSI installer</em>. Install on your PC for all users. Install Python to folder c:\python27</span></li>
<li><span style="color: #dfdfdf;">Optional: install an enhanced command console ConEmu from <a style="color: #dfdfdf;" href="https://conemu.github.io/">https://conemu.github.io/</a>. Alternatively, you can use a regular command prompt.</span></li>
<li><span style="color: #dfdfdf;">Additional packages, see PYPI</span></li>
<li><span style="color: #dfdfdf;">Optional: install notepad++, <a style="color: #dfdfdf;" href="https://notepad-plus-plus.org/download/v7.6.html">https://notepad-plus-plus.org/download/v7.6.html</a></span></li>
<li><span style="color: #dfdfdf;">Install NumPy, Matplotlib and IPython. Open a command console, either by start|Run|Cmd or by running ConEmu. Change directory to c:\python27\scripts and install additional packages:</span></li>
</ol>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">cd \python27\scripts</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">pip install numpy matplotlib ipython scipy</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Development environment – Testing Python</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567679478053" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">1. Open ConEmu and and change directory to c:\python\scripts, run ipytho<br />
<span style="font-family: Consolas, Monaco, monospace;">ipython</span></span></p>
<p class="Standard" style="text-align: left; padding-left: 40px;" align="left"><span style="color: #dfdfdf;">a. Exercise: set ConEmu to run IPython in a console on startup</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;">2. Test ipython, matplotlib and numpy.</span></p>
<p class="Standard" style="text-align: left; padding-left: 40px;" align="left"><span style="color: #dfdfdf;">a. Issue <span style="font-family: Consolas, Monaco, monospace;">from pylab import *</span><br />
b. Test command completion, start writing pl and press Tab.<br />
c. Test console commands (type <span style="font-family: Consolas, Monaco, monospace;">ls</span>)<br />
d. Show a graph:</span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> </span></p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">t=arange(0, 100, 0.01)
plot(t, sin(t))
title('Sin(t)')
xlabel('time [sec]')
grid()
show()
# ion()
# ioff()
close('all') – close all open graphs
grid()
savefig(fname)</pre>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"> </span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #dfdfdf;"><br />
Matplotlib supports a wide range of graphs, see https://matplotlib.org/gallery/index.html<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="3" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Interactive Python</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563360296705" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Character completion</span></p>
<p><span style="color: #dfdfdf;">Up/down arrows for last commands</span></p>
<p><span style="color: #dfdfdf;">Useful commands:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">ls<br />
run<br />
help<br />
reset<br />
cd<br />
pwd<br />
del</span></p>
<p><span style="color: #dfdfdf;">Using Python as a calculator</span></p>
<p><span style="color: #dfdfdf;">Using the last answer (_)</span></p>
<p><span style="color: #dfdfdf;">Notice integer division vs. floating point division: 2/3, 2.0/3, 2//3, 2.0//3</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="4" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >DOS for non interactive Python</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563360635968" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">path=%PATH%;c:\python27</span>/span&gt;</p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="5" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Modules and Packages</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563360672421" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">There are three several ways to import (load) a library:</span></span></p>
<p style="padding-left: 40px;"><span style="color: #dfdfdf;">1. Import with context (usage: math.sin()):<br />
<span style="font-family: Consolas, Monaco, monospace;">import math</span><br />
2. Import the entire library (usage: sin()):<br />
<span style="font-family: Consolas, Monaco, monospace;">from math import *</span><br />
3. Import a specific function (usage: sin()):<br />
<span style="font-family: Consolas, Monaco, monospace;">from math import sin</span><br />
4. Import a specific function, renamed (usage: sine()):<br />
<span style="font-family: Consolas, Monaco, monospace;">from math import sin as sine</span></span></p>
<p><span style="color: #dfdfdf;">Exploring a package:</span></p>
<p style="padding-left: 40px;"><span style="color: #dfdfdf;">1. Character completion<br />
2. <span style="font-family: Consolas, Monaco, monospace;">dir(library)</span></span></p>
<p><span style="color: #dfdfdf;">Matlab-like functionality package:</span><br />
<span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">from pylab import *</span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="6" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Data Types</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563360950739" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Int and long, sys.maxint, 2**2000</span></p>
<p><span style="color: #dfdfdf;">Absolute precision vs. floating point precision: 3*(1./3+2.2)</span></p>
<p><span style="color: #dfdfdf;">Other bases: <span style="font-family: Consolas, Monaco, monospace;">0xab, int(‘100’, 5)</span></span></p>
<p><span style="color: #dfdfdf;">Float and complex numbers: <span style="font-family: Consolas, Monaco, monospace;">1j, 100.23, a=complex(10,2), a.real, a.imag</span></span></p>
<p><span style="color: #dfdfdf;">Booleans: <span style="font-family: Consolas, Monaco, monospace;">2*3&gt;5, True, False</span></span></p>
<p><span style="color: #dfdfdf;">Bitwise operators: <span style="font-family: Consolas, Monaco, monospace;">2&lt;&lt;5</span></span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;">Strings: <span style="font-family: Consolas, Monaco, monospace;">&#8216;shai&#8217;, &#8216;shai\&#8217;s&#8217;, &#8220;shai&#8221;, &#8220;shai&#8217;s&#8221;, r&#8221;shai&#8217;s&#8221;, &#8220;&#8221;&#8221;docstring&#8221;&#8221;&#8221;</span></span></p>
<p><span style="color: #dfdfdf;">String accessing/indexing/slicing</span></p>
<p><span style="color: #dfdfdf;">Lists: <span style="font-family: Consolas, Monaco, monospace;">[1, &#8216;shai&#8217;], [&#8216;shai&#8217;]+[&#8216;shai&#8217;], [[1, 2], [3, 4]], append, count, extend, remove, etc.</span></span></p>
<p><span style="color: #dfdfdf;">Tuples, tuple unpacking</span></p>
<p><span style="color: #dfdfdf;">Dictionary: <span style="font-family: Consolas, Monaco, monospace;">d=dict(), d[&#8216;shai&#8217;]=2, dict(((1, 2), (3, 4))), clear, get, items, keys, etc.</span></span></p>
<p><span style="color: #dfdfdf;">arrays</span></p>
<p><span style="color: #dfdfdf;">Ndarray: <a style="color: #dfdfdf;" href="https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.array-creation.html">https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.array-creation.html</a></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="7" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Flow Control</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567685828992" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>While loop</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">While condition:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;"><strong>If then else</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">if condition:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">elif:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">else:</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;"><strong>For loop</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">for val in iterable:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [57]: x</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Out[57]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [58]: for val in x:</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;"><br />
&#8230;:     print val, val**2</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">0 0</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">1 1</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">2 4</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">3 9</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">4 16</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">5 25</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">6 36</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">7 49</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">8 64</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">9 81</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;"><strong>Zipping arrays</strong></span></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">A=[1, 5, 'shai']
B=[3, -1, 1j]
zip(A, B)
[(1, 3), (5, -1), ('shai', 1j)]

For a, b in zip(A, B):
print a, b</pre>
<p><span style="color: #dfdfdf;"><strong>Enumerate</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [12]: for i, val in enumerate(A):</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:     print i, val</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">0 1</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">1 5</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">2 shai</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Everyday Python part 2</title>
		<link>https://www.shivay.co.il/2016/01/13/everyday-python-part-2/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Wed, 13 Jan 2016 15:24:08 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=1443</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Everyday Python part 2</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h4 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >// Shai Vaingast, 2019</h4></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Flow Control</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>Files</u></a></strong></span><u></u></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Flow Control</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567681759963" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>While loop</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">While condition:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567692678626" >
		<div class="wpb_wrapper">
			<p><span style="color: #7ac411;"><b>Exercise</b></span></p>
<p>&nbsp;</p>
<ol>
<li><span style="color: #ebebeb;">Write a script to sum the digits of a number. Example: 1234 should results 10.</span></li>
<li><span style="color: #ebebeb;">Write a script to calculate n!</span></li>
<li><span style="color: #ebebeb;">Write a script to calculate sqrt(2) using the bisection method</span></li>
</ol>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567681784197" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>If then else</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">if condition:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">elif condition2:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">else:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567679969202" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>For loop</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">for val in iterable:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Do_Block</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [57]: x</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Out[57]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [58]: for val in x:</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;"><br />
&#8230;:     print val, val**2</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">0 0</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">1 1</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">2 4</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">3 9</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">4 16</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">5 25</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">6 36</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">7 49</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">8 64</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">9 81</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;"><strong>Enumerate</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [12]: for i, val in enumerate(A):</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:     print i, val</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">0 1</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">1 5</span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">2 shai</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Files</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563368503283" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>Functions</strong></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [4]: def f(x):</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:     return(sqrt(1-x**2))</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">&#8230;:</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [5]: f(0)</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Out[5]: 1.0</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [6]: f(-1)</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Out[6]: 0.0</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">In [7]: f(1)</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">Out[7]: 0.0</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;">Functions can also return complex objects (dictionaries, arrays, etc).</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567679900391" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>Simple files </strong></span></p>
<p><span style="color: #dfdfdf;">Open a file for reading, read the data and close the file:</span></p>
<p><span style="color: #dfdfdf;"> </span></p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">f = open(filenane)

f = open('pg97.txt')

data = f.read()
f.close()</pre>
<p><span style="color: #dfdfdf;"> </span></p>
<p><span style="color: #dfdfdf;"> </span><br />
<span style="color: #dfdfdf;">Do it in one line</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">data = open(filename).read()</span><br />
<span style="color: #dfdfdf;"> </span><br />
<span style="color: #dfdfdf;">Read a text file and split it into lines</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">lines=open(&#8216;noam.py&#8217;).readlines()</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567680069679" >
		<div class="wpb_wrapper">
			<p><span style="color: #7ac411;"><strong>Excercise</strong></span></p>
<p>&nbsp;</p>
<ol>
<li><span style="color: #dfdfdf;">Download the file Flatland from <a style="color: #dfdfdf;" href="http://www.gutenberg.org/cache/epub/97/pg97.txt">http://www.gutenberg.org/cache/epub/97/pg97.txt</a> and analyze the following: how many lines, words and characters in the file. How many unique words are in the file? Generate a new file with every occurrence of Flatland renamed to Spaceland</span></li>
</ol>
<p><span style="color: #dfdfdf;"><em>Hints:</em></span><br />
<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">len(), split(), text()</span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567680116634" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>Reading a CSV file </strong></span></p>
<p><span style="color: #dfdfdf;">Use the module urllib to read the file https://www.cia.gov/library/publications/the-world-factbook/rankorder/rawdata_2001.txt and store it locally to file cia.csv</span></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">import urllib
f=urllib.urlopen('https://www.cia.gov/library/publications/the-world-factbook/rankorder/rawdata_2001.txt')
data=f.read()
f.close()
fout = open('cia.csv','w')
fout.write(data)
f.close()</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567680142000" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Draw a bar chart of the first 10 nations </span></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">top10=open('cia.csv').readlines()[:10]
nations, gdp = [], []
for row in top10:


nations.append(row[7:58].strip())
gdp.append(int(row[59:].strip().replace(',','')))

bar(nations, gdp)
gca().set_xticklabels(nations, rotation=45)</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="624" height="602" src="https://www.shivay.co.il/wp-content/uploads/2016/01/1-1.jpg" class="vc_single_image-img attachment-full" alt="" title="1" srcset="https://www.shivay.co.il/wp-content/uploads/2016/01/1-1.jpg 624w, https://www.shivay.co.il/wp-content/uploads/2016/01/1-1-300x289.jpg 300w, https://www.shivay.co.il/wp-content/uploads/2016/01/1-1-500x482.jpg 500w" sizes="(max-width: 624px) 100vw, 624px" /></div>
		</figure>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567685658956" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>Download QQQ historical data and plot the graph using loadtxt() </strong></span></p>
<p><span style="color: #dfdfdf;">File location: https://finance.yahoo.com/quote/QQQ/history/ , click on Download data and save as QQQ.csv</span></p>
<p><span style="color: #dfdfdf;">Skip the first row and use only columns 2, 3, 4 and 5. Plot some graphs:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">d = loadtxt(&#8216;QQQ.csv&#8217;, skiprows=1, delimiter=&#8217;,&#8217;, usecols=(2, 3, 4, 5))<br />
for i in range(4): plot(d[:, i])<br />
</span></p>
<p><span style="color: #dfdfdf;">More elaborate:</span></p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">d = loadtxt('QQQ.csv', skiprows=1, delimiter=',', converters={0: datestr2num})

for i in range(1, 6):

plot(d[:, i])

gca().set_xticklabels([num2date(x).strftime('%Y-%m-%d') for x in d[:,0]], rotation=45)</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="624" height="565" src="https://www.shivay.co.il/wp-content/uploads/2016/01/2-1.jpg" class="vc_single_image-img attachment-full" alt="" title="2" srcset="https://www.shivay.co.il/wp-content/uploads/2016/01/2-1.jpg 624w, https://www.shivay.co.il/wp-content/uploads/2016/01/2-1-300x272.jpg 300w, https://www.shivay.co.il/wp-content/uploads/2016/01/2-1-500x453.jpg 500w" sizes="(max-width: 624px) 100vw, 624px" /></div>
		</figure>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Everyday Python part 3</title>
		<link>https://www.shivay.co.il/2016/01/12/everyday-python-part-3/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Tue, 12 Jan 2016 16:53:32 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=144</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Everyday Python part 3</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h4 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >// Shai Vaingast, 2019</h4></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Installing</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>Reading, Writing and Displaying Images</u></a></strong><u></u></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#3"><u>Channels</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#4"><u>Cloning</u></a></strong><u></u></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#5"><u>Image Depth</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#6"><u>Modules</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#7"><u>Solutions</u></a></strong></span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Installing</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563371360664" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Ensure OpenCV is available and check its version:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">pip install opencv-python</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">import cv2<br />
cv2.__version__<br />
&#8216;4.0.0&#8217;<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Reading, Writing and Displaying Images</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563371800674" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Reading an image file</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">airplane=cv2.imread(‘airplane.jpg’)</span><br />
<span style="color: #dfdfdf;">Writing image to file: <span style="font-family: Consolas, Monaco, monospace;">cv2.imwrite(filename, img)</span>. The extension defines the image format.</span></p>
<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">cv2.imshow(&#8216;airplane&#8217;, airplane) </span>will display the image, or alternatively, use pylab’s <span style="font-family: Consolas, Monaco, monospace;">imshow(airplane)</span>.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563371816629" >
		<div class="wpb_wrapper">
			<p><strong><span style="color: #7ac411;">Exercise</span></strong>: <span style="color: #dfdfdf;">write a function to convert jpeg images in the current working directory to PNG images.</span></p>
<p><span style="color: #dfdfdf;"><span style="text-decoration: underline;">Tip</span>: use <span style="font-family: Consolas, Monaco, monospace;">os.listdir() </span> or</span><br />
<span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">glob.glob() </span> functions to list the directory content</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="3" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Channels</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563372114953" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">img.shape </span>holds the image shape. If the image is RGB, the size would be 3 dimensional (width, height, 3). To extract just one channel, use the : operator:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">R = airplane[:, :, 0]</span></p>
<p><span style="color: #dfdfdf;">You can change the colormap:<span style="font-family: Consolas, Monaco, monospace;">hot(), cool()</span>. See help(colormaps) for more options.</span></p>
<p><span style="color: #dfdfdf;">Combining channels can be done similarly.</span></p>
<p><span style="color: #dfdfdf;">Another important function is <span style="font-family: Consolas, Monaco, monospace;">R = airplane[:, :, 0] </span>to convert to gray levels and back.</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">img = cv2.cvtColor(airplane, cv2.COLOR_BGR2GRAY)<br />
gray()<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="4" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Cloning</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563372169625" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Need to understand the concept of binding, copy, deep copy, etc.</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">img = airplane.copy()</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="5" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Image Depth</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563372258120" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">How many bytes/bits represent a pixel in an image. Common values </span><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">cv2.CV_8U, cv2.CV_64F</span><span style="color: #dfdfdf;">.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="6" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Modules</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563372536681" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">See https://docs.opencv.org/master/</span></p>
<p><span style="color: #dfdfdf;">Examples: </span></p>
<p style="padding-left: 40px;"><span style="color: #dfdfdf;">1. Gaussian blur (highly used). </span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">g = cv2.GaussianBlur(airplane, (51, 51), 3.0)</span></p>
<p style="padding-left: 40px;"><span style="color: #dfdfdf;">2. Sobel (derivative)</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">g = cv2.cvtColor(airplane, cv2.COLOR_BGR2GRAY)<br />
s = cv2.Sobel(g, cv2.CV_64F, 1, 1)<br />
imshow(s)<br />
</span></p>
<p style="padding-left: 40px;"><span style="color: #dfdfdf;">3. Canny edge detector</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">edges = cv2.Canny(g,80,180,apertureSize = 3)</span></p>
<p style="padding-left: 40px;"><span style="color: #dfdfdf;">4. Hough line transform (or circle transform)</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">lines = cv2.HoughLinesP(edges,1,np.pi/180,15,minLineLength,maxLineGap)</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div>
	<div class="wpb_text_column wpb_content_element vc_custom_1563372686354" >
		<div class="wpb_wrapper">
			<p><span style="color: #7ac411;"><strong>Final Exercise</strong></span></p>
<p><span style="color: #dfdfdf;">Find the image in focus and derive the Z value in directory autofocus.</span></p>
<p><span style="color: #dfdfdf;"><span style="text-decoration: underline;">Tip</span>: Have a look at the image processing documentation of OpenCV</span></p>
<p><span style="color: #dfdfdf;">Have a look at <span style="font-family: Consolas, Monaco, monospace;">cv2.threshold()</span>with OTSU’s method. Highly recommended.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 12px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_30 vc_sep_dashed vc_sep_pos_align_left vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#81d742;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#81d742;" class="vc_sep_line"></span></span>
</div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="7" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Solutions</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567680690975" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><strong>Solution to image conversion:</strong><br />
</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;"><span style="text-decoration: underline;">Option 1: quick and dirty</span><br />
</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">from glob import glob</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">for fn in glob(&#8216;*.bmp&#8217;):</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">cv2.imwrite(fn.replace(&#8216;bmp&#8217;, &#8216;jpg&#8217;), cv2.imread(fn))</span></p>
<p><span style="color: #dfdfdf;">Downside with this option: in case the filename contains the sequence ‘bmp’ it will not work. Example: If the filename is edpbmp32.bmp, the code above will create a file named edpjpg32.bmp (the first bmp occurrence will be replaced).</span></p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><span style="color: #dfdfdf; text-decoration: underline;">Option 2: replace the last 3 characters</span></span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">from glob import glob</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">for fn in glob(&#8216;*.bmp&#8217;):</span></p>
<p><span style="color: #dfdfdf;">If you’d like to use </span><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">os.listdir() </span><span style="color: #dfdfdf;">instead of glob, use the following:</span></p>
<p>&nbsp;</p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">for fn in os.listdir(&#8216;.&#8217;):</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">if fn.endswith(&#8216;bmp&#8217;): </span></p>
<p style="padding-left: 80px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">cv2.imwrite(fn.replace(&#8216;bmp&#8217;, &#8216;jpg&#8217;), cv2.imread(fn))</span></p>
<p>&nbsp;</p>
<p><span style="color: #dfdfdf;">In Windows, you probably want this to be case insensitive so consider changing to this:</span></p>
<p><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">for fn in os.listdir(&#8216;.&#8217;):</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">if fn.lower().endswith(&#8216;bmp&#8217;): </span></p>
<p style="padding-left: 80px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">cv2.imwrite(fn[:-3]+&#8217;jpg&#8217;, cv2.imread(fn))</span></p>
<p>&nbsp;</p>
<p><strong><span style="color: #dfdfdf;">Solution to the final exercise:</span></strong></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">from pylab import *
import cv2, glob

x, y = [], []

for fn in glob.glob('*.bmp'):

    # Sobel is the indicator for focus
    focus = cv2.Sobel(imread(fn), cv2.CV_64F, 1, 1)
    y.append(norm(focus))
    
    # extract the Z from the filename
    start = fn.find('(')+1
    stop = fn.find(')')
    x.append(int(fn[start:stop]))

# plot the focus indicator as a function of z	
plot(x, y, 'ob')

# the value in focus corresponds to argmax
plot(x[argmax(y)], y[argmax(y)], 'or')

# add text on the graph
text(x[argmax(y)], y[argmax(y)], str(x[argmax(y)]))

grid()
xlabel('Z [mm]')
ylabel('Focus')
title('Best focus @'+ str(x[argmax(y)]))
show()
</pre>
<p>&nbsp;</p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="614" height="461" src="https://www.shivay.co.il/wp-content/uploads/2016/01/python-part-3.jpg" class="vc_single_image-img attachment-full" alt="" title="python part 3" srcset="https://www.shivay.co.il/wp-content/uploads/2016/01/python-part-3.jpg 614w, https://www.shivay.co.il/wp-content/uploads/2016/01/python-part-3-300x225.jpg 300w, https://www.shivay.co.il/wp-content/uploads/2016/01/python-part-3-500x375.jpg 500w" sizes="(max-width: 614px) 100vw, 614px" /></div>
		</figure>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Everyday Python part 4</title>
		<link>https://www.shivay.co.il/2016/01/11/everyday-python-part-4/</link>
		
		<dc:creator><![CDATA[svaingast@gmail.com]]></dc:creator>
		<pubDate>Mon, 11 Jan 2016 22:33:01 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">http://themes.ad-theme.com/wp/flownews_demos/black/?p=1526</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h1 style="text-align: center" class="vc_custom_heading vc_do_custom_heading" >Everyday Python part 4</h1><div class="vc_empty_space"   style="height: 32px"><span class="vc_empty_space_inner"></span></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h4 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >// Shai Vaingast, 2019</h4></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Index:</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#1"><u>Matplotlib</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#2"><u>SciPy</u></a></strong><u></u></span></p>
<p class="Standard" style="text-align: left;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#3"><u>Integration</u></a></strong></span></p>
<p class="Standard" style="text-align: left; page-break-before: always;" align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#4"><u>Fourier Transforms (fftpack)</u></a></strong><u></u></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#5"><u>Signal Processing (signal)</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#6"><u>Optimization</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#7"><u>I/O (io)</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#8"><u>GUI (if you must have it)</u></a></strong></span></p>
<p align="left"><span style="color: #f9f9f9;"><strong><a style="color: #f9f9f9;" href="#9"><u>Some Machine Learning</u></a></strong></span></p>

		</div>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#dfdfdf;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="1" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Matplotlib</h3><h5 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Example: spectrogram</h5><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693293457" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">First install moviepy:</span></p>
<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">pip install moviepy</span></p>
<p><span style="color: #dfdfdf;">Then run this script:</span></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python"># screech.py
# spectrogram analysis of the screeching motor
# must install moviepy: pip install moviepy
from pylab import *
import moviepy.editor as mp
clip = mp.VideoFileClip("screeching gratings motor.mp4")
d = clip.audio.to_soundarray()
specgram(d[:,0], NFFT=1024, Fs=clip.audio.fps, noverlap=900)
show()</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="531" height="383" src="https://www.shivay.co.il/wp-content/uploads/2016/01/python-1.png" class="vc_single_image-img attachment-full" alt="" title="python 1" srcset="https://www.shivay.co.il/wp-content/uploads/2016/01/python-1.png 531w, https://www.shivay.co.il/wp-content/uploads/2016/01/python-1-300x216.png 300w, https://www.shivay.co.il/wp-content/uploads/2016/01/python-1-325x235.png 325w, https://www.shivay.co.il/wp-content/uploads/2016/01/python-1-500x361.png 500w" sizes="(max-width: 531px) 100vw, 531px" /></div>
		</figure>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="2" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >SciPy</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693387719" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Documentation: https://docs.scipy.org/doc/scipy-1.2.1/reference/</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h4 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Linear Algebra (linalg)</h4><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693614359" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Matrix operations: <span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">dot(), inner(), outer(), matrix_power(), det(), trace(), inv(), matrix_rand()</span></span></p>
<p><span style="color: #dfdfdf;">Vector operations: <span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">vdot(), norm()</span></span></p>
<p><span style="color: #dfdfdf;">Eigenvalues/eigenvectors: <span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">eig()</span></span></p>
<p><span style="color: #dfdfdf;">Solve: <span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">solve(), lstsq()</span></span></p>
<p><span style="color: #dfdfdf;">Decompositions:<span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;"> svd(), qr()</span></span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h4 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Special Functions (special)</h4><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693696316" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Bessel, Airy, etc.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="3" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Integration</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693809285" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Gaussian quadrature – <span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">quad()</span>, Trapezoidal method – <span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">trapz(), Simpson – simps(),</span> etc.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h5 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Example: calculate pi using integration method. Half a unit circle of radius 1 is equal to pi/2.</h5><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693892875" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="python">from scipy.integrate import quad, simps, trapz
from pylab import *

dh = 1e-3
x = arange(-1, 1, dh)
y = sqrt(1-x**2)

# simple sum
pi1 = 2*sum(y)*dh
print "Using sum, error is ", abs(pi1-pi)

# trapz
pi2 = 2*trapz(y, x)
print "Using trapz, error is ", abs(pi2-pi)

# Simpson
pi3 = 2*simps(y, x)
print "Using simps, error is ", abs(pi3-pi)

# Gaussian quadrature
def circ(x):
    return sqrt(1-x**2)
    
pi4 = 2*quad(circ, -1, 1)[0]
print "Using quad, error is ", abs(pi4-pi)
</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h4 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Fourier Transforms (fftpack)</h4><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567693987015" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Including 2-d fft, convolutions, DCT (Discrete Cosine Transform) etc.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h4 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Signal Processing (signal)</h4><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567694465999" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Including filter design (IIR, FIR), Wiener filters, convolution/deconvolution, spectral analysis (spectrogram) etc.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h5 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Example 1: Heart rate filtering</h5><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567694551256" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="python">from pylab import *
import scipy.signal as signal
t = arange(512)/256.0
y = 5*sin(2*pi*t*0.7)
beats = zeros(size(y))
for i in range(5):
    beats[i*90:i*90+10] = signal.triang(10)
y += beats

subplot(2, 1, 1)
plot(t, y); grid();
ylabel('Signal')

[b, a] = signal.butter(3, 0.05, 'high')
yf = signal.lfilter(b, a, y)
subplot(2, 1, 2)
plot(t, yf); grid()
xlabel('Time[sec]'); ylabel('Signal')
show()
</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="614" height="461" src="https://www.shivay.co.il/wp-content/uploads/2016/01/python2.png" class="vc_single_image-img attachment-full" alt="" title="python2" srcset="https://www.shivay.co.il/wp-content/uploads/2016/01/python2.png 614w, https://www.shivay.co.il/wp-content/uploads/2016/01/python2-300x225.png 300w, https://www.shivay.co.il/wp-content/uploads/2016/01/python2-500x375.png 500w" sizes="(max-width: 614px) 100vw, 614px" /></div>
		</figure>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="4" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="color: #dfdfdf;text-align: left" class="vc_custom_heading vc_do_custom_heading" >Optimization</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567694669335" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Finding the maximum/minimum.</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567694750622" >
		<div class="wpb_wrapper">
			<p><span style="color: #7ac411;"><strong>Exercise:</strong></span></p>
<p><span style="color: #dfdfdf;">Exercise: solve the following set of equations using Linear Programming (<span style="font-family: Consolas, Monaco, monospace;">scipy.optimize.linprog)</span>, aka as the Simplex algorithm.</span></p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1567694825045" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Maximize x+y<br />
Subject to:</span></p>
<p><span style="color: #dfdfdf;">1. 4x+3y&lt;=12<br />
</span></p>
<p><span style="color: #dfdfdf;">2. 3x+4x&lt;=12 </span></p>
<p><span style="color: #dfdfdf;">3. x=0 </span></p>
<p><span style="color: #dfdfdf;">4. y&gt;=0<br />
</span></p>
<p><span style="color: #dfdfdf;">Tip: change “maximize x+y” to minimize “-x-y”<br />
</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h4 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Solution</h4>
	<div class="wpb_text_column wpb_content_element vc_custom_1567695027789" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="python">In [3]: c=[-1, -1]
In [4]: A=[[4, 3], [3, 4]]
In [5]: b=[12, 12]
In [6]: so.linprog(c, A, b)
Out[6]:
     fun: -3.4285714285714284
 message: 'Optimization terminated successfully.'
     nit: 2
   slack: array([0., 0.])
  status: 0
 success: True
       x: array([1.71428571, 1.71428571])
</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div  class="wpb_single_image wpb_content_element vc_align_center wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="253" height="269" src="https://www.shivay.co.il/wp-content/uploads/2016/01/python3.png" class="vc_single_image-img attachment-full" alt="" title="python3" /></div>
		</figure>
	</div>
<div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="5" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >I/O (io)</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567695162812" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;"><span style="font-family: Consolas, Monaco, monospace;">Especially useful to read MAT files. The results are stored in a dictionary. </span></span></p>
<p>&nbsp;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">loadmat(), savemat(), whosmat()
Out[57]:
{'__globals__': [],
 '__header__': 'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Sun Mar 03 11:04:50 2019',
 '__version__': '1.0',
 'a': array([[ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10]], dtype=uint8),
 'b': array([u'Nova'], dtype='&lt;U4')}

In [58]: d['a']
Out[58]: array([[ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10]], dtype=uint8)

In [59]: d['b']
Out[59]: array([u'Nova'], dtype='&lt;U4')
</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="6" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >GUI (if you must have it)</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567695223835" >
		<div class="wpb_wrapper">
			<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">pip install wxpython</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><h5 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Minimal GUI example</h5><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567695322726" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="python">import wx

class MinimalGUI(wx.Frame):
    """docstring for MinimalFrame"""
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title="Minimal GUI", size=(640, 480))

app = wx.App()
frame = MinimalGUI(None).Show()
app.MainLoop()
</pre>

		</div>
	</div>
<h5 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Sizers and Buttons</h5><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567695398501" >
		<div class="wpb_wrapper">
			<p><span style="color: #dfdfdf;">Now let’s add a button. First we must learn about sizers.  See here: <a style="color: #dfdfdf;" href="https://docs.wxwidgets.org/3.0/overview_sizer.html">https://docs.wxwidgets.org/3.0/overview_sizer.html</a></span></p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element vc_custom_1567695432014" >
		<div class="wpb_wrapper">
			<pre class="EnlighterJSRAW" data-enlighter-language="python">import wx
from pylab import *

class MinimalGUI(wx.Frame):
    """docstring for MinimalFrame"""
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title="Minimal GUI", size=(300, 200))

        # several buttons
        buttonsTxt = ['Plot', 'Talk', 'Exit']
        
        # a sizer object
        sizerH = wx.BoxSizer(wx.HORIZONTAL)
        
        # a list holding all buttons
        self.buttons = []
        for btn in buttonsTxt:
            # we store the button object in the class
            self.buttons.append(wx.Button(self, label=btn))

            # and add it to the panel
            sizerH.Add(self.buttons[-1], border=10, flag=wx.ALL)

            # next, we connect it to a callback function
            self.Bind(wx.EVT_BUTTON, self.OnClick,self.buttons[-1])
        
        # add a text edit for fun
        self.txtCtrl = wx.TextCtrl(self, value="Everyday Python")

        # sizer stuff
        sizerV = wx.BoxSizer(wx.VERTICAL)
        sizerV.Add(sizerH)
        sizerV.Add(self.txtCtrl, border=10, flag=wx.ALL|wx.ALIGN_CENTER)
        sizerV.Fit(self)
        self.SetSizer(sizerV)
        
    # the callback function to the text
    def	OnClick(self, event):
        btnText = event.GetEventObject().GetLabel()
        if(btnText=='Exit'):
            exit()
        if(btnText=='Plot'):
            figure()
            plot(arange(10), sin(arange(10)))
            show()
        if(btnText=='Talk'):
            print "I'm not doing that, ", self.txtCtrl.Value
        
app = wx.App()
frame = MinimalGUI(None).Show()
app.MainLoop()
</pre>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div><div id="7" class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h3 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Some Machine Learning</h3><div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1567695498881" >
		<div class="wpb_wrapper">
			<p style="padding-left: 40px;"><span style="font-family: Consolas, Monaco, monospace; color: #dfdfdf;">pip install scikit</span></p>

		</div>
	</div>
<div class="vc_empty_space"   style="height: 22px"><span class="vc_empty_space_inner"></span></div><div class="vc_separator wpb_content_element vc_separator_align_center vc_sep_width_100 vc_sep_border_width_2 vc_sep_pos_align_center vc_separator_no_text wpb_content_element  wpb_content_element" ><span class="vc_sep_holder vc_sep_holder_l"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span><span class="vc_sep_holder vc_sep_holder_r"><span style="border-color:#1e73be;" class="vc_sep_line"></span></span>
</div></div></div></div></div>
</div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
