<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1042702913368601588</id><updated>2026-05-10T03:30:19.605-07:00</updated><category term="Big Data"/><category term="JavaScript"/><category term="Algorithms"/><category term="SQL"/><category term="Angular 2"/><category term="Angular"/><category term="Python"/><category term="Hadoop"/><category term="Arrays"/><category term="Apache Spark"/><category term="Node"/><category term="AI"/><category term="Helpers"/><category term="CSS"/><category term="Performance"/><category term="Deep Learning"/><category term="Strings"/><category term="Cognitive technologies"/><category term="JavaScript Run-time"/><category term="React"/><category term="Hive"/><category term="Machine learning"/><category term="AWS"/><category term="Architecture"/><category term="Apache Kafka"/><category term="ES6"/><category term="Cloud services"/><category term="Data Science"/><category term="Datawarehouse"/><category term="Express"/><category term="Maths"/><category term="Neural Networks"/><category term="Security"/><category term="Spark Streaming"/><category term="WCAG"/><category term="Computer vision"/><category term="Data Analytics"/><category term="Networking"/><category term="Spark Sql"/><category term="System design"/><category term="ssis"/><category term="unix"/><category term="Aurelia"/><category term="Bigdata"/><category term="Java"/><category term="Linux"/><category term="MVC"/><category term="NPM"/><category term="No SQL"/><category term="React Native"/><category term="Services"/><category term="Sqoop"/><category term="c#"/><category term="jupyter Notebook"/><category term="mongoDb"/><category term="#Management"/><category term="AOP"/><category term="ASP.NET and MVC 6"/><category term="Angular 4"/><category term="Azure"/><category term="Bot Framework"/><category term="Concepts"/><category term="DSTREAM"/><category term="Design"/><category term="Flume"/><category term="GAN"/><category term="GCP"/><category term="HBase"/><category term="Mobile development"/><category term="MySQL"/><category term="NLP"/><category term="News"/><category term="OOPS"/><category term="Pig"/><category term="Projects"/><category term="Scala"/><category term="Scaling"/><category term="Self Driving Cars"/><category term="Shell"/><category term="Spark Grpahx"/><category term="Spark MLlib"/><category term="devOps"/><category term="helper"/><title type='text'>Web Snippets</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>460</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-5604249570039840261</id><published>2020-06-23T05:08:00.002-07:00</published><updated>2020-06-23T05:13:04.483-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#Management"/><title type='text'>THOUGHT AND CHARACTER</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_HliP9jTgMAuOiEwjZOvpdJao3UvVj1REsGRhMzK3hKDOllak4Kw0W328Rm9Op80Hzws9tQ0b_dITwAk88cdthxxDO2ZA0sboLUK2JBoxbKcMql7R8LN03fPKT0_2Lo8NNWpbtHl-Y4Y/s1600/thought.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;468&quot; data-original-width=&quot;730&quot; height=&quot;256&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_HliP9jTgMAuOiEwjZOvpdJao3UvVj1REsGRhMzK3hKDOllak4Kw0W328Rm9Op80Hzws9tQ0b_dITwAk88cdthxxDO2ZA0sboLUK2JBoxbKcMql7R8LN03fPKT0_2Lo8NNWpbtHl-Y4Y/s400/thought.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br style=&quot;background-color: white; box-sizing: inherit; color: rgba(0, 0, 0, 0.9); font-family: -apple-system, system-ui, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;Fira Sans&amp;quot;, Ubuntu, Oxygen, &amp;quot;Oxygen Sans&amp;quot;, Cantarell, &amp;quot;Droid Sans&amp;quot;, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: inherit !important;&quot; /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.9); font-family: , , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;roboto&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;fira sans&amp;quot; , &amp;quot;ubuntu&amp;quot; , &amp;quot;oxygen&amp;quot; , &amp;quot;oxygen sans&amp;quot; , &amp;quot;cantarell&amp;quot; , &amp;quot;droid sans&amp;quot; , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;A man is literally what he thinks, his character being the complete sum of all his thoughts.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.9); font-family: , , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;roboto&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;fira sans&amp;quot; , &amp;quot;ubuntu&amp;quot; , &amp;quot;oxygen&amp;quot; , &amp;quot;oxygen sans&amp;quot; , &amp;quot;cantarell&amp;quot; , &amp;quot;droid sans&amp;quot; , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;Every act of man springs from the hidden seeds of thought, and could not have appeared without them.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.9); font-family: , , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;roboto&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;fira sans&amp;quot; , &amp;quot;ubuntu&amp;quot; , &amp;quot;oxygen&amp;quot; , &amp;quot;oxygen sans&amp;quot; , &amp;quot;cantarell&amp;quot; , &amp;quot;droid sans&amp;quot; , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;Act is a blossom of thought and joy and suffering are its fruits.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.9); font-family: , , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;roboto&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;fira sans&amp;quot; , &amp;quot;ubuntu&amp;quot; , &amp;quot;oxygen&amp;quot; , &amp;quot;oxygen sans&amp;quot; , &amp;quot;cantarell&amp;quot; , &amp;quot;droid sans&amp;quot; , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;Godlike character is not a thing of favor or chance, but is the natural result of continued effort of like thinking.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.9); font-family: , , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;roboto&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;fira sans&amp;quot; , &amp;quot;ubuntu&amp;quot; , &amp;quot;oxygen&amp;quot; , &amp;quot;oxygen sans&amp;quot; , &amp;quot;cantarell&amp;quot; , &amp;quot;droid sans&amp;quot; , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;By patience and practice shall a man enter the door of the temple of knowledge&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.9); font-family: , , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;roboto&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;fira sans&amp;quot; , &amp;quot;ubuntu&amp;quot; , &amp;quot;oxygen&amp;quot; , &amp;quot;oxygen sans&amp;quot; , &amp;quot;cantarell&amp;quot; , &amp;quot;droid sans&amp;quot; , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot; , &amp;quot;lucida grande&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;Courtesy: As a man thinketh. By James Allen&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/5604249570039840261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/06/thought-and-character.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/5604249570039840261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/5604249570039840261'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/06/thought-and-character.html' title='THOUGHT AND CHARACTER'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_HliP9jTgMAuOiEwjZOvpdJao3UvVj1REsGRhMzK3hKDOllak4Kw0W328Rm9Op80Hzws9tQ0b_dITwAk88cdthxxDO2ZA0sboLUK2JBoxbKcMql7R8LN03fPKT0_2Lo8NNWpbtHl-Y4Y/s72-c/thought.JPG" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-8858895268061710205</id><published>2020-06-15T11:55:00.001-07:00</published><updated>2020-06-15T11:55:28.341-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><title type='text'> Human-AI Interaction Design Guidelines</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgniyksulHCvi1Uu89W40Tiwj5MUXBfxpesBD7R2oGcnMK2oryCpGy5jLpg0yMbOPGcaf963-elGp0i6uzM_fHnmwmqpNY9b99WXosUq3nyazVdzHGYWrvdJ2q9IyDysJrRADAWwyVr9tI/s1600/AIInteraction.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;561&quot; data-original-width=&quot;999&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgniyksulHCvi1Uu89W40Tiwj5MUXBfxpesBD7R2oGcnMK2oryCpGy5jLpg0yMbOPGcaf963-elGp0i6uzM_fHnmwmqpNY9b99WXosUq3nyazVdzHGYWrvdJ2q9IyDysJrRADAWwyVr9tI/s640/AIInteraction.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;line-height: 16.25px; text-align: left;&quot;&gt;
Human&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;AI Interaction Design Guidelines&lt;/h2&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;INITIALLY&lt;/b&gt;&lt;/h3&gt;
&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;01&lt;/span&gt; Make clear what the system can do&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Help the user understand what the AI system &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;is&lt;/span&gt; capable of doing&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;02&lt;/span&gt; Make clear how well the system can do what it can do&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Help the user understand how often the AI system may make mistakes&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
DURING INTERACTION&lt;/h3&gt;
&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;03&lt;/span&gt; Time services based on context&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Time when to act &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; interrupt based on the user&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s current task &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; environment&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;04&lt;/span&gt; Show contextually relevant information&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Display information relevant to the user&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s current task &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; environment&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;05&lt;/span&gt; Match relevant social norms&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Ensure the experience &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;is&lt;/span&gt; delivered &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;in&lt;/span&gt; a way that users would expect, given their social &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; cultural context&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;06&lt;/span&gt; Mitigate social biases&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Ensure the AI system&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s language &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; behaviors do &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;not&lt;/span&gt; reinforce undesirable &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; unfair stereotypes &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; biases&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;h3 style=&quot;text-align: left;&quot;&gt;
WHEN WRONG&lt;/h3&gt;
&lt;span style=&quot;color: #4400ee; font-weight: bold;&quot;&gt;07&lt;/span&gt; Support efficient invocation&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Make it easy to invoke &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; request the AI system&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s services when needed&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;08&lt;/span&gt; Support efficient dismissal&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Make it easy to dismiss &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; ignore undesired AI system services&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;09&lt;/span&gt; Support efficient correction&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Make it easy to edit, refine, &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; recover when the AI system &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;is&lt;/span&gt; wrong&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt; Scope services when &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;in&lt;/span&gt; doubt&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Engage &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;in&lt;/span&gt; disambiguation &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; gracefully degrade the AI system&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s services when uncertain about a user&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s goals&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;11&lt;/span&gt; Make clear why the system did what it did&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Enable the user to access an explanation of why the AI system behaved &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;as&lt;/span&gt; it did&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;OVER TIME&lt;/b&gt;&lt;/h3&gt;
&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;12&lt;/span&gt; Remember recent interactions&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Maintain short&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;term memory &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; allow the user to make efficient references to that memory&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;13&lt;/span&gt; Learn &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;user&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;behavior.&lt;/span&gt;

Personalize the user&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s experience by learning &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;their&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;actions&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;over&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;time.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;14&lt;/span&gt; Update &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; adapt cautiously&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Limit disruptive changes when updating &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; adapting the AI system&lt;span style=&quot;background-color: #ffaaaa; color: red;&quot;&gt;’&lt;/span&gt;s behaviors&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;15&lt;/span&gt; Encourage granular feedback&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Enable the user to provide feedback indicating their preferences during regular interaction &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;with&lt;/span&gt; the AI system&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;16&lt;/span&gt; Convey the consequences of user actions&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Immediately update &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; convey how user actions will impact future behaviors of the AI system&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;17&lt;/span&gt; Provide &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;global&lt;/span&gt; controls&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Allow the user to globally customize what the AI system monitors &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;and&lt;/span&gt; how it behaves&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;18&lt;/span&gt; Notify users about changes&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;

Inform the user when the AI system adds &lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;or&lt;/span&gt; updates its capabilities&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;MORE INFO:&lt;/b&gt;&lt;br /&gt;
https://www.microsoft.com/en-us/research/blog/guidelines-for-human-ai-interaction-design/&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/8858895268061710205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/06/human-ai-interaction-design-guidelines.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8858895268061710205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8858895268061710205'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/06/human-ai-interaction-design-guidelines.html' title=' Human-AI Interaction Design Guidelines'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgniyksulHCvi1Uu89W40Tiwj5MUXBfxpesBD7R2oGcnMK2oryCpGy5jLpg0yMbOPGcaf963-elGp0i6uzM_fHnmwmqpNY9b99WXosUq3nyazVdzHGYWrvdJ2q9IyDysJrRADAWwyVr9tI/s72-c/AIInteraction.JPG" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-7874503368836033463</id><published>2020-02-05T16:45:00.002-08:00</published><updated>2020-02-05T16:45:25.566-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Machine learning"/><title type='text'>Machine Learning workflow</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp1uHKbzfwRaUqxRwH-fbg5M13r3sd9SjMRRpUs-nWgeB9Z_XXUGRKCvfnpGc4ko72cf-XoVk7VsIwUmmBSksITfvBDSRXhQu9pkoB8gVUR4P6OxCTdZHUJ7EIrfB4GU0W6mwDhDpV0tc/s1600/Deployment_model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;686&quot; data-original-width=&quot;869&quot; height=&quot;504&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp1uHKbzfwRaUqxRwH-fbg5M13r3sd9SjMRRpUs-nWgeB9Z_XXUGRKCvfnpGc4ko72cf-XoVk7VsIwUmmBSksITfvBDSRXhQu9pkoB8gVUR4P6OxCTdZHUJ7EIrfB4GU0W6mwDhDpV0tc/s640/Deployment_model.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Machine Learning Workflow consists of 3 components&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Explore and process data&lt;/li&gt;
&lt;li&gt;Modeling&lt;/li&gt;
&lt;li&gt;Deployment&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;EXPLORE AND PROCESS DATA&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
This component consists of exploring and processing the data.&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Retrieve&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
The first step is to retrieve the data, which includes test and train dataset. Lets take an example of housing dataset which contains csv files. We need to download the data from the source.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Clean and Explore&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
The data might have to be cleaned to identtify and remove anomalous values such as outliers and mistakes&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Prepare and transform&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The final step in this block is to prepare and transform the data&lt;/li&gt;
&lt;li&gt;This steps involves normalization and converting the format of the data&lt;/li&gt;
&lt;li&gt;This steps involves splitting data into training, validation and test sets&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;MODELING&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
This component focuses on developing the model that is deployed to production&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Develop and train model&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The first step where the model is developed and trained using the training dataset.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Evaluate and model&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Final step is to evaluate and validate the model. Here we tune the model using the validation data set.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;DEPLOYMENT&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
This component focuses on deployment, monitoring and updating the model in the production environment&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Deploy to production&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Deployment means making the model available for use by web or software applications. We can also deploy the model to a smartphone application&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Monitor and update model and data&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
If there is any changes in the features and data, we can update the model and data&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/7874503368836033463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/02/machine-learning-workflow.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7874503368836033463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7874503368836033463'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/02/machine-learning-workflow.html' title='Machine Learning workflow'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp1uHKbzfwRaUqxRwH-fbg5M13r3sd9SjMRRpUs-nWgeB9Z_XXUGRKCvfnpGc4ko72cf-XoVk7VsIwUmmBSksITfvBDSRXhQu9pkoB8gVUR4P6OxCTdZHUJ7EIrfB4GU0W6mwDhDpV0tc/s72-c/Deployment_model.JPG" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-5458880627080927453</id><published>2020-01-29T11:57:00.001-08:00</published><updated>2020-01-29T11:57:42.131-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Science"/><category scheme="http://www.blogger.com/atom/ns#" term="Neural Networks"/><title type='text'>Error functions </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zn4mFhDpHKJCf6hyphenhyphenA7g1rlvrQC53vkF6JG9ItobJDytZLIw_z6OM0qhbsYjfymBjdPxTwA9tPLpf2x9Qkty-wgXO1wylEME8ZQuIzKU2xUxH5rSpNPWme_A3fNGRUZ2fSVpTrbnFtNc/s1600/gd.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;362&quot; data-original-width=&quot;645&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zn4mFhDpHKJCf6hyphenhyphenA7g1rlvrQC53vkF6JG9ItobJDytZLIw_z6OM0qhbsYjfymBjdPxTwA9tPLpf2x9Qkty-wgXO1wylEME8ZQuIzKU2xUxH5rSpNPWme_A3fNGRUZ2fSVpTrbnFtNc/s640/gd.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In most learning networks, error is calculated as the difference between the actual output and the predicted output.&lt;/li&gt;
&lt;li&gt;The error function is which tells us how far are we from the solution.&lt;/li&gt;
&lt;li&gt;The function that is used to compute this error is known as loss function.&lt;/li&gt;
&lt;li&gt;Different loss functions will give different errors for the same prediction and thus would have a considerable effort on the performance of the model.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;EXAMPLE:&lt;/b&gt;&lt;br /&gt;
Imagine, we are standing on top of a mountain(mount Everest) and we want to descend.It is not that easy and it is cloudy and it is big and we cant see the big picture.We would look at all the possible directions where we can walk.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcaqEDFHn9wEXSx24uzklXJesxO1aKMggdO7z-8-BpOi5tFddWCEvf_svcgKGMWJJG4VtTvL-psKUPmgJYXomccXTPW65y3HrvZVXme8XamYJv2dADWeZtaud7mVLOr9_lYUTyHxxcSZM/s1600/mount_everest.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;359&quot; data-original-width=&quot;480&quot; height=&quot;298&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcaqEDFHn9wEXSx24uzklXJesxO1aKMggdO7z-8-BpOi5tFddWCEvf_svcgKGMWJJG4VtTvL-psKUPmgJYXomccXTPW65y3HrvZVXme8XamYJv2dADWeZtaud7mVLOr9_lYUTyHxxcSZM/s400/mount_everest.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
If we constantly take step to decrease the error by decreasing the height then we would reach all the way down the mountain.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv3O6g-eSgQj10C7Q4rS3zfmUiDoUsn8bcZZB94gBxU2_6td_HNMHsYvdnaAZbwHxINNV8hyphenhyphenJYJ96JWTlXUj5qhZb6cdMxHz08G2_1giGcBsLLDSHeh8Oe2TwiIUJQ8UQ7-pdONpZi50E/s1600/mount_everest_1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;217&quot; data-original-width=&quot;496&quot; height=&quot;175&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv3O6g-eSgQj10C7Q4rS3zfmUiDoUsn8bcZZB94gBxU2_6td_HNMHsYvdnaAZbwHxINNV8hyphenhyphenJYJ96JWTlXUj5qhZb6cdMxHz08G2_1giGcBsLLDSHeh8Oe2TwiIUJQ8UQ7-pdONpZi50E/s400/mount_everest_1.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;KEY MATRIX&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In this case the key matrix that we use to solve the problem is the height.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;We can call the height the error.This would say that how badly we are doing at the mountain and how far we are then an ideal solution.&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;GRADIENT DESCENT&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We might also be stuck in a valley.This would often happen in solving real world problems. We have to resolve this issue.Many time the local min would give a pretty good solution to the problem.This method is called gradient descend&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;GOAL TO SPLIT DATA&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
How do we tell the computer how far are they from a perfect solution?&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9odDGoAy0NIYzZrWcpXZi9lv2HJQKvw7OKZbr0EGtEPs-AAWCRlcyzsKGJ5brYxT6l0-GjdGnD5SpyFVfRB9DyXOE2hcTgQnTjpFqy2LrTu4tFCeDBn6dj7jP5L5czIalP_jxYWd7a-k/s1600/Heightgradientdescend.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;519&quot; data-original-width=&quot;850&quot; height=&quot;243&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9odDGoAy0NIYzZrWcpXZi9lv2HJQKvw7OKZbr0EGtEPs-AAWCRlcyzsKGJ5brYxT6l0-GjdGnD5SpyFVfRB9DyXOE2hcTgQnTjpFqy2LrTu4tFCeDBn6dj7jP5L5czIalP_jxYWd7a-k/s400/Heightgradientdescend.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
We can count the no of mistakes. (example that is our height)&lt;/div&gt;
&lt;div&gt;
Now let us try to decrease the no of errors&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;SOLUTION&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
1) After moving once step we had decreased the errors&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP4ilt-lL-8kqNe5QOfZY_nTyn54DO7hjnWF_zDMLdbWVhkGyKq8a3uKN2WkAGMEa9mVmKwOBMWPWnwv5xR9Gkumer1WppW5hJvmIubir-Jt3taAfSRWEVoiIZNiGpX93H8_Aw3Zgj0hQ/s1600/erros_1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;619&quot; data-original-width=&quot;1497&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP4ilt-lL-8kqNe5QOfZY_nTyn54DO7hjnWF_zDMLdbWVhkGyKq8a3uKN2WkAGMEa9mVmKwOBMWPWnwv5xR9Gkumer1WppW5hJvmIubir-Jt3taAfSRWEVoiIZNiGpX93H8_Aw3Zgj0hQ/s320/erros_1.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
2) After moving another steps we have decreased all the errors&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;ISSUE&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The problem with this approach is that,algorithm would be taking very small steps.The reason for this is calculus. Tiny steps would be calculated by derivatives.&lt;/li&gt;
&lt;li&gt;The problem with small steps is:&lt;/li&gt;
&lt;/ul&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;ol&gt;
&lt;li&gt;We start with 2 errors&lt;/li&gt;
&lt;li&gt;We move a small amount&lt;/li&gt;
&lt;li&gt;We are still at 2 errors&lt;/li&gt;
&lt;li&gt;Even after moving a tiny amount we are at 2 error&lt;/li&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;div&gt;
This is equivalent to using gradient descend from an aesthetic pyramid with flat steps.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;DISCRETE&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;If we are standing above and looking for errors, then we would always get 2 errors and we would get confused what to do.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;CONTINUOUS&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In this case we can figure out which direction we can decrease the most.&lt;/li&gt;
&lt;li&gt;In math terms, in order for us , it means to do the gradient descent, our error function cannot be discrete. It should be continuos&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;LOG LOSS ERROR FUNCTION&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;As shown above in the figure, we have 6 points, out of which 4 are correctly classified and other 2 are incorrectly classified.&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Assuming error function would give penalty to incorrectly classified points an small penalty to the 4 correctly specified points&lt;/li&gt;
&lt;li&gt;Here we are representing the size of the points as penalty&lt;/li&gt;
&lt;/ul&gt;
Note:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Penalty is the distance from the boundary when the points are missclassified and 0 when they are correctly classified&lt;/li&gt;
&lt;li&gt;Lets add all the errors from the corresponding points&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnlFYKdLxENmcCKtpCBXhBtGpkC9eEoiDx3OF3hxm_dmsrtsfglhY48aisAsCKZDd6msxmMCOP5bja8e32kiVFz6m7HJDgsabIC2CW5Hbo9XvOYS_wG2QAy9IDPUgSPmZA0gMG7NKOwbU/s1600/misclassfied+error.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;87&quot; data-original-width=&quot;603&quot; height=&quot;57&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnlFYKdLxENmcCKtpCBXhBtGpkC9eEoiDx3OF3hxm_dmsrtsfglhY48aisAsCKZDd6msxmMCOP5bja8e32kiVFz6m7HJDgsabIC2CW5Hbo9XvOYS_wG2QAy9IDPUgSPmZA0gMG7NKOwbU/s400/misclassfied+error.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;The idea now is to move the line around to decrease these errors. In the fig below we have decreased the error.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdWazwkT1oHQe_TYXzOZtpO1DPSmuDewsyzJvzlQqYDSO8oCbDHMZ4d2nHmPh3Z6Z0l6jruR99MSFU97ycPdGDOTXinyHYUroVKmEiqIJP0L2CtZI1brevV2henCYXR1jJzkxKQ3TWCWY/s1600/errorfunctionwithpropertyJPG.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;619&quot; data-original-width=&quot;923&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdWazwkT1oHQe_TYXzOZtpO1DPSmuDewsyzJvzlQqYDSO8oCbDHMZ4d2nHmPh3Z6Z0l6jruR99MSFU97ycPdGDOTXinyHYUroVKmEiqIJP0L2CtZI1brevV2henCYXR1jJzkxKQ3TWCWY/s320/errorfunctionwithpropertyJPG.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;We can now use gradient descent to solve our problem&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
SOLUTION&lt;/h3&gt;
&lt;b&gt;GRADIENT DESCENT&lt;/b&gt;&lt;br /&gt;
ERROR : In this example error is the sum of blue and red areas&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We explore around to see what direction brings us the down most or equivalent.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;We explore what direction we can move to reduce the error the most&lt;/li&gt;
&lt;li&gt;We take a step in that direction&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEGKsZmmVyXEGRfVbnxyeNhPet2kM_KY_RepqUym0XDN5M4uXdZFOOrGV1Baa8wBEuCdscNHcnp1lbAsQonLKjR0n5peXoT864mbZq3oK2y0rTNS29mRv8Uoq3k0nhmzBp5hOJRNTyb8Y/s1600/Gradient_descent.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;797&quot; data-original-width=&quot;1295&quot; height=&quot;392&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEGKsZmmVyXEGRfVbnxyeNhPet2kM_KY_RepqUym0XDN5M4uXdZFOOrGV1Baa8wBEuCdscNHcnp1lbAsQonLKjR0n5peXoT864mbZq3oK2y0rTNS29mRv8Uoq3k0nhmzBp5hOJRNTyb8Y/s640/Gradient_descent.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLzBRCwCmWdjw-XhvXazTtKcJcZ5A9O27WoJgKgOefnl_EDmWTuvl1dkQ3VL-GqMggH5DpCU9egwExUAAkaGmDukE69j7zKH6B5rfPSTLRcA1BibkuQ2DM_GVVLo_FoOdYEbobpVQ9W_Y/s1600/m2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;617&quot; data-original-width=&quot;1183&quot; height=&quot;332&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLzBRCwCmWdjw-XhvXazTtKcJcZ5A9O27WoJgKgOefnl_EDmWTuvl1dkQ3VL-GqMggH5DpCU9egwExUAAkaGmDukE69j7zKH6B5rfPSTLRcA1BibkuQ2DM_GVVLo_FoOdYEbobpVQ9W_Y/s640/m2.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the mountain we go one step down and in the graph we reduce the error a bit by classifying one of the points&lt;/li&gt;
&lt;li&gt;Now we look again and follow the steps described above&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPuVQ-bVR-YGG0LyoYFgGTiH0snFLGroQ6yvCSBC2tJYGHzYAl51mp-VZ9qWQRBJCL_dfVdCiU4yKfIiQ0IzhlY-Vgj8UTF-G98eHVLAgKJLao9dsO7sKQee2mWWzzN7KwtLMHVn35r8I/s1600/left.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;638&quot; data-original-width=&quot;1233&quot; height=&quot;329&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPuVQ-bVR-YGG0LyoYFgGTiH0snFLGroQ6yvCSBC2tJYGHzYAl51mp-VZ9qWQRBJCL_dfVdCiU4yKfIiQ0IzhlY-Vgj8UTF-G98eHVLAgKJLao9dsO7sKQee2mWWzzN7KwtLMHVn35r8I/s640/left.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
On the left we have reduced the height and have successfully descended from the mountain and on the right we have reduced the error to the min possible value and successfully classified our points&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/5458880627080927453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/error-functions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/5458880627080927453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/5458880627080927453'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/error-functions.html' title='Error functions '/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zn4mFhDpHKJCf6hyphenhyphenA7g1rlvrQC53vkF6JG9ItobJDytZLIw_z6OM0qhbsYjfymBjdPxTwA9tPLpf2x9Qkty-wgXO1wylEME8ZQuIzKU2xUxH5rSpNPWme_A3fNGRUZ2fSVpTrbnFtNc/s72-c/gd.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-1364006912844230033</id><published>2020-01-29T11:49:00.000-08:00</published><updated>2020-01-29T11:49:09.666-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer vision"/><title type='text'>Canny edge detector</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2k6jSMEtAtTKmM1MpMXwxIVw-pTJ7_xWEP06nYcD2jAhsvAy2dv4E-r7GzHOg6ywj54JLnOyRW6wbVQq0ibMyZzlMT7L8mbJfOMvL0KGx8xMOM2-ud_gHYl0J6MTsN7U00iVyz7FBbM/s1600/cannyEdgedetection.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;518&quot; data-original-width=&quot;686&quot; height=&quot;301&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2k6jSMEtAtTKmM1MpMXwxIVw-pTJ7_xWEP06nYcD2jAhsvAy2dv4E-r7GzHOg6ywj54JLnOyRW6wbVQq0ibMyZzlMT7L8mbJfOMvL0KGx8xMOM2-ud_gHYl0J6MTsN7U00iVyz7FBbM/s400/cannyEdgedetection.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;The&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;Canny edge detector&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;is an&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Edge_detection&quot; style=&quot;background: none rgb(255, 255, 255); color: #0b0080; font-family: sans-serif; font-size: 14px; text-decoration-line: none;&quot; title=&quot;Edge detection&quot;&gt;edge detection&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;operator that uses a multi-stage&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Algorithm&quot; style=&quot;background: none rgb(255, 255, 255); color: #0b0080; font-family: sans-serif; font-size: 14px; text-decoration-line: none;&quot; title=&quot;Algorithm&quot;&gt;algorithm&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;to detect a wide range of edges in images. It was developed by&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;mw-redirect&quot; href=&quot;https://en.wikipedia.org/wiki/John_F._Canny&quot; style=&quot;background: none rgb(255, 255, 255); color: #0b0080; font-family: sans-serif; font-size: 14px; text-decoration-line: none;&quot; title=&quot;John F. Canny&quot;&gt;John F. Canny&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;in 1986. Canny also produced a&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;computational theory of edge detection&lt;/i&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;explaining why the technique works.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px; line-height: inherit; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
Canny edge detection is a technique to extract useful structural information from different vision objects and dramatically reduce the amount of data to be processed. It has been widely applied in various&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_vision&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Computer vision&quot;&gt;computer vision&lt;/a&gt;&amp;nbsp;systems. Canny has found that the requirements for the application of&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Edge_detection&quot; style=&quot;background: none; color: #0b0080;&quot; title=&quot;&quot;&gt;edge detection&lt;/a&gt;&amp;nbsp;on diverse vision systems are relatively similar. Thus, an edge detection solution to address these requirements can be implemented in a wide range of situations. The general criteria for edge detection include:&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px; list-style-image: none; margin: 0.3em 0px 0px 3.2em; padding: 0px;&quot;&gt;
&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;Detection of edge with low error rate, which means that the detection should accurately catch as many edges shown in the image as possible&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;The edge point detected from the operator should accurately localize on the center of the edge.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.1em;&quot;&gt;A given edge in the image should only be marked once, and where possible, image noise should not create false edges.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px; line-height: inherit; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
To satisfy these requirements Canny used the&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Calculus_of_variations&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Calculus of variations&quot;&gt;calculus of variations&lt;/a&gt;&amp;nbsp;– a technique which finds the&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Function_(mathematics)&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Function (mathematics)&quot;&gt;function&lt;/a&gt;&amp;nbsp;which optimizes a given&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Functional_(mathematics)&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Functional (mathematics)&quot;&gt;functional&lt;/a&gt;. The optimal function in Canny&#39;s detector is described by the sum of four&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Exponential_function&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Exponential function&quot;&gt;exponential&lt;/a&gt;&amp;nbsp;terms, but it can be approximated by the first&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Derivative&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Derivative&quot;&gt;derivative&lt;/a&gt;&amp;nbsp;of a&amp;nbsp;&lt;a href=&quot;https://en.wikipedia.org/wiki/Gaussian_function&quot; style=&quot;background: none; color: #0b0080; text-decoration-line: none;&quot; title=&quot;Gaussian function&quot;&gt;Gaussian&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px; line-height: inherit; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
Among the edge detection methods developed so far, Canny edge detection algorithm is one of the most strictly defined methods that provides good and reliable detection. Owing to its optimality to meet with the three criteria for edge detection and the simplicity of process for implementation, it became one of the most popular algorithms for edge detection.&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: sans-serif; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/1364006912844230033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/canny-edge-detector.html#comment-form' title='45 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/1364006912844230033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/1364006912844230033'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/canny-edge-detector.html' title='Canny edge detector'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2k6jSMEtAtTKmM1MpMXwxIVw-pTJ7_xWEP06nYcD2jAhsvAy2dv4E-r7GzHOg6ywj54JLnOyRW6wbVQq0ibMyZzlMT7L8mbJfOMvL0KGx8xMOM2-ud_gHYl0J6MTsN7U00iVyz7FBbM/s72-c/cannyEdgedetection.JPG" height="72" width="72"/><thr:total>45</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-7708203252139324326</id><published>2020-01-29T11:38:00.001-08:00</published><updated>2020-01-29T11:39:50.212-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><title type='text'>Grayscale to RGB conversion</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWcxSET5OzalfJZdgbY9ieYwORi-3npW6630oRbTTy8Kju38kmbc__pqtk2M3gn_AloFYDdPg_3HsT9tDgBCxuL6JPhudoE1Dd_Hr6pt1vXD9gMr7oUtEmTBIAfgcmLovHDuII3W6efUc/s1600/greyscale_to_rgb.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;449&quot; data-original-width=&quot;874&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWcxSET5OzalfJZdgbY9ieYwORi-3npW6630oRbTTy8Kju38kmbc__pqtk2M3gn_AloFYDdPg_3HsT9tDgBCxuL6JPhudoE1Dd_Hr6pt1vXD9gMr7oUtEmTBIAfgcmLovHDuII3W6efUc/s640/greyscale_to_rgb.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
we will convert an color image into a grayscale image. There are two methods to convert it. Both has their own merits and demerits. The methods are:&lt;/div&gt;
&lt;ul class=&quot;list&quot; style=&quot;box-sizing: border-box; color: #313131; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;Average method&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;Weighted method or luminosity method&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;using skimage&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: #121214; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.7em; font-weight: normal; left: 0px; letter-spacing: -1px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Average method&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Average method is the most simple one. You just have to take the average of three colors. Since its an RGB image, so it means that you have add r with g with b and then divide it by 3 to get your desired grayscale image.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Its done in this way.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Grayscale = (R + G + B / 3)&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;For example:&lt;/div&gt;
&lt;img alt=&quot;rgb&quot; src=&quot;https://www.tutorialspoint.com/dip/images/rgb.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; color: #313131; display: block; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto; max-width: 100%; padding-bottom: 4px; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
If you have an color image like the image shown above and you want to convert it into grayscale using average method. The following result would appear.&lt;/div&gt;
&lt;img alt=&quot;rgb_gray&quot; src=&quot;https://www.tutorialspoint.com/dip/images/rgb_gray.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; color: #313131; display: block; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto; max-width: 100%; padding-bottom: 4px; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;h3 style=&quot;border: 0px; box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.3em; font-weight: normal; left: 0px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Explanation&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
There is one thing to be sure, that something happens to the original works. It means that our average method works. But the results were not as expected. We wanted to convert the image into a grayscale, but this turned out to be a rather black image.&lt;/div&gt;
&lt;h3 style=&quot;border: 0px; box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.3em; font-weight: normal; left: 0px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Problem&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
This problem arise due to the fact, that we take average of the three colors. Since the three different colors have three different wavelength and have their own contribution in the formation of image, so we have to take average according to their contribution, not done it averagely using average method. Right now what we are doing is this,&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
33% of Red, 33% of Green, 33% of Blue&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
We are taking 33% of each, that means, each of the portion has same contribution in the image. But in reality thats not the case. The solution to this has been given by luminosity method.&lt;/div&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: #121214; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.7em; font-weight: normal; left: 0px; letter-spacing: -1px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Weighted method or luminosity method&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
You have seen the problem that occur in the average method. Weighted method has a solution to that problem. Since red color has more wavelength of all the three colors, and green is the color that has not only less wavelength then red color but also green is the color that gives more soothing effect to the eyes.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
It means that we have to decrease the contribution of red color, and increase the contribution of the green color, and put blue color contribution in between these two.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
So the new equation that form is:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
New grayscale image = ( (0.3 * R) + (0.59 * G) + (0.11 * B) ).&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
According to this equation, Red has contribute 30%, Green has contributed 59% which is greater in all three colors and Blue has contributed 11%.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Applying this equation to the image, we get this&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Original Image:&lt;/div&gt;
&lt;img alt=&quot;rgb&quot; src=&quot;https://www.tutorialspoint.com/dip/images/rgb.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; color: #313131; display: block; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto; max-width: 100%; padding-bottom: 4px; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Grayscale Image:&lt;/div&gt;
&lt;img alt=&quot;weighted_gray&quot; src=&quot;https://www.tutorialspoint.com/dip/images/weighted_gray.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; color: #313131; display: block; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto; max-width: 100%; padding-bottom: 4px; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;h3 style=&quot;border: 0px; box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.3em; font-weight: normal; left: 0px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Explanation&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
As you can see here, that the image has now been properly converted to grayscale using weighted method. As compare to the result of average method, this image is more brighter.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;border: 0px; box-sizing: border-box; font-size: 1.3em; font-weight: normal; left: 0px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-align: left; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
using skimage&lt;/h3&gt;
&lt;pre id=&quot;codecell1&quot; style=&quot;background-color: whitesmoke; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.15); color: #333333; font-size: 13px; line-height: 20px; margin-bottom: 10px; overflow-wrap: break-word; padding: 9.5px; text-align: start; white-space: pre-wrap; word-break: break-all;&quot;&gt;&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;plt&lt;/span&gt;

&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;skimage&lt;/span&gt; &lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;
&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;skimage.color&lt;/span&gt; &lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;a href=&quot;https://scikit-image.org/docs/dev/api/skimage.color.html#skimage.color.rgb2gray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for skimage.color.rgb2gray&quot;&gt;rgb2gray&lt;/a&gt;

&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;original&lt;/a&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;https://scikit-image.org/docs/dev/api/skimage.data.html#skimage.data.astronaut&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for skimage.data.astronaut&quot;&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astronaut&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;grayscale&lt;/a&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;https://scikit-image.org/docs/dev/api/skimage.color.html#skimage.color.rgb2gray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for skimage.color.rgb2gray&quot;&gt;rgb2gray&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;original&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;a href=&quot;https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for matplotlib.figure.Figure&quot;&gt;fig&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;axes&lt;/a&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for matplotlib.pyplot.subplots&quot;&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subplots&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;ax&lt;/a&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.ravel.html#numpy.ndarray.ravel&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray.ravel&quot;&gt;&lt;span class=&quot;n&quot;&gt;axes&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ravel&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;ax&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;original&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;ax&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #4070a0;&quot;&gt;&quot;Original&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;ax&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;grayscale&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cm&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gray&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for numpy.ndarray&quot;&gt;ax&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #4070a0;&quot;&gt;&quot;Grayscale&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;a href=&quot;https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.tight_layout&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for matplotlib.figure.Figure.tight_layout&quot;&gt;&lt;span class=&quot;n&quot;&gt;fig&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tight_layout&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;a href=&quot;https://matplotlib.org/api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show&quot; style=&quot;color: #ce5c00; text-decoration-line: none;&quot; title=&quot;View documentation for matplotlib.pyplot.show&quot;&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/7708203252139324326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/grayscale-to-rgb-conversion.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7708203252139324326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7708203252139324326'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/grayscale-to-rgb-conversion.html' title='Grayscale to RGB conversion'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWcxSET5OzalfJZdgbY9ieYwORi-3npW6630oRbTTy8Kju38kmbc__pqtk2M3gn_AloFYDdPg_3HsT9tDgBCxuL6JPhudoE1Dd_Hr6pt1vXD9gMr7oUtEmTBIAfgcmLovHDuII3W6efUc/s72-c/greyscale_to_rgb.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-6190416364874584466</id><published>2020-01-29T11:33:00.005-08:00</published><updated>2020-01-29T11:33:56.787-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>pyplot </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghok-Ioglsw3Qin6MUG4ZeKWWitlmlJ_N7Polugra9pxxzS5oKW-rvd37usYvtTdJ2_OvWPryGfo-bEKXhSeG6H4JTfmZgAyRczrZMeGdfZiSvFe1SqyJO68hCRGlT-qDpFsIL_SAEPQY/s1600/pyplotlib.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;622&quot; data-original-width=&quot;973&quot; height=&quot;408&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghok-Ioglsw3Qin6MUG4ZeKWWitlmlJ_N7Polugra9pxxzS5oKW-rvd37usYvtTdJ2_OvWPryGfo-bEKXhSeG6H4JTfmZgAyRczrZMeGdfZiSvFe1SqyJO68hCRGlT-qDpFsIL_SAEPQY/s640/pyplotlib.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #11557c; font-family: &amp;quot;helvetica neue&amp;quot;, helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; margin: 0.5em 0px; padding-top: 0.5em; text-align: left;&quot;&gt;
&lt;code class=&quot;xref py py-mod docutils literal&quot; style=&quot;color: black; font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot&quot; style=&quot;color: black; font-size: 1.7em;&quot; title=&quot;matplotlib.pyplot&quot;&gt;matplotlib.pyplot&lt;/a&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #11557c; font-family: &amp;quot;helvetica neue&amp;quot;, helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; margin: 0.5em 0px; padding-top: 0.5em; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #333333; font-size: 14px;&quot;&gt;Provides a MATLAB-like plotting framework.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;module-matplotlib.pyplot&quot; style=&quot;background-color: white; color: #333333; font-family: &amp;quot;helvetica neue&amp;quot;, Helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; font-size: 14px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
&lt;code class=&quot;xref py py-mod docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;pylab&lt;/code&gt;&amp;nbsp;combines pyplot with numpy into a single namespace. This is convenient for interactive work, but for programming it is recommended that the namespaces be kept separate, e.g.:&lt;/div&gt;
&lt;div class=&quot;highlight-default&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;plt&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;border-top: 1px solid rgb(136, 136, 136); margin-bottom: 15px; margin-top: 20px; padding-top: 0px;&quot;&gt;
&lt;dt id=&quot;matplotlib.pyplot.acorr&quot; style=&quot;background-color: #eff3f4; padding: 2px 6px 1px;&quot;&gt;&lt;code class=&quot;descclassname&quot; style=&quot;color: #aaaaaa; letter-spacing: 0.01em;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;matplotlib.pyplot.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;letter-spacing: 0.01em;&quot;&gt;acorr&lt;/code&gt;&lt;span class=&quot;sig-paren&quot;&gt;(&lt;/span&gt;&lt;em style=&quot;font-family: monospace;&quot;&gt;x&lt;/em&gt;,&amp;nbsp;&lt;em style=&quot;font-family: monospace;&quot;&gt;hold=None&lt;/em&gt;,&amp;nbsp;&lt;em style=&quot;font-family: monospace;&quot;&gt;data=None&lt;/em&gt;,&amp;nbsp;&lt;em style=&quot;font-family: monospace;&quot;&gt;**kwargs&lt;/em&gt;&lt;span class=&quot;sig-paren&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.acorr&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;margin-bottom: 10px; margin-left: 30px; margin-top: 3px; padding: 10px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
Plot the autocorrelation of&amp;nbsp;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;x&lt;/code&gt;.&lt;/div&gt;
&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin: 0px -0.5em 10px; width: 869px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;background-color: #eeeeee; border-color: rgb(136, 136, 136); border-width: 1px 0px; padding: 10px; text-align: left; vertical-align: top; width: 125px;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border-color: rgb(136, 136, 136) rgb(204, 204, 204) rgb(204, 204, 204); border-width: 1px 0px; padding: 10px 10px 10px 20px; vertical-align: top;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;margin-bottom: 0.8em;&quot;&gt;
&lt;strong&gt;x&lt;/strong&gt;&amp;nbsp;: sequence of scalar&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;strong&gt;hold&lt;/strong&gt;&amp;nbsp;: boolean, optional,&amp;nbsp;&lt;em&gt;deprecated&lt;/em&gt;, default: True&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;strong&gt;detrend&lt;/strong&gt;&amp;nbsp;: callable, optional, default:&amp;nbsp;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;mlab.detrend_none&lt;/code&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style=&quot;font-size: 13px; line-height: 18px; margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
x is detrended by the&amp;nbsp;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;detrend&lt;/code&gt;&amp;nbsp;callable. Default is no normalization.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;strong&gt;normed&lt;/strong&gt;&amp;nbsp;: boolean, optional, default: True&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style=&quot;font-size: 13px; line-height: 18px; margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
if True, input vectors are normalised to unit length.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;strong&gt;usevlines&lt;/strong&gt;&amp;nbsp;: boolean, optional, default: True&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style=&quot;font-size: 13px; line-height: 18px; margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
if True, Axes.vlines is used to plot the vertical lines from the origin to the acorr. Otherwise, Axes.plot is used.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;strong&gt;maxlags&lt;/strong&gt;&amp;nbsp;: integer, optional, default: 10&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style=&quot;font-size: 13px; line-height: 18px; margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
number of lags to show. If None, will return all 2 * len(x) - 1 lags.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;field-even field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;background-color: #eeeeee; border-color: rgb(136, 136, 136); border-width: 1px 0px; padding: 10px; text-align: left; vertical-align: top; width: 125px;&quot;&gt;Returns:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border-color: rgb(204, 204, 204); border-width: 1px 0px; padding: 10px 10px 10px 20px; vertical-align: top;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;margin-bottom: 0.8em;&quot;&gt;
&lt;strong&gt;(lags, c, line, b)&lt;/strong&gt;&amp;nbsp;: where:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot; style=&quot;margin-bottom: 10px;&quot;&gt;
&lt;li&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;lags&lt;/code&gt;&amp;nbsp;are a length 2`maxlags+1 lag vector.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;c&lt;/code&gt;&amp;nbsp;is the 2`maxlags+1 auto correlation vectorI&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;line&lt;/code&gt;&amp;nbsp;is a&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.lines.Line2D&quot;&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;Line2D&lt;/code&gt;&lt;/a&gt;&amp;nbsp;instance returned by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.pyplot.plot&quot;&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;plot&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;b&lt;/code&gt;&amp;nbsp;is the x-axis.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; colspan=&quot;2&quot; style=&quot;background-color: #eeeeee; border-color: rgb(136, 136, 136); border-width: 1px 0px; padding: 10px; text-align: left; vertical-align: top; width: 125px;&quot;&gt;Other Parameters:&lt;/th&gt;&lt;/tr&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;td style=&quot;border-color: rgb(204, 204, 204) rgb(204, 204, 204) rgb(136, 136, 136); border-width: 1px 0px; padding: 0.2em 0.5em;&quot;&gt;&lt;/td&gt;&lt;td class=&quot;field-body&quot; style=&quot;border-color: rgb(204, 204, 204) rgb(204, 204, 204) rgb(136, 136, 136); border-width: 1px 0px; padding: 10px 10px 10px 20px; vertical-align: top;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;margin-bottom: 0.8em;&quot;&gt;
&lt;strong&gt;linestyle&lt;/strong&gt;&amp;nbsp;:&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.lines.Line2D&quot;&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;Line2D&lt;/code&gt;&lt;/a&gt;&amp;nbsp;prop, optional, default: None&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style=&quot;font-size: 13px; line-height: 18px; margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
Only used if usevlines is False.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;last&quot; style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;strong&gt;marker&lt;/strong&gt;&amp;nbsp;: string, optional, default: ‘o’&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;rubric&quot; style=&quot;font-size: 19px; font-weight: 700; margin-bottom: 10px; margin-top: 15px;&quot;&gt;
Notes&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
The cross correlation is performed with&amp;nbsp;&lt;code class=&quot;xref py py-func docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;numpy.correlate()&lt;/code&gt;&amp;nbsp;with&amp;nbsp;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;mode&lt;/code&gt;&amp;nbsp;= 2.&lt;/div&gt;
&lt;div class=&quot;rubric&quot; style=&quot;font-size: 19px; font-weight: 700; margin-bottom: 10px; margin-top: 15px;&quot;&gt;
Examples&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.pyplot.xcorr&quot;&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;xcorr&lt;/code&gt;&lt;/a&gt;&amp;nbsp;is top graph, and&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.acorr&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.pyplot.acorr&quot;&gt;&lt;code class=&quot;xref py py-obj docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;acorr&lt;/code&gt;&lt;/a&gt;&amp;nbsp;is bottom graph.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 1px;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/mpl_examples/pylab_examples/xcorr_demo.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/mpl_examples/pylab_examples/xcorr_demo.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/mpl_examples/pylab_examples/xcorr_demo.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/xcorr_demo2.png&quot; src=&quot;https://matplotlib.org/_images/xcorr_demo2.png&quot; /&gt;&lt;/div&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/6190416364874584466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/pyplot.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/6190416364874584466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/6190416364874584466'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/pyplot.html' title='pyplot '/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghok-Ioglsw3Qin6MUG4ZeKWWitlmlJ_N7Polugra9pxxzS5oKW-rvd37usYvtTdJ2_OvWPryGfo-bEKXhSeG6H4JTfmZgAyRczrZMeGdfZiSvFe1SqyJO68hCRGlT-qDpFsIL_SAEPQY/s72-c/pyplotlib.JPG" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-8317582442539873900</id><published>2020-01-23T15:52:00.000-08:00</published><updated>2020-01-23T15:53:10.154-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Science"/><category scheme="http://www.blogger.com/atom/ns#" term="Deep Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Neural Networks"/><title type='text'>Transfer learning </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQbDD_bKEOCzUTAwXQywVb60RMDJycL4k82Jhvuqv2WnGrH0ez55ZdIgtpTlJnrstFdw0gZHMVsHvQyIdmu9KtULuqbE8LoHJK10IO-Znk1GHhfsOJIV_40GR9lGGVAPl0eM4sgr-g1s/s1600/transfer_learning.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;510&quot; data-original-width=&quot;809&quot; height=&quot;401&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQbDD_bKEOCzUTAwXQywVb60RMDJycL4k82Jhvuqv2WnGrH0ez55ZdIgtpTlJnrstFdw0gZHMVsHvQyIdmu9KtULuqbE8LoHJK10IO-Znk1GHhfsOJIV_40GR9lGGVAPl0eM4sgr-g1s/s640/transfer_learning.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TRANSFER LEARNING
Using a pre trained network on images not in training set is known as transfer learning
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9PoyG3zWaAtbeFCiUQw0nMagTWa2cpKWJSGNNjnF-gCnazXd6PyZZU8sFHTarkl8E-FfLRKc5NZFzz0vGCHcaCFQqkgbfDmZoaMtc4BdSimu4DFglL6JelNd6AHL5lGJIRtO8sLs6gjo/s1600/transfer_learning.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;444&quot; data-original-width=&quot;1191&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9PoyG3zWaAtbeFCiUQw0nMagTWa2cpKWJSGNNjnF-gCnazXd6PyZZU8sFHTarkl8E-FfLRKc5NZFzz0vGCHcaCFQqkgbfDmZoaMtc4BdSimu4DFglL6JelNd6AHL5lGJIRtO8sLs6gjo/s640/transfer_learning.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;DIFFERENT ARCHITECTURES WE CAN USE&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqU8WLVhdtaP5APMUhk7v7px1zmO57W5Xr2FxIDoi8mUj84IybYst9YhP0L67m5PT68ziUS3bRkUEwg1JRJrWv2iNCs2zzcs_HA0Sq_nhmXWOfzoM7N8ItTOfMa8cKy7tNEvGA6A675Ig/s1600/md.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;267&quot; data-original-width=&quot;777&quot; height=&quot;218&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqU8WLVhdtaP5APMUhk7v7px1zmO57W5Xr2FxIDoi8mUj84IybYst9YhP0L67m5PT68ziUS3bRkUEwg1JRJrWv2iNCs2zzcs_HA0Sq_nhmXWOfzoM7N8ItTOfMa8cKy7tNEvGA6A675Ig/s640/md.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;THESE ARE THE TOP 1 AND TOP 2 ERROR&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The numbers such as VCG-11 where 11 are the no of layers.&lt;/li&gt;
&lt;li&gt;When we are using this we need to do the trade-off between accuracy and speed.&lt;/li&gt;
&lt;li&gt;They are massively deep.They have 100&#39;s&amp;nbsp; of hidden&amp;nbsp; layer&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO965cHSNfdg3rkhLFVxXa_QiPwT773OF_-yOA69zXd6T3naiep5bJfX_wSfM5Bbo5Fy66ucBZrZ6n21FQ7gXYYWylAuVru4MA7404ivb3Rp8FN-7wW-ihaAXgzH-7pFHNGKZgyBztnYA/s1600/ar2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;620&quot; data-original-width=&quot;737&quot; height=&quot;336&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO965cHSNfdg3rkhLFVxXa_QiPwT773OF_-yOA69zXd6T3naiep5bJfX_wSfM5Bbo5Fy66ucBZrZ6n21FQ7gXYYWylAuVru4MA7404ivb3Rp8FN-7wW-ihaAXgzH-7pFHNGKZgyBztnYA/s400/ar2.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;MODELS&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeHyW6qweuktW8h39VCwTK-DdFwSyV3wTg_VnMhLqEgHPrPiWJ05m9Y_MXZfZ9Li2TJZxMFPAhVsyojlpzzMSVns_r9auqtbFZLha-8AjUwy-uPpxk0Xb_M4oV845XFQO9ASi5Odi2LrA/s1600/models.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;337&quot; data-original-width=&quot;934&quot; height=&quot;230&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeHyW6qweuktW8h39VCwTK-DdFwSyV3wTg_VnMhLqEgHPrPiWJ05m9Y_MXZfZ9Li2TJZxMFPAhVsyojlpzzMSVns_r9auqtbFZLha-8AjUwy-uPpxk0Xb_M4oV845XFQO9ASi5Odi2LrA/s640/models.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAwsKKHjV5B_f65h-4ELOTCvOFlOikRL2uAw4wq4QeWg5DnEbx9YFfQNIZLLeIKPvYKe30eRaO_itz3gcbbSOyVisoGalW6xntTSlLpkH-lV8qU_iqBEogMz3RNS6N3RrqsrkjR0Mhh4s/s1600/PT1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;462&quot; data-original-width=&quot;1211&quot; height=&quot;244&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAwsKKHjV5B_f65h-4ELOTCvOFlOikRL2uAw4wq4QeWg5DnEbx9YFfQNIZLLeIKPvYKe30eRaO_itz3gcbbSOyVisoGalW6xntTSlLpkH-lV8qU_iqBEogMz3RNS6N3RrqsrkjR0Mhh4s/s640/PT1.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;USING DENSENET&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;It has 121 different layers&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjRQehZwE74WL1-viJ4JQzfk04OJ39v2YwauR8jwkeKJLvSq8qZFNVc5boucq-wofbZdMV_VquOE0Bg8rGb0sw_AgMBD0gHQucllu6zc5ms1JyME6L-pgQYCSiSmOcFsTCSAXfWFDkGiA/s1600/DENS.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;294&quot; data-original-width=&quot;770&quot; height=&quot;152&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjRQehZwE74WL1-viJ4JQzfk04OJ39v2YwauR8jwkeKJLvSq8qZFNVc5boucq-wofbZdMV_VquOE0Bg8rGb0sw_AgMBD0gHQucllu6zc5ms1JyME6L-pgQYCSiSmOcFsTCSAXfWFDkGiA/s400/DENS.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;LOADING AND ARCHITECTURE&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;After loading we can see the architecture.We have features and classifiers&lt;/li&gt;
&lt;li&gt;The classifier has 1024 input features and 1000 output features&lt;/li&gt;
&lt;li&gt;Imagenet dataset has 1000 different classes.The no of output should be 1000 for these classes.&lt;/li&gt;
&lt;li&gt;The features would not be used and need to be freezed.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOfrk-BlkP6-nZFpZLmOmz-xHoBDsNDTPnwhTYKKh2j8PxI7JZbwBxHyU_PxUvsCvqFb9Qo7qCZmLEfjSte_k0V_yQyOO2hFK0qwM_nAQm5LchhM6FhjS3PUjITqNtDqonD2b95d54guk/s1600/ld_arch.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;653&quot; data-original-width=&quot;1600&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOfrk-BlkP6-nZFpZLmOmz-xHoBDsNDTPnwhTYKKh2j8PxI7JZbwBxHyU_PxUvsCvqFb9Qo7qCZmLEfjSte_k0V_yQyOO2hFK0qwM_nAQm5LchhM6FhjS3PUjITqNtDqonD2b95d54guk/s640/ld_arch.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic5LhYuJvJX_tUkRRrdK_q52v6G96BerRGvnOAUvi8xG5RsUdZZ_7BcKNWPsKBO2xzAiU2yeUemKtYHjuMp44_M_En987ywqzQB028H2KXcl0L0ut5qQQID9__Gsv-GOOFsHQqb4w7rdQ/s1600/features_cl.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;249&quot; data-original-width=&quot;1178&quot; height=&quot;134&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic5LhYuJvJX_tUkRRrdK_q52v6G96BerRGvnOAUvi8xG5RsUdZZ_7BcKNWPsKBO2xzAiU2yeUemKtYHjuMp44_M_En987ywqzQB028H2KXcl0L0ut5qQQID9__Gsv-GOOFsHQqb4w7rdQ/s640/features_cl.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;FREEZING THE FEATURES&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We need feature part static, to this we would freeze our feature parameter as shown below&lt;/li&gt;
&lt;li&gt;This would increase processing speed as it would not keep track of features&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi89yZeTrne_b8jeyRftIeB0uWNfo8NlS3lQ7H7sVlexPyRqZknZCZtOLGToyeySua-sZztR6uzAOmmTOyHvUFbw3ZG2CaAFNIKmUOXUHjmu5pBPk1FYK7kUG9tW4IxrnlZUMUmJCreuz8/s1600/Fr.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;447&quot; data-original-width=&quot;1325&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi89yZeTrne_b8jeyRftIeB0uWNfo8NlS3lQ7H7sVlexPyRqZknZCZtOLGToyeySua-sZztR6uzAOmmTOyHvUFbw3ZG2CaAFNIKmUOXUHjmu5pBPk1FYK7kUG9tW4IxrnlZUMUmJCreuz8/s640/Fr.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;BUILD CLASSIFIER&lt;/b&gt;&lt;br /&gt;
We would build our classifier as shown below&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4iJZP65_BQUocLmatA-iZjprKzJp0bX4CZ-77kerSSqk04JHZmeLKVectQxEzAJGWcT3WL30bpuczslTB_6ZHIOjyvpHelPMmv4bj5bJ5_Ny9YEvc8zOIBijsP4cxIJXxcpvUHMZeJxM/s1600/Classifier.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;201&quot; data-original-width=&quot;658&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4iJZP65_BQUocLmatA-iZjprKzJp0bX4CZ-77kerSSqk04JHZmeLKVectQxEzAJGWcT3WL30bpuczslTB_6ZHIOjyvpHelPMmv4bj5bJ5_Ny9YEvc8zOIBijsP4cxIJXxcpvUHMZeJxM/s400/Classifier.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;ATTACH TO OUR MODEL&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9kvKtQAPJxpSP-a-BOEquaYvgB7-HQRURO_KVYv9CS9af9MU8aKExH91LzReN8KPP8dJ6v5gG88pCwwAW38Pzz4x7cnfnhcEqBdPJPzobw5c3iSTBU0nnaTUQJwtL4xrJMscqrFnByQk/s1600/NM.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;72&quot; data-original-width=&quot;755&quot; height=&quot;37&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9kvKtQAPJxpSP-a-BOEquaYvgB7-HQRURO_KVYv9CS9af9MU8aKExH91LzReN8KPP8dJ6v5gG88pCwwAW38Pzz4x7cnfnhcEqBdPJPzobw5c3iSTBU0nnaTUQJwtL4xrJMscqrFnByQk/s400/NM.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;MOVE TO GPU&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We can move all the computing to a GPU by specifying model.cuda . This would move all the parameters and model to the GPU&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyV4M6NmxIWR87Jh2w52BlcBQ3FSuVuYPzAUH1lUC5KTtW7105-7sHq3K9hbTFokNYo10hHZIGBH16hVuKFvNmvC1GIA9QCxBmleIUTk2xu9FbVooRk6j9UrJyYsfMED8w0LoDDQ4RfXI/s1600/modal_cuda.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;636&quot; data-original-width=&quot;1299&quot; height=&quot;312&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyV4M6NmxIWR87Jh2w52BlcBQ3FSuVuYPzAUH1lUC5KTtW7105-7sHq3K9hbTFokNYo10hHZIGBH16hVuKFvNmvC1GIA9QCxBmleIUTk2xu9FbVooRk6j9UrJyYsfMED8w0LoDDQ4RfXI/s640/modal_cuda.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;To move the tensors to the GPU, we need to use image.cuda&lt;/li&gt;
&lt;li&gt;To specify cpu we need to change it to image.cpu, model.cpu&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-aOFj5Oqraqp_pyV4L0qae9liY3fMvI8u9Ej5Cpfr9Z6NVjrWX92R1lX2X-zUlEB4tQwulAoRHZx6Dzkz52_iMxuFXEb-MmCA5_aZjU8bnxTmLAyz6_c70Gpfo7KA4rF8-YdSa_u-cAQ/s1600/md_cuda.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;111&quot; data-original-width=&quot;599&quot; height=&quot;73&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-aOFj5Oqraqp_pyV4L0qae9liY3fMvI8u9Ej5Cpfr9Z6NVjrWX92R1lX2X-zUlEB4tQwulAoRHZx6Dzkz52_iMxuFXEb-MmCA5_aZjU8bnxTmLAyz6_c70Gpfo7KA4rF8-YdSa_u-cAQ/s400/md_cuda.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;COMPARISON BETWEEN CPU AND GPU&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We would get a speed of over a 100 times&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvV3kXIWa_Oam5bu3figID93fXVep0GTptemnu5_ff4J89CeWzG9CnowYVs5GUP4nGiorbo7D2W8LT4rQRG6pYdYfEhPTIyFb719W4ietO3MqJ6mOA_UoXXTtkMltnBH3OdrI5nzQz8og/s1600/C.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;403&quot; data-original-width=&quot;955&quot; height=&quot;270&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvV3kXIWa_Oam5bu3figID93fXVep0GTptemnu5_ff4J89CeWzG9CnowYVs5GUP4nGiorbo7D2W8LT4rQRG6pYdYfEhPTIyFb719W4ietO3MqJ6mOA_UoXXTtkMltnBH3OdrI5nzQz8og/s640/C.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBFgdOM4trJ80-lIPONRjmLS833YI5yYqlz4_ZRJgp3RAKU-qfCbhF8gf4wmM_xjrehdti6748XheX0gcOIkMHUXaWH4GIyvRvnQtb42Rqo68wuaB595FPA_fdTS6hzUJw4ZKtkIDcVps/s1600/c1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;387&quot; data-original-width=&quot;1186&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBFgdOM4trJ80-lIPONRjmLS833YI5yYqlz4_ZRJgp3RAKU-qfCbhF8gf4wmM_xjrehdti6748XheX0gcOIkMHUXaWH4GIyvRvnQtb42Rqo68wuaB595FPA_fdTS6hzUJw4ZKtkIDcVps/s640/c1.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/8317582442539873900/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/transfer-learning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8317582442539873900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8317582442539873900'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/transfer-learning.html' title='Transfer learning '/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQbDD_bKEOCzUTAwXQywVb60RMDJycL4k82Jhvuqv2WnGrH0ez55ZdIgtpTlJnrstFdw0gZHMVsHvQyIdmu9KtULuqbE8LoHJK10IO-Znk1GHhfsOJIV_40GR9lGGVAPl0eM4sgr-g1s/s72-c/transfer_learning.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-7475059641216668526</id><published>2020-01-23T15:43:00.000-08:00</published><updated>2020-01-23T15:43:03.277-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Deep Learning"/><title type='text'>MNIST GAN</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguGhKK7Jl_VrXeW2g9D2qwpj2-cL9vspLTwKrFlV9Tu0MQC4hYL9fNYmemXxvmqUVAKvyEcEXwwV6zUqOE5WIgz5_RJY6od4CMeiFk6P0BN39GSeJOA1O5m-lYCUKOOK-1YG3C6KYvOYM/s1600/MNgan.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;734&quot; data-original-width=&quot;1388&quot; height=&quot;338&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguGhKK7Jl_VrXeW2g9D2qwpj2-cL9vspLTwKrFlV9Tu0MQC4hYL9fNYmemXxvmqUVAKvyEcEXwwV6zUqOE5WIgz5_RJY6od4CMeiFk6P0BN39GSeJOA1O5m-lYCUKOOK-1YG3C6KYvOYM/s640/MNgan.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here we have 2 neural networks GENERATOR and&amp;nbsp; DISCRIMINATOR&lt;br /&gt;
&lt;br /&gt;
DISCRIMINATOR:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Is a simple classifier that tries to classify the images as &lt;b&gt;real &lt;/b&gt;from the training set or &lt;b&gt;fake &lt;/b&gt;generated images.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
GENERATOR:&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Acting as an adversary to the discriminator.&lt;/li&gt;
&lt;li&gt;It aims to trick the discrminator, giving it generated images that look as if they&#39;ve come from the training set.&lt;/li&gt;
&lt;li&gt;If the generator produces an image that the discriminator thinks is fake, then it would change it behavior and try again.&lt;/li&gt;
&lt;li&gt;Generator would trick till the discrimnator starts thinking that its generated data comes from the real training set.( Goal is to force the discriminator to have a high error rate as possible.Note that at the same time discriminator is also training. it looks at examples of real and fake images and getting better at recognizing differences between them.its goal is to have a low error rate.)&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Task is to have both discriminator and generator networks with opposing goals.We define opposing generator and discriminator loss functions.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
At the end of the training discriminator should not be able to tell the difference between real and fake images&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/7475059641216668526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/mnist-gan.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7475059641216668526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7475059641216668526'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/mnist-gan.html' title='MNIST GAN'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguGhKK7Jl_VrXeW2g9D2qwpj2-cL9vspLTwKrFlV9Tu0MQC4hYL9fNYmemXxvmqUVAKvyEcEXwwV6zUqOE5WIgz5_RJY6od4CMeiFk6P0BN39GSeJOA1O5m-lYCUKOOK-1YG3C6KYvOYM/s72-c/MNgan.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-7561915254497704382</id><published>2020-01-23T14:26:00.000-08:00</published><updated>2020-01-23T14:26:16.111-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Glob module in python</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8Fr-6LVqna5KK-ghP3RtG8DcCO5j2dU_l8m3SDdsWIZDXSopat4BwcmG2j075Pdef1QgC5Uc377jvBTsDC4FLKa2bBd7F_SOjV5a4dznrAyUqe1fThp-F_WkOWJiOLZBiSbMwnu-dGdI/s1600/glob.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;325&quot; data-original-width=&quot;620&quot; height=&quot;334&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8Fr-6LVqna5KK-ghP3RtG8DcCO5j2dU_l8m3SDdsWIZDXSopat4BwcmG2j075Pdef1QgC5Uc377jvBTsDC4FLKa2bBd7F_SOjV5a4dznrAyUqe1fThp-F_WkOWJiOLZBiSbMwnu-dGdI/s640/glob.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
Usually, the programmers require to traverse through a list of files at some location, mostly having a specific pattern. Python’s glob module has several functions that can help in listing files under a specified folder. We may filter them based on extensions, or with a particular string as a portion of the filename.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
All the methods of Glob module follow the Unix-style pattern matching mechanism and rules. However, it doesn’t allow expanding the tilde (~) and environment variables.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 23px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-weight: 400; line-height: 1.4; margin: 0px 0px 15px; overflow-wrap: break-word; padding: 0px; text-transform: capitalize; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Python Glob() Methods&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
There are three primary functions of Glob module.&lt;/div&gt;
&lt;div class=&quot;no_bullets&quot; id=&quot;toc_container&quot; style=&quot;background: rgb(249, 249, 249); border: 1px solid rgb(170, 170, 170); box-sizing: border-box; color: #4d4d4d; display: table; font-family: Helvetica, Arial, sans-serif; font-size: 15.2px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px 0px 1em; padding: 10px; vertical-align: baseline; width: auto; word-spacing: 3px;&quot;&gt;
&lt;div class=&quot;toc_title&quot; style=&quot;border: 0px; box-sizing: border-box; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 700; line-height: inherit; overflow-wrap: break-word; padding: 0px; text-align: center; vertical-align: baseline;&quot;&gt;
Contents&amp;nbsp;&lt;span class=&quot;toc_toggle&quot; style=&quot;border: 0px; box-sizing: border-box; font-family: inherit; font-size: 13.68px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 400; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;[&lt;a href=&quot;https://www.techbeamers.com/python-glob/#&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; text-shadow: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot;&gt;hide&lt;/a&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;ul class=&quot;toc_list&quot; style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 1em 0px 0px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://www.techbeamers.com/python-glob/#globfile-pattern-recursive-false&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; text-shadow: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;1&lt;/span&gt;&amp;nbsp;glob(file_pattern, recursive = False)&lt;/a&gt;&lt;ul style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 0px 0px 0px 1.5em; overflow-wrap: break-word; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://www.techbeamers.com/python-glob/#check-the-current-directory-for-python-script-files&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; text-shadow: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;toc_number toc_depth_2&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;1.1&lt;/span&gt;&amp;nbsp;Check the current directory for Python script files&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://www.techbeamers.com/python-glob/#list-files-with-a-pattern&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; text-shadow: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;toc_number toc_depth_2&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;1.2&lt;/span&gt;&amp;nbsp;List files with a pattern&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://www.techbeamers.com/python-glob/#iglob-method-python-glob&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; text-shadow: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;2&lt;/span&gt;&amp;nbsp;iglob() method | Python Glob&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; font: inherit; list-style: none; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://www.techbeamers.com/python-glob/#escape-method&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; text-shadow: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;3&lt;/span&gt;&amp;nbsp;escape() method&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-weight: 400; line-height: 1.4; margin: 0px 0px 15px; overflow-wrap: break-word; padding: 0px; text-transform: capitalize; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;span id=&quot;globfile-pattern-recursive-false&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Glob(File_pattern, Recursive = False)&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
It retrieves the list of files matching the specified pattern in the file_pattern parameter.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
The file_pattern can be an absolute or relative path. It may also contain wild cards such as “*” or “?” symbols.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
The recursive parameter is turn off (False) by default. When True, it recursively searches files under all subdirectories of the current directory.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
Let’s now check out some examples:&lt;/div&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 19px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-weight: 400; line-height: 1.4; margin: 0px 0px 15px; overflow-wrap: break-word; padding: 0px; text-transform: capitalize; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;span id=&quot;check-the-current-directory-for-python-script-files&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Check The Current Directory For Python Script Files&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
The below code checks for .py files in the current dir only.&lt;/div&gt;
&lt;pre class=&quot; prettyprinted&quot; style=&quot;background: rgb(238, 238, 238); border: 0px; box-sizing: border-box; color: #444444; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3em; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 15px; position: relative; vertical-align: baseline; word-spacing: 3px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; py &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;*.py&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
copy_file1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
copy_file2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
decimal_sample&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
Another sample code – It checks for .py files in current dir and subdirectories.&lt;/div&gt;
&lt;pre class=&quot; prettyprinted&quot; style=&quot;background: rgb(238, 238, 238); border: 0px; box-sizing: border-box; color: #444444; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3em; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 15px; position: relative; vertical-align: baseline; word-spacing: 3px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; py &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;*.py&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
copy_file1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
copy_file2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
decimal_sample&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
test_num&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
test_python_in_with_if&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
test_scope&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;/pre&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 19px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-weight: 400; line-height: 1.4; margin: 0px 0px 15px; overflow-wrap: break-word; padding: 0px; text-transform: capitalize; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;span id=&quot;list-files-with-a-pattern&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;List Files With A Pattern&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
We can provide a pathname pattern by including some wild cards like ? or numeric range [0-9].&amp;nbsp; The below code lists all files whose name starts with “test” followed by a number.&lt;/div&gt;
&lt;pre class=&quot; prettyprinted&quot; style=&quot;background: rgb(238, 238, 238); border: 0px; box-sizing: border-box; color: #444444; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3em; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 15px; position: relative; vertical-align: baseline; word-spacing: 3px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; py &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;test[0-9].py&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
test1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
test2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
Let’s check one more example using the question mark in the pattern.&lt;/div&gt;
&lt;pre class=&quot; prettyprinted&quot; style=&quot;background: rgb(238, 238, 238); border: 0px; box-sizing: border-box; color: #444444; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3em; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 15px; position: relative; vertical-align: baseline; word-spacing: 3px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; py &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;?????.py&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
quiz1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
test1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
test2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
The above for loop statement printed all .py files having five letters.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
The following statement would print the names of folders recursively in the current working directory.&lt;/div&gt;
&lt;pre class=&quot; prettyprinted&quot; style=&quot;background: rgb(238, 238, 238); border: 0px; box-sizing: border-box; color: #444444; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3em; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 15px; position: relative; vertical-align: baseline; word-spacing: 3px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;selenium/**/&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; recursive&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;selenium\&#39;, &#39;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;selenium\webdriver\&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;selenium\webdriver\firefox\&#39;, &#39;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;selen
ium\webdriver\firefox\amd64\&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;selenium\webdriver\firefox\x86\&#39;]&lt;/span&gt;&lt;/pre&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-weight: 400; line-height: 1.4; margin: 0px 0px 15px; overflow-wrap: break-word; padding: 0px; text-transform: capitalize; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;span id=&quot;iglob-method-python-glob&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Iglob() Method | Python Glob&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
This method creates a&amp;nbsp;&lt;span style=&quot;border: 0px; box-sizing: border-box; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: 700; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://www.techbeamers.com/python-generator/&quot; rel=&quot;noopener noreferrer&quot; style=&quot;border-bottom-style: dotted; border-color: initial; border-image: initial; border-left-style: initial; border-right-style: initial; border-top-style: initial; border-width: 0px 0px 1px; box-sizing: border-box; color: #252830; font: inherit; margin: 0px; padding: 0px; text-decoration-line: none; transition: all 0.25s ease 0s; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Python generator&lt;/a&gt;&lt;/span&gt;&amp;nbsp;object which can be used to list files under a given directory. You can call the next() function to print names of files.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
Check the sample code below:&lt;/div&gt;
&lt;pre class=&quot; prettyprinted&quot; style=&quot;background: rgb(238, 238, 238); border: 0px; box-sizing: border-box; color: #444444; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3em; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 15px; position: relative; vertical-align: baseline; word-spacing: 3px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; gen &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;iglob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;*.py&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; type&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;gen&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;border: 0px; box-sizing: border-box; color: #008800; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&#39;generator&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; py &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; gen&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;border: 0px; box-sizing: border-box; color: #000088; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
copy_file1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
copy_file2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
decimal_sample&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
find_seed&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py
frozen_set&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;border: 0px; box-sizing: border-box; color: #666600; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;border: 0px; box-sizing: border-box; color: black; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;py&lt;/span&gt;&lt;/pre&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #444444; font-family: Helvetica, Arial, sans-serif; font-size: 21px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-weight: 400; line-height: 1.4; margin: 0px 0px 15px; overflow-wrap: break-word; padding: 0px; text-transform: capitalize; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
&lt;span id=&quot;escape-method&quot; style=&quot;border: 0px; box-sizing: border-box; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Escape() Method&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #4d4d4d; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 25px; overflow-wrap: break-word; padding: 0px; vertical-align: baseline; word-spacing: 3px;&quot;&gt;
It allows for escaping the given character sequence. You can find it handy for locating files with certain characters in their file names.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/7561915254497704382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/glob-module-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7561915254497704382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7561915254497704382'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/glob-module-in-python.html' title='Glob module in python'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8Fr-6LVqna5KK-ghP3RtG8DcCO5j2dU_l8m3SDdsWIZDXSopat4BwcmG2j075Pdef1QgC5Uc377jvBTsDC4FLKa2bBd7F_SOjV5a4dznrAyUqe1fThp-F_WkOWJiOLZBiSbMwnu-dGdI/s72-c/glob.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-8693667505180050880</id><published>2020-01-22T14:02:00.001-08:00</published><updated>2020-01-22T14:02:14.370-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Deep Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="NLP"/><title type='text'>Flattening in NLP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzyQOW3nB6H46Z7ijieqOMOOK_qzwe2WFYQjTTeZ5VaITxyuIm5WEfVAOfEgcbM46X_BKZUGz0c4xPk8aCKeR_wZElWg_9dnCRFqvXh-Y72LvshmWRGtgBy0Y6raDjZY-aVTzKuWfLZSc/s1600/flatten.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;418&quot; data-original-width=&quot;484&quot; height=&quot;343&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzyQOW3nB6H46Z7ijieqOMOOK_qzwe2WFYQjTTeZ5VaITxyuIm5WEfVAOfEgcbM46X_BKZUGz0c4xPk8aCKeR_wZElWg_9dnCRFqvXh-Y72LvshmWRGtgBy0Y6raDjZY-aVTzKuWfLZSc/s400/flatten.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Instead of representing this 4*4 matrix, we can construct a vector with 16 entries.&lt;/li&gt;
&lt;li&gt;First 4 entries correspond to the first row.similarly 2nd 3rd and 4th&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7qkRjKCvK1Kq1WacCOzSDArLci0KcJTotLucmykJKTI8NdPaBZRAWzLZtZaz-hKyy1Sj2PmvQIWjpkGb6WaOyH-XLSc8S_SM7PC8eQgHfs8PWwXT_8xNdM9x_sOdyYNo7SBZ_EG1VLjM/s1600/flatten_2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;209&quot; data-original-width=&quot;1550&quot; height=&quot;86&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7qkRjKCvK1Kq1WacCOzSDArLci0KcJTotLucmykJKTI8NdPaBZRAWzLZtZaz-hKyy1Sj2PmvQIWjpkGb6WaOyH-XLSc8S_SM7PC8eQgHfs8PWwXT_8xNdM9x_sOdyYNo7SBZ_EG1VLjM/s640/flatten_2.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note:After converting our image to an vector they can be fed to an input layer on NLP.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/8693667505180050880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/flattening-in-nlp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8693667505180050880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8693667505180050880'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/flattening-in-nlp.html' title='Flattening in NLP'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzyQOW3nB6H46Z7ijieqOMOOK_qzwe2WFYQjTTeZ5VaITxyuIm5WEfVAOfEgcbM46X_BKZUGz0c4xPk8aCKeR_wZElWg_9dnCRFqvXh-Y72LvshmWRGtgBy0Y6raDjZY-aVTzKuWfLZSc/s72-c/flatten.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-9069557955943741736</id><published>2020-01-22T13:57:00.002-08:00</published><updated>2020-01-22T13:57:26.231-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer vision"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>MoviePy</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv9DBnqBI1tagf4KZrEqWuUd35MocbSojX-nxLXgurMUyAeaM3SgsrjNj71d-Ujsp79RM1dULUzNBGz9bIbMYegrj3TYHw5H508O13631Bf3dube6hYWjIc2-EeaxC4S5PleNcpJ_l3yA/s1600/movie_py.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;408&quot; data-original-width=&quot;943&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv9DBnqBI1tagf4KZrEqWuUd35MocbSojX-nxLXgurMUyAeaM3SgsrjNj71d-Ujsp79RM1dULUzNBGz9bIbMYegrj3TYHw5H508O13631Bf3dube6hYWjIc2-EeaxC4S5PleNcpJ_l3yA/s640/movie_py.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px; line-height: 24px; margin-bottom: 24px;&quot;&gt;
MoviePy is a Python module for video editing, which can be used for basic operations (like cuts, concatenations, title insertions), video compositing (a.k.a. non-linear editing), video processing, or to create advanced effects. It can read and write the most common video formats, including GIF.&lt;/div&gt;
&lt;div style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px; line-height: 24px; margin-bottom: 24px;&quot;&gt;
Here it is in action (run in an IPython Notebook):&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a class=&quot;reference internal image-reference&quot; href=&quot;https://zulko.github.io/moviepy/_images/demo_preview1.jpeg&quot; style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #9b59b6; cursor: pointer; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px; text-decoration-line: none;&quot;&gt;&lt;img alt=&quot;_images/demo_preview1.jpeg&quot; class=&quot;align-center&quot; src=&quot;https://zulko.github.io/moviepy/_images/demo_preview1.jpeg&quot; style=&quot;border: 0px; box-sizing: border-box; display: block; height: auto !important; margin: auto; max-width: 100%; vertical-align: middle; width: 500px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
More information is available at&amp;nbsp;&lt;a href=&quot;https://zulko.github.io/moviepy/&quot;&gt;https://zulko.github.io/moviepy/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;section&quot; id=&quot;do-i-need-moviepy&quot; style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; font-family: &amp;quot;Roboto Slab&amp;quot;, ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; margin-top: 0px;&quot;&gt;
Do I need MoviePy ?&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
Here are a few reasons why you may want to edit videos in Python:&lt;/div&gt;
&lt;ul class=&quot;simple&quot; style=&quot;box-sizing: border-box; line-height: 24px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 24px; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You have many videos to process or to compose in a complicated way.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You want to automatize the creation of videos or GIFs on a web server (Django, Flask, etc.)&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You want to automatize tedious tasks, like title insertions tracking objects, cuting scenes, making end credits, subtitles, etc...&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You want to code your own video effects to do something no existing video editor can.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You want to create animations from images generated by another python library (Matplotlib, Mayavi, Gizeh, scikit-images...)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
And here are a few uses for which MoviePy is NOT the best solution:&lt;/div&gt;
&lt;ul class=&quot;simple&quot; style=&quot;box-sizing: border-box; line-height: 24px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 24px; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You only need to do frame-by-frame video analysis (with face detection or other fancy stuff). This could be done with MoviePy in association with other libraries, but really, just use&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://imageio.github.io/&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;imageio&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;http://opencv.org/&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;OpenCV&lt;/a&gt;&amp;nbsp;or SimpleCV, these are libraries that specialize in these tasks.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;You only want to convert a video file, or turn a series of image files into a movie. In this case it is better to directly call&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;ffmpeg&lt;/span&gt;&lt;/code&gt;&amp;nbsp;(or&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;avconv&lt;/span&gt;&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;mencoder&lt;/span&gt;&lt;/code&gt;...) it will be faster more memory-efficient than going through MoviePy.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;advantages-and-limitations&quot; style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; font-family: &amp;quot;Roboto Slab&amp;quot;, ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; margin-top: 0px;&quot;&gt;
Advantages and limitations&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
MoviePy has been developed with the following goals in mind:&lt;/div&gt;
&lt;ul class=&quot;simple&quot; style=&quot;box-sizing: border-box; line-height: 24px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 24px; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Simple an intuitive&lt;/strong&gt;. Basic operations can be done in one line. The code is easy to learn and easy to understand for newcomers.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Flexible&lt;/strong&gt;. You have total control over the frames of the video and audio, and creating your own effects is easy as Py.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style: disc; margin-left: 24px;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;&quot;&gt;Portable&lt;/strong&gt;. The code uses very common software (Numpy and FFMPEG) and can run on (almost) any machine with (almost) any version of Python.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
For the limitations: MoviePy cannot (yet) stream videos (read from a webcam, or render a video live on a distant machine), and is not really designed for video processing involving many successive frames of a movie (like video stabilization, you’ll need another software for that). You can also have memory problems if you use many video, audio, and image sources at the same time (&amp;gt;100), but this will be fixed in future versions.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;example-code&quot; style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; font-family: &amp;quot;Roboto Slab&amp;quot;, ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; margin-top: 0px;&quot;&gt;
Example code&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
In a typical MoviePy script, you load video or audio files, modify them, put them together, and write the final result to a new video file. As an example, let us load a video of my last holidays, lower the volume, add a title in the center of the video for the first ten seconds, and write the result in a file:&lt;/div&gt;
&lt;div class=&quot;highlight-default&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; margin: 1px 0px 24px; overflow-x: auto; padding: 0px;&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: none; border: none; box-sizing: border-box; margin: 0px; overflow-x: auto; padding: 0px;&quot;&gt;
&lt;pre style=&quot;box-sizing: border-box; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; line-height: normal; overflow: auto; padding: 12px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Import everything needed to edit video clips&lt;/span&gt;
&lt;span class=&quot;kn&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;box-sizing: border-box; color: #555555;&quot;&gt;moviepy.editor&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;clip&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;VideoFileClip&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&quot;myHolidays.mp4&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;subclip&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #009999;&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #009999;&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Reduce the audio volume (volume x 0.8)&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;clip&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;clip&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;volumex&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot; style=&quot;box-sizing: border-box; color: #009999;&quot;&gt;0.8&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Generate a text clip. You can customize the font, color, etc.&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;txt_clip&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;TextClip&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&quot;My Holidays 2013&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;fontsize&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #009999;&quot;&gt;70&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&#39;white&#39;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Say that you want it to appear 10s at the center of the screen&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;txt_clip&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;txt_clip&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;set_pos&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&#39;center&#39;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;set_duration&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: #009999;&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Overlay the text clip on the first video clip&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;video&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;CompositeVideoClip&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;clip&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;txt_clip&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: #999988; font-style: italic;&quot;&gt;# Write the result to a file (many options available !)&lt;/span&gt;
&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;video&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;write_videofile&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&quot;myHolidays_edited.webm&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;how-moviepy-works&quot; style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; font-family: &amp;quot;Roboto Slab&amp;quot;, ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; margin-top: 0px;&quot;&gt;
How MoviePy works&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
MoviePy uses the software&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;ffmpeg&lt;/span&gt;&lt;/code&gt;&amp;nbsp;to read and to export video and audio files. It also (optionally) uses ImageMagick to generate texts and write GIF files. The processing of the different media is ensured by Python’s fast numerical library Numpy. Advanced effects and enhancements use some of Python’s numerous image processing libraries (PIL, Scikit-image, scipy, etc.).&lt;/div&gt;
&lt;a class=&quot;reference internal image-reference&quot; href=&quot;https://zulko.github.io/moviepy/_images/explanations.jpeg&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;&lt;img alt=&quot;../_images/explanations.jpeg&quot; class=&quot;align-center&quot; src=&quot;https://zulko.github.io/moviepy/_images/explanations.jpeg&quot; style=&quot;border: 0px; box-sizing: border-box; display: block; height: auto !important; margin: auto auto 24px; max-width: 100%; vertical-align: middle; width: 570px;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;basic-concepts&quot; style=&quot;background-color: #fcfcfc; box-sizing: border-box; color: #404040; font-family: Lato, proxima-nova, &amp;quot;Helvetica Neue&amp;quot;, Arial, sans-serif; font-size: 16px;&quot;&gt;
&lt;h2 style=&quot;box-sizing: border-box; font-family: &amp;quot;Roboto Slab&amp;quot;, ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; margin-top: 0px;&quot;&gt;
Basic concepts&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
The central objects of MoviePy are&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;clips&lt;/em&gt;, which can be&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;AudioClips&lt;/span&gt;&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;VideoClips&lt;/span&gt;&lt;/code&gt;. They can be modified (cut, slowed down, darkened...) or put mixed with clips to form new clips, they can be previewed (using either PyGame or the IPython Notebook) and rendered to a file (as a MP4, a GIF, a MP3, etc.).&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;VideoClips&lt;/span&gt;&lt;/code&gt;&amp;nbsp;for instance can be created from a video file, an image, a text, or a custom animation. They can have an audio track (which is an&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;AudioClip&lt;/span&gt;&lt;/code&gt;) and a mask (a special&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;VideoClip&lt;/span&gt;&lt;/code&gt;&amp;nbsp;indicating which parts of the clip to hide when the clip is mixed with other clips). See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://zulko.github.io/moviepy/getting_started/videoclips.html#videoclips&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;Creating and exporting video clips&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://zulko.github.io/moviepy/getting_started/compositing.html#compositevideoclips&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;Mixing clips&lt;/a&gt;&amp;nbsp;for more details.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
A clip can be modified using one of moviepy’s numerous effects (like in&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;clip.resize(width=&quot;360&quot;)&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;clip.subclip(t1,t2)&lt;/span&gt;&lt;/code&gt;, or&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;clip.fx(vfx.black_white)&lt;/span&gt;&lt;/code&gt;) or using a user-implemented effect. MoviePy implements many functions (like&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;clip.fl&lt;/span&gt;&lt;/code&gt;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;clip.fx&lt;/span&gt;&lt;/code&gt;, etc.) which make it very easy to code your own effect in a few lines. See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://zulko.github.io/moviepy/getting_started/effects.html#effects&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;Clips transformations and effects&lt;/a&gt;&amp;nbsp;for more.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
You will also find a few advanced goodies in&amp;nbsp;&lt;code class=&quot;docutils literal&quot; style=&quot;background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); box-sizing: border-box; color: #e74c3c; font-family: Consolas, &amp;quot;Andale Mono WT&amp;quot;, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Lucida Sans Typewriter&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Nimbus Mono L&amp;quot;, Monaco, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 12px; max-width: 100%; overflow-x: auto; padding: 2px 5px; white-space: nowrap;&quot;&gt;&lt;span class=&quot;pre&quot; style=&quot;box-sizing: border-box;&quot;&gt;moviepy.video.tools&lt;/span&gt;&lt;/code&gt;&amp;nbsp;to track objects in a video, draw simple shapes and color gradients (very useful for masks), generate subtitles and end credits, etc. See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://zulko.github.io/moviepy/advanced_tools/advanced_tools.html#advancedtools&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;Advanced tools&lt;/a&gt;&amp;nbsp;for a description of these.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 24px;&quot;&gt;
Finally, although MoviePy has no graphical user interface, there are many ways to preview a clip which allow you to fine-tune your scripts and be sure that everything is perfect when you render you video in high quality. See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://zulko.github.io/moviepy/getting_started/efficient_moviepy.html#efficient&quot; style=&quot;box-sizing: border-box; color: #9b59b6; cursor: pointer; text-decoration-line: none;&quot;&gt;How to be efficient with MoviePy&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/9069557955943741736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/moviepy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/9069557955943741736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/9069557955943741736'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/moviepy.html' title='MoviePy'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv9DBnqBI1tagf4KZrEqWuUd35MocbSojX-nxLXgurMUyAeaM3SgsrjNj71d-Ujsp79RM1dULUzNBGz9bIbMYegrj3TYHw5H508O13631Bf3dube6hYWjIc2-EeaxC4S5PleNcpJ_l3yA/s72-c/movie_py.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-2145014412112382723</id><published>2020-01-22T13:47:00.003-08:00</published><updated>2020-01-22T13:48:04.606-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer vision"/><title type='text'>Gaussian Blur operation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhecKgKipp0wshkeKje8rQwbUO7qfuyQ8uTOkAN84HbGjv-frEYk_rsBbXu0ObeP4xPAeZGZ1PKluvgwOKP2QhK5ukW7bUEW1lRW91JVHFAyx6rh6wAJJ_Mg1GFwwGAqukYCdWqqp3dxgc/s1600/Gaussian_filter.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;380&quot; data-original-width=&quot;781&quot; height=&quot;311&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhecKgKipp0wshkeKje8rQwbUO7qfuyQ8uTOkAN84HbGjv-frEYk_rsBbXu0ObeP4xPAeZGZ1PKluvgwOKP2QhK5ukW7bUEW1lRW91JVHFAyx6rh6wAJJ_Mg1GFwwGAqukYCdWqqp3dxgc/s640/Gaussian_filter.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;hr style=&quot;background-image: none; border-bottom: 0px; border-image: initial; border-left: 0px; border-right: 0px; border-top-color: rgb(214, 214, 214) !important; border-top-style: solid !important; box-sizing: content-box; clear: both; color: #313131; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; height: 0px; margin: 7px 0px;&quot; /&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
In Gaussian Blur operation, the image is convolved with a Gaussian filter instead of the box filter. The Gaussian filter is a low-pass filter that removes the high-frequency components are reduced.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
You can perform this operation on an image using the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;Gaussianblur()&lt;/span&gt;method of the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;imgproc&lt;/span&gt;&amp;nbsp;class. Following is the syntax of this method −&lt;/div&gt;
&lt;pre class=&quot;result notranslate&quot; style=&quot;background-color: #f1f1f1; border-radius: 0px; border: 1px solid rgb(214, 214, 214); box-sizing: border-box; color: #313131; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; overflow: auto; padding: 5px; width: 604px;&quot;&gt;GaussianBlur(src, dst, ksize, sigmaX)
&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
This method accepts the following parameters −&lt;/div&gt;
&lt;ul class=&quot;list&quot; style=&quot;box-sizing: border-box; color: #313131; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;src&lt;/span&gt;&amp;nbsp;− A&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;Mat&lt;/span&gt;&amp;nbsp;object representing the source (input image) for this operation.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;dst&lt;/span&gt;&amp;nbsp;− A&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;Mat&lt;/span&gt;&amp;nbsp;object representing the destination (output image) for this operation.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;ksize&lt;/span&gt;&amp;nbsp;− A&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;Size&lt;/span&gt;&amp;nbsp;object representing the size of the kernel.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-image: url(&amp;quot;/images/icon-bullet.png&amp;quot;); background-origin: initial; background-position: 0px 4px; background-repeat: no-repeat; background-size: initial; box-sizing: border-box; color: black; line-height: 24px; list-style: none; margin-bottom: 5px; padding: 0px 0px 0px 19px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;sigmaX&lt;/span&gt;&amp;nbsp;− A variable of the type double representing the Gaussian kernel standard deviation in X direction.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: #121214; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.7em; font-weight: normal; left: 0px; letter-spacing: -1px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: #121214; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.7em; font-weight: normal; left: 0px; letter-spacing: -1px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Example&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
The following program demonstrates how to perform the Gaussian blur operation on an image.&lt;/div&gt;
&lt;pre class=&quot;prettyprint notranslate prettyprinted&quot; style=&quot;background-color: #eeeeee; border-radius: 0px; border: 1px solid rgb(214, 214, 214); box-sizing: border-box; color: #313131; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13px; line-height: 16px; margin-bottom: 10px; margin-top: 15px; overflow: auto; padding: 5px; width: 604px;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; org&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;opencv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Core&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; org&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;opencv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Mat&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; org&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;opencv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; org&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;opencv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;imgcodecs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Imgcodecs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; org&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;opencv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;imgproc&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Imgproc&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;GaussianTest&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; main&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; args&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;[])&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Loading the OpenCV core library&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;loadLibrary&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Core&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;NATIVE_LIBRARY_NAME&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;

      &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Reading the Image from the file and storing it in to a Matrix object&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;C:/EXAMPLES/OpenCV/sample.jpg&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Mat&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; src &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Imgcodecs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;imread&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;

      &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Creating an empty matrix to store the result&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Mat&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; dst &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Mat&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
    
      &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Applying GaussianBlur on the Image&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Imgproc&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;GaussianBlur&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; dst&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;

      &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Writing the image&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;Imgcodecs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;imwrite&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;E:/OpenCV/chap9/Gaussian.jpg&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt; dst&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #7f0055;&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;Image Processed&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
Assume that following is the input image&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 640;&quot;&gt;sample.jpg&lt;/span&gt;&amp;nbsp;specified in the above program.&lt;/div&gt;
&lt;img alt=&quot;Sample Image&quot; src=&quot;https://www.tutorialspoint.com/opencv/images/sample_image.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; color: #313131; display: block; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto; max-width: 100%; padding-bottom: 4px; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;h2 style=&quot;box-sizing: border-box; color: #121214; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 1.7em; font-weight: normal; left: 0px; letter-spacing: -1px; line-height: 1.5em; margin: 0.2em 0.2em 0.2em 0px; padding: 0px; position: relative; text-shadow: rgb(204, 204, 204) 1px 1px 2px;&quot;&gt;
Output&lt;/h2&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
On executing the program, you will get the following output −&lt;/div&gt;
&lt;pre class=&quot;result notranslate&quot; style=&quot;background-color: #f1f1f1; border-radius: 0px; border: 1px solid rgb(214, 214, 214); box-sizing: border-box; color: #313131; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 12px; overflow: auto; padding: 5px; width: 604px;&quot;&gt;Image Processed
&lt;/pre&gt;
&lt;div style=&quot;box-sizing: border-box; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 15px !important; line-height: 24px; margin: 0em 0.2em 0.6em; overflow-wrap: break-word; padding: 0px; text-align: justify;&quot;&gt;
If you open the specified path, you can observe the output image as follows −&lt;/div&gt;
&lt;img alt=&quot;Gaussian Blur&quot; src=&quot;https://www.tutorialspoint.com/opencv/images/gaussian_blur.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; color: #313131; display: block; font-family: Verdana, Geneva, Tahoma, Arial, Helvetica, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto; max-width: 100%; padding-bottom: 4px; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/2145014412112382723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/gaussian-blur-operation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/2145014412112382723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/2145014412112382723'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/gaussian-blur-operation.html' title='Gaussian Blur operation'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhecKgKipp0wshkeKje8rQwbUO7qfuyQ8uTOkAN84HbGjv-frEYk_rsBbXu0ObeP4xPAeZGZ1PKluvgwOKP2QhK5ukW7bUEW1lRW91JVHFAyx6rh6wAJJ_Mg1GFwwGAqukYCdWqqp3dxgc/s72-c/Gaussian_filter.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-5587916260747819032</id><published>2020-01-22T13:41:00.001-08:00</published><updated>2020-01-22T13:41:43.466-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Geometric Image Transformation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL4vdKHtSeGWO6tO6CE3xXrxEuT6OPmzGbIOCZdMAQl8liRKTs4z1bEZPp0vCJgMIedO4urBGcLrPfoqADLS3pAB9nAACxgs4L-dt7dONSdz3ubKuSoLAWzaPlZot2BFUjfJEMd9sTlUY/s1600/Geometric_image_transformation.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;449&quot; data-original-width=&quot;966&quot; height=&quot;296&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL4vdKHtSeGWO6tO6CE3xXrxEuT6OPmzGbIOCZdMAQl8liRKTs4z1bEZPp0vCJgMIedO4urBGcLrPfoqADLS3pAB9nAACxgs4L-dt7dONSdz3ubKuSoLAWzaPlZot2BFUjfJEMd9sTlUY/s640/Geometric_image_transformation.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div px=&quot;&quot; syle:width:=&quot;50px&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 32px; font-weight: normal; margin: 0px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
Geometric Image Transformations&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#geometric-image-transformations&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The functions in this section perform various geometrical transformations of 2D images. They do not change the image content but deform the pixel grid and map this deformed grid to the destination image. In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from destination to the source. That is, for each pixel&amp;nbsp;&lt;img alt=&quot;(x, y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/dee21a914bf9088bc0dfbd38a96c1f859c412ec7.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;of the destination image, the functions compute coordinates of the corresponding “donor” pixel in the source image and copy the pixel value:&lt;/div&gt;
&lt;div class=&quot;math&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{dst} (x,y)= \texttt{src} (f_x(x,y), f_y(x,y))&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/5586964cd29886b8967be9e8415e936b777ff237.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
In case when you specify the forward mapping&amp;nbsp;&lt;img alt=&quot;\left&amp;lt;g_x, g_y\right&amp;gt;: \texttt{src} \rightarrow \texttt{dst}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/b44ea225e88d2d84cb8ad7cf6f7f0b4ddad2c833.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;, the OpenCV functions first compute the corresponding inverse mapping&amp;nbsp;&lt;img alt=&quot;\left&amp;lt;f_x, f_y\right&amp;gt;: \texttt{dst} \rightarrow \texttt{src}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/5f54615e5c8a8ff86fafb72fc7802b76da9e47dd.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and then use the above formula.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;The actual implementations of the geometrical transformations, from the most generic&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;remap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;and to the simplest and the fastest&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;resize()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;, need to solve two main problems with the above formula:&lt;/div&gt;
&lt;ul class=&quot;simple&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;Extrapolation of non-existing pixels. Similarly to the filtering functions described in the previous section, for some&amp;nbsp;&lt;img alt=&quot;(x,y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/45b34b73b5a1fed1fd38b3a37ca1ada031de9970.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;, either one of&amp;nbsp;&lt;img alt=&quot;f_x(x,y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/da67f35faec802ef36cfb926cd7c6d02fbcbb87e.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;, or&amp;nbsp;&lt;img alt=&quot;f_y(x,y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/203f8a44e19f0413462b5221f9d2376143ccf071.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;, or both of them may fall outside of the image. In this case, an extrapolation method needs to be used. OpenCV provides the same selection of extrapolation methods as in the filtering functions. In addition, it provides the method&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;BORDER_TRANSPARENT&lt;/code&gt;&amp;nbsp;. This means that the corresponding pixels in the destination image will not be modified at all.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;Interpolation of pixel values. Usually&amp;nbsp;&lt;img alt=&quot;f_x(x,y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/da67f35faec802ef36cfb926cd7c6d02fbcbb87e.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;f_y(x,y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/203f8a44e19f0413462b5221f9d2376143ccf071.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;are floating-point numbers. This means that&amp;nbsp;&lt;img alt=&quot;\left&amp;lt;f_x, f_y\right&amp;gt;&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/26549f994bdf2bb4799fb99a35ada30df175e7f9.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;can be either an affine or perspective transformation, or radial lens distortion correction, and so on. So, a pixel value at fractional coordinates needs to be retrieved. In the simplest case, the coordinates can be just rounded to the nearest integer coordinates and the corresponding pixel can be used. This is called a nearest-neighbor interpolation. However, a better result can be achieved by using more sophisticated&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Multivariate_interpolation&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot;&gt;interpolation methods&lt;/a&gt;&amp;nbsp;, where a polynomial function is fit into some neighborhood of the computed pixel&amp;nbsp;&lt;img alt=&quot;(f_x(x,y), f_y(x,y))&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/bbc20ad3d60b55f78dd96263cf73b4060c688f5d.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;, and then the value of the polynomial at&amp;nbsp;&lt;img alt=&quot;(f_x(x,y), f_y(x,y))&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/bbc20ad3d60b55f78dd96263cf73b4060c688f5d.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;is taken as the interpolated pixel value. In OpenCV, you can choose between several interpolation methods. See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;resize()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;for details.&lt;/li&gt;
&lt;/ul&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
convertMaps&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#convertmaps&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;convertmaps&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Converts image transformation maps from one representation to another.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void convertMaps(InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;convertMaps&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;map1&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;map2&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dstmap1&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dstmap2&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;dstmap1type&lt;/strong&gt;, bool&amp;nbsp;&lt;strong&gt;nninterpolation&lt;/strong&gt;=false&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20convertMaps(InputArray%20map1,%20InputArray%20map2,%20OutputArray%20dstmap1,%20OutputArray%20dstmap2,%20int%20dstmap1type,%20bool%20nninterpolation)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.convertMaps&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;convertMaps&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;map1, map2, dstmap1type&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dstmap1&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dstmap2&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, nninterpolation&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dstmap1, dstmap2&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.convertMaps&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map1&lt;/strong&gt;&amp;nbsp;– The first input map of type&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_16SC2&lt;/code&gt;&amp;nbsp;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC1&lt;/code&gt;&amp;nbsp;, or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC2&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map2&lt;/strong&gt;&amp;nbsp;– The second input map of type&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_16UC1&lt;/code&gt;&amp;nbsp;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC1&lt;/code&gt;&amp;nbsp;, or none (empty matrix), respectively.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dstmap1&lt;/strong&gt;&amp;nbsp;– The first output map that has the type&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dstmap1type&lt;/code&gt;&amp;nbsp;and the same size as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dstmap2&lt;/strong&gt;&amp;nbsp;– The second output map.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dstmap1type&lt;/strong&gt;&amp;nbsp;– Type of the first output map that should be&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_16SC2&lt;/code&gt;&amp;nbsp;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC1&lt;/code&gt;&amp;nbsp;, or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC2&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;nninterpolation&lt;/strong&gt;&amp;nbsp;– Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function converts a pair of maps for&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;remap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;from one representation to another. The following options (&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;(map1.type(),&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot;&gt;map2.type())&lt;/span&gt;&lt;/code&gt;&amp;nbsp;&lt;img alt=&quot;\rightarrow&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/58b7ec42688624f44250d3934b7d7da5164dae2c.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;(dstmap1.type(),&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot;&gt;dstmap2.type())&lt;/span&gt;&lt;/code&gt;&amp;nbsp;) are supported:&lt;/div&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;img alt=&quot;\texttt{(CV\_32FC1, CV\_32FC1)} \rightarrow \texttt{(CV\_16SC2, CV\_16UC1)}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/7b5ead4c463b9acf2fc23ff5cbb0c8644f273389.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;. This is the most frequently used conversion operation, in which the original floating-point maps (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;remap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;nninterpolation=false&lt;/code&gt;&amp;nbsp;) contains indices in the interpolation tables.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;img alt=&quot;\texttt{(CV\_32FC2)} \rightarrow \texttt{(CV\_16SC2, CV\_16UC1)}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/6de37720f0eb8f70d3e18c92c6d442ce9573f37d.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;. The same as above but the original maps are stored in one 2-channel matrix.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;remap()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20undistort(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20newCameraMatrix)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void undistort(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;undistort()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20initUndistortRectifyMap(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20R,%20InputArray%20newCameraMatrix,%20Size%20size,%20int%20m1type,%20OutputArray%20map1,%20OutputArray%20map2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;initUndistortRectifyMap()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
getAffineTransform&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getaffinetransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;getaffinetransform&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Calculates an affine transform from three pairs of the corresponding points.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;Mat getAffineTransform(InputArray src, InputArray dst)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;Mat&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getAffineTransform(InputArray%20src,%20InputArray%20dst)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;Mat getAffineTransform(const Point2f src[], const Point2f dst[])&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;Mat&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const Point2f&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;[], const Point2f&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;[]&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getAffineTransform(const%20Point2f%20src[],%20const%20Point2f%20dst[])&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.getAffineTransform&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ retval&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.getAffineTransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;CvMat* cvGetAffineTransform(const CvPoint2D32f * src, const CvPoint2D32f * dst, CvMat * map_matrix)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;CvMat*&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvGetAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvPoint2D32f*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, const CvPoint2D32f*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, CvMat*&amp;nbsp;&lt;strong&gt;map_matrix&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#CvMat*%20cvGetAffineTransform(const%20CvPoint2D32f%20*%20src,%20const%20CvPoint2D32f%20*%20dst,%20CvMat%20*%20map_matrix)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.GetAffineTransform&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;GetAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, mapMatrix&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.GetAffineTransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Coordinates of triangle vertices in the source image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Coordinates of the corresponding triangle vertices in the destination image.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function calculates the&amp;nbsp;&lt;img alt=&quot;2 \times 3&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/f1f16ce7385b2d3da848512fba020c85ce9d8c67.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;matrix of an affine transform so that:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{bmatrix} x&#39;_i \\ y&#39;_i \end{bmatrix} = \texttt{map\_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/fbd69da4149b9b78bd1b3fa7e672072d848373f2.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst(i)=(x&#39;_i,y&#39;_i),
src(i)=(x_i, y_i),
i=0,1,2&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/4c5b043b81b0b43a08b17ead21968a1a4523c56c.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpAffine()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#void%20transform(InputArray%20src,%20OutputArray%20dst,%20InputArray%20m)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void transform(InputArray src, OutputArray dst, InputArray m)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;transform()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
getPerspectiveTransform&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getperspectivetransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;getperspectivetransform&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Calculates a perspective transform from four pairs of the corresponding points.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;Mat getPerspectiveTransform(InputArray src, InputArray dst)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;Mat&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getPerspectiveTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getPerspectiveTransform(InputArray%20src,%20InputArray%20dst)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;Mat getPerspectiveTransform(const Point2f src[], const Point2f dst[])&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;Mat&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getPerspectiveTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const Point2f&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;[], const Point2f&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;[]&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getPerspectiveTransform(const%20Point2f%20src[],%20const%20Point2f%20dst[])&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.getPerspectiveTransform&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getPerspectiveTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ retval&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.getPerspectiveTransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;CvMat* cvGetPerspectiveTransform(const CvPoint2D32f* src, const CvPoint2D32f* dst, CvMat* map_matrix)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;CvMat*&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvGetPerspectiveTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvPoint2D32f*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, const CvPoint2D32f*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, CvMat*&amp;nbsp;&lt;strong&gt;map_matrix&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#CvMat*%20cvGetPerspectiveTransform(const%20CvPoint2D32f*%20src,%20const%20CvPoint2D32f*%20dst,%20CvMat*%20map_matrix)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.GetPerspectiveTransform&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;GetPerspectiveTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, mapMatrix&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.GetPerspectiveTransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Coordinates of quadrangle vertices in the source image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Coordinates of the corresponding quadrangle vertices in the destination image.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function calculates the&amp;nbsp;&lt;img alt=&quot;3 \times 3&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/4e17330236365b9188352f6e0aeef470b1f872f1.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;matrix of a perspective transform so that:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{bmatrix} t_i x&#39;_i \\ t_i y&#39;_i \\ t_i \end{bmatrix} = \texttt{map\_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/6246ed0e2d25dc1f8301de4c822741fbe1d1cde0.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst(i)=(x&#39;_i,y&#39;_i),
src(i)=(x_i, y_i),
i=0,1,2,3&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/943082517cd4a9cc108c0adf9212ce0282419a94.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#Mat%20findHomography(InputArray%20srcPoints,%20InputArray%20dstPoints,%20int%20method,%20double%20ransacReprojThreshold,%20OutputArray%20mask)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method, double ransacReprojThreshold, OutputArray mask)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;findHomography()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpPerspective()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#void%20perspectiveTransform(InputArray%20src,%20OutputArray%20dst,%20InputArray%20m)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void perspectiveTransform(InputArray src, OutputArray dst, InputArray m)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;perspectiveTransform()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
getRectSubPix&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getrectsubpix&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;getrectsubpix&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Retrieves a pixel rectangle from an image with sub-pixel accuracy.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void getRectSubPix(InputArray image, Size patchSize, Point2f center, OutputArray patch, int patchType)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getRectSubPix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;image&lt;/strong&gt;, Size&amp;nbsp;&lt;strong&gt;patchSize&lt;/strong&gt;, Point2f&amp;nbsp;&lt;strong&gt;center&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;patch&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;patchType&lt;/strong&gt;=-1&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20getRectSubPix(InputArray%20image,%20Size%20patchSize,%20Point2f%20center,%20OutputArray%20patch,%20int%20patchType)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.getRectSubPix&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getRectSubPix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;image, patchSize, center&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, patch&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, patchType&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ patch&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.getRectSubPix&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvGetRectSubPix(const CvArr* src, CvArr* dst, CvPoint2D32f center)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvGetRectSubPix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, CvPoint2D32f&amp;nbsp;&lt;strong&gt;center&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvGetRectSubPix(const%20CvArr*%20src,%20CvArr*%20dst,%20CvPoint2D32f%20center)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.GetRectSubPix&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;GetRectSubPix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, center&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.GetRectSubPix&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Source image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;patchSize&lt;/strong&gt;&amp;nbsp;– Size of the extracted patch.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;center&lt;/strong&gt;&amp;nbsp;– Floating point coordinates of the center of the extracted rectangle within the source image. The center must be inside the image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Extracted patch that has the size&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;patchSize&lt;/code&gt;&amp;nbsp;and the same number of channels as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;patchType&lt;/strong&gt;&amp;nbsp;– Depth of the extracted pixels. By default, they have the same depth as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;getRectSubPix&lt;/code&gt;&amp;nbsp;extracts pixels from&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst(x, y) = src(x +  \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y +  \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/07ec4cca5e9cc8c312398710e9d757e35c3a8489.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where the values of the pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multi-channel images is processed independently. While the center of the rectangle must be inside the image, parts of the rectangle may be outside. In this case, the replication border mode (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#int%20borderInterpolate(int%20p,%20int%20len,%20int%20borderType)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;int borderInterpolate(int p, int len, int borderType)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;borderInterpolate()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;) is used to extrapolate the pixel values outside of the image.&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpAffine()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpPerspective()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
getRotationMatrix2D&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getrotationmatrix2d&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;getrotationmatrix2d&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Calculates an affine matrix of 2D rotation.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;Mat getRotationMatrix2D(Point2f center, double angle, double scale)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;Mat&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getRotationMatrix2D&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;Point2f&amp;nbsp;&lt;strong&gt;center&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;angle&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;scale&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getRotationMatrix2D(Point2f%20center,%20double%20angle,%20double%20scale)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.getRotationMatrix2D&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getRotationMatrix2D&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;center, angle, scale&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ retval&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.getRotationMatrix2D&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;CvMat* cv2DRotationMatrix(CvPoint2D32f center, double angle, double scale, CvMat* map_matrix)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;CvMat*&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cv2DRotationMatrix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;CvPoint2D32f&amp;nbsp;&lt;strong&gt;center&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;angle&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;scale&lt;/strong&gt;, CvMat*&amp;nbsp;&lt;strong&gt;map_matrix&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#CvMat*%20cv2DRotationMatrix(CvPoint2D32f%20center,%20double%20angle,%20double%20scale,%20CvMat*%20map_matrix)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.GetRotationMatrix2D&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;GetRotationMatrix2D&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;center, angle, scale, mapMatrix&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.GetRotationMatrix2D&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;center&lt;/strong&gt;&amp;nbsp;– Center of the rotation in the source image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;angle&lt;/strong&gt;&amp;nbsp;– Rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;scale&lt;/strong&gt;&amp;nbsp;– Isotropic scale factor.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map_matrix&lt;/strong&gt;&amp;nbsp;– The output affine transformation, 2x3 floating-point matrix.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function calculates the following matrix:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{bmatrix} \alpha &amp;amp;  \beta &amp;amp; (1- \alpha )  \cdot \texttt{center.x} -  \beta \cdot \texttt{center.y} \\ - \beta &amp;amp;  \alpha &amp;amp;  \beta \cdot \texttt{center.x} + (1- \alpha )  \cdot \texttt{center.y} \end{bmatrix}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/9b2f7b18b914fea0d6712fafb52f2d425becd7d4.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{array}{l} \alpha =  \texttt{scale} \cdot \cos \texttt{angle} , \\ \beta =  \texttt{scale} \cdot \sin \texttt{angle} \end{array}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/ec67bb21242806438616d772f8223aa094d8f296.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The transformation maps the rotation center to itself. If this is not the target, adjust the shift.&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getAffineTransform(InputArray%20src,%20InputArray%20dst)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;Mat getAffineTransform(InputArray src, InputArray dst)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;getAffineTransform()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpAffine()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#void%20transform(InputArray%20src,%20OutputArray%20dst,%20InputArray%20m)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void transform(InputArray src, OutputArray dst, InputArray m)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;transform()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
invertAffineTransform&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#invertaffinetransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;invertaffinetransform&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Inverts an affine transformation.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void invertAffineTransform(InputArray M, OutputArray iM)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;invertAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;M&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;iM&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20invertAffineTransform(InputArray%20M,%20OutputArray%20iM)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.invertAffineTransform&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;invertAffineTransform&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;M&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, iM&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ iM&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.invertAffineTransform&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;M&lt;/strong&gt;&amp;nbsp;– Original affine transformation.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;iM&lt;/strong&gt;&amp;nbsp;– Output reverse affine transformation.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function computes an inverse affine transformation represented by&amp;nbsp;&lt;img alt=&quot;2 \times 3&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/f1f16ce7385b2d3da848512fba020c85ce9d8c67.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;matrix&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;M&lt;/code&gt;&amp;nbsp;:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{bmatrix} a_{11} &amp;amp; a_{12} &amp;amp; b_1  \\ a_{21} &amp;amp; a_{22} &amp;amp; b_2 \end{bmatrix}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/3108fbd6fb3e95f812360ea64911fd1f386af65a.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The result is also a&amp;nbsp;&lt;img alt=&quot;2 \times 3&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/f1f16ce7385b2d3da848512fba020c85ce9d8c67.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;matrix of the same type as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;M&lt;/code&gt;&amp;nbsp;.&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
LinearPolar&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#linearpolar&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;linearpolar&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Remaps an image to polar space.&lt;/div&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvLinearPolar(const CvArr* src, CvArr* dst, CvPoint2D32f center, double maxRadius, int flags)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvLinearPolar&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, CvPoint2D32f&amp;nbsp;&lt;strong&gt;center&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;maxRadius&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvLinearPolar(const%20CvArr*%20src,%20CvArr*%20dst,%20CvPoint2D32f%20center,%20double%20maxRadius,%20int%20flags)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Source image&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Destination image. It will have same size and type as src.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;center&lt;/strong&gt;&amp;nbsp;– The transformation center;&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;maxRadius&lt;/strong&gt;&amp;nbsp;– The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too. See below&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;flags&lt;/strong&gt;&amp;nbsp;–&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
A combination of interpolation methods and the following optional flags:&lt;/div&gt;
&lt;ul style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;CV_WARP_FILL_OUTLIERS&lt;/strong&gt;&amp;nbsp;fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;CV_WARP_INVERSE_MAP&lt;/strong&gt;&amp;nbsp;See below&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cvLinearPolar&lt;/code&gt;&amp;nbsp;transforms the source image using the following transformation:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Forward transformation (&lt;code class=&quot;docutils literal&quot;&gt;CV_WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;is not set):&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst( \rho , \phi ) = src(x,y)&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/2ee2f3949fb676f9f379e45188eac6c713b92d99.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Inverse transformation (&lt;code class=&quot;docutils literal&quot;&gt;CV_WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;is set):&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst(x,y) = src( \rho , \phi )&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/160d7bd753e5d51c8d439d7b4942f6ad05722bc8.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{array}{l}
I = (dx,dy) = (x - center.x,y - center.y) \\
\rho = Kx \cdot \texttt{magnitude} (I) ,\\
\phi = Ky \cdot \texttt{angle} (I)_{0..360 deg}
\end{array}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/4ab3bec73697069e687d7bd6c11e48f119ec9757.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
and&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{array}{l}
Kx = src.cols / maxRadius \\
Ky = src.rows / 360
\end{array}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/b7295b801abcef914f42185142e9d949764807fe.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div class=&quot;admonition note&quot; style=&quot;background-color: #eeeeee; border: 1px solid rgb(204, 204, 204); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
Note&lt;/div&gt;
&lt;ul class=&quot;last simple&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;The function can not operate in-place.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;To calculate magnitude and angle in degrees&amp;nbsp;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;cvCartToPolar()&lt;/code&gt;&amp;nbsp;is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;An example using the LinearPolar operation can be found at opencv_source_code/samples/c/polar_transforms.c&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
LogPolar&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#logpolar&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;logpolar&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Remaps an image to log-polar space.&lt;/div&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvLogPolar(const CvArr* src, CvArr* dst, CvPoint2D32f center, double M, int flags)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvLogPolar&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, CvPoint2D32f&amp;nbsp;&lt;strong&gt;center&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;M&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvLogPolar(const%20CvArr*%20src,%20CvArr*%20dst,%20CvPoint2D32f%20center,%20double%20M,%20int%20flags)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.LogPolar&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;LogPolar&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, center, M, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.LogPolar&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Source image&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Destination image. It will have same size and type as src.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;center&lt;/strong&gt;&amp;nbsp;– The transformation center; where the output precision is maximal&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;M&lt;/strong&gt;&amp;nbsp;– Magnitude scale parameter. It determines the radius of the bounding circle to transform too. See below&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;flags&lt;/strong&gt;&amp;nbsp;–&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
A combination of interpolation methods and the following optional flags:&lt;/div&gt;
&lt;ul style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;CV_WARP_FILL_OUTLIERS&lt;/strong&gt;&amp;nbsp;fills all of the destination image pixels. If some of them correspond to outliers in the source image, they are set to zero&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;CV_WARP_INVERSE_MAP&lt;/strong&gt;&amp;nbsp;See below&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cvLogPolar&lt;/code&gt;&amp;nbsp;transforms the source image using the following transformation:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Forward transformation (&lt;code class=&quot;docutils literal&quot;&gt;CV_WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;is not set):&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst( \rho , \phi ) = src(x, y)&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/96c3a731ab8bacd5e0d7a46a07fc108736b6dc60.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;&lt;div class=&quot;first&quot; style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Inverse transformation (&lt;code class=&quot;docutils literal&quot;&gt;CV_WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;is set):&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;dst(x,y) = src( \rho , \phi )&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/160d7bd753e5d51c8d439d7b4942f6ad05722bc8.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{array}{l}
I = (dx,dy) = (x - center.x,y - center.y) \\
\rho = M \cdot log_e(\texttt{magnitude} (I)) ,\\
\phi = Ky \cdot \texttt{angle} (I)_{0..360 deg}
\end{array}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/f98a8431e38ad0cc514958e26ce27fd22a3c171f.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
and&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{array}{l}
M = src.cols / log_e(maxRadius) \\
Ky = src.rows / 360
\end{array}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/bae8921c47ec95ede5ebc21f911b9c9322477263.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function emulates the human “foveal” vision and can be used for fast scale and rotation-invariant template matching, for object tracking and so forth.&lt;/div&gt;
&lt;div class=&quot;admonition note&quot; style=&quot;background-color: #eeeeee; border: 1px solid rgb(204, 204, 204); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
Note&lt;/div&gt;
&lt;ul class=&quot;last simple&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;The function can not operate in-place.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;To calculate magnitude and angle in degrees&amp;nbsp;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;cvCartToPolar()&lt;/code&gt;&amp;nbsp;is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;An example using the geometric logpolar operation in 4 applications can be found at opencv_source_code/samples/cpp/logpolar_bsm.cpp&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
remap&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#remap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;remap&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Applies a generic geometrical transformation to an image.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;remap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;map1&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;map2&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;interpolation&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;borderMode&lt;/strong&gt;=BORDER_CONSTANT, const Scalar&amp;amp;&amp;nbsp;&lt;strong&gt;borderValue&lt;/strong&gt;=Scalar()&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.remap&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;remap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, map1, map2, interpolation&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dst&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, borderMode&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, borderValue&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dst&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.remap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvRemap(const CvArr* src, CvArr* dst, const CvArr* mapx, const CvArr* mapy, int flags, CvScalar fillval)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvRemap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, const CvArr*&amp;nbsp;&lt;strong&gt;mapx&lt;/strong&gt;, const CvArr*&amp;nbsp;&lt;strong&gt;mapy&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar&amp;nbsp;&lt;strong&gt;fillval&lt;/strong&gt;=cvScalarAll(0)&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvRemap(const%20CvArr*%20src,%20CvArr*%20dst,%20const%20CvArr*%20mapx,%20const%20CvArr*%20mapy,%20int%20flags,%20CvScalar%20fillval)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.Remap&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;Remap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, mapx, mapy, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0)&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.Remap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Source image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Destination image. It has the same size as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;map1&lt;/code&gt;&amp;nbsp;and the same type as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map1&lt;/strong&gt;&amp;nbsp;– The first map of either&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;(x,y)&lt;/code&gt;&amp;nbsp;points or just&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;x&lt;/code&gt;&amp;nbsp;values having the type&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_16SC2&lt;/code&gt;&amp;nbsp;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC1&lt;/code&gt;&amp;nbsp;, or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC2&lt;/code&gt;&amp;nbsp;. See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20convertMaps(InputArray%20map1,%20InputArray%20map2,%20OutputArray%20dstmap1,%20OutputArray%20dstmap2,%20int%20dstmap1type,%20bool%20nninterpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void convertMaps(InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;convertMaps()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;for details on converting a floating point representation to fixed-point for speed.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map2&lt;/strong&gt;&amp;nbsp;– The second map of&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;y&lt;/code&gt;&amp;nbsp;values having the type&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_16UC1&lt;/code&gt;&amp;nbsp;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC1&lt;/code&gt;&amp;nbsp;, or none (empty map if&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;map1&lt;/code&gt;&amp;nbsp;is&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;(x,y)&lt;/code&gt;&amp;nbsp;points), respectively.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;interpolation&lt;/strong&gt;&amp;nbsp;– Interpolation method (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;resize()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;). The method&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;INTER_AREA&lt;/code&gt;&amp;nbsp;is not supported by this function.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;borderMode&lt;/strong&gt;&amp;nbsp;– Pixel extrapolation method (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#int%20borderInterpolate(int%20p,%20int%20len,%20int%20borderType)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;int borderInterpolate(int p, int len, int borderType)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;borderInterpolate()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;). When&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;borderMode=BORDER_TRANSPARENT&lt;/code&gt;&amp;nbsp;, it means that the pixels in the destination image that corresponds to the “outliers” in the source image are not modified by the function.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;borderValue&lt;/strong&gt;&amp;nbsp;– Value used in case of a constant border. By default, it is 0.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;remap&lt;/code&gt;&amp;nbsp;transforms the source image using the specified map:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{dst} (x,y) =  \texttt{src} (map_x(x,y),map_y(x,y))&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/f9449cd3bdb73686991442e9a15db0caff2b568b.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where values of pixels with non-integer coordinates are computed using one of available interpolation methods.&amp;nbsp;&lt;img alt=&quot;map_x&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/91970ab096944ce7fe3efb5c8b49ae0b5525b927.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;map_y&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/78f6c85562823bd76628b40e365853579dfb1818.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;can be encoded as separate floating-point maps in&amp;nbsp;&lt;img alt=&quot;map_1&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/e036710662d71a6b65c4a0d41392c019d914772a.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;map_2&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/ca86e1582a85b178cfc4ebb410c2eca74336f7ef.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;respectively, or interleaved floating-point maps of&amp;nbsp;&lt;img alt=&quot;(x,y)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/45b34b73b5a1fed1fd38b3a37ca1ada031de9970.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;in&amp;nbsp;&lt;img alt=&quot;map_1&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/e036710662d71a6b65c4a0d41392c019d914772a.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;, or fixed-point maps created by using&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20convertMaps(InputArray%20map1,%20InputArray%20map2,%20OutputArray%20dstmap1,%20OutputArray%20dstmap2,%20int%20dstmap1type,%20bool%20nninterpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void convertMaps(InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;convertMaps()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (~2x) remapping operations. In the converted case,&amp;nbsp;&lt;img alt=&quot;map_1&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/e036710662d71a6b65c4a0d41392c019d914772a.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;contains pairs&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;(cvFloor(x),&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;pre&quot;&gt;cvFloor(y))&lt;/span&gt;&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;map_2&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/ca86e1582a85b178cfc4ebb410c2eca74336f7ef.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;contains indices in a table of interpolation coefficients.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
This function cannot operate in-place.&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
resize&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#resize&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;resize&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Resizes an image.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;resize&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, Size&amp;nbsp;&lt;strong&gt;dsize&lt;/strong&gt;, double&amp;nbsp;&lt;strong&gt;fx&lt;/strong&gt;=0, double&amp;nbsp;&lt;strong&gt;fy&lt;/strong&gt;=0, int&amp;nbsp;&lt;strong&gt;interpolation&lt;/strong&gt;=INTER_LINEAR&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.resize&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;resize&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dsize&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dst&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, fx&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, fy&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, interpolation&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dst&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.resize&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvResize(const CvArr* src, CvArr* dst, int interpolation)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvResize&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;interpolation&lt;/strong&gt;=CV_INTER_LINEAR&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvResize(const%20CvArr*%20src,%20CvArr*%20dst,%20int%20interpolation)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.Resize&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;Resize&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, interpolation=CV_INTER_LINEAR&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.Resize&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– input image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– output image; it has the size&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dsize&lt;/code&gt;&amp;nbsp;(when it is non-zero) or the size computed from&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src.size()&lt;/code&gt;,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;fx&lt;/code&gt;, and&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;fy&lt;/code&gt;; the type of&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dst&lt;/code&gt;&amp;nbsp;is the same as of&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dsize&lt;/strong&gt;&amp;nbsp;–&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
output image size; if it equals zero, it is computed as:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/35ed0468ed221de8a5f35516bceafda9788cd015.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Either&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dsize&lt;/code&gt;&amp;nbsp;or both&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;fx&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;fy&lt;/code&gt;&amp;nbsp;must be non-zero.&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;fx&lt;/strong&gt;&amp;nbsp;–&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
scale factor along the horizontal axis; when it equals 0, it is computed as&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{(double)dsize.width/src.cols}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/68bc15bc90b1ec313d34f5d72485fa04c51f5c3e.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;fy&lt;/strong&gt;&amp;nbsp;–&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
scale factor along the vertical axis; when it equals 0, it is computed as&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{(double)dsize.height/src.rows}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/af495c626474d56d29d356d581a18f143109e972.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;interpolation&lt;/strong&gt;&amp;nbsp;–&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
interpolation method:&lt;/div&gt;
&lt;ul style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;INTER_NEAREST&lt;/strong&gt;&amp;nbsp;- a nearest-neighbor interpolation&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;INTER_LINEAR&lt;/strong&gt;&amp;nbsp;- a bilinear interpolation (used by default)&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;INTER_AREA&lt;/strong&gt;&amp;nbsp;- resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;INTER_NEAREST&lt;/code&gt;method.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;INTER_CUBIC&lt;/strong&gt;&amp;nbsp;- a bicubic interpolation over 4x4 pixel neighborhood&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;INTER_LANCZOS4&lt;/strong&gt;&amp;nbsp;- a Lanczos interpolation over 8x8 pixel neighborhood&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;resize&lt;/code&gt;&amp;nbsp;resizes the image&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;down to or up to the specified size. Note that the initial&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dst&lt;/code&gt;&amp;nbsp;type or size are not taken into account. Instead, the size and type are derived from the&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;,``dsize``,``fx`` , and&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;fy&lt;/code&gt;&amp;nbsp;. If you want to resize&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;so that it fits the pre-created&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dst&lt;/code&gt;&amp;nbsp;, you may call the function as follows:&lt;/div&gt;
&lt;div class=&quot;highlight-cpp&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #e0f5ff; border-bottom: 1px solid rgb(170, 204, 238); border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(170, 204, 238); color: #333333; line-height: 15.6px; overflow: auto hidden; padding: 5px;&quot;&gt;&lt;span class=&quot;c1&quot; style=&quot;color: #408090; font-style: italic;&quot;&gt;// explicitly specify dsize=dst.size(); fx and fy will be computed from that.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dst&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dst&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interpolation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
If you want to decimate the image by factor of 2 in each direction, you can call the function this way:&lt;/div&gt;
&lt;div class=&quot;highlight-cpp&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #e0f5ff; border-bottom: 1px solid rgb(170, 204, 238); border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(170, 204, 238); color: #333333; line-height: 15.6px; overflow: auto hidden; padding: 5px;&quot;&gt;&lt;span class=&quot;c1&quot; style=&quot;color: #408090; font-style: italic;&quot;&gt;// specify fx and fy and let the function compute the destination image size.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dst&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interpolation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK).&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpAffine()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpPerspective()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;remap()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
warpAffine&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#warpaffine&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;warpaffine&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Applies an affine transformation to an image.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;warpAffine&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;M&lt;/strong&gt;, Size&amp;nbsp;&lt;strong&gt;dsize&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=INTER_LINEAR, int&amp;nbsp;&lt;strong&gt;borderMode&lt;/strong&gt;=BORDER_CONSTANT, const Scalar&amp;amp;&amp;nbsp;&lt;strong&gt;borderValue&lt;/strong&gt;=Scalar()&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.warpAffine&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;warpAffine&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, M, dsize&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dst&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, flags&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, borderMode&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, borderValue&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dst&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.warpAffine&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvWarpAffine(const CvArr* src, CvArr* dst, const CvMat* map_matrix, int flags, CvScalar fillval)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvWarpAffine&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;map_matrix&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar&amp;nbsp;&lt;strong&gt;fillval&lt;/strong&gt;=cvScalarAll(0)&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvWarpAffine(const%20CvArr*%20src,%20CvArr*%20dst,%20const%20CvMat*%20map_matrix,%20int%20flags,%20CvScalar%20fillval)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.WarpAffine&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;WarpAffine&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, mapMatrix, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0)&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.WarpAffine&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvGetQuadrangleSubPix(const CvArr* src, CvArr* dst, const CvMat* map_matrix)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvGetQuadrangleSubPix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;map_matrix&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvGetQuadrangleSubPix(const%20CvArr*%20src,%20CvArr*%20dst,%20const%20CvMat*%20map_matrix)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.GetQuadrangleSubPix&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;GetQuadrangleSubPix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, mapMatrix&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.GetQuadrangleSubPix&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– input image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– output image that has the size&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dsize&lt;/code&gt;&amp;nbsp;and the same type as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;M&lt;/strong&gt;&amp;nbsp;–&amp;nbsp;&lt;img alt=&quot;2\times 3&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/f335f976f482cd08e9c6c198204b18c1fc769882.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;transformation matrix.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dsize&lt;/strong&gt;&amp;nbsp;– size of the output image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;flags&lt;/strong&gt;&amp;nbsp;– combination of interpolation methods (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;resize()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;) and the optional flag&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;that means that&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;M&lt;/code&gt;&amp;nbsp;is the inverse transformation (&amp;nbsp;&lt;img alt=&quot;\texttt{dst}\rightarrow\texttt{src}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/79358c8b893d7d0db75b629175a7eab3db5f192b.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;).&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;borderMode&lt;/strong&gt;&amp;nbsp;– pixel extrapolation method (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#int%20borderInterpolate(int%20p,%20int%20len,%20int%20borderType)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;int borderInterpolate(int p, int len, int borderType)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;borderInterpolate()&lt;/code&gt;&lt;/a&gt;); when&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;borderMode=BORDER_TRANSPARENT&lt;/code&gt;&amp;nbsp;, it means that the pixels in the destination image corresponding to the “outliers” in the source image are not modified by the function.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;borderValue&lt;/strong&gt;&amp;nbsp;– value used in case of a constant border; by default, it is 0.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;warpAffine&lt;/code&gt;&amp;nbsp;transforms the source image using the specified matrix:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{dst} (x,y) =  \texttt{src} ( \texttt{M} _{11} x +  \texttt{M} _{12} y +  \texttt{M} _{13}, \texttt{M} _{21} x +  \texttt{M} _{22} y +  \texttt{M} _{23})&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/189dfa6dbab9ff81eaeaa453b1a1e2313dcd3a26.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
when the flag&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;is set. Otherwise, the transformation is first inverted with&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20invertAffineTransform(InputArray%20M,%20OutputArray%20iM)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void invertAffineTransform(InputArray M, OutputArray iM)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;invertAffineTransform()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;and then put in the formula above instead of&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;M&lt;/code&gt;&amp;nbsp;. The function cannot operate in-place.&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpPerspective()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;resize()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;remap()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20getRectSubPix(InputArray%20image,%20Size%20patchSize,%20Point2f%20center,%20OutputArray%20patch,%20int%20patchType)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void getRectSubPix(InputArray image, Size patchSize, Point2f center, OutputArray patch, int patchType)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;getRectSubPix()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#void%20transform(InputArray%20src,%20OutputArray%20dst,%20InputArray%20m)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void transform(InputArray src, OutputArray dst, InputArray m)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;transform()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;admonition note&quot; style=&quot;background-color: #eeeeee; border: 1px solid rgb(204, 204, 204); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
Note&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;code class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;cvGetQuadrangleSubPix&lt;/span&gt;&lt;/code&gt;&amp;nbsp;is similar to&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;cvWarpAffine&lt;/span&gt;&lt;/code&gt;, but the outliers are extrapolated using replication border mode.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
warpPerspective&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#warpperspective&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;warpperspective&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Applies a perspective transformation to an image.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;warpPerspective&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;M&lt;/strong&gt;, Size&amp;nbsp;&lt;strong&gt;dsize&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=INTER_LINEAR, int&amp;nbsp;&lt;strong&gt;borderMode&lt;/strong&gt;=BORDER_CONSTANT, const Scalar&amp;amp;&amp;nbsp;&lt;strong&gt;borderValue&lt;/strong&gt;=Scalar()&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpPerspective(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.warpPerspective&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;warpPerspective&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, M, dsize&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dst&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, flags&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, borderMode&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, borderValue&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dst&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.warpPerspective&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvWarpPerspective(const CvArr* src, CvArr* dst, const CvMat* map_matrix, int flags, CvScalar fillval)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvWarpPerspective&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;map_matrix&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;flags&lt;/strong&gt;=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar&amp;nbsp;&lt;strong&gt;fillval&lt;/strong&gt;=cvScalarAll(0)&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvWarpPerspective(const%20CvArr*%20src,%20CvArr*%20dst,%20const%20CvMat*%20map_matrix,%20int%20flags,%20CvScalar%20fillval)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.WarpPerspective&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;WarpPerspective&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, mapMatrix, flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0)&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.WarpPerspective&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– input image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– output image that has the size&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dsize&lt;/code&gt;&amp;nbsp;and the same type as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;M&lt;/strong&gt;&amp;nbsp;–&amp;nbsp;&lt;img alt=&quot;3\times 3&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/268e62297468c4d7ef109727ed4bcbfad953ad61.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;transformation matrix.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dsize&lt;/strong&gt;&amp;nbsp;– size of the output image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;flags&lt;/strong&gt;&amp;nbsp;– combination of interpolation methods (&lt;code class=&quot;docutils literal&quot;&gt;INTER_LINEAR&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;INTER_NEAREST&lt;/code&gt;) and the optional flag&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;WARP_INVERSE_MAP&lt;/code&gt;, that sets&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;M&lt;/code&gt;&amp;nbsp;as the inverse transformation (&amp;nbsp;&lt;img alt=&quot;\texttt{dst}\rightarrow\texttt{src}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/79358c8b893d7d0db75b629175a7eab3db5f192b.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;).&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;borderMode&lt;/strong&gt;&amp;nbsp;– pixel extrapolation method (&lt;code class=&quot;docutils literal&quot;&gt;BORDER_CONSTANT&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;BORDER_REPLICATE&lt;/code&gt;).&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;borderValue&lt;/strong&gt;&amp;nbsp;– value used in case of a constant border; by default, it equals 0.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;warpPerspective&lt;/code&gt;&amp;nbsp;transforms the source image using the specified matrix:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{dst} (x,y) =  \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
     \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/fa7e99ae84a2294284e680e2d4c4011121be6492.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
when the flag&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;WARP_INVERSE_MAP&lt;/code&gt;&amp;nbsp;is set. Otherwise, the transformation is first inverted with&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#double%20invert(InputArray%20src,%20OutputArray%20dst,%20int%20flags)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;double invert(InputArray src, OutputArray dst, int flags)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;invert()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;and then put in the formula above instead of&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;M&lt;/code&gt;&amp;nbsp;. The function cannot operate in-place.&lt;/div&gt;
&lt;div class=&quot;admonition seealso&quot; style=&quot;background-color: #ffffcc; border: 1px solid rgb(255, 255, 102); margin-bottom: 10px; margin-top: 10px; padding: 7px;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;display: inline; font-weight: bold; line-height: 20.8px; margin-bottom: 1em; margin-right: 10px; margin-top: 1em; text-align: justify;&quot;&gt;
See also&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;last&quot; style=&quot;display: inline; line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;warpAffine()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20resize(InputArray%20src,%20OutputArray%20dst,%20Size%20dsize,%20double%20fx,%20double%20fy,%20int%20interpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void resize(InputArray src, OutputArray dst, Size dsize, double fx, double fy, int interpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;resize()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;remap()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20getRectSubPix(InputArray%20image,%20Size%20patchSize,%20Point2f%20center,%20OutputArray%20patch,%20int%20patchType)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void getRectSubPix(InputArray image, Size patchSize, Point2f center, OutputArray patch, int patchType)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;getRectSubPix()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#void%20perspectiveTransform(InputArray%20src,%20OutputArray%20dst,%20InputArray%20m)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void perspectiveTransform(InputArray src, OutputArray dst, InputArray m)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;&lt;span class=&quot;pre&quot;&gt;perspectiveTransform()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
initUndistortRectifyMap&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#initundistortrectifymap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;initundistortrectifymap&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Computes the undistortion and rectification transformation map.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;initUndistortRectifyMap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;cameraMatrix&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;distCoeffs&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;R&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;newCameraMatrix&lt;/strong&gt;, Size&amp;nbsp;&lt;strong&gt;size&lt;/strong&gt;, int&amp;nbsp;&lt;strong&gt;m1type&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;map1&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;map2&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20initUndistortRectifyMap(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20R,%20InputArray%20newCameraMatrix,%20Size%20size,%20int%20m1type,%20OutputArray%20map1,%20OutputArray%20map2)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.initUndistortRectifyMap&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;initUndistortRectifyMap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;cameraMatrix, distCoeffs, R, newCameraMatrix, size, m1type&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, map1&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, map2&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ map1, map2&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.initUndistortRectifyMap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvInitUndistortRectifyMap(const CvMat* camera_matrix, const CvMat* dist_coeffs, const CvMat * R, const CvMat* new_camera_matrix, CvArr* mapx, CvArr* mapy)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvInitUndistortRectifyMap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvMat*&amp;nbsp;&lt;strong&gt;camera_matrix&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;dist_coeffs&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;R&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;new_camera_matrix&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;mapx&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;mapy&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvInitUndistortRectifyMap(const%20CvMat*%20camera_matrix,%20const%20CvMat*%20dist_coeffs,%20const%20CvMat%20*%20R,%20const%20CvMat*%20new_camera_matrix,%20CvArr*%20mapx,%20CvArr*%20mapy)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvInitUndistortMap(const CvMat* camera_matrix, const CvMat* distortion_coeffs, CvArr* mapx, CvArr* mapy)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvInitUndistortMap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvMat*&amp;nbsp;&lt;strong&gt;camera_matrix&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;distortion_coeffs&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;mapx&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;mapy&lt;/strong&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvInitUndistortMap(const%20CvMat*%20camera_matrix,%20const%20CvMat*%20distortion_coeffs,%20CvArr*%20mapx,%20CvArr*%20mapy)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.InitUndistortRectifyMap&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;InitUndistortRectifyMap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;cameraMatrix, distCoeffs, R, newCameraMatrix, map1, map2&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.InitUndistortRectifyMap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.InitUndistortMap&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;InitUndistortMap&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;cameraMatrix, distCoeffs, map1, map2&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.InitUndistortMap&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;cameraMatrix&lt;/strong&gt;&amp;nbsp;– Input camera matrix&amp;nbsp;&lt;img alt=&quot;A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/3356c05a942d297035284c0bce1fbfb94102238e.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;distCoeffs&lt;/strong&gt;&amp;nbsp;– Input vector of distortion coefficients&amp;nbsp;&lt;img alt=&quot;(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/94288b7709d10a7ddf286e33db0074512bda0411.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;R&lt;/strong&gt;&amp;nbsp;– Optional rectification transformation in the object space (3x3 matrix).&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R1&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R2&lt;/code&gt;&amp;nbsp;, computed by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20stereoRectify(InputArray%20cameraMatrix1,%20InputArray%20distCoeffs1,%20InputArray%20cameraMatrix2,%20InputArray%20distCoeffs2,%20Size%20imageSize,%20InputArray%20R,%20InputArray%20T,%20OutputArray%20R1,%20OutputArray%20R2,%20OutputArray%20P1,%20OutputArray%20P2,%20OutputArray%20Q,%20int%20flags,%20double%20alpha,%20Size%20newImageSize,%20Rect*%20validPixROI1,%20Rect*%20validPixROI2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, double alpha, Size newImageSize, Rect* validPixROI1, Rect* validPixROI2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoRectify()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;can be passed here. If the matrix is empty, the identity transformation is assumed. In&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cvInitUndistortMap&lt;/code&gt;&amp;nbsp;R assumed to be an identity matrix.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;newCameraMatrix&lt;/strong&gt;&amp;nbsp;– New camera matrix&amp;nbsp;&lt;img alt=&quot;A&#39;=\vecthreethree{f_x&#39;}{0}{c_x&#39;}{0}{f_y&#39;}{c_y&#39;}{0}{0}{1}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/0e0f1576ba6043068b1c62c942958d75e801a2ea.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;size&lt;/strong&gt;&amp;nbsp;– Undistorted image size.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;m1type&lt;/strong&gt;&amp;nbsp;– Type of the first output map that can be&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_32FC1&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;CV_16SC2&lt;/code&gt;&amp;nbsp;. See&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20convertMaps(InputArray%20map1,%20InputArray%20map2,%20OutputArray%20dstmap1,%20OutputArray%20dstmap2,%20int%20dstmap1type,%20bool%20nninterpolation)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void convertMaps(InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, int dstmap1type, bool nninterpolation)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;convertMaps()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;for details.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map1&lt;/strong&gt;&amp;nbsp;– The first output map.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;map2&lt;/strong&gt;&amp;nbsp;– The second output map.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function computes the joint undistortion and rectification transformation and represents the result in the form of maps for&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;remap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. The undistorted image looks like original, as if it is captured with a camera using the camera matrix&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;=newCameraMatrix&lt;/code&gt;&amp;nbsp;and zero distortion. In case of a monocular camera,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;newCameraMatrix&lt;/code&gt;&amp;nbsp;is usually equal to&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cameraMatrix&lt;/code&gt;&amp;nbsp;, or it can be computed by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#Mat%20getOptimalNewCameraMatrix(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20Size%20imageSize,%20double%20alpha,%20Size%20newImgSize,%20Rect*%20validPixROI,%20bool%20centerPrincipalPoint)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;Mat getOptimalNewCameraMatrix(InputArray cameraMatrix, InputArray distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect* validPixROI, bool centerPrincipalPoint)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;getOptimalNewCameraMatrix()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;for a better control over scaling. In case of a stereo camera,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;newCameraMatrix&lt;/code&gt;&amp;nbsp;is normally set to&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;P1&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;P2&lt;/code&gt;&amp;nbsp;computed by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20stereoRectify(InputArray%20cameraMatrix1,%20InputArray%20distCoeffs1,%20InputArray%20cameraMatrix2,%20InputArray%20distCoeffs2,%20Size%20imageSize,%20InputArray%20R,%20InputArray%20T,%20OutputArray%20R1,%20OutputArray%20R2,%20OutputArray%20P1,%20OutputArray%20P2,%20OutputArray%20Q,%20int%20flags,%20double%20alpha,%20Size%20newImageSize,%20Rect*%20validPixROI1,%20Rect*%20validPixROI2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, double alpha, Size newImageSize, Rect* validPixROI1, Rect* validPixROI2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoRectify()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Also, this new camera is oriented differently in the coordinate space, according to&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R&lt;/code&gt;&amp;nbsp;. That, for example, helps to align two heads of a stereo camera so that the epipolar lines on both images become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function actually builds the maps for the inverse mapping algorithm that is used by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;remap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. That is, for each pixel&amp;nbsp;&lt;img alt=&quot;(u, v)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/8a26bd6b76072e327e2462b2fe05546ba899e682.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;in the destination (corrected and rectified) image, the function computes the corresponding coordinates in the source image (that is, in the original image from camera). The following process is applied:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{array}{l} x  \leftarrow (u - {c&#39;}_x)/{f&#39;}_x  \\ y  \leftarrow (v - {c&#39;}_y)/{f&#39;}_y  \\{[X\,Y\,W]} ^T  \leftarrow R^{-1}*[x \, y \, 1]^T  \\ x&#39;  \leftarrow X/W  \\ y&#39;  \leftarrow Y/W  \\ x&amp;quot;  \leftarrow x&#39; (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + 2p_1 x&#39; y&#39; + p_2(r^2 + 2 x&#39;^2)  \\ y&amp;quot;  \leftarrow y&#39; (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + p_1 (r^2 + 2 y&#39;^2) + 2 p_2 x&#39; y&#39;  \\ map_x(u,v)  \leftarrow x&amp;quot; f_x + c_x  \\ map_y(u,v)  \leftarrow y&amp;quot; f_y + c_y \end{array}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/8808430360ef87d99c3a5725cd2ba7d2852ba689.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&amp;nbsp;&lt;img alt=&quot;(k_1, k_2, p_1, p_2[, k_3])&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/1cf983c88f452726ea3655ebe8d92882db4eff90.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;are the distortion coefficients.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
In case of a stereo camera, this function is called twice: once for each camera head, after&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20stereoRectify(InputArray%20cameraMatrix1,%20InputArray%20distCoeffs1,%20InputArray%20cameraMatrix2,%20InputArray%20distCoeffs2,%20Size%20imageSize,%20InputArray%20R,%20InputArray%20T,%20OutputArray%20R1,%20OutputArray%20R2,%20OutputArray%20P1,%20OutputArray%20P2,%20OutputArray%20Q,%20int%20flags,%20double%20alpha,%20Size%20newImageSize,%20Rect*%20validPixROI1,%20Rect*%20validPixROI2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, double alpha, Size newImageSize, Rect* validPixROI1, Rect* validPixROI2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoRectify()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;, which in its turn is called after&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#double%20stereoCalibrate(InputArrayOfArrays%20objectPoints,%20InputArrayOfArrays%20imagePoints1,%20InputArrayOfArrays%20imagePoints2,%20InputOutputArray%20cameraMatrix1,%20InputOutputArray%20distCoeffs1,%20InputOutputArray%20cameraMatrix2,%20InputOutputArray%20distCoeffs2,%20Size%20imageSize,%20OutputArray%20R,%20OutputArray%20T,%20OutputArray%20E,%20OutputArray%20F,%20TermCriteria%20criteria,%20int%20flags)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, Size imageSize, OutputArray R, OutputArray T, OutputArray E, OutputArray F, TermCriteria criteria, int flags)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoCalibrate()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. But if the stereo camera was not calibrated, it is still possible to compute the rectification transformations directly from the fundamental matrix using&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#bool%20stereoRectifyUncalibrated(InputArray%20points1,%20InputArray%20points2,%20InputArray%20F,%20Size%20imgSize,%20OutputArray%20H1,%20OutputArray%20H2,%20double%20threshold)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;bool stereoRectifyUncalibrated(InputArray points1, InputArray points2, InputArray F, Size imgSize, OutputArray H1, OutputArray H2, double threshold)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoRectifyUncalibrated()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. For each camera, the function computes homography&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;H&lt;/code&gt;&amp;nbsp;as the rectification transformation in a pixel domain, not a rotation matrix&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R&lt;/code&gt;&amp;nbsp;in 3D space.&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R&lt;/code&gt;&amp;nbsp;can be computed from&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;H&lt;/code&gt;&amp;nbsp;as&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\texttt{R} =  \texttt{cameraMatrix} ^{-1}  \cdot \texttt{H} \cdot \texttt{cameraMatrix}&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/59b747d7c0408805084a5b6a98070accf380ae2a.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cameraMatrix&lt;/code&gt;&amp;nbsp;can be chosen arbitrarily.&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
getDefaultNewCameraMatrix&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getdefaultnewcameramatrix&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;getdefaultnewcameramatrix&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Returns the default new camera matrix.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgsize, bool centerPrincipalPoint)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;Mat&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getDefaultNewCameraMatrix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;cameraMatrix&lt;/strong&gt;, Size&amp;nbsp;&lt;strong&gt;imgsize&lt;/strong&gt;=Size(), bool&amp;nbsp;&lt;strong&gt;centerPrincipalPoint&lt;/strong&gt;=false&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#Mat%20getDefaultNewCameraMatrix(InputArray%20cameraMatrix,%20Size%20imgsize,%20bool%20centerPrincipalPoint)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.getDefaultNewCameraMatrix&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;getDefaultNewCameraMatrix&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;cameraMatrix&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, imgsize&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, centerPrincipalPoint&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ retval&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.getDefaultNewCameraMatrix&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;cameraMatrix&lt;/strong&gt;&amp;nbsp;– Input camera matrix.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;imgsize&lt;/strong&gt;&amp;nbsp;– Camera view image size in pixels.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;centerPrincipalPoint&lt;/strong&gt;&amp;nbsp;– Location of the principal point in the new camera matrix. The parameter indicates whether this location should be at the image center or not.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function returns the camera matrix that is either an exact copy of the input&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cameraMatrix&lt;/code&gt;&amp;nbsp;(when&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;centerPrinicipalPoint=false&lt;/code&gt;&amp;nbsp;), or the modified one (when&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;centerPrincipalPoint=true&lt;/code&gt;).&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
In the latter case, the new camera matrix will be:&lt;/div&gt;
&lt;div class=&quot;math&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 10px; margin-top: 10px; text-align: center;&quot;&gt;
&lt;img alt=&quot;\begin{bmatrix} f_x &amp;amp;&amp;amp; 0 &amp;amp;&amp;amp; ( \texttt{imgSize.width} -1)*0.5  \\ 0 &amp;amp;&amp;amp; f_y &amp;amp;&amp;amp; ( \texttt{imgSize.height} -1)*0.5  \\ 0 &amp;amp;&amp;amp; 0 &amp;amp;&amp;amp; 1 \end{bmatrix} ,&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/4ff134c6310643e9d3ba23b67075489e04fdcc6a.png&quot; style=&quot;border: 0px; max-width: 100%;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&amp;nbsp;&lt;img alt=&quot;f_x&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/90cbff5be10b7d5d6a3ec6cabfe05e306e99ac1c.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;f_y&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/0a9dfcd96704b05afe921dcabeefcd77bfdbd863.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;are&amp;nbsp;&lt;img alt=&quot;(0,0)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/efcf02ab5643293fb10588214b1ed71ead4edd4c.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;(1,1)&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/849b2bba16eb4db658d192d8748dc7c837dc4d45.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;elements of&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cameraMatrix&lt;/code&gt;&amp;nbsp;, respectively.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
By default, the undistortion functions in OpenCV (see&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20initUndistortRectifyMap(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20R,%20InputArray%20newCameraMatrix,%20Size%20size,%20int%20m1type,%20OutputArray%20map1,%20OutputArray%20map2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;initUndistortRectifyMap()&lt;/code&gt;&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20undistort(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20newCameraMatrix)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void undistort(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;undistort()&lt;/code&gt;&lt;/a&gt;) do not move the principal point. However, when you work with stereo, it is important to move the principal points in both views to the same y-coordinate (which is required by most of stereo correspondence algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for each view where the principal points are located at the center.&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
undistort&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#undistort&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;undistort&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Transforms an image to compensate for lens distortion.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void undistort(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;undistort&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;cameraMatrix&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;distCoeffs&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;newCameraMatrix&lt;/strong&gt;=noArray()&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20undistort(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20newCameraMatrix)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.undistort&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;undistort&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, cameraMatrix, distCoeffs&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dst&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, newCameraMatrix&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dst&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.undistort&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvUndistort2(const CvArr* src, CvArr* dst, const CvMat* camera_matrix, const CvMat* distortion_coeffs, const CvMat* new_camera_matrix)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvUndistort2&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvArr*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvArr*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;camera_matrix&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;distortion_coeffs&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;new_camera_matrix&lt;/strong&gt;=0&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvUndistort2(const%20CvArr*%20src,%20CvArr*%20dst,%20const%20CvMat*%20camera_matrix,%20const%20CvMat*%20distortion_coeffs,%20const%20CvMat*%20new_camera_matrix)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.Undistort2&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;Undistort2&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, cameraMatrix, distCoeffs&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.Undistort2&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Input (distorted) image.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Output (corrected) image that has the same size and type as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;src&lt;/code&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;cameraMatrix&lt;/strong&gt;&amp;nbsp;– Input camera matrix&amp;nbsp;&lt;img alt=&quot;A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/5017fc06df8951eb2ca115915d52e6fe6d8034de.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;distCoeffs&lt;/strong&gt;&amp;nbsp;– Input vector of distortion coefficients&amp;nbsp;&lt;img alt=&quot;(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/94288b7709d10a7ddf286e33db0074512bda0411.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;newCameraMatrix&lt;/strong&gt;&amp;nbsp;– Camera matrix of the distorted image. By default, it is the same as&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;cameraMatrix&lt;/code&gt;&amp;nbsp;but you may additionally scale and shift the result by using a different matrix.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function transforms an image to compensate radial and tangential lens distortion.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function is simply a combination of&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20initUndistortRectifyMap(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20R,%20InputArray%20newCameraMatrix,%20Size%20size,%20int%20m1type,%20OutputArray%20map1,%20OutputArray%20map2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;initUndistortRectifyMap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;(with unity&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R&lt;/code&gt;&amp;nbsp;) and&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20remap(InputArray%20src,%20OutputArray%20dst,%20InputArray%20map1,%20InputArray%20map2,%20int%20interpolation,%20int%20borderMode,%20const%20Scalar&amp;amp;%20borderValue)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode, const Scalar&amp;amp; borderValue)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;remap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;(with bilinear interpolation). See the former function for details of the transformation being performed.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
A particular subset of the source image that will be visible in the corrected image can be regulated by&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;newCameraMatrix&lt;/code&gt;&amp;nbsp;. You can use&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#Mat%20getOptimalNewCameraMatrix(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20Size%20imageSize,%20double%20alpha,%20Size%20newImgSize,%20Rect*%20validPixROI,%20bool%20centerPrincipalPoint)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;Mat getOptimalNewCameraMatrix(InputArray cameraMatrix, InputArray distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect* validPixROI, bool centerPrincipalPoint)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;getOptimalNewCameraMatrix()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;to compute the appropriate&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;newCameraMatrix&lt;/code&gt;&amp;nbsp;depending on your requirements.&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The camera matrix and the distortion parameters can be determined using&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#double%20calibrateCamera(InputArrayOfArrays%20objectPoints,%20InputArrayOfArrays%20imagePoints,%20Size%20imageSize,%20InputOutputArray%20cameraMatrix,%20InputOutputArray%20distCoeffs,%20OutputArrayOfArrays%20rvecs,%20OutputArrayOfArrays%20tvecs,%20int%20flags,%20TermCriteria%20criteria)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;double calibrateCamera(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags, TermCriteria criteria)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;calibrateCamera()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. If the resolution of images is different from the resolution used at the calibration stage,&amp;nbsp;&lt;img alt=&quot;f_x, f_y, c_x&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/9ea57d8a2d5aab0891c30971ecb4861d676236df.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;and&amp;nbsp;&lt;img alt=&quot;c_y&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/690b7a0c20d6a00f67e5c16ca5dcab66d7969184.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;need to be scaled accordingly, while the distortion coefficients remain the same.&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
undistortPoints&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#undistortpoints&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h2 style=&quot;background-color: #f2f2f2; border-bottom: 1px solid rgb(204, 204, 204); color: #003048; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif; font-size: 25.6px; font-weight: normal; margin: 20px -20px 10px; padding: 3px 0px 3px 10px;&quot;&gt;
&lt;div class=&quot;section&quot; id=&quot;undistortpoints&quot; style=&quot;background-color: white; color: black; font-family: sans-serif; font-size: 16px;&quot;&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
Computes the ideal point coordinates from the observed point coordinates.&lt;/div&gt;
&lt;dl class=&quot;function&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void undistortPoints(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray P)&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C++:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;undistortPoints&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;InputArray&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, OutputArray&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;cameraMatrix&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;distCoeffs&lt;/strong&gt;, InputArray&amp;nbsp;&lt;strong&gt;R&lt;/strong&gt;=noArray(), InputArray&amp;nbsp;&lt;strong&gt;P&lt;/strong&gt;=noArray()&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20undistortPoints(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20R,%20InputArray%20P)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv2.undistortPoints&quot; style=&quot;margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv2.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;undistortPoints&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, cameraMatrix, distCoeffs&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, dst&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, R&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;[&lt;/span&gt;, P&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;optional&quot; style=&quot;font-size: 1.3em;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ dst&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv2.undistortPoints&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;cfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;void cvUndistortPoints(const CvMat* src, CvMat* dst, const CvMat* camera_matrix, const CvMat* dist_coeffs, const CvMat* R, const CvMat* P)&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;C:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;void&amp;nbsp;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;cvUndistortPoints&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;const CvMat*&amp;nbsp;&lt;strong&gt;src&lt;/strong&gt;, CvMat*&amp;nbsp;&lt;strong&gt;dst&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;camera_matrix&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;dist_coeffs&lt;/strong&gt;, const CvMat*&amp;nbsp;&lt;strong&gt;R&lt;/strong&gt;=0, const CvMat*&amp;nbsp;&lt;strong&gt;P&lt;/strong&gt;=0&amp;nbsp;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20cvUndistortPoints(const%20CvMat*%20src,%20CvMat*%20dst,%20const%20CvMat*%20camera_matrix,%20const%20CvMat*%20dist_coeffs,%20const%20CvMat*%20R,%20const%20CvMat*%20P)&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;dl class=&quot;pyoldfunction&quot; style=&quot;margin-bottom: 15px;&quot;&gt;
&lt;dt id=&quot;cv.UndistortPoints&quot; style=&quot;color: #8080b0; margin-bottom: 7px;&quot;&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;descclassname&quot; style=&quot;background-color: transparent;&quot;&gt;cv.&lt;/code&gt;&lt;code class=&quot;descname&quot; style=&quot;background-color: transparent; font-size: 1.2em; font-weight: bold;&quot;&gt;UndistortPoints&lt;/code&gt;&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;(&lt;/span&gt;src, dst, cameraMatrix, distCoeffs, R=None, P=None&lt;span class=&quot;sig-paren&quot; style=&quot;font-size: larger;&quot;&gt;)&lt;/span&gt;&amp;nbsp;→ None&lt;a class=&quot;headerlink&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#cv.UndistortPoints&quot; style=&quot;color: #65a136; font-size: 0.8em; padding: 0px 4px; text-decoration-line: none; visibility: hidden;&quot; title=&quot;Permalink to this definition&quot;&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-left: 30px; margin-top: 1em; text-align: justify;&quot;&gt;&lt;table class=&quot;docutils field-list&quot; frame=&quot;void&quot; rules=&quot;none&quot; style=&quot;border-collapse: collapse; border: 0px; margin-bottom: 10px; margin-top: 20px;&quot;&gt;&lt;colgroup&gt;&lt;col class=&quot;field-name&quot;&gt;&lt;/col&gt;&lt;col class=&quot;field-body&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;
&lt;tr class=&quot;field-odd field&quot;&gt;&lt;th class=&quot;field-name&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px; text-align: left;&quot;&gt;Parameters:&lt;/th&gt;&lt;td class=&quot;field-body&quot; style=&quot;border: 0px !important; padding: 1px 8px 1px 5px;&quot;&gt;&lt;ul class=&quot;first last simple&quot; style=&quot;margin: 0px; padding-left: 1em;&quot;&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&amp;nbsp;– Observed point coordinates, 1xN or Nx1 2-channel (CV_32FC2 or CV_64FC2).&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;dst&lt;/strong&gt;&amp;nbsp;– Output ideal point coordinates after undistortion and reverse perspective transformation. If matrix&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;P&lt;/code&gt;&amp;nbsp;is identity or omitted,&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;dst&lt;/code&gt;&amp;nbsp;will contain normalized point coordinates.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;cameraMatrix&lt;/strong&gt;&amp;nbsp;– Camera matrix&amp;nbsp;&lt;img alt=&quot;\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/c568b55fba0b37aca4e37dd3a7452eba5602347a.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;distCoeffs&lt;/strong&gt;&amp;nbsp;– Input vector of distortion coefficients&amp;nbsp;&lt;img alt=&quot;(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]])&quot; class=&quot;math&quot; src=&quot;https://docs.opencv.org/2.4/_images/math/94288b7709d10a7ddf286e33db0074512bda0411.png&quot; style=&quot;border: 0px; max-width: 100%; vertical-align: middle;&quot; /&gt;&amp;nbsp;of 4, 5, or 8 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;R&lt;/strong&gt;&amp;nbsp;– Rectification transformation in the object space (3x3 matrix).&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R1&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R2&lt;/code&gt;&amp;nbsp;computed by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20stereoRectify(InputArray%20cameraMatrix1,%20InputArray%20distCoeffs1,%20InputArray%20cameraMatrix2,%20InputArray%20distCoeffs2,%20Size%20imageSize,%20InputArray%20R,%20InputArray%20T,%20OutputArray%20R1,%20OutputArray%20R2,%20OutputArray%20P1,%20OutputArray%20P2,%20OutputArray%20Q,%20int%20flags,%20double%20alpha,%20Size%20newImageSize,%20Rect*%20validPixROI1,%20Rect*%20validPixROI2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, double alpha, Size newImageSize, Rect* validPixROI1, Rect* validPixROI2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoRectify()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;can be passed here. If the matrix is empty, the identity transformation is used.&lt;/li&gt;
&lt;li style=&quot;line-height: 20.8px; margin: 0px; text-align: justify;&quot;&gt;&lt;strong&gt;P&lt;/strong&gt;&amp;nbsp;– New camera matrix (3x3) or new projection matrix (3x4).&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;P1&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;P2&lt;/code&gt;&amp;nbsp;computed by&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20stereoRectify(InputArray%20cameraMatrix1,%20InputArray%20distCoeffs1,%20InputArray%20cameraMatrix2,%20InputArray%20distCoeffs2,%20Size%20imageSize,%20InputArray%20R,%20InputArray%20T,%20OutputArray%20R1,%20OutputArray%20R2,%20OutputArray%20P1,%20OutputArray%20P2,%20OutputArray%20Q,%20int%20flags,%20double%20alpha,%20Size%20newImageSize,%20Rect*%20validPixROI1,%20Rect*%20validPixROI2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, double alpha, Size newImageSize, Rect* validPixROI1, Rect* validPixROI2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;stereoRectify()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;can be passed here. If the matrix is empty, the identity new camera matrix is used.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/dd&gt;&lt;/dl&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function is similar to&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20undistort(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20newCameraMatrix)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void undistort(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;undistort()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#void%20initUndistortRectifyMap(InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20R,%20InputArray%20newCameraMatrix,%20Size%20size,%20int%20m1type,%20OutputArray%20map1,%20OutputArray%20map2)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;initUndistortRectifyMap()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;but it operates on a sparse set of points instead of a raster image. Also the function performs a reverse transformation to&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20projectPoints(InputArray%20objectPoints,%20InputArray%20rvec,%20InputArray%20tvec,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20OutputArray%20imagePoints,%20OutputArray%20jacobian,%20double%20aspectRatio)&quot; style=&quot;color: #0090d9; text-decoration-line: none;&quot; title=&quot;void projectPoints(InputArray objectPoints, InputArray rvec, InputArray tvec, InputArray cameraMatrix, InputArray distCoeffs, OutputArray imagePoints, OutputArray jacobian, double aspectRatio)&quot;&gt;&lt;code class=&quot;xref ocv ocv-func docutils literal&quot; style=&quot;background-color: transparent; font-weight: bold;&quot;&gt;projectPoints()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a planar object, it does, up to a translation vector, if the proper&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;R&lt;/code&gt;&amp;nbsp;is specified.&lt;/div&gt;
&lt;div class=&quot;highlight-cpp&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #e0f5ff; border-bottom: 1px solid rgb(170, 204, 238); border-image: initial; border-left: none; border-right: none; border-top: 1px solid rgb(170, 204, 238); color: #333333; line-height: 15.6px; overflow: auto hidden; padding: 5px;&quot;&gt;// (u,v) is the input point, (u&#39;, v&#39;) is the output point
// camera_matrix=[fx 0 cx; 0 fy cy; 0 0 1]
// P=[fx&#39; 0 cx&#39; tx; 0 fy&#39; cy&#39; ty; 0 0 1 tz]
x&quot; = (u - cx)/fx
y&quot; = (v - cy)/fy
(x&#39;,y&#39;) = undistort(x&quot;,y&quot;,dist_coeffs)
[X,Y,W]T = R*[x&#39; y&#39; 1]T
x = X/W, y = Y/W
// only performed if P=[fx&#39; 0 cx&#39; [tx]; 0 fy&#39; cy&#39; [ty]; 0 0 1 [tz]] is specified
u&#39; = x*fx&#39; + cx&#39;
v&#39; = y*fy&#39; + cy&#39;,
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
where&amp;nbsp;&lt;code class=&quot;docutils literal&quot;&gt;undistort()&lt;/code&gt;&amp;nbsp;is an approximate iterative algorithm that estimates the normalized original point coordinates out of the normalized distorted point coordinates (“normalized” means that the coordinates do not depend on the camera matrix).&lt;/div&gt;
&lt;div style=&quot;line-height: 20.8px; margin-bottom: 1em; margin-top: 1em; text-align: justify;&quot;&gt;
The function can be used for both a stereo camera head or a monocular camera (when R is empty).&lt;/div&gt;
&lt;/div&gt;
&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/5587916260747819032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/geometric-image-transformation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/5587916260747819032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/5587916260747819032'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/geometric-image-transformation.html' title='Geometric Image Transformation'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL4vdKHtSeGWO6tO6CE3xXrxEuT6OPmzGbIOCZdMAQl8liRKTs4z1bEZPp0vCJgMIedO4urBGcLrPfoqADLS3pAB9nAACxgs4L-dt7dONSdz3ubKuSoLAWzaPlZot2BFUjfJEMd9sTlUY/s72-c/Geometric_image_transformation.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-8409408315182940788</id><published>2020-01-21T12:10:00.001-08:00</published><updated>2020-01-22T16:19:42.507-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI"/><category scheme="http://www.blogger.com/atom/ns#" term="Deep Learning"/><title type='text'>Softmax function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiP3Q8WzuNrPc5_xk_yOXIDTwTs2dQkah5Y7-4CIP9zlK7WYaSrv2TadmMa2guHp6XYwEfj4uazR2_tg3mXlj5aDyXn2xdbNk4w9Ac3k_7yLv9uVgZee8g_6t_1q-l3vWBAEr62_nB7ao/s1600/Softmax.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;358&quot; data-original-width=&quot;837&quot; height=&quot;272&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiP3Q8WzuNrPc5_xk_yOXIDTwTs2dQkah5Y7-4CIP9zlK7WYaSrv2TadmMa2guHp6XYwEfj4uazR2_tg3mXlj5aDyXn2xdbNk4w9Ac3k_7yLv9uVgZee8g_6t_1q-l3vWBAEr62_nB7ao/s640/Softmax.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;A wonderful activation function that turns numbers aka logits into probabilities that sum to one.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Outputs a vector that represents the probability distributions of a list of potential outcomes&lt;/li&gt;
&lt;li&gt;Core element that is used in deep learning task&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Lets predict a model to see if we receive a gift or not?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;MODEL PREDICTIONS&lt;/b&gt;&lt;br /&gt;
The probability that we get a gift is 0.8&lt;br /&gt;
The probability that we would not receive a gift is 0.2&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;JOB OF MODEL&lt;/b&gt;&lt;br /&gt;
Based on the existing features (Birthdate,year) it calculates the linear model which would be the score&lt;br /&gt;
Then the probability that we get a gift or not is the sigmoid function applied to that score&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs8TZQbwyDHN0XoYJ6t-ZaZH8jWEqXQJ5FYez5KTABwiYNLmDR2ODLUjgViA_OGVOKem2Ch33dxi9OjJEdloNSBIV4YRAaDDFtdn5Y8mgy7ivx7-K7gL7rsZM3qUGtF63UzOreqH5GbqQ/s1600/init.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;795&quot; data-original-width=&quot;1488&quot; height=&quot;339&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs8TZQbwyDHN0XoYJ6t-ZaZH8jWEqXQJ5FYez5KTABwiYNLmDR2ODLUjgViA_OGVOKem2Ch33dxi9OjJEdloNSBIV4YRAaDDFtdn5Y8mgy7ivx7-K7gL7rsZM3qUGtF63UzOreqH5GbqQ/s640/init.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
M&lt;b&gt;ODEL WHICH WOULD TELL US WHICH ANIMAL WHAT WE SAW&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi00gappx6JGOTxtfzyn_U07N5s8GhtWT7k5aVz5RhZlQgvzllJoPEgUEuJbZTaJZbTvDSo11bmVJAaOMsBe9yOWEOCF4OaYkNArLz8ZGO72B-FHP25NUJYjSVYGzxRP_Wqq-6CrZfXGM0/s1600/model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;579&quot; data-original-width=&quot;1585&quot; height=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi00gappx6JGOTxtfzyn_U07N5s8GhtWT7k5aVz5RhZlQgvzllJoPEgUEuJbZTaJZbTvDSo11bmVJAaOMsBe9yOWEOCF4OaYkNArLz8ZGO72B-FHP25NUJYjSVYGzxRP_Wqq-6CrZfXGM0/s640/model.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Notice that the probability of the model needs to add to 1.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Assuming we have a linear model based on some inputs, We calculate linear function based on inputs like if it has a feather, teeth etc&lt;/li&gt;
&lt;li&gt;After calculating linear functions based on these inputs , assuming that we get some scores&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsXO0zsuwwjfE395OBRsJSg6M_TmrC70XbM1hwyCSSUI4gLeRt1EZNpidpmK0Z_A8ZJs73sduYOLaRXRYiwtUb6y0MsNMCR-lsB6btrMcHmlMfU8h6QAhutGMZ0bnjXDKuPt5lcVGalas/s1600/Scores_of.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;635&quot; data-original-width=&quot;1599&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsXO0zsuwwjfE395OBRsJSg6M_TmrC70XbM1hwyCSSUI4gLeRt1EZNpidpmK0Z_A8ZJs73sduYOLaRXRYiwtUb6y0MsNMCR-lsB6btrMcHmlMfU8h6QAhutGMZ0bnjXDKuPt5lcVGalas/s640/Scores_of.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We need to change the scores to 1. (Requirement for probability)&lt;/li&gt;
&lt;li&gt;The probability of duck is higher then beaver and the beaver is higher then walrus&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
We can take the sum of scores and divide it by zero&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0H4ZWqUsax4Zu3u0rIzJql4iGmADBgUBD4QbXWuZApbgmpg7ou-i_FsEXeR3LVgQ-i7GdE9T9fXCQ9pQRMARTntX_p1TLkVY6Lspz7nppy9KuzFfwAlFk9gqiY8QHnU5UEkXeZ35uW3g/s1600/dividebyzero.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;703&quot; data-original-width=&quot;775&quot; height=&quot;362&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0H4ZWqUsax4Zu3u0rIzJql4iGmADBgUBD4QbXWuZApbgmpg7ou-i_FsEXeR3LVgQ-i7GdE9T9fXCQ9pQRMARTntX_p1TLkVY6Lspz7nppy9KuzFfwAlFk9gqiY8QHnU5UEkXeZ35uW3g/s400/dividebyzero.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The probability would be 2/3 for the duck 1/3 for the beaver and 0 for the walrus&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCfMM7_3T-DtNHt4jv9NSUMynK9XX1FHGZ0m1fO5ldQhY3f0wQR5HB_g8U_AP_XVPKn1f4zDmvjlyPv65gSfUVQfMg2xiS9STBGYfbiSmtSoX3ir7kB-9zfUoiXejots-ihNoByuu2oyE/s1600/problem.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;869&quot; data-original-width=&quot;1600&quot; height=&quot;346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCfMM7_3T-DtNHt4jv9NSUMynK9XX1FHGZ0m1fO5ldQhY3f0wQR5HB_g8U_AP_XVPKn1f4zDmvjlyPv65gSfUVQfMg2xiS9STBGYfbiSmtSoX3ir7kB-9zfUoiXejots-ihNoByuu2oyE/s640/problem.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
NOTE:&lt;br /&gt;
We need to store these scores into positive scores. This can be achieved using exponential function&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEKbqmBwlEqllvztNIGRt_No3oS6rjppIjui8J9AUybLxZR3xlG0aB24njc7-CEi5fDEgU-leTSE_g6a0Wvks31SEbqoV54WXmBt0Fmkus0djbF2auqweqAMdfDUCzW0HqX0_TYn9vUyM/s1600/softmax_fucn.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;642&quot; data-original-width=&quot;1600&quot; height=&quot;256&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEKbqmBwlEqllvztNIGRt_No3oS6rjppIjui8J9AUybLxZR3xlG0aB24njc7-CEi5fDEgU-leTSE_g6a0Wvks31SEbqoV54WXmBt0Fmkus0djbF2auqweqAMdfDUCzW0HqX0_TYn9vUyM/s640/softmax_fucn.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
It is called as&amp;nbsp;&lt;b&gt;softmax&lt;/b&gt;&amp;nbsp;function&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdfzwPdfn4tkzk57sA5EhZHLkX_KryWQLMlJicnvfuQS3_26PcphUk1rRX9OSVpMk_T32aMKdpayJT0osOO-qCUyniO2ueWYyQGUBklpxpj6FzPKJs-NQEy76mT3V3ge_UqrOMfbRuQd8/s1600/linear_func.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;422&quot; data-original-width=&quot;588&quot; height=&quot;229&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdfzwPdfn4tkzk57sA5EhZHLkX_KryWQLMlJicnvfuQS3_26PcphUk1rRX9OSVpMk_T32aMKdpayJT0osOO-qCUyniO2ueWYyQGUBklpxpj6FzPKJs-NQEy76mT3V3ge_UqrOMfbRuQd8/s320/linear_func.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/8409408315182940788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/sofmax-function.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8409408315182940788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/8409408315182940788'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/sofmax-function.html' title='Softmax function'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiP3Q8WzuNrPc5_xk_yOXIDTwTs2dQkah5Y7-4CIP9zlK7WYaSrv2TadmMa2guHp6XYwEfj4uazR2_tg3mXlj5aDyXn2xdbNk4w9Ac3k_7yLv9uVgZee8g_6t_1q-l3vWBAEr62_nB7ao/s72-c/Softmax.JPG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-765856496053454522</id><published>2020-01-21T12:04:00.002-08:00</published><updated>2020-01-21T12:04:29.892-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>matplotlib and pyplot </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIInbKbW2AhogX_Tn2H0QscM73RzasfEmI9eAU3fsA_M6gdQreupdO1kijeiDXHXNtY2idxxCoMOYiieW057b0lZ8yWjA3cTg6QcdCo0K3ZYPsy8L2qfmwqs-gCFiwycSp0hwrIuuY6uM/s1600/matplotlib.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;316&quot; data-original-width=&quot;929&quot; height=&quot;216&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIInbKbW2AhogX_Tn2H0QscM73RzasfEmI9eAU3fsA_M6gdQreupdO1kijeiDXHXNtY2idxxCoMOYiieW057b0lZ8yWjA3cTg6QcdCo0K3ZYPsy8L2qfmwqs-gCFiwycSp0hwrIuuY6uM/s640/matplotlib.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #11557c; font-family: &amp;quot;helvetica neue&amp;quot;, helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; margin: 0.5em 0px; padding-top: 0.5em; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #333333; font-size: 1.7em;&quot;&gt;Startup commands&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;startup-commands&quot; style=&quot;background-color: white; color: #333333; font-family: &amp;quot;helvetica neue&amp;quot;, Helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; font-size: 14px;&quot;&gt;
&lt;h2 style=&quot;font-size: 1.7em; margin: 0.5em 0px 0.2em; padding-top: 0.5em;&quot;&gt;
&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#startup-commands&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
First, let’s start IPython. It is a most excellent enhancement to the standard Python prompt, and it ties in especially well with Matplotlib. Start IPython either at a shell, or the IPython Notebook now.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
With IPython started, we now need to connect to a GUI event loop. This tells IPython where (and how) to display plots. To connect to a GUI loop, execute the&amp;nbsp;&lt;strong&gt;%matplotlib&lt;/strong&gt;&amp;nbsp;magic at your IPython prompt. There’s more detail on exactly what this does at&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;http://ipython.org/ipython-doc/2/interactive/reference.html#gui-event-loop-support&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;IPython’s documentation on GUI event loops&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
If you’re using IPython Notebook, the same commands are available, but people commonly use a specific argument to the %matplotlib magic:&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [1]: &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;matplotlib&lt;/span&gt; inline
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
This turns on inline plotting, where plot graphics will appear in your notebook. This has important implications for interactivity. For inline plotting, commands in cells below the cell that outputs a plot will not affect the plot. For example, changing the color map is not possible from cells below the cell that creates a plot. However, for other backends, such as qt4, that open a separate window, cells below those that create the plot will change the plot - it is a live object in memory.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
This tutorial will use matplotlib’s imperative-style plotting interface, pyplot. This interface maintains global state, and is very useful for quickly and easily experimenting with various plot settings. The alternative is the object-oriented interface, which is also very powerful, and generally more suitable for large application development. If you’d like to learn about the object-oriented interface, a great place to start is our&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;http://matplotlib.org/faq/usage_faq.html&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;FAQ on usage&lt;/a&gt;. For now, let’s get on with the imperative-style approach:&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [2]: &lt;/span&gt;&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [3]: &lt;/span&gt;&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;matplotlib.image&lt;/span&gt; &lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;mpimg&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [4]: &lt;/span&gt;&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;np&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;importing-image-data-into-numpy-arrays&quot; style=&quot;background-color: white; color: #333333; font-family: &amp;quot;helvetica neue&amp;quot;, Helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; font-size: 14px;&quot;&gt;
&lt;span id=&quot;importing-data&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;font-size: 1.7em; margin: 0.5em 0px 0.2em; padding-top: 0.5em;&quot;&gt;
Importing image data into Numpy arrays&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#importing-image-data-into-numpy-arrays&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Loading image data is supported by the&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;http://python-imaging.github.io/&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Pillow&lt;/a&gt;&amp;nbsp;library. Natively, matplotlib only supports PNG images. The commands shown below fall back on Pillow if the native read fails.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
The image used in this example is a PNG file, but keep that Pillow requirement in mind for your own data.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Here’s the image we’re going to play with:&lt;/div&gt;
&lt;img alt=&quot;../_images/stinkbug.png&quot; src=&quot;https://matplotlib.org/_images/stinkbug.png&quot; /&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
It’s a 24-bit RGB PNG image (8 bits for each of R, G, B). Depending on where you get your data, the other kinds of image that you’ll most likely encounter are RGBA images, which allow for transparency, or single-channel grayscale (luminosity) images. You can right click on it and choose “Save image as” to download it to your computer for the rest of this tutorial.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
And here we go...&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [5]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mpimg&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;stinkbug.png&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gh&quot; style=&quot;color: navy; font-weight: 700;&quot;&gt;Out[5]:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;array([[[ 0.40784314,  0.40784314,  0.40784314],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.40784314,  0.40784314,  0.40784314],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.40784314,  0.40784314,  0.40784314],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        ...,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.42745098,  0.42745098,  0.42745098],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.42745098,  0.42745098,  0.42745098],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.42745098,  0.42745098,  0.42745098]],&lt;/span&gt;

&lt;span class=&quot;go&quot;&gt;       ...,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;       [[ 0.44313726,  0.44313726,  0.44313726],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.4509804 ,  0.4509804 ,  0.4509804 ],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.4509804 ,  0.4509804 ,  0.4509804 ],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        ...,&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.44705883,  0.44705883,  0.44705883],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.44705883,  0.44705883,  0.44705883],&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;        [ 0.44313726,  0.44313726,  0.44313726]]], dtype=float32)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Note the dtype there - float32. Matplotlib has rescaled the 8 bit data from each channel to floating point data between 0.0 and 1.0. As a side note, the only datatype that Pillow can work with is uint8. Matplotlib plotting can handle float32 and uint8, but image reading/writing for any format other than PNG is limited to uint8 data. Why 8 bits? Most displays can only render 8 bits per channel worth of color gradation. Why can they only render 8 bits/channel? Because that’s about all the human eye can see. More here (from a photography standpoint):&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://luminous-landscape.com/bit-depth/&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Luminous Landscape bit depth tutorial&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Each inner list represents a pixel. Here, with an RGB image, there are 3 values. Since it’s a black and white image, R, G, and B are all similar. An RGBA (where A is alpha, or transparency), has 4 values per inner list, and a simple luminance image just has one value (and is thus only a 2-D array, not a 3-D array). For RGB and RGBA images, matplotlib supports float32 and uint8 data types. For grayscale, matplotlib supports only float32. If your array data does not meet one of these descriptions, you need to rescale it.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;plotting-numpy-arrays-as-images&quot; style=&quot;background-color: white; color: #333333; font-family: &amp;quot;helvetica neue&amp;quot;, Helvetica, &amp;quot;lucida grande&amp;quot;, &amp;quot;lucida sans unicode&amp;quot;, geneva, verdana, sans-serif; font-size: 14px;&quot;&gt;
&lt;span id=&quot;plotting-data&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;font-size: 1.7em; margin: 0.5em 0px 0.2em; padding-top: 0.5em;&quot;&gt;
Plotting numpy arrays as images&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#plotting-numpy-arrays-as-images&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
So, you have your data in a numpy array (either by importing it, or by generating it). Let’s render it. In Matplotlib, this is performed using the&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.pyplot.imshow&quot;&gt;&lt;code class=&quot;xref py py-func docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;imshow()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;function. Here we’ll grab the plot object. This object gives you an easy way to manipulate the plot from the prompt.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [6]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-1.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-1.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-1.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-1.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-1.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
You can also plot any numpy array.&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;applying-pseudocolor-schemes-to-image-plots&quot;&gt;
&lt;span id=&quot;pseudocolor&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;font-size: 1.2em; margin: 0.2em 0px 0.1em; padding-top: 0.5em;&quot;&gt;
Applying pseudocolor schemes to image plots&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#applying-pseudocolor-schemes-to-image-plots&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Pseudocolor can be a useful tool for enhancing contrast and visualizing your data more easily. This is especially useful when making presentations of your data using projectors - their contrast is typically quite poor.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Pseudocolor is only relevant to single-channel, grayscale, luminosity images. We currently have an RGB image. Since R, G, and B are all similar (see for yourself above or in your data), we can just pick one channel of our data:&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [7]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,:,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
This is array slicing. You can read more in the&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://docs.scipy.org/doc/numpy-dev/user/quickstart.html&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Numpy tutorial&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [8]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-2.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-2.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-2.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-2.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-2.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Now, with a luminosity (2D, no color) image, the default colormap (aka lookup table, LUT), is applied. The default is called viridis. There are plenty of others to choose from.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [9]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #4070a0;&quot;&gt;&quot;hot&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-3.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-3.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-3.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-3.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-3.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Note that you can also change colormaps on existing plot objects using the&amp;nbsp;&lt;code class=&quot;xref py py-meth docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;set_cmap()&lt;/code&gt;&amp;nbsp;method:&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [10]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [11]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;nipy_spectral&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-4.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-4.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-4.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-4.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-4.png&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;admonition note&quot; style=&quot;background-color: #eeeeee; border-bottom-color: rgb(204, 204, 204); border-left: 5px solid rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-top-color: rgb(204, 204, 204); margin: 10px 0px; padding: 0.7em 1.4em;&quot;&gt;
&lt;div class=&quot;first admonition-title&quot; style=&quot;font-size: 1.2em; font-weight: 700; margin-bottom: 0.6em; margin-top: 0.6em; padding: 0px;&quot;&gt;
Note&lt;/div&gt;
&lt;div class=&quot;last&quot; style=&quot;margin-bottom: 0.6em; margin-top: 0.6em; padding: 0px;&quot;&gt;
However, remember that in the IPython notebook with the inline backend, you can’t make changes to plots that have already been rendered. If you create imgplot here in one cell, you cannot call set_cmap() on it in a later cell and expect the earlier plot to change. Make sure that you enter these commands together in one cell. plt commands will not change plots from earlier cells.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
There are many other colormap schemes available. See the&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/examples/color/colormaps_reference.html&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;list and images of the colormaps&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;color-scale-reference&quot;&gt;
&lt;span id=&quot;color-bars&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;font-size: 1.2em; margin: 0.2em 0px 0.1em; padding-top: 0.5em;&quot;&gt;
Color scale reference&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#color-scale-reference&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
It’s helpful to have an idea of what value a color represents. We can do that by adding color bars.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [12]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [13]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;colorbar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-5.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-5.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-5.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-5.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-5.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
This adds a colorbar to your existing figure. This won’t automatically change if you change you switch to a different colormap - you have to re-create your plot, and add in the colorbar again.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;examining-a-specific-data-range&quot;&gt;
&lt;span id=&quot;data-ranges&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;font-size: 1.2em; margin: 0.2em 0px 0.1em; padding-top: 0.5em;&quot;&gt;
Examining a specific data range&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#examining-a-specific-data-range&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Sometimes you want to enhance the contrast in your image, or expand the contrast in a particular region while sacrificing the detail in colors that don’t vary much, or don’t matter. A good tool to find interesting regions is the histogram. To create a histogram of our image data, we use the&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.hist&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.pyplot.hist&quot;&gt;&lt;code class=&quot;xref py py-func docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;hist()&lt;/code&gt;&lt;/a&gt;function.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [14]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hist&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ravel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bins&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;color: #007020;&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fc&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;k&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ec&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;k&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-6.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-6.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-6.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-6.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-6.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Most often, the “interesting” part of the image is around the peak, and you can get extra contrast by clipping the regions above and/or below the peak. In our histogram, it looks like there’s not much useful information in the high end (not many white things in the image). Let’s adjust the upper limit, so that we effectively “zoom in on” part of the histogram. We do this by passing the clim argument to imshow. You could also do this by calling the&amp;nbsp;&lt;code class=&quot;xref py py-meth docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;set_clim()&lt;/code&gt;&amp;nbsp;method of the image plot object, but make sure that you do so in the same cell as your plot command when working with the IPython Notebook - it will not change plots from earlier cells.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [15]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lum_img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clim&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot; style=&quot;color: #208050;&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-7.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-7.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-7.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-7.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-7.png&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;array-interpolation-schemes&quot;&gt;
&lt;span id=&quot;interpolation&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;font-size: 1.2em; margin: 0.2em 0px 0.1em; padding-top: 0.5em;&quot;&gt;
Array Interpolation schemes&lt;a class=&quot;headerlink&quot; href=&quot;https://matplotlib.org/users/image_tutorial.html#array-interpolation-schemes&quot; style=&quot;color: rgb(198, 15, 15) !important; font-size: 1em; margin-left: 6px; padding: 0px 4px; text-decoration-line: none !important; visibility: hidden;&quot; title=&quot;Permalink to this headline&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Interpolation calculates what the color or value of a pixel “should” be, according to different mathematical schemes. One common place that this happens is when you resize an image. The number of pixels change, but you want the same information. Since pixels are discrete, there’s missing space. Interpolation is how you fill that space. This is why your images sometimes come out looking pixelated when you blow them up. The effect is more pronounced when the difference between the original image and the expanded image is greater. Let’s take our image and shrink it. We’re effectively discarding pixels, only keeping a select few. Now when we plot it, that data gets blown up to the size on your screen. The old pixels aren’t there anymore, and the computer has to draw in pixels to fill that space.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
We’ll use the Pillow library that we used to load the image also to resize the image.&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [16]: &lt;/span&gt;&lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot; style=&quot;color: #0e84b5; font-weight: 700;&quot;&gt;PIL&lt;/span&gt; &lt;span class=&quot;kn&quot; style=&quot;color: #007020; font-weight: 700;&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [17]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;color: #4070a0;&quot;&gt;&#39;../_static/stinkbug.png&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [18]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;thumbnail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;color: #208050;&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ANTIALIAS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;color: #408090; font-style: italic;&quot;&gt;# resizes image in-place&lt;/span&gt;
&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [19]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-8.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-8.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-8.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-8.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-8.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Here we have the default interpolation, bilinear, since we did not give&amp;nbsp;&lt;a class=&quot;reference internal&quot; href=&quot;https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot; title=&quot;matplotlib.pyplot.imshow&quot;&gt;&lt;code class=&quot;xref py py-func docutils literal&quot; style=&quot;font-family: consolas, &amp;quot;deja vu sans mono&amp;quot;, &amp;quot;bitstream vera sans mono&amp;quot;, monospace; font-size: 0.95em; letter-spacing: 0.01em;&quot;&gt;imshow()&lt;/code&gt;&lt;/a&gt;&amp;nbsp;any interpolation argument.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Let’s try some others:&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [20]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interpolation&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #4070a0;&quot;&gt;&quot;nearest&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-9.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-9.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-9.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-9.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-9.png&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;highlight-ipython&quot;&gt;
&lt;div class=&quot;highlight&quot; style=&quot;background: rgb(238, 255, 204);&quot;&gt;
&lt;pre style=&quot;background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); font-family: Monaco, Menlo, Consolas, &amp;quot;courier new&amp;quot;, monospace; font-size: 0.9em; letter-spacing: 0.015em; line-height: 17.64px; overflow-x: auto; padding: 1em;&quot;&gt;&lt;span class=&quot;gp&quot; style=&quot;color: #c65d09; font-weight: 700;&quot;&gt;In [21]: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgplot&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interpolation&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #4070a0;&quot;&gt;&quot;bicubic&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
(&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-10.py&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;Source code&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-10.png&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;png&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;reference external&quot; href=&quot;https://matplotlib.org/users/image_tutorial-10.pdf&quot; style=&quot;color: #ca7900; text-decoration-line: none;&quot;&gt;pdf&lt;/a&gt;)&lt;/div&gt;
&lt;div class=&quot;figure&quot;&gt;
&lt;img alt=&quot;../_images/image_tutorial-10.png&quot; src=&quot;https://matplotlib.org/_images/image_tutorial-10.png&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.8em; margin-top: 0.8em;&quot;&gt;
Bicubic interpolation is often used when blowing up photos - people tend to prefer blurry over pixelated.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/765856496053454522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/matplotlib-and-pyplot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/765856496053454522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/765856496053454522'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/matplotlib-and-pyplot.html' title='matplotlib and pyplot '/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIInbKbW2AhogX_Tn2H0QscM73RzasfEmI9eAU3fsA_M6gdQreupdO1kijeiDXHXNtY2idxxCoMOYiieW057b0lZ8yWjA3cTg6QcdCo0K3ZYPsy8L2qfmwqs-gCFiwycSp0hwrIuuY6uM/s72-c/matplotlib.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-2503504705841175364</id><published>2020-01-21T11:58:00.003-08:00</published><updated>2020-01-21T11:58:44.698-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Rolling average</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;row narrower&quot; style=&quot;-webkit-box-pack: center; box-sizing: border-box; color: #53595e; display: flex; font-family: Calibre, sans-serif; font-size: 17px; height: auto; justify-content: center; letter-spacing: 0.68px; margin-left: auto; margin-right: auto; max-width: 804px; padding-left: 0px; padding-right: 0px; position: relative; text-align: center; width: 804px;&quot;&gt;
&lt;div class=&quot;column center-content&quot; style=&quot;-webkit-box-align: center; -webkit-box-direction: normal; -webkit-box-flex: 0; -webkit-box-orient: vertical; align-items: center; box-sizing: border-box; display: flex; flex-direction: column; flex: 0 1 auto; height: auto; padding-left: 16px; padding-right: 16px; position: relative; width: 804px;&quot;&gt;
&lt;div class=&quot;spacer1&quot; style=&quot;box-sizing: border-box; height: 16px; position: relative; width: 772px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivUDo3a8c8DIfX2TKgB92fl6N-qbiYfvdErTaGz85kVXWquCFbZmRCqe0Kpjdp2HAcSM-vtD1-hgKUmR-BZ1f_4b5j-XeWq-LKs7ErQoTVGr3dFI27Q5-hNW36zG9ZSJTpu6AOCMscM-w/s1600/rolling_average.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;340&quot; data-original-width=&quot;492&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivUDo3a8c8DIfX2TKgB92fl6N-qbiYfvdErTaGz85kVXWquCFbZmRCqe0Kpjdp2HAcSM-vtD1-hgKUmR-BZ1f_4b5j-XeWq-LKs7ErQoTVGr3dFI27Q5-hNW36zG9ZSJTpu6AOCMscM-w/s400/rolling_average.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;row narrower&quot; style=&quot;-webkit-box-pack: center; box-sizing: border-box; color: #53595e; display: flex; font-family: Calibre, sans-serif; font-size: 17px; height: auto; justify-content: center; letter-spacing: 0.68px; margin-left: auto; margin-right: auto; max-width: 804px; padding-left: 0px; padding-right: 0px; position: relative; text-align: center; width: 804px;&quot;&gt;
&lt;div class=&quot;column no-padding&quot; style=&quot;-webkit-box-align: start; -webkit-box-direction: normal; -webkit-box-flex: 0; -webkit-box-orient: vertical; align-items: flex-start; box-sizing: border-box; display: flex; flex-direction: column; flex: 0 1 auto; height: auto; padding-left: 0px; padding-right: 0px; position: relative; text-align: left; width: 804px;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;row narrower&quot; style=&quot;-webkit-box-pack: center; box-sizing: border-box; color: #53595e; display: flex; font-family: Calibre, sans-serif; font-size: 17px; height: auto; justify-content: center; letter-spacing: 0.68px; margin-left: auto; margin-right: auto; max-width: 804px; padding-left: 0px; padding-right: 0px; position: relative; text-align: center; width: 804px;&quot;&gt;
&lt;div class=&quot;column center-content&quot; style=&quot;-webkit-box-align: center; -webkit-box-direction: normal; -webkit-box-flex: 0; -webkit-box-orient: vertical; align-items: center; box-sizing: border-box; display: flex; flex-direction: column; flex: 0 1 auto; height: auto; padding-left: 16px; padding-right: 16px; position: relative; width: 804px;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;GRAPH SHOWING MOVING AVERAGE FOR THE 7 DAY PRECEDING AVERAGE.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;img src=&quot;https://s3.amazonaws.com/periscope-blog-assets/rolling_average/new_customers_7_preceding.png&quot; style=&quot;border: 0px; box-sizing: border-box; color: #53595e; display: inline-block; font-family: calibre, sans-serif; font-size: 19px; letter-spacing: 0.68px; max-width: 100%; vertical-align: middle;&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;row narrower&quot; style=&quot;-webkit-box-pack: center; -webkit-text-stroke-width: 0px; box-sizing: border-box; color: #53595e; display: flex; font-family: Calibre, sans-serif; font-size: 17px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; height: auto; justify-content: center; letter-spacing: 0.68px; margin-left: auto; margin-right: auto; max-width: 804px; orphans: 2; padding-left: 0px; padding-right: 0px; position: relative; text-align: center; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: 804px; word-spacing: 0px;&quot;&gt;
&lt;div class=&quot;column no-padding center-content&quot; style=&quot;-webkit-box-align: center; -webkit-box-direction: normal; -webkit-box-flex: 0; -webkit-box-orient: vertical; align-items: center; box-sizing: border-box; display: flex; flex-direction: column; flex: 0 1 auto; height: auto; padding-left: 0px; padding-right: 0px; position: relative; text-align: center; width: 804px;&quot;&gt;
&lt;div class=&quot;blog-body w-richtext&quot; data-w-id=&quot;e6c47a37-1818-329d-d49a-a91ac1999399&quot; style=&quot;-webkit-box-align: center; -webkit-box-direction: normal; -webkit-box-orient: vertical; align-items: center; box-sizing: border-box; flex-direction: column; font-size: 19px; line-height: 28px; max-width: 100%; padding-bottom: 40px; padding-top: 64px; position: relative; text-align: left; width: 804px;&quot;&gt;
&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;
&lt;img src=&quot;https://s3.amazonaws.com/periscope-blog-assets/rolling_average/new_customers_basic.png&quot; style=&quot;border: 0px; box-sizing: border-box; display: inline-block; max-width: 100%; vertical-align: middle;&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;letter-spacing: 0.68px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;figure class=&quot;w-richtext-align-center&quot; data-rt-align=&quot;center&quot; data-rt-max-width=&quot;&quot; data-rt-type=&quot;image&quot; style=&quot;box-sizing: border-box; clear: both; display: table; margin: 32px auto; max-width: 100%; position: relative; text-align: center; width: 804px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; color: transparent; display: inline-block; font-size: 0px; max-width: 100%;&quot;&gt;
&lt;/div&gt;
&lt;/figure&gt;&lt;br /&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
With a 7-day preceding average line like this:&lt;/div&gt;
&lt;br /&gt;
&lt;figure class=&quot;w-richtext-align-center&quot; data-rt-align=&quot;center&quot; data-rt-max-width=&quot;&quot; data-rt-type=&quot;image&quot; style=&quot;box-sizing: border-box; clear: both; display: table; margin: 32px auto; max-width: 100%; position: relative; text-align: center; width: 804px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; color: transparent; display: inline-block; font-size: 0px; max-width: 100%;&quot;&gt;
&lt;/div&gt;
&lt;/figure&gt;&lt;br /&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #23292e; font-size: 33.25px; font-weight: 600; line-height: 36px; margin-bottom: 10px; margin-top: 2rem; max-width: 780px; width: 780px;&quot;&gt;
The Big Idea&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
Our first graph above is pretty noisy and hard to get useful information from. We can smooth it out by plotting a 7-day average on top of the underlying data. This can be done with window functions, self-joins, or correlated subqueries - we’ll cover the first two.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
We’ll start with a preceding average, which means that the average point on the 7th of the month is the average of the first seven days.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
Visually this shifts the spikes in the graph to the right, as a big spike is averaged over the following seven days.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #23292e; font-size: 33.25px; font-weight: 600; line-height: 36px; margin-bottom: 10px; margin-top: 2rem; max-width: 780px; width: 780px;&quot;&gt;
First, Create an Intermediate Count Table&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
We want to compute an average over the total signups for each day. Assuming we have a typical users table with a row per new user and a timestamp created_at, we can create our aggregate our&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;signups&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;table like so:&lt;/div&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: 1rem 0px -1rem; max-width: 780px; padding: 1rem 2rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;select&lt;/strong&gt;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp; created_at::date&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;as&lt;/strong&gt;&amp;nbsp;date,&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;count&lt;/strong&gt;(&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;1&lt;/em&gt;)&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;as&lt;/strong&gt;&amp;nbsp;value&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;from&lt;/strong&gt;&amp;nbsp;new_customers&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;group&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;by&lt;/strong&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;1&lt;/em&gt;&lt;/blockquote&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 3rem;&quot;&gt;
In Postgres and SQL Server you can use this as a CTE. In MySQL you can save it as a temporary table.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #23292e; font-size: 33.25px; font-weight: 600; line-height: 36px; margin-bottom: 10px; margin-top: 2rem; max-width: 780px; width: 780px;&quot;&gt;
Postgres Rolling Average&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
Fortunately Postgres has window functions which are the simplest way to compute a running average.&lt;/div&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: 1rem 0px -1rem; max-width: 780px; padding: 1rem 2rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;select&lt;/strong&gt;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp; date,&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp; value,&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;avg&lt;/strong&gt;(value)&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp; &amp;nbsp; over (&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;order&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;by&lt;/strong&gt;&amp;nbsp;date&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;asc&lt;/strong&gt;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;rows&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;between&lt;/strong&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;6&lt;/em&gt;&amp;nbsp;preceding&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;and&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;current&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;row&lt;/strong&gt;)&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;as&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;avg&lt;/strong&gt;,&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;from&lt;/strong&gt;&amp;nbsp;signups&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;order&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;by&lt;/strong&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;1&lt;/em&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;desc&lt;/strong&gt;&lt;/blockquote&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 3rem;&quot;&gt;
This query assumes that the dates do not have gaps. The query is averaging over the past seven rows, not the past seven dates. If your data has gaps, fill them in with&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;generate_series&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;or joining against a table with dense date rows.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #23292e; font-size: 33.25px; font-weight: 600; line-height: 36px; margin-bottom: 10px; margin-top: 2rem; max-width: 780px; width: 780px;&quot;&gt;
MySQL Rolling Average&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
MySQL lacks window functions, but we can do a similar computation using self-joins. For each row in our count table, we join every row that was within the past seven days and take the average.&lt;/div&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: 1rem 0px -1rem; max-width: 780px; padding: 1rem 2rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;select&lt;/strong&gt;&amp;nbsp;signups.date, signups.&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;count&lt;/strong&gt;,&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;avg&lt;/strong&gt;(signups_past.&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;count&lt;/strong&gt;)&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;from&lt;/strong&gt;&amp;nbsp;signups&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;join&lt;/strong&gt;&amp;nbsp;signups&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;as&lt;/strong&gt;&amp;nbsp;signups_past&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;on&lt;/strong&gt;&amp;nbsp;signups_past.date&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;between&lt;/strong&gt;&amp;nbsp;signups.date&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;-&lt;/strong&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;6&lt;/em&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;and&lt;/strong&gt;&amp;nbsp;signups.date&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;group&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;by&lt;/strong&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;1&lt;/em&gt;,&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;2&lt;/em&gt;&lt;/blockquote&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 3rem;&quot;&gt;
This query automatically handles date gaps, as we are looking at rows within a date range rather than the preceding N rows.&lt;/div&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #23292e; font-size: 33.25px; font-weight: 600; line-height: 36px; margin-bottom: 10px; margin-top: 2rem; max-width: 780px; width: 780px;&quot;&gt;
SQL Server Rolling Average&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
SQL Server has window functions, so computing the rolling average can be done in either the Postgres style or MySQL style. For simplicity, we’re using the MySQL version with a self join.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
This is conceptually the same as in MySQL. The only translations are the&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;dateadd&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;function and explicitly named&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;group by&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;columns.&lt;/div&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: 1rem 0px -1rem; max-width: 780px; padding: 1rem 2rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;select&lt;/strong&gt;&amp;nbsp;signups.date, signups.&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;count&lt;/strong&gt;,&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;avg&lt;/strong&gt;(signups_past.&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;count&lt;/strong&gt;)&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;from&lt;/strong&gt;&amp;nbsp;signups&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;join&lt;/strong&gt;&amp;nbsp;signups&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;as&lt;/strong&gt;&amp;nbsp;signups_past&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;on&lt;/strong&gt;&amp;nbsp;signups_past.date&amp;nbsp;&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;between&lt;/strong&gt;&amp;nbsp;dateadd(&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;day&lt;/strong&gt;,&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;-&lt;/strong&gt;&lt;em style=&quot;box-sizing: border-box; color: #8b99e0; font-style: normal; font-weight: 600;&quot;&gt;6&lt;/em&gt;, signups.date)&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;and&lt;/strong&gt;&amp;nbsp;signups.date&lt;/blockquote&gt;
&lt;blockquote style=&quot;background-color: #fafafa; border-bottom: 1px solid rgb(227, 229, 232); border-image: initial; border-left: 1px solid rgb(227, 229, 232); border-radius: 4px; border-right: 1px solid rgb(227, 229, 232); border-top: none; box-sizing: border-box; color: #4f5d75; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; margin: -4px 0px -1rem; max-width: 780px; padding: 0px 2rem 1rem; width: 780px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;group&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;by&lt;/strong&gt;&amp;nbsp;signups.date, signups.&lt;strong style=&quot;box-sizing: border-box; color: #874ca3; font-weight: bold;&quot;&gt;count&lt;/strong&gt;&lt;/blockquote&gt;
&lt;h3 style=&quot;box-sizing: border-box; color: #23292e; font-size: 33.25px; font-weight: 600; line-height: 36px; margin-bottom: 10px; margin-top: 3rem; max-width: 780px; width: 780px;&quot;&gt;
Other Averages&lt;/h3&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;&quot;&gt;
We focused on the 7-day trailing average in this post. If we wanted to look at the 7-day leading average, it’s as simple as sorting the dates in the other direction. If we wanted to look at a centered average, we’d use:&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; margin-bottom: 10px; margin-top: 0px; overflow: hidden; padding-left: 24px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; display: block;&quot;&gt;Postgres:&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;rows between 3 preceding and 3 following&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; display: block;&quot;&gt;MySql:&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;between signups.date - 3 and signups.date + 3&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;in MySQL&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; display: block;&quot;&gt;SQL Server:&amp;nbsp;&lt;em style=&quot;box-sizing: border-box; font-style: italic;&quot;&gt;&lt;strong style=&quot;border-radius: 4px; border: 1px solid rgb(227, 229, 232); box-sizing: border-box; color: black; font: 0.79rem/1.602 Consolas, &amp;quot;Roboto Mono&amp;quot;, monospace; padding: 0.25rem 0.5rem 0.125rem; white-space: nowrap;&quot;&gt;between dateadd(day, -3, signups.date) and dateadd(day, 3, signups.date)&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/2503504705841175364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/rolling-average.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/2503504705841175364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/2503504705841175364'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/rolling-average.html' title='Rolling average'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivUDo3a8c8DIfX2TKgB92fl6N-qbiYfvdErTaGz85kVXWquCFbZmRCqe0Kpjdp2HAcSM-vtD1-hgKUmR-BZ1f_4b5j-XeWq-LKs7ErQoTVGr3dFI27Q5-hNW36zG9ZSJTpu6AOCMscM-w/s72-c/rolling_average.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-153300760225806767</id><published>2020-01-21T11:50:00.003-08:00</published><updated>2020-01-21T11:50:21.908-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="Big Data"/><title type='text'>Difference between AWS glue and Hive warehouse</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;&lt;br /&gt;&lt;/strong&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf_yDPRMXiIbzvrs1AX1Roh9NwJYvjXn-tkhxkjtoQAYoHY6exZHtKxbNvLc8ijTQWbQVZ_CklYEoBvogCnnRciE6yGTUtJ9hct9KMVxC6tDIE45U9szXJlr-li70xJrrUOo47_Ykl5Tc/s1600/awsglue.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;466&quot; data-original-width=&quot;939&quot; height=&quot;316&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf_yDPRMXiIbzvrs1AX1Roh9NwJYvjXn-tkhxkjtoQAYoHY6exZHtKxbNvLc8ijTQWbQVZ_CklYEoBvogCnnRciE6yGTUtJ9hct9KMVxC6tDIE45U9szXJlr-li70xJrrUOo47_Ykl5Tc/s640/awsglue.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;&lt;br /&gt;&lt;/strong&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;&lt;br /&gt;&lt;/strong&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;Apache Hive vs AWS Glue: What are the differences?&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;Apache Hive:&lt;/strong&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Data Warehouse Software for Reading, Writing, and Managing Large Datasets&lt;/em&gt;. Hive facilitates reading, writing, and managing large datasets residing in distributed storage using SQL. Structure can be projected onto data already in storage;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;AWS Glue:&lt;/strong&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;Fully managed extract, transform, and load (ETL) service&lt;/em&gt;. A fully managed extract, transform, and load (ETL) service that makes it easy for customers to prepare and load their data for analytics.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
Apache Hive and AWS Glue can be primarily classified as&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;&quot;Big Data&quot;&lt;/strong&gt;&amp;nbsp;tools.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
Some of the features offered by Apache Hive are:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-top: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Built on top of Apache Hadoop&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Tools to enable easy access to data via SQL&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Support for extract/transform/load (ETL), reporting, and data analysis&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
On the other hand, AWS Glue provides the following key features:&lt;/div&gt;
&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px; margin-top: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Easy - AWS Glue automates much of the effort in building, maintaining, and running ETL jobs. AWS Glue crawls your data sources, identifies data formats, and suggests schemas and transformations. AWS Glue automatically generates the code to execute your data transformations and loading processes.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Integrated - AWS Glue is integrated across a wide range of AWS services.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Serverless - AWS Glue is serverless. There is no infrastructure to provision or manage. AWS Glue handles provisioning, configuration, and scaling of the resources required to run your ETL jobs on a fully managed, scale-out Apache Spark environment. You pay only for the resources used while your jobs are running.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
Apache Hive is an open source tool with&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;2.62K&lt;/strong&gt;&amp;nbsp;GitHub stars and&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;2.58K&lt;/strong&gt;&amp;nbsp;GitHub forks.&amp;nbsp;&lt;a href=&quot;https://github.com/apache/hive&quot; style=&quot;-webkit-font-smoothing: antialiased !important; background-color: transparent; box-sizing: border-box; color: #333333; text-decoration-line: none;&quot;&gt;Here&#39;s&lt;/a&gt;&amp;nbsp;a link to Apache Hive&#39;s open source repository on GitHub.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #707070; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans; font-size: 13px; line-height: 18px; margin-bottom: 10px;&quot;&gt;
According to the StackShare community, Apache Hive has a broader approval, being mentioned in&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;27&lt;/strong&gt;&amp;nbsp;company stacks &amp;amp;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;12&lt;/strong&gt;developers stacks; compared to AWS Glue, which is listed in&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;13&lt;/strong&gt;&amp;nbsp;company stacks and&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box; color: #333333;&quot;&gt;7&lt;/strong&gt;&amp;nbsp;developer stacks.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/153300760225806767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/difference-between-aws-glue-and-hive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/153300760225806767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/153300760225806767'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/difference-between-aws-glue-and-hive.html' title='Difference between AWS glue and Hive warehouse'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf_yDPRMXiIbzvrs1AX1Roh9NwJYvjXn-tkhxkjtoQAYoHY6exZHtKxbNvLc8ijTQWbQVZ_CklYEoBvogCnnRciE6yGTUtJ9hct9KMVxC6tDIE45U9szXJlr-li70xJrrUOo47_Ykl5Tc/s72-c/awsglue.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-6303673339061805624</id><published>2020-01-21T11:48:00.000-08:00</published><updated>2020-01-21T11:48:05.080-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'>Lag and lead in sql</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;header class=&quot;entry-header&quot; style=&quot;border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 10.8px; margin: 0px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDYJc2trF_Xb8Rb6tj7eWG37RTdHEfQmzpu306ZMDzEFfDoUDqfqatm61UNUApnn1rfZvl3f5DOMVysGDvjAhxlw2loBmJl8bm8K5semtAtulzcOwrtqyxiHuteaYVUdrX4H22NNOjazI/s1600/sql.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;512&quot; data-original-width=&quot;512&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDYJc2trF_Xb8Rb6tj7eWG37RTdHEfQmzpu306ZMDzEFfDoUDqfqatm61UNUApnn1rfZvl3f5DOMVysGDvjAhxlw2loBmJl8bm8K5semtAtulzcOwrtqyxiHuteaYVUdrX4H22NNOjazI/s320/sql.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;border: 0px; clear: both; font-size: 28px; font-weight: 400; line-height: 1.2; margin: 0px 0px 15px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/h1&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;border: 0px; clear: both; font-size: 28px; font-weight: 400; line-height: 1.2; margin: 0px 0px 15px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/h1&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;border: 0px; clear: both; font-size: 28px; font-weight: 400; line-height: 1.2; margin: 0px 0px 15px; padding: 0px; vertical-align: baseline;&quot;&gt;
LEAD() and LAG() Function&lt;/h1&gt;
&lt;/header&gt;&lt;br /&gt;
&lt;div class=&quot;entry-content&quot; style=&quot;border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 19px; margin: 0px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
The LEAD() and LAG() function in MySQL are used to get preceding and succeeding value of any row within its partition. These functions are termed as nonaggregate Window functions.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Window&lt;/strong&gt;&amp;nbsp;functions are those functions which perform operations for each row of the partition or window. These functions produce the result for each query row unlikely to the aggregate functions that group them and results in a single row.&lt;/div&gt;
&lt;ul style=&quot;border: 0px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;The row on which operation occur is termed as current row.&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;The set of rows which are realted to current row or using which function opaerates on current row is termed as Window.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
The LAG() function is used to get value from row that precedes the current row.&lt;/div&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
The LEAD() function is used to get value from row that succedes the current row.&lt;/div&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Syntax:&lt;/strong&gt;&lt;br /&gt;
For LEAD() function-&lt;/div&gt;
&lt;pre style=&quot;background-color: #e0e0e0; border-radius: 10px; border: 0px; color: rgba(0, 0, 0, 0.9); font-family: Consolas, monospace; font-size: 15px; line-height: 1.58; margin-bottom: 10px; overflow: auto; padding: 10px; text-align: left; vertical-align: baseline;&quot;&gt;LEAD(expr, N, default) 
          OVER (Window_specification | Window_name)&lt;/pre&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
For LAG() function-&lt;/div&gt;
&lt;pre style=&quot;background-color: #e0e0e0; border-radius: 10px; border: 0px; color: rgba(0, 0, 0, 0.9); font-family: Consolas, monospace; font-size: 15px; line-height: 1.58; margin-bottom: 10px; overflow: auto; padding: 10px; text-align: left; vertical-align: baseline;&quot;&gt;LAG(expr, N, default) 
          OVER (Window_specification | Window_name)&lt;/pre&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;N&lt;/strong&gt;&amp;nbsp;and&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;default&lt;/strong&gt;&amp;nbsp;argument in the function is optional.&lt;/div&gt;
&lt;div style=&quot;border: 0px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Parameters used:&lt;/strong&gt;&lt;/div&gt;
&lt;ol style=&quot;border: 0px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;expr:&lt;/strong&gt;&amp;nbsp;It can be a column or any bulit-in function.&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;N:&lt;/strong&gt;&amp;nbsp;It is a positive value which determine number of rows preceding/succeeding the current row. If it is omitted in query then its default value is 1.&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;default:&lt;/strong&gt;&amp;nbsp;It is the default value return by function in-case no row precedes/succeedes the current row by&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;N&lt;/strong&gt;&amp;nbsp;rows. If it is missing then it is by default NULL.&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;OVER():&lt;/strong&gt;&amp;nbsp;It defines how rows are partitioned into groups. If OVER() is empty then function compute result using all rows.&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Window_specification:&lt;/strong&gt;&amp;nbsp;It consist of query partition clause which determines how the query rows are partitioned and ordered.&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Window_name:&lt;/strong&gt;&amp;nbsp;If window is specified elsewhere in the query then it is referenced using this Window_name.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/6303673339061805624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/lag-and-lead-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/6303673339061805624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/6303673339061805624'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/lag-and-lead-in-sql.html' title='Lag and lead in sql'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDYJc2trF_Xb8Rb6tj7eWG37RTdHEfQmzpu306ZMDzEFfDoUDqfqatm61UNUApnn1rfZvl3f5DOMVysGDvjAhxlw2loBmJl8bm8K5semtAtulzcOwrtqyxiHuteaYVUdrX4H22NNOjazI/s72-c/sql.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-1602465624386514937</id><published>2020-01-21T11:44:00.002-08:00</published><updated>2020-01-21T11:44:24.789-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Azure"/><category scheme="http://www.blogger.com/atom/ns#" term="Big Data"/><title type='text'>AZURE BLOB STORAGE</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_KJjNFVWJUrlaUYVLxSEofQIk3eXXCxX0l550MK12o5A_NtZSqXKXaIJckUsRxMteYKR5Wqn0Y6t5Bk6cgYTAoVA2KL_fcTIjbe1Aisiai1KHfGJKLRUZQ29PT6D0ujZjli7ICdI-jIc/s1600/azurestorage.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;492&quot; data-original-width=&quot;848&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_KJjNFVWJUrlaUYVLxSEofQIk3eXXCxX0l550MK12o5A_NtZSqXKXaIJckUsRxMteYKR5Wqn0Y6t5Bk6cgYTAoVA2KL_fcTIjbe1Aisiai1KHfGJKLRUZQ29PT6D0ujZjli7ICdI-jIc/s640/azurestorage.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Service for storing large amount of unstructured object data, such as text or binary data&lt;/li&gt;
&lt;li&gt;Expose data publicly to the world, or store application data privately&lt;/li&gt;
&lt;li&gt;Common uses of blob storage&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Serving images or documents directly to a browser&lt;/li&gt;
&lt;li&gt;Storing files for distributed access&lt;/li&gt;
&lt;li&gt;Storing data for backup and restore, disaster, recovery and archiving&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;STORAGE ACCOUNT&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;All access to storage is done through a storage account.&lt;/li&gt;
&lt;li&gt;This account can be a General purpose or a blob storage.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;CONTAINER&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;A container provides a grouping of a set of blobs&lt;/li&gt;
&lt;li&gt;All blobs must be in a container&lt;/li&gt;
&lt;li&gt;An account can contain an unlimited number of containers&lt;/li&gt;
&lt;li&gt;A container can store an unlimited no of blobs&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;BLOB&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;A file of any type and size&lt;/li&gt;
&lt;li&gt;Azure storage offers 3 types of blobs&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;CREATION OF BLOBS&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Create a storage account&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Create a container&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Create blobs&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
TYPES OF BLOB&lt;br /&gt;
BLOCK BLOBS&lt;br /&gt;
&amp;nbsp;Each blob can be of different size, up to max of 100 mb&lt;br /&gt;
used for stoing text and binary&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/1602465624386514937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/azure-blob-storage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/1602465624386514937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/1602465624386514937'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/azure-blob-storage.html' title='AZURE BLOB STORAGE'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_KJjNFVWJUrlaUYVLxSEofQIk3eXXCxX0l550MK12o5A_NtZSqXKXaIJckUsRxMteYKR5Wqn0Y6t5Bk6cgYTAoVA2KL_fcTIjbe1Aisiai1KHfGJKLRUZQ29PT6D0ujZjli7ICdI-jIc/s72-c/azurestorage.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-7377635167750063166</id><published>2020-01-21T11:35:00.001-08:00</published><updated>2020-01-21T11:35:26.995-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache Spark"/><category scheme="http://www.blogger.com/atom/ns#" term="Big Data"/><title type='text'>Spark Executors and Drivers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kWQ2E57H2XkWgFj0nGQzlgjIocRXoG57VconuLJpThurVsvLu0sk7sIfzNywYFPH9hIRkWKau3vaaWKttz8HaI_6p4T_Yfmvb-s_SF5cEyK9Jc7B-aU_j_hKkygbrmTvYNMzzfbgHhc/s1600/Spark+executor.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;360&quot; data-original-width=&quot;732&quot; height=&quot;313&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kWQ2E57H2XkWgFj0nGQzlgjIocRXoG57VconuLJpThurVsvLu0sk7sIfzNywYFPH9hIRkWKau3vaaWKttz8HaI_6p4T_Yfmvb-s_SF5cEyK9Jc7B-aU_j_hKkygbrmTvYNMzzfbgHhc/s640/Spark+executor.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;SPARK CONSISTS OF DRIVER PROGRAM&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Our code that defines which datasources to consume from and which data sources to consume to which is driving all our execution&lt;/li&gt;
&lt;li&gt;Responsible for getting the spark context&lt;/li&gt;
&lt;li&gt;It would understand how to communicate with the cluster manager.(Yarn mesos or stand-alone)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;CLUSTER MANAGER&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Requests resources which are the worker node. This worker node contains executor&lt;/li&gt;
&lt;li&gt;Driver is acting as a scheduler&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;EXECUTOR&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Its a jvm, which can spawn different tasks&lt;/li&gt;
&lt;li&gt;These tasks performs specific tasks what the driver tells them&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;EXECUTOR MEMORY (SPARK CACHE)&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;Each executor carries a memory that it keeps as cache. This is known as spark cache&lt;/li&gt;
&lt;li&gt;There is a portion of jvm memory inside the executor&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Note: Spark data off heap, so outside the jvm&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzGLF6Ae-e8dbpeBLrqS9LOM59bG6DPJUqMfXAr0iFL-g9XBXuJtsrTk_8l0Def8OxKOUW7U5OwUOHFdGF1TUebFw3EscfgnJYXJSuK6oaPiaHEs2kiHIEmmYbSbhm17wq0O-wcBXUfW4/s1600/sparkdriverprogram.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;681&quot; data-original-width=&quot;1254&quot; height=&quot;345&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzGLF6Ae-e8dbpeBLrqS9LOM59bG6DPJUqMfXAr0iFL-g9XBXuJtsrTk_8l0Def8OxKOUW7U5OwUOHFdGF1TUebFw3EscfgnJYXJSuK6oaPiaHEs2kiHIEmmYbSbhm17wq0O-wcBXUfW4/s640/sparkdriverprogram.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;DRIVER&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Requests resources from a scheduler (YARN)&lt;/li&gt;
&lt;li&gt;Once the program gets the resources it needs in the form of executors. Its the job of the driver to schedule the execution of tasks that it sends to the executors&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;SCHEDULING&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;There are 2 types of scheduler&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CLUSTER MANAGER SCHEDULER (YARN)&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;ul&gt;
&lt;li&gt;Responsible for responding to resource requests for executors.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBREHb1AfNSGfFC2hVf5nWqTndt2wJVXHmOrdWqSeYYUX0KcIBdfyzm4LAuKAHEHTWrlEVvWVA5eINSFrsjr84nyKErJLfnepMbCkS6aI_AkV0j_bKR__nchmyAyuLmg4a8rqqLf-Lrss/s1600/schedular.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;646&quot; data-original-width=&quot;1377&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBREHb1AfNSGfFC2hVf5nWqTndt2wJVXHmOrdWqSeYYUX0KcIBdfyzm4LAuKAHEHTWrlEVvWVA5eINSFrsjr84nyKErJLfnepMbCkS6aI_AkV0j_bKR__nchmyAyuLmg4a8rqqLf-Lrss/s400/schedular.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPARK SCHEDULER(Driver)&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;ul&gt;
&lt;li&gt;Responsible translating transformation and actions into a DAG&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjsitbcaB9j1zUObI5W0p7b4ThONVNHNrHh7HQtvrbLaE8aJRVTIsFoVIBYwK28GgxsVMOqO0HiuyNBYy3n_3sBjRTN7A22Oph9Qo0OcwCIv6VlkMhfYMnoXiyJ_VhksGZ0hUi-a8ItUs/s1600/translator.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;641&quot; data-original-width=&quot;1411&quot; height=&quot;181&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjsitbcaB9j1zUObI5W0p7b4ThONVNHNrHh7HQtvrbLaE8aJRVTIsFoVIBYwK28GgxsVMOqO0HiuyNBYy3n_3sBjRTN7A22Oph9Qo0OcwCIv6VlkMhfYMnoXiyJ_VhksGZ0hUi-a8ItUs/s400/translator.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;CLUSTER MODE&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
There are 2 types of cluster modes&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &lt;b&gt;&amp;nbsp;1. CLIENT MODE&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;When submitted as client mode, the machine or the client host that you are submitting your application from actually hosts the driver code&lt;/li&gt;
&lt;li&gt;Their requests are made to yarn to submit the application and request the resources and then YARN creates an application master and containers that would communicate back to the application master, which the becomes aware of.&lt;/li&gt;
&lt;li&gt;Host is responsible for the livelihood of the driver. Driver goes down then the whole application goes down.&lt;/li&gt;
&lt;li&gt;Availability depends on client&lt;/li&gt;
&lt;li&gt;Interactive (Spark Shell/REPL)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0o6GnsmNt4YKQYwHOYsJGVU-IBrc_YzHnqtM6mZoZkEbytGif50sNJG1s2na6DbRybXsy7W4jnLcYMcS2iIH94CKqTChweU2HKpYSVu6nC6m8xndofqZUm_iBeYKERaZfL7vX-OfGYNg/s1600/Clientmode.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;769&quot; data-original-width=&quot;1447&quot; height=&quot;211&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0o6GnsmNt4YKQYwHOYsJGVU-IBrc_YzHnqtM6mZoZkEbytGif50sNJG1s2na6DbRybXsy7W4jnLcYMcS2iIH94CKqTChweU2HKpYSVu6nC6m8xndofqZUm_iBeYKERaZfL7vX-OfGYNg/s400/Clientmode.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &lt;b&gt;&amp;nbsp; &amp;nbsp;2. CLUSTER MODE&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Driver itself (spark scheduler) is introduced as a container within your cluster manager&lt;/li&gt;
&lt;li&gt;Driver actually leaves within the boundary of application master&lt;/li&gt;
&lt;li&gt;It communicates with executors with other containers just as it does in the client mode&lt;/li&gt;
&lt;li&gt;Cluster manger manages drivers livelihood&lt;/li&gt;
&lt;li&gt;Better availability guarantees&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Non interactive&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;CONTAINER&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;A container is an allocation or share of memory and cpu.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;One job may need multiple containers&lt;/li&gt;
&lt;li&gt;Containers will be allocated across the cluster depending upon the availability&lt;/li&gt;
&lt;li&gt;The tasks will be executed inside the container&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;PARTITIONS&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Each of these containers is spark executor. This carries different tasks and cache&lt;/li&gt;
&lt;li&gt;Spark splits out its body of work that it creates partitions that it has to work on.&lt;/li&gt;
&lt;li&gt;Every partitions consumes one of this task slots (similar to input splits)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;APPLICATION MASTER&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Stand alone application that YARN runs in a YARN container to manage spark application running in a YARN cluster&lt;/li&gt;
&lt;li&gt;Framework specific library tasked with negotiating cluster resources from the YARN ResourceManager and working with YARN nodemanger to execute and monitor the task.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0kGoL1_1wY8YOsiYdzbTMqlRTDgr6b5-1FQjUQE1GBBTFfGgGaSg2UgFleKY_WW-_oqTkl9PAQGqT7EXmsR7V32Ob9_IrU-zsCbmm0QFtWvjfb4lTWywBUUg2gTrrnq-DEc0ZHlXoE94/s1600/clientCluster.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;648&quot; data-original-width=&quot;1343&quot; height=&quot;192&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0kGoL1_1wY8YOsiYdzbTMqlRTDgr6b5-1FQjUQE1GBBTFfGgGaSg2UgFleKY_WW-_oqTkl9PAQGqT7EXmsR7V32Ob9_IrU-zsCbmm0QFtWvjfb4lTWywBUUg2gTrrnq-DEc0ZHlXoE94/s400/clientCluster.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;MASTER IN SPARKSESSION&lt;/b&gt;&lt;br /&gt;
&lt;blockquote style=&quot;background-color: #fbf2d4; border-bottom-color: initial; border-bottom-style: initial; border-image: initial; border-left-color: rgb(255, 235, 142); border-left-style: solid; border-right-color: initial; border-right-style: initial; border-top-color: initial; border-top-style: initial; border-width: 0px 0px 0px 2px; box-sizing: inherit; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px 0px 10px; padding: 10px; quotes: none; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;border: 0px; box-sizing: inherit; clear: both; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; padding: 0px; vertical-align: baseline;&quot;&gt;
The --master option specifies the master URL for a distributed cluster, or local to run locally with one thread, or local[N] to run locally with N threads. You should start by using local for testing.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
And from&amp;nbsp;&lt;a href=&quot;http://spark.apache.org/docs/latest/submitting-applications.html#master-urls&quot; rel=&quot;noreferrer&quot; style=&quot;border: 0px; box-sizing: inherit; color: #0064bd; cursor: pointer; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;here&lt;/a&gt;:&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #202020; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #6ab825; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #447fcf; text-decoration: underline;&quot;&gt;org.apache.spark.sql.SparkSession&lt;/span&gt;
&lt;span style=&quot;color: #24909d;&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;Ingest&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #d0d0d0;&quot;&gt;//&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;Main&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;Method&lt;/span&gt;
  &lt;span style=&quot;color: #6ab825; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #447fcf;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: #d0d0d0;&quot;&gt;(args:&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;Array[String])&lt;/span&gt;
  &lt;span style=&quot;color: #d0d0d0;&quot;&gt;{&lt;/span&gt;

     &lt;span style=&quot;color: #d0d0d0;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;spark&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #d0d0d0;&quot;&gt;SparkSession&lt;/span&gt;
      &lt;span style=&quot;color: #d0d0d0;&quot;&gt;.builder()&lt;/span&gt;
       &lt;span style=&quot;color: #d0d0d0;&quot;&gt;.master(&lt;/span&gt;&lt;span style=&quot;color: #ed9d13;&quot;&gt;&quot;local[2]&quot;&lt;/span&gt;&lt;span style=&quot;color: #d0d0d0;&quot;&gt;)&lt;/span&gt;
      &lt;span style=&quot;color: #d0d0d0;&quot;&gt;.appName(&lt;/span&gt;&lt;span style=&quot;color: #ed9d13;&quot;&gt;&quot;Spark SQL basic example&quot;&lt;/span&gt;&lt;span style=&quot;color: #d0d0d0;&quot;&gt;).getOrCreate()&lt;/span&gt;

   &lt;span style=&quot;color: #d0d0d0;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #d0d0d0;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;local&lt;/strong&gt;&amp;nbsp;: Run Spark locally with one worker thread (i.e. no parallelism at all).&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;local[K]&lt;/strong&gt;&amp;nbsp;: Run Spark locally with K worker threads (ideally, set this to the number of cores on your machine).&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;local[K,F]&lt;/strong&gt;&amp;nbsp;: Run Spark locally with K worker threads and F maxFailures (see spark.task.maxFailures for an explanation of this variable)&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;local[*]&lt;/strong&gt;&amp;nbsp;: Run Spark locally with as many worker threads as logical cores on your machine.&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;local[*,F]&lt;/strong&gt;&amp;nbsp;: Run Spark locally with as many worker threads as logical cores on your machine and F maxFailures.&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;spark://HOST:PORT&lt;/strong&gt;&amp;nbsp;: Connect to the given Spark standalone cluster master. The port must be whichever one your master is configured to use, which is 7077 by default.&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;spark://HOST1:PORT1,HOST2:PORT2&lt;/strong&gt;&amp;nbsp;: Connect to the given Spark standalone cluster with standby masters with Zookeeper. The list must have all the master hosts in the high availability cluster set up with Zookeeper. The port must be whichever each master is configured to use, which is 7077 by default.&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;mesos://HOST:PORT&lt;/strong&gt;&amp;nbsp;: Connect to the given Mesos cluster. The port must be whichever one your is configured to use, which is 5050 by default. Or, for a Mesos cluster using ZooKeeper, use mesos://zk://.... To submit with --deploy-mode cluster, the HOST:PORT should be configured to connect to the MesosClusterDispatcher.&lt;/div&gt;
&lt;hr style=&quot;background-color: #d6d9dc; border: 0px; box-sizing: inherit; color: #d6d9dc; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; height: 1px; margin-bottom: 20px;&quot; /&gt;
&lt;div style=&quot;background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; box-sizing: inherit; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;yarn&lt;/strong&gt;&amp;nbsp;: Connect to a YARN cluster in client or cluster mode depending on the value of --deploy-mode. The cluster location will be found based on the HADOOP_CONF_DIR or YARN_CONF_DIR variable&lt;/div&gt;
YARN NODE MANAGER&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
YARN RESOURCE MANAGER&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/7377635167750063166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/spark-executors-and-drivers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7377635167750063166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/7377635167750063166'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/spark-executors-and-drivers.html' title='Spark Executors and Drivers'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6kWQ2E57H2XkWgFj0nGQzlgjIocRXoG57VconuLJpThurVsvLu0sk7sIfzNywYFPH9hIRkWKau3vaaWKttz8HaI_6p4T_Yfmvb-s_SF5cEyK9Jc7B-aU_j_hKkygbrmTvYNMzzfbgHhc/s72-c/Spark+executor.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-3049809373827801331</id><published>2020-01-21T11:30:00.000-08:00</published><updated>2020-01-21T11:30:07.122-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Big Data"/><category scheme="http://www.blogger.com/atom/ns#" term="Datawarehouse"/><title type='text'>Loading facts in ETL</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYevfdUt4ggRkRslmrVPmOF952BRW2XOAbM51XTUCPpAd1llOBt2tEUHJ4OpPtT87q803dM-dhFYx1zonFTFxagZdWDgIKg8qLKLNSaq_Zisv_Iy20ssppk-ltypic9suPXurUoJzofXM/s1600/fact.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;601&quot; data-original-width=&quot;936&quot; height=&quot;410&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYevfdUt4ggRkRslmrVPmOF952BRW2XOAbM51XTUCPpAd1llOBt2tEUHJ4OpPtT87q803dM-dhFYx1zonFTFxagZdWDgIKg8qLKLNSaq_Zisv_Iy20ssppk-ltypic9suPXurUoJzofXM/s640/fact.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;LOADING FACTS&lt;/b&gt;&lt;br /&gt;
The most important thing about loading fact tables is that first you need to load dimension tables and then according to the specification the fact tables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &lt;b&gt;fact table &lt;/b&gt;is often located in the center of a star schema, surrounded by dimension tables. It has two types of columns: those containing facts and other containing foreign keys to dimension tables.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;FACT TABLE CONSISTS OF:&lt;/b&gt;&lt;br /&gt;
Measurements: additive-measures that can be added across all dimensions , non-additive cannot be added and semi-additive can be added across few dimensions.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;METRICS&lt;/b&gt;&lt;br /&gt;
Facts - The fact table has frequently more than one measurement field and then each field is called a fact. Usually one fact table has at least three dimension tables.&lt;br /&gt;
Fact table granulatity&lt;br /&gt;
First point is creating the grain of a table.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;GRAIN&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The grain is simply a definition of a measurement event and allows dimension tables to fallow appropriate fact table. The connection between both appears through the foreign keys in the fact table and provide the context of the measurements. Every fact table should have only one grain(two or more are not recommended).&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;TYPES OF FACT TABLE&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Transaction grain&lt;/b&gt;. Use only if the measurement events take place. It is for instantaneous actions. Those tables are the largest of all three types.&lt;br /&gt;
&lt;b&gt;Periodic snapshot&lt;/b&gt;. Use for long tracking processes like bank account. It is a measurement at a specific point of time , regularly repeated and it refers to the period of time in the dimension table. The most common is monthly snapshot.&lt;br /&gt;
&lt;b&gt;Accumulating snapshot&lt;/b&gt;. Use for processes that have defined beginning and end. It shows a status in every moment we need.&lt;br /&gt;
Preserving integrity&lt;br /&gt;
To preserve the integrity all foreign keys references should be correct and known. However there are two situations when this integrity may be broken. It is when we load fact tables with incorrect foreign key or when we delete a dimension with a related primary key. Then it is impossible to make a connection between those tables and we may loose some very important relationships.&lt;br /&gt;
&lt;br /&gt;
Any query that references this relationship will fail. To avoid this problem you should analyze the loading phase in every step from preparation , through loading and after loading by scanning the fact table and looking for bad foreign keys.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next point is checking the surrogate keys. When we load fact table we assume that all records are current. This operation refers to a surrogate key pipeline where the source data for the fact table contains natural keys that must be replaced by surrogate keys before the records are loaded. They are found through the line of little lookup surrogate tables which are updated every time a new dimension entity is created or changed.&lt;br /&gt;
&lt;br /&gt;
Only with appropriate current surrogate key we may connect to a fact table with good results. However the lookup surrogate tables are not effective if we are handling with late arriving records. Then the dimension is a source of the surrogate key.&lt;br /&gt;
&lt;br /&gt;
In the beginning of this article I have mentioned about the primary and surrogate key of the dimension table. Now we will look closer at those two elements considering two cases: the current database type and the temporary database type.&lt;br /&gt;
&lt;br /&gt;
A current database stores only current data and the relationship between the surrogate and primary key is one to one so the surrogate key may be used as a primary key.&lt;br /&gt;
&lt;br /&gt;
In the temporary database this relationship is many to one and then we cannot make this replacement.&lt;br /&gt;
&lt;br /&gt;
The database should reflect the data of its source to provide appropriate business activity. In other words all data should be current and correct.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;HANDLING INCORRECT DATA&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Negate the fact (do nothing)&lt;br /&gt;
Update the fact (overwrite)&lt;br /&gt;
Delete and remove the fact - the most common way. We may delete facts physically and logically. When deleted physically we just delete permanently unwanted record while in logically deleting we create a delete column for unwanted records. The first one is easier but the second is much safer and most widely used.&lt;br /&gt;
Factless fact tables&lt;br /&gt;
Now we will say shortly about some other points of loading fact tables.&lt;br /&gt;
&lt;br /&gt;
The fact less fact table is a table that contains only dimensional keys without any measured values.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;TYPES OF FACT TABLE:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First type is used for capturing the event for information not calculation purposes. It is just an information about the even that happened.&lt;br /&gt;
Second used for support negative analysis report and guarantee coverage.&lt;br /&gt;
Multiple measures units&lt;br /&gt;
Sometimes the number of measurements is so big that presenting them may be quite inconvenient. To resolve this problem we use special units of measure in a fact table.&lt;br /&gt;
&lt;br /&gt;
The currencies&lt;br /&gt;
In many databases which influence business decisions there is a need to express facts in many currencies. Then we create a foreign key in the fact table(like a sale fact table) which connect to the currency dimension table.&lt;br /&gt;
&lt;br /&gt;
Late arriving facts&lt;br /&gt;
We locate those late arriving facts in historical position but we have to be very careful in choosing old contemporary dimension records. To make this operation appropriately you should follow these steps: First - find the corresponding dimension record, then replace the natural keys of late arriving facts with the surrogate key founded in dimension records and locate this late arriving fact into a correct place in the database where other fact tables from that time are stored.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/3049809373827801331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/loading-facts-in-etl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/3049809373827801331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/3049809373827801331'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/loading-facts-in-etl.html' title='Loading facts in ETL'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYevfdUt4ggRkRslmrVPmOF952BRW2XOAbM51XTUCPpAd1llOBt2tEUHJ4OpPtT87q803dM-dhFYx1zonFTFxagZdWDgIKg8qLKLNSaq_Zisv_Iy20ssppk-ltypic9suPXurUoJzofXM/s72-c/fact.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-6671366169759762759</id><published>2020-01-21T11:23:00.000-08:00</published><updated>2020-01-21T11:23:07.949-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache Spark"/><category scheme="http://www.blogger.com/atom/ns#" term="Big Data"/><title type='text'>Installing spark on windows</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBoXU8Y-m9pNzmYBiWZtyMK28ld_puDW20ypzcfCpnglomLpaNxzUcl9o-oUmvy3hzLfXRxNDYmp2-CFJqmNpAPa-Bd52X6tOKtLKdUEPRneXzKWBtb9iFJJYptFj407O41YiCLIG7sIg/s1600/install_spark.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;274&quot; data-original-width=&quot;616&quot; height=&quot;284&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBoXU8Y-m9pNzmYBiWZtyMK28ld_puDW20ypzcfCpnglomLpaNxzUcl9o-oUmvy3hzLfXRxNDYmp2-CFJqmNpAPa-Bd52X6tOKtLKdUEPRneXzKWBtb9iFJJYptFj407O41YiCLIG7sIg/s640/install_spark.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;https://www.youtube.com/watch?v=2CvtwKTjI4Q&amp;amp;vl=en&quot;&gt;https://www.youtube.com/watch?v=2CvtwKTjI4Q&amp;amp;vl=en&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
1) Download specific version of spark&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;http://spark.apache.org/downloads.html&quot;&gt;http://spark.apache.org/downloads.html&lt;/a&gt;&lt;br /&gt;
2) Unzip and create a directory for spark&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQt5eOOyhtTtexO97R1sa0BgmqjXG5Ls3Mp3Mt_RygBqCzl2HXwLJhfHne3vNx9dzjyi5BiysHRzvxOrYx-fEDtBe-57mxvrzUt23ZuUIIwXxicdyHzDV682-eKvlbvTvpYbTH54Y14f8/s1600/env.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;451&quot; data-original-width=&quot;451&quot; height=&quot;638&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQt5eOOyhtTtexO97R1sa0BgmqjXG5Ls3Mp3Mt_RygBqCzl2HXwLJhfHne3vNx9dzjyi5BiysHRzvxOrYx-fEDtBe-57mxvrzUt23ZuUIIwXxicdyHzDV682-eKvlbvTvpYbTH54Y14f8/s640/env.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyAQ_9vQu_lC94cdOho8Xot12bVH9xnrxaC8IZJNDLmS75knICyeRcp-ApvrrxjCRetVaGEnNZd2vlX88N_O_lEuOkHBO8yR-mUrglYeeRqDTY86HNdmz-edKc-JqJsH1HSI6laQTsYEk/s1600/path.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;462&quot; data-original-width=&quot;640&quot; height=&quot;462&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyAQ_9vQu_lC94cdOho8Xot12bVH9xnrxaC8IZJNDLmS75knICyeRcp-ApvrrxjCRetVaGEnNZd2vlX88N_O_lEuOkHBO8yR-mUrglYeeRqDTY86HNdmz-edKc-JqJsH1HSI6laQTsYEk/s640/path.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/6671366169759762759/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/installing-spark-on-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/6671366169759762759'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/6671366169759762759'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/installing-spark-on-windows.html' title='Installing spark on windows'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBoXU8Y-m9pNzmYBiWZtyMK28ld_puDW20ypzcfCpnglomLpaNxzUcl9o-oUmvy3hzLfXRxNDYmp2-CFJqmNpAPa-Bd52X6tOKtLKdUEPRneXzKWBtb9iFJJYptFj407O41YiCLIG7sIg/s72-c/install_spark.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-4209560542573075957</id><published>2020-01-21T11:21:00.002-08:00</published><updated>2020-01-21T11:21:27.128-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Big Data"/><category scheme="http://www.blogger.com/atom/ns#" term="Cloud services"/><title type='text'>Wasb</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJbbGi1tcMJhvcNZN7k_9Pk2_NrP24sB77gQ6WHVY-MBcKLSjemmZ3P5jAkbFDe6u_1hKJAjgb_-FKwI0zndzjSElOb1vtmTFB9W23FSsQbaM_0DvyfIFC2n3JrCAnykpgYeCz-kp6RXE/s1600/wasb.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;362&quot; data-original-width=&quot;649&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJbbGi1tcMJhvcNZN7k_9Pk2_NrP24sB77gQ6WHVY-MBcKLSjemmZ3P5jAkbFDe6u_1hKJAjgb_-FKwI0zndzjSElOb1vtmTFB9W23FSsQbaM_0DvyfIFC2n3JrCAnykpgYeCz-kp6RXE/s320/wasb.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;What is HDFS?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
The Hadoop Distributed File System (HDFS) is one of the core Hadoop components, it is how Hadoop manages data and storage. At a high level, when you load a file into Hadoop the &quot;name node&quot; uses HDFS to chunk the file into blocks and it spreads those blocks of data across the worker nodes within the cluster. Each chunk of data is stored on multiple nodes (assuming the replication factor is set to &amp;gt; 1) for higher availability. The name node knows where each chunk of data is stored and that information is used by the job manager to allocate tasks and resources appropriately across nodes.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;What is WASB?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
Windows Azure Storage Blob (WASB) is an extension built on top of the HDFS APIs. The WASBS variation uses SSL certificates for improved security. It in many ways &quot;is&quot; HDFS. However, WASB creates a layer of abstraction that enables separation of storage. This separation is what enables your data to persist even when no clusters currently exist and enables multiple clusters plus other applications to access a single piece of data all at the same time. This increases functionality and flexibility while reducing costs and reducing the time from question to insight.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;What is an Azure blob store, an Azure storage account, and an Azure container? For that matter, what is Azure again?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
Azure is Microsoft&#39;s cloud solution. A cloud is essentially a collection of host data centers that you don&#39;t have to directly manage. You can request services from that cloud. For example, you can request virtual machines and&amp;nbsp;&lt;a href=&quot;http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/#concepts&quot; style=&quot;background-color: transparent; box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;storage&lt;/a&gt;, data services such as SQL Azure Database or HDInsight, or services such as Websites or Service Bus. In Azure you store blobs on containers within&amp;nbsp;&lt;a href=&quot;http://azure.microsoft.com/en-us/documentation/articles/storage-whatis-account/&quot; style=&quot;background-color: transparent; box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;Azure storage accounts&lt;/a&gt;. You grant access to a storage account, you create collections at the container level, and you place blobs (files of any format) inside the containers. This illustration from Microsoft&#39;s documentation helps to show the structure:&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
&lt;img alt=&quot;Blob1&quot; height=&quot;130&quot; src=&quot;https://acomdpsstorage.blob.core.windows.net/dpsmedia-prod/azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/20150128060354/includes/howto-blob-storage/blob1.jpg&quot; style=&quot;border: 0px; box-sizing: border-box; height: auto; max-width: 100%; vertical-align: middle;&quot; width=&quot;209&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;How do I manage and configure block/chunk size and the replication factor with WASB?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
You don&#39;t. It&#39;s not generally necessary. The data is stored in the Azure storage accounts, remaining accessible to many applications at once. Each blob (file) is replicated 3x within the data center. If you choose to use geo-replication on your account you also get 3 copies of the data in another data center within the same region. The data is chunked and distributed to nodes when a job is run. If you need to change the chunk size for memory related performance at run time that is still an option. You can pass in any Hadoop configuration parameter setting when you create the cluster or you can use the SET command for a given job.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Isn&#39;t one of the selling points of Hadoop that the data sits with the compute? How does that work with WASB?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; margin-bottom: 10px;&quot;&gt;
Just like with any Hadoop system the data is loaded into memory on the individual nodes at compute time (when the job runs). The difference with WASB is that the data is loaded from the storage accounts instead of from local disks. Given the way Azure data center backbones are built the performance is generally the same or better than if you used disks locally attached to the VMs.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/4209560542573075957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/wasb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/4209560542573075957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/4209560542573075957'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/wasb.html' title='Wasb'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJbbGi1tcMJhvcNZN7k_9Pk2_NrP24sB77gQ6WHVY-MBcKLSjemmZ3P5jAkbFDe6u_1hKJAjgb_-FKwI0zndzjSElOb1vtmTFB9W23FSsQbaM_0DvyfIFC2n3JrCAnykpgYeCz-kp6RXE/s72-c/wasb.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1042702913368601588.post-2192070607733984270</id><published>2020-01-21T11:18:00.000-08:00</published><updated>2020-01-21T11:18:10.871-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache Spark"/><category scheme="http://www.blogger.com/atom/ns#" term="DSTREAM"/><title type='text'>DStream vs RDD</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSHPDvBnEYq3eU04BzT119US5KPn5soS-w600dy9JvjpsfCyaZ3P2Q6U6RoSfwY6PGA-Ab4PmXMHjssjdjtc4vxNe6IjZfTUcMTXCyyWe89d6knX_RHHXOWLSMZN27_jczOUH4tzxUytw/s1600/Dstreams.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;764&quot; data-original-width=&quot;1389&quot; height=&quot;352&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSHPDvBnEYq3eU04BzT119US5KPn5soS-w600dy9JvjpsfCyaZ3P2Q6U6RoSfwY6PGA-Ab4PmXMHjssjdjtc4vxNe6IjZfTUcMTXCyyWe89d6knX_RHHXOWLSMZN27_jczOUH4tzxUytw/s640/Dstreams.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;DSTREAM TRANSFORM&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLRlOLISNZKOvHIALqzEe-jGkbKtvuEocXQsYGytqiTzYCwEE98hY4LCOpn0jA3l5f3V76L3aYKD1U4gjuPAQy5HOLxUiG9LPi4e33XDRcvP6SK6DOjpoEqfS41Cm767KV4NmBphHfXp0/s1600/TransformDstream.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;553&quot; data-original-width=&quot;1349&quot; height=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLRlOLISNZKOvHIALqzEe-jGkbKtvuEocXQsYGytqiTzYCwEE98hY4LCOpn0jA3l5f3V76L3aYKD1U4gjuPAQy5HOLxUiG9LPi4e33XDRcvP6SK6DOjpoEqfS41Cm767KV4NmBphHfXp0/s640/TransformDstream.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxDy4L0-YvgcgoSdZRYx20HLO7hGOFZbggrbhliT6LNJPJyJ36GikK93ZrzxOZ2ovJvApiF1P-x7x6DDtqrKSpl_njhyqjVteW9sqjQ057tbr6u1ADSDtD0gOAPwTBBmlsrZmJaaB-3nE/s1600/Dstreams_01.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;745&quot; data-original-width=&quot;1382&quot; height=&quot;344&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxDy4L0-YvgcgoSdZRYx20HLO7hGOFZbggrbhliT6LNJPJyJ36GikK93ZrzxOZ2ovJvApiF1P-x7x6DDtqrKSpl_njhyqjVteW9sqjQ057tbr6u1ADSDtD0gOAPwTBBmlsrZmJaaB-3nE/s640/Dstreams_01.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;DSTREAM&amp;nbsp; foreachRDD&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAGmrLp17wKltBJtuCBSexZEp08VrIGwM0Nvr2o9pd8P3X6F2X0ZM9UL_hy-I-3UNNGzD_pa_L-RId98GYyLQkhxAdQkV7NBPawXUDE6J2D6Ir7ldo2JOr3EfGsgD-agK5guDMoc6Gm4/s1600/Dstreams_02.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;759&quot; data-original-width=&quot;1465&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAGmrLp17wKltBJtuCBSexZEp08VrIGwM0Nvr2o9pd8P3X6F2X0ZM9UL_hy-I-3UNNGzD_pa_L-RId98GYyLQkhxAdQkV7NBPawXUDE6J2D6Ir7ldo2JOr3EfGsgD-agK5guDMoc6Gm4/s640/Dstreams_02.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.prathapkudupublog.com/feeds/2192070607733984270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.prathapkudupublog.com/2020/01/dstream-vs-rdd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/2192070607733984270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1042702913368601588/posts/default/2192070607733984270'/><link rel='alternate' type='text/html' href='http://www.prathapkudupublog.com/2020/01/dstream-vs-rdd.html' title='DStream vs RDD'/><author><name>Prathap Kudupu</name><uri>http://www.blogger.com/profile/16371801182403879026</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDqtm7QSapLb0NJTQ6NW5KkizAoXmoVhPpgCBympjku6aceJblQhDyUc8wmewZllFPhVBJ7WfcNPu9EWvN6gNPlXqKrCMkXTFvjS4YIT2jjBcbXQhkkklHsoqPRV1uGYI/s113/Prathap.PNG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSHPDvBnEYq3eU04BzT119US5KPn5soS-w600dy9JvjpsfCyaZ3P2Q6U6RoSfwY6PGA-Ab4PmXMHjssjdjtc4vxNe6IjZfTUcMTXCyyWe89d6knX_RHHXOWLSMZN27_jczOUH4tzxUytw/s72-c/Dstreams.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>