{"id":2136,"date":"2026-05-14T16:49:06","date_gmt":"2026-05-14T12:49:06","guid":{"rendered":"https:\/\/iremi.univ-reunion.fr\/?p=2136"},"modified":"2026-05-14T16:53:05","modified_gmt":"2026-05-14T12:53:05","slug":"homothetie","status":"publish","type":"post","link":"https:\/\/iremi.univ-reunion.fr\/?p=2136","title":{"rendered":"G\u00e9om\u00e9trie de l&rsquo;espace des couleurs"},"content":{"rendered":"\n<p>Au programme de SNT, on peut lire parmi les capacit\u00e9s attendues :<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Traiter par programme une image pour la transformer en agissant sur les trois composantes de ses points.<\/p>\n<\/blockquote>\n\n\n\n<p>Or puisque les points (pixels en fait) d&rsquo;une photo ont trois composantes, c&rsquo;est que les couleurs sont plac\u00e9es dans un espace de dimension 3, en prenant<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pour abscisse le niveau de rouge (de 0 \u00e0 255),<\/li>\n\n\n\n<li>pour ordonn\u00e9e le niveau de vert (de 0 \u00e0 255),<\/li>\n\n\n\n<li>pour hauteur le niveau de bleu (de 0 \u00e0 255).<\/li>\n<\/ul>\n\n\n\n<p>Changer les couleurs d&rsquo;une photo (par exemple pour la d\u00e9saturer) peut donc se faire par des transformations de l&rsquo;espace de dimension 3. Bouger des points (y compris par des rotations dans l&rsquo;espace) peut se faire  <a href=\"http:\/\/revue.sesamath.net\/spip.php?article1587\">avec Css<\/a>, mais ici, c&rsquo;est bien dans l&rsquo;espace des couleurs qu&rsquo;on va effectuer ces transformations (sym\u00e9tries, rotations, homoth\u00e9ties, projections) et ce sont des couleurs qu&rsquo;on va changer. Et, comme par ailleurs, le programme de SNT pr\u00e9cise aussi :<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Au moment de la conception de ce programme, le langage choisi est Python version 3 (ou sup\u00e9rieure).<\/p>\n<\/blockquote>\n\n\n\n<p>C&rsquo;est donc en Python qu&rsquo;on va programmer ces filtres photo, avec le module <code>PIL<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from PIL import Image\nimg = Image.open('CamphrierTampon2.jpg')\n(largeur,hauteur) = img.size<\/code><\/pre>\n\n\n\n<p>On constate que les dimensions de la photo forment un couple (largeur,hauteur). Les \u00e9l\u00e8ves sont cens\u00e9s retoucher leurs propres photos mais au cas o\u00f9, il a \u00e9t\u00e9 choisi <a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:CamphrierTampon2.jpg\">cette photo<\/a> sous licence Creative Commons, extraite de <a href=\"https:\/\/fr.wikipedia.org\/wiki\/Le_Tampon\">l&rsquo;article sur Le Tampon<\/a> :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/CamphrierTampon2.jpg\" alt=\"\" class=\"wp-image-2139\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/CamphrierTampon2.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/CamphrierTampon2-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/CamphrierTampon2-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>On remarque qu&rsquo;il y a une voiture bleue tout \u00e0 gauche, et, \u00e0 c\u00f4t\u00e9 de celle-ci, une voiture rouge. Cela va changer si on inverse les composantes rouge et bleue :<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sym\u00e9trie<\/h2>\n\n\n\n<p>On effectue une sym\u00e9trie par rapport au plan vert (les composantes rouge et bleue sont \u00e9gales) en parcourant l&rsquo;image pixel par pixel, et en lisant les couleurs du pixel, puis en modifiant celui-ci avec <code>(b,g,r)<\/code> au lieu de <code>(r,g,b)<\/code> :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for x in range(largeur):\n    for y in range(hauteur):\n        (r,g,b) = img.getpixel((x,y))\n        img.putpixel((x,y),(b,g,r))<\/code><\/pre>\n\n\n\n<p>Sans surprise, la voiture rouge est devenue bleue, et vice-versa :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriermirroir.jpg\" alt=\"\" class=\"wp-image-2141\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriermirroir.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriermirroir-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriermirroir-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Pour voir la photo retouch\u00e9e, on peut faire<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>img.show()<\/code><\/pre>\n\n\n\n<p>mais il faut attendre quelques secondes pour que le script Python ait parcouru tous les pixels de l&rsquo;image&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rotations<\/h2>\n\n\n\n<p>On tourne autour de l&rsquo;axe des gris, de 120\u00b0, d&rsquo;abord dans un sens avec <code>img.putpixel((x,y),(g,b,r))<\/code> :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation1.jpg\" alt=\"\" class=\"wp-image-2143\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation1.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation1-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation1-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>puis dans l&rsquo;autre avec <code>img.putpixel((x,y),(b,r,g))<\/code> :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation2.jpg\" alt=\"\" class=\"wp-image-2144\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation2.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation2-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierrotation2-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Projections<\/h2>\n\n\n\n<p>Pour projeter sur le plan des images sans rouge, on fait <code>img.putpixel((x,y),(0,g,b))<\/code>, ce qui donne une image sans rouge :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection1.jpg\" alt=\"\" class=\"wp-image-2146\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection1.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection1-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection1-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>et pour projeter sur le plan sans bleu, on fait <code>img.putpixel((x,y),(r,g,0))<\/code>, ce qui donne une image sans bleu (ce qui imite certaines formes de daltonisme) :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection2.jpg\" alt=\"\" class=\"wp-image-2147\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection2.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection2-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection2-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>On peut aussi projeter sur une droite comme celle des gris (r=g=b), avec <code>img.putpixel((x,y),(g,g,g))<\/code>, ce qui donne une image en niveaux de gris :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection3.jpg\" alt=\"\" class=\"wp-image-2150\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection3.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection3-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierprojection3-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<h4 class=\"wp-block-post-title\">G\u00e9om\u00e9trie de l&rsquo;espace des couleurs<\/h4>\n\n\n<h2 class=\"wp-block-heading\">Homoth\u00e9ties<\/h2>\n\n\n\n<p>Comme on veut \u00e9viter de d\u00e9passer 255 comme valeur de rouge, vert ou bleu, on choisit un rapport d&rsquo;homoth\u00e9tie inf\u00e9rieur \u00e0 1, par exemple 1\/2. On va donc remplacer chaque composante par sa moiti\u00e9 enti\u00e8re avec <code>img.putpixel((x,y),(r\/\/2,g\/\/2,b\/\/2))<\/code> ce qui donne une image plu sombre :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierhomothetie.jpg\" alt=\"\" class=\"wp-image-2152\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierhomothetie.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierhomothetie-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphrierhomothetie-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Solarisation<\/h2>\n\n\n\n<p>On peut faire des choses plus riches, par exemple en donnant \u00e0 chaque pixel une teinte en arc-en-ciel, qui \u00e9voque une solarisation, avec la formule <code>img.putpixel((x,y),(255-g,255-abs(g-128),g))<\/code> :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriersolar.jpg\" alt=\"\" class=\"wp-image-2153\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriersolar.jpg 1024w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriersolar-300x225.jpg 300w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/camphriersolar-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">G\u00e9olocalisation<\/h2>\n\n\n\n<p>L&rsquo;arbre photographie ci-dessus se trouve aux coordonn\u00e9es (-21.281207 , 55.521736) ce qui permet de le voir d&rsquo;un autre angle sur photos satellite, par exemple sur G\u00e9oportail :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"455\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/Capture-decran-2026-05-14-164151.png\" alt=\"\" class=\"wp-image-2155\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/Capture-decran-2026-05-14-164151.png 707w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/Capture-decran-2026-05-14-164151-300x193.png 300w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p>ou sur maps :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"353\" src=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/Capture-decran-2026-05-14-164636.png\" alt=\"\" class=\"wp-image-2156\" srcset=\"https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/Capture-decran-2026-05-14-164636.png 565w, https:\/\/iremi.univ-reunion.fr\/wp-content\/uploads\/2026\/05\/Capture-decran-2026-05-14-164636-300x187.png 300w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/figure>\n\n\n\n<p>Le \u00ab\u00a0gigantesque pied de bois\u00a0\u00bb est en fait un ravintsara.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Au programme de SNT, on peut lire parmi les capacit\u00e9s attendues : Traiter par programme une image pour la transformer en agissant sur les trois composantes de ses points. Or puisque les points (pixels en fait) d&rsquo;une photo ont trois composantes, c&rsquo;est que les couleurs sont plac\u00e9es dans un espace de dimension 3, en prenant [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,4,10],"tags":[80],"coauthors":[54],"class_list":["post-2136","post","type-post","status-publish","format-standard","hentry","category-algorithmes-programmation-et-langages","category-geometrie","category-machines-information-codage","tag-snt"],"_links":{"self":[{"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=\/wp\/v2\/posts\/2136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2136"}],"version-history":[{"count":14,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=\/wp\/v2\/posts\/2136\/revisions"}],"predecessor-version":[{"id":2161,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=\/wp\/v2\/posts\/2136\/revisions\/2161"}],"wp:attachment":[{"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2136"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/iremi.univ-reunion.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcoauthors&post=2136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}