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

<channel>
	<title>MB.MathemaTeX</title>
	<atom:link href="http://mb.mathematex.net/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://mb.mathematex.net/blog</link>
	<description>- Blog à vocation de Mémo Personnel -</description>
	<lastBuildDate>Sat, 24 Sep 2011 10:08:21 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rechercher des fichiers avec apt-file</title>
		<link>http://mb.mathematex.net/blog/?p=606</link>
		<comments>http://mb.mathematex.net/blog/?p=606#comments</comments>
		<pubDate>Sat, 24 Sep 2011 10:08:21 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=606</guid>
		<description><![CDATA[Le logiciel apt-file (à installer sous ubuntu via apt-get) permet de rechercher des fichiers dans l&#8217;ensemble des paquets disponibles dans les dépôts indiqués dans le sources.list. Par exemple : $ apt-file update $ apt-file search pdflatex]]></description>
			<content:encoded><![CDATA[<p>Le logiciel <strong>apt-file</strong> (à installer sous ubuntu via apt-get) permet de rechercher des fichiers dans l&#8217;ensemble des paquets disponibles dans les dépôts indiqués dans le sources.list. Par exemple :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-file</span> update
$ <span style="color: #c20cb9; font-weight: bold;">apt-file</span> search pdflatex</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=606</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Afficher les 10 plus gros consommateurs cpu</title>
		<link>http://mb.mathematex.net/blog/?p=603</link>
		<comments>http://mb.mathematex.net/blog/?p=603#comments</comments>
		<pubDate>Tue, 09 Aug 2011 19:03:47 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=603</guid>
		<description><![CDATA[On peut utiliser la commande suivante : ps -eo pcpu,pid,user,args &#124; sort -k 1 -r &#124; head -10]]></description>
			<content:encoded><![CDATA[<p>On peut utiliser la commande suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-eo</span> pcpu,pid,user,args <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-k</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-10</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=603</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Client ftp en ligne de commande : lftp</title>
		<link>http://mb.mathematex.net/blog/?p=601</link>
		<comments>http://mb.mathematex.net/blog/?p=601#comments</comments>
		<pubDate>Mon, 04 Jul 2011 11:15:15 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=601</guid>
		<description><![CDATA[La commande de base sous linux permettant de se connecter à un serveur ftp en ligne de commande est ftp. Cependant celle-ci a certaines limitations (notamment au niveau de l&#8217;affichage des caractères utf-8). Il est grandement préférable d&#8217;utiliser l&#8217;excellent lftp qui s&#8217;avère bien plus pratique et performant. $ lftp &#91;-d&#93; &#91;-e cmd&#93; &#91;-p port&#93; &#91;-u [...]]]></description>
			<content:encoded><![CDATA[<p>La commande de base sous linux permettant de se connecter à un serveur ftp en ligne de commande est <strong>ftp</strong>. Cependant celle-ci a certaines limitations (notamment au niveau de l&#8217;affichage des caractères utf-8). Il est grandement préférable d&#8217;utiliser l&#8217;excellent <strong>lftp</strong> qui s&#8217;avère bien plus pratique et performant.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ lftp <span style="color: #7a0874; font-weight: bold;">&#91;</span>-d<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-e cmd<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-p port<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-u user<span style="color: #7a0874; font-weight: bold;">&#91;</span>,pass<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>site<span style="color: #7a0874; font-weight: bold;">&#93;</span>
$ lftp <span style="color: #660033;">-f</span> script_file
$ lftp <span style="color: #660033;">-c</span> commands
$ lftp <span style="color: #660033;">--version</span>
$ lftp <span style="color: #660033;">--help</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=601</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Informations sur le matériel avec lshw</title>
		<link>http://mb.mathematex.net/blog/?p=599</link>
		<comments>http://mb.mathematex.net/blog/?p=599#comments</comments>
		<pubDate>Sun, 03 Jul 2011 15:53:24 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=599</guid>
		<description><![CDATA[La commande lshw (fournie dans le paquet debian du même nom) permet d&#8217;ontenir un grand nombre d&#8217;informations sur le matériel équipant la machine. On utilise simplement : $ sudo lshw]]></description>
			<content:encoded><![CDATA[<p>La commande <strong>lshw</strong> (fournie dans le paquet debian du même nom) permet d&#8217;ontenir un grand nombre d&#8217;informations sur le matériel équipant la machine. On utilise simplement :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> lshw</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=599</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monter un partage Samba (cli)</title>
		<link>http://mb.mathematex.net/blog/?p=595</link>
		<comments>http://mb.mathematex.net/blog/?p=595#comments</comments>
		<pubDate>Sun, 03 Jul 2011 08:42:41 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=595</guid>
		<description><![CDATA[L&#8217;objectif est de monter en ligne de commandes un partage samba. Pour ça, le paquet smbfs est nécessaire. On peut l&#8217;installer comme suit: $ sudo apt-get install smbfs Ensuite, pour monter le partage //server/share/ dans le dossier /media/smb/, on utilise la commande suivante: $ sudo mount -t smbfs //server/share/ /media/smb/ -o username=thename,password=thepassword ou $ sudo [...]]]></description>
			<content:encoded><![CDATA[<p>L&#8217;objectif est de monter en <strong>ligne de commandes</strong> un partage samba. Pour ça, le paquet smbfs est nécessaire. On peut l&#8217;installer comme suit:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> smbfs</pre></div></div>

<p>Ensuite, pour monter le partage //server/share/ dans le dossier /media/smb/, on utilise la commande suivante:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-t</span> smbfs <span style="color: #000000; font-weight: bold;">//</span>server<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>smb<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">username</span>=thename,<span style="color: #007800;">password</span>=thepassword</pre></div></div>

<p>ou</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> smbmount <span style="color: #000000; font-weight: bold;">//</span>server<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>smb<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">username</span>=thename,<span style="color: #007800;">password</span>=thepassword</pre></div></div>

<p>Pour un montage permanent, il faudra passer par <strong>fstab</strong>. Voir <a href="http://www.justlinux.com/nhf/Filesystems/Mounting_smbfs_Shares_Permanently.html">ici</a> pour plus de détails.</p>
]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=595</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ack(-grep) bien pratique</title>
		<link>http://mb.mathematex.net/blog/?p=591</link>
		<comments>http://mb.mathematex.net/blog/?p=591#comments</comments>
		<pubDate>Wed, 29 Jun 2011 22:12:50 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=591</guid>
		<description><![CDATA[Le programme ack peut se révéler très pratique pour tous ceux qui font parfois quelques recherches dans le code source d&#8217;une application qu&#8217;ils utilisent ou souhaitent utiliser. Ce programme, développé en perl, remplace avantageusement la classique conbinaison grep+find, comme le prouve l&#8217;exemple suivant: $ grep pattern $&#40;find . -name '*.pl' -or -name '*.pm' -or -name [...]]]></description>
			<content:encoded><![CDATA[<p>Le programme <a href="http://betterthangrep.com/">ack</a> peut se révéler très pratique pour tous ceux qui font parfois quelques recherches dans le code source d&#8217;une application qu&#8217;ils utilisent ou souhaitent utiliser. Ce programme, développé en perl, remplace avantageusement la classique conbinaison grep+find, comme le prouve l&#8217;exemple suivant:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">grep</span> pattern $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.pl'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.pm'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.pod'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> .svn<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ ack-grep <span style="color: #660033;">--perl</span> pattern</pre></div></div>

<p>Cette commande permet de rechercher la chaine &#8216;pattern&#8217; dans tous les fichiers perl présents dans le dossier courant et dans tous ses sous-dossiers. On constate que la version ack est bien plus agréable. Il affiche également le nom des fichiers qui contiennent les occurrences recherchées et affiche le numéro de ligne associé. Le tout est très rapide.</p>
<p>Pour installer ack (ou plus précisémement ack-grep) sous Debian :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ack-grep</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=591</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rechercher des fichiers avec locate</title>
		<link>http://mb.mathematex.net/blog/?p=587</link>
		<comments>http://mb.mathematex.net/blog/?p=587#comments</comments>
		<pubDate>Wed, 29 Jun 2011 09:58:13 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=587</guid>
		<description><![CDATA[Contrairement à la commande find, locate ne recherche pas directement les fichiers dans l&#8217;arborescence mais utilise une base de donnée. On peut mettre à jour cette base via la commande (à exécuter en root): $ sudo updatedb Les trois commandes suivantes sont équivalentes : $ locate pattern $ locate 'pattern' $ locate '*pattern*' Ces commandes [...]]]></description>
			<content:encoded><![CDATA[<p>Contrairement à la commande <strong>find</strong>, <strong>locate</strong> ne recherche pas directement les fichiers dans l&#8217;arborescence mais utilise une base de donnée. On peut mettre à jour cette base via la commande (à exécuter en root):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">updatedb</span></pre></div></div>

<p>Les trois commandes suivantes sont équivalentes :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">locate</span> pattern
$ <span style="color: #c20cb9; font-weight: bold;">locate</span> <span style="color: #ff0000;">'pattern'</span>
$ <span style="color: #c20cb9; font-weight: bold;">locate</span> <span style="color: #ff0000;">'*pattern*'</span></pre></div></div>

<p>Ces commandes vont rechercher tous les fichiers qui contiennent la chaîne <em>pattern</em> dans leur <strong>chemin complet</strong>. Si on ne souhaite recherche que dans les noms de fichiers (et non plus dans les chemins), on utilisera l&#8217;option <strong>-b</strong> (&#8211;basename).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">locate</span> <span style="color: #660033;">-b</span> pattern</pre></div></div>

<p>La commande suivante permet de rechercher des fichiers via leur nom exact (on ne souhaite donc pas que &#8216;pattern&#8217; devienne &#8216;*pattern*&#8217;).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">locate</span> <span style="color: #660033;">-b</span> <span style="color: #ff0000;">'\pattern'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=587</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Afficher l&#8217;utilisateur courant</title>
		<link>http://mb.mathematex.net/blog/?p=584</link>
		<comments>http://mb.mathematex.net/blog/?p=584#comments</comments>
		<pubDate>Tue, 28 Jun 2011 09:25:05 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=584</guid>
		<description><![CDATA[La commande whoami permet d&#8217;afficher l&#8217;utilsateur courant: $ whoami]]></description>
			<content:encoded><![CDATA[<p>La commande whoami permet d&#8217;afficher l&#8217;utilsateur courant:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">whoami</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=584</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Afficher la taille d&#8217;un dossier</title>
		<link>http://mb.mathematex.net/blog/?p=577</link>
		<comments>http://mb.mathematex.net/blog/?p=577#comments</comments>
		<pubDate>Sun, 26 Jun 2011 11:27:29 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=577</guid>
		<description><![CDATA[Le programme du (disk usage) permet de déterminer la taille d&#8217;un dossier : $ du -sh chemin_du_dossier L&#8217;option -s permet de n&#8217;afficher que la taille du dossier spécifié (et pas celle de tous ces sous-dossier) alors que l&#8217;option -h permet de rendre le résultat (ie la taille du dossier) plus lisible.]]></description>
			<content:encoded><![CDATA[<p>Le programme <strong>du</strong> (disk usage) permet de déterminer la taille d&#8217;un dossier :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-sh</span> chemin_du_dossier</pre></div></div>

<p>L&#8217;option <strong>-s</strong> permet de n&#8217;afficher que la taille du dossier spécifié (et pas celle de tous ces sous-dossier) alors que l&#8217;option <strong>-h</strong> permet de rendre le résultat (ie la taille du dossier) plus lisible.</p>
]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=577</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Traitement d&#8217;images</title>
		<link>http://mb.mathematex.net/blog/?p=574</link>
		<comments>http://mb.mathematex.net/blog/?p=574#comments</comments>
		<pubDate>Sun, 26 Jun 2011 09:52:14 +0000</pubDate>
		<dc:creator>MB</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://mb.mathematex.net/blog/?p=574</guid>
		<description><![CDATA[Le module Python Image permet (entre autres) de récupérer les informations concernant chaque pixel d&#8217;une image. Par exemple, nous allons utiliser ce module pour déterminer le nombre exact de pixels noirs contenus dans une image. 1 2 3 4 5 6 7 8 9 10 11 import Image black = &#40;0,0,0&#41; img = Image.open&#40;'./img.png'&#41; hsize [...]]]></description>
			<content:encoded><![CDATA[<p>Le module Python <a href="http://www.pythonware.com/products/pil/">Image</a> permet (entre autres) de récupérer les informations concernant chaque pixel d&#8217;une image. Par exemple, nous allons utiliser ce module pour déterminer le nombre exact de pixels noirs contenus dans une image.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> Image
black = <span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
img = Image.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'./img.png'</span><span style="color: black;">&#41;</span>
hsize = img.<span style="color: black;">size</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
vsize = img.<span style="color: black;">size</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
n = <span style="color: #ff4500;">0</span>
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>hsize<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>vsize<span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">if</span> img.<span style="color: black;">getpixel</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>i,j<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> == black:
			n = n+<span style="color: #ff4500;">1</span>
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Nombre de pixels noirs : '</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>n<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Cette méthode qui utilise <strong>getpixel</strong> est bien moins rapide (presque 7 fois plus lente) que la méthode suivante, basée sur <strong>load</strong>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> Image
black = <span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
img = Image.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'./img.png'</span><span style="color: black;">&#41;</span>
hsize = img.<span style="color: black;">size</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
vsize = img.<span style="color: black;">size</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
n = <span style="color: #ff4500;">0</span>
pixels = img.<span style="color: black;">load</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>hsize<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>vsize<span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">if</span> pixels<span style="color: black;">&#91;</span>i,j<span style="color: black;">&#93;</span> == black:
			n = n+<span style="color: #ff4500;">1</span>
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Nombre de pixels noirs : '</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>n<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Il faut utiliser Python 2.6 car le module n&#8217;est pas encore disponible pour les versions 3 de Python.</p>
]]></content:encoded>
			<wfw:commentRss>http://mb.mathematex.net/blog/?feed=rss2&#038;p=574</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

