<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC3%2FImage-manipulation-using-Arrays%2FEnglish-timed</id>
		<title>Python-3.4.3/C3/Image-manipulation-using-Arrays/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC3%2FImage-manipulation-using-Arrays%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Image-manipulation-using-Arrays/English-timed&amp;action=history"/>
		<updated>2026-04-10T02:22:14Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Image-manipulation-using-Arrays/English-timed&amp;diff=47666&amp;oldid=prev</id>
		<title>Pratik kamble: Created page with &quot;{| border=1 | '''Time''' | '''Narration'''  |- | 00:01 | Welcome to the spoken tutorial on '''Image manipulation using arrays'''.   |- | 00:07 |In this tutorial, you will lear...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Image-manipulation-using-Arrays/English-timed&amp;diff=47666&amp;oldid=prev"/>
				<updated>2019-06-03T10:00:18Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| border=1 | &amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039; | &amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;  |- | 00:01 | Welcome to the spoken tutorial on &amp;#039;&amp;#039;&amp;#039;Image manipulation using arrays&amp;#039;&amp;#039;&amp;#039;.   |- | 00:07 |In this tutorial, you will lear...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
| '''Time'''&lt;br /&gt;
| '''Narration'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:01&lt;br /&gt;
| Welcome to the spoken tutorial on '''Image manipulation using arrays'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:07&lt;br /&gt;
|In this tutorial, you will learn to - &lt;br /&gt;
&lt;br /&gt;
Read '''images''' into '''arrays'''&lt;br /&gt;
&lt;br /&gt;
Perform processing on them using simple array manipulations &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:19&lt;br /&gt;
|To record this tutorial, I am using &lt;br /&gt;
&lt;br /&gt;
'''Ubuntu Linux 16.04''' operating system&lt;br /&gt;
&lt;br /&gt;
'''Python 3.4.3 '''and&lt;br /&gt;
&lt;br /&gt;
'''IPython 5.1.0'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:35&lt;br /&gt;
| To practise this tutorial, you should know how to   run basic '''Python commands''' on the '''ipython console '''and  access parts of '''arrays'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:46&lt;br /&gt;
|If not, see the relevant '''Python '''tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:51&lt;br /&gt;
| Please download the files''' Squares.png '''and '''Python.png''' from the '''Code files''' link of this tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:00&lt;br /&gt;
| Save the files in the current '''working directory'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:04&lt;br /&gt;
| First we will learn how to '''access''' parts of an '''array'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:09&lt;br /&gt;
| For this purpose, we shall use the image '''Squares.png''' present in the current '''working directory'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:16&lt;br /&gt;
| Let us start '''ipython'''. Open the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:21&lt;br /&gt;
| Type '''ipython3 '''and press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:26&lt;br /&gt;
| From here onwards remember to press the '''Enter''' key after typing every '''command''' on the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:33&lt;br /&gt;
| To read an '''image''' into an '''array''', we use the '''imread command'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:38&lt;br /&gt;
| Let us now read the data in '''Squares.png''' into the array '''img'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:44&lt;br /&gt;
| Type, '''import matplotlib.pyplot as plt'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:51&lt;br /&gt;
| Then type, '''img''''' is equal to''''' plt.imread '''''inside brackets inside single quotes '''''Squares.png '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:02&lt;br /&gt;
| In the first line '''pyplot''' is imported from '''matplotlib '''module with '''plt '''as alias.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:09&lt;br /&gt;
| This is to make use of '''methods''' like '''imread '''which are part of '''pyplot.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:15&lt;br /&gt;
| We can see the image by using the '''functions imshow''' followed by '''show'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:21&lt;br /&gt;
| Type, '''plt.imshow '''''inside brackets '''''img''' Then type, '''plt.show '''''open and close brackets''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:33&lt;br /&gt;
| It displays the image in a separate popup window.The original image is in the black and white.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:41&lt;br /&gt;
| But here we do not see black and white, because '''imshow''' has '''mapped''' black and white to different colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:49&lt;br /&gt;
| This can be changed by using a different '''color map'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:53&lt;br /&gt;
| Close the image window to return to the '''IPython console'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:58&lt;br /&gt;
| In order to see the original black and white image type, '''plt.imshow '''''inside brackets '''''img '''''comma''''' cmap '''''is equal to inside single quotes '''''gray'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:13&lt;br /&gt;
| Then type, '''plt.show '''''open and close brackets''. Now we can see the image in black and white.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:22&lt;br /&gt;
| Close the image now.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:24&lt;br /&gt;
| To see what has been read into '''img''' variable, type,'''img'''. We can see that an '''array''' is displayed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:34&lt;br /&gt;
| To check the '''dimensions''' of any '''array''', we can use '''shape function'''.  Type, '''img.shape '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:44&lt;br /&gt;
| As we can see, we got the dimensions of the image. The image''' Squares.png''' has the dimensions of 300 by 300. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:54&lt;br /&gt;
| Now, we wish to obtain the top left quarter of the image.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:59&lt;br /&gt;
| To do this, we need to access top half of the rows and left half of the columns of the '''array'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:06&lt;br /&gt;
| We know that the shape of the image is 300 by 300.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:11&lt;br /&gt;
| For '''top'''-'''left''' '''corner''' of the '''image '''we need first 150 '''rows''' and the first 150 '''columns'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:19&lt;br /&gt;
| So type, '''img '''''inside square brackets colon''''' 150 '''''comma colon''''' 150'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:27&lt;br /&gt;
| This gives us the '''top'''-'''left''' '''corner''' of the '''image'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:32&lt;br /&gt;
| We use the '''imshow command''' to see the slice we obtained in the form of an image. Type as shown. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:42&lt;br /&gt;
| We got the required slice now. Close this image.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:48&lt;br /&gt;
| Pause the video. Try this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:54&lt;br /&gt;
| Obtain the square in the center of the image '''Squares.png''' with size 150 by 150. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:02&lt;br /&gt;
| Since we need to get center of the image, we take rows from one-fourth to three-fourth of the rows i.e. from '''75''' to '''225''' and  columns from one-fourth to three-fourth of the columns, i.e. from '''75''' to '''225'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:21&lt;br /&gt;
| Switch to the '''terminal''' for the solution. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:25&lt;br /&gt;
| Type as shown. Hence, we get the center of the image. Close this image.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:34&lt;br /&gt;
| You can also save the sliced image '''array''' to a new variable.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:39&lt;br /&gt;
| Type, '''img1''''' is equal to''''' img''''' inside square brackets '''''75 '''''colon '''''225 '''''comma''''' 75 '''''colon '''''225]''' Then to see the image type as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:56&lt;br /&gt;
| Close this image window&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:59&lt;br /&gt;
| We also know how to '''stride''' over an '''array.''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:03&lt;br /&gt;
| For that we can drop alternate rows and columns out of the image. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:08&lt;br /&gt;
| Type, '''img '''''inside square brackets colon colon '''''2 '''''comma colon colon '''''2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:16&lt;br /&gt;
| To see this image, type as shown. We can see that the scale has reduced. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:24&lt;br /&gt;
| We can observe some '''blurring''' near the '''edges '''if you scale it down further.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:30&lt;br /&gt;
| Close the image window to return to the '''IPython console'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:35&lt;br /&gt;
| To increase the '''step''' to 4, type as shown.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:41&lt;br /&gt;
| Close the image window to return to the '''IPython console'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:45&lt;br /&gt;
| We shall use the '''Python.png''' present in the current '''working directory'''.Now we have an '''RGB''' image.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:54&lt;br /&gt;
| Let us slice the image and see what happens.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:58&lt;br /&gt;
| Type as shown. We can see the image. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:03&lt;br /&gt;
| Close the image window to return to the '''IPython console'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:07&lt;br /&gt;
| To check the dimensions of '''img''', we can use '''shape function'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:12&lt;br /&gt;
| Type, '''img.shape '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:16&lt;br /&gt;
| The third number shows that there are 4 channels. These are corresponding to red, green, blue, and transparency value of the image.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:28&lt;br /&gt;
| The first number shows that the height of the image is 600. The second number shows that the width of the image is also 600.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:39&lt;br /&gt;
| Now we will slice the red channel of the '''array'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:43&lt;br /&gt;
| Type, '''plt.imshow '''''inside brackets''''' img '''''inside square brackets colon comma colon comma '''''0'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:53&lt;br /&gt;
| Then type, '''plt.show '''''open and close brackets.''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:00&lt;br /&gt;
| We got the required red channel of the '''array'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:04&lt;br /&gt;
| Close this image.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:06&lt;br /&gt;
| This brings us to the end of this tutorial. Let us summarize. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:12&lt;br /&gt;
|In this tutorial, we have learned to,&lt;br /&gt;
&lt;br /&gt;
Read '''images''' into '''arrays''' and manipulate them. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:19&lt;br /&gt;
| Here is a self assessment question for you to solve &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:23&lt;br /&gt;
| The shape of the variable '''img''' is (600, 600, 4). &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:29&lt;br /&gt;
| What will be the shape of '''img1''' if '''img1''' ''is equal to'' '''img''' ''inside brackets colon colon ''2 ''comma colon colon ''4&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:39&lt;br /&gt;
| And the answer is, (300, 150, 4)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:45&lt;br /&gt;
| Please post your timed queries in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:49&lt;br /&gt;
| Please post your general queries on Python in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:54&lt;br /&gt;
| FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:58&lt;br /&gt;
| Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India. For more details, visit this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:07&lt;br /&gt;
| This is Priya from IIT Bombay signing off. Thanks for watching.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pratik kamble</name></author>	</entry>

	</feed>