diff --git a/photo numérique/activité_décryptage_image/sujet.pdf b/photo numérique/activité_décryptage_image/sujet.pdf index 0368236..2b0aa94 100644 Binary files a/photo numérique/activité_décryptage_image/sujet.pdf and b/photo numérique/activité_décryptage_image/sujet.pdf differ diff --git a/photo numérique/activité_décryptage_image/sujet.tex b/photo numérique/activité_décryptage_image/sujet.tex index ad88f20..09586e8 100644 --- a/photo numérique/activité_décryptage_image/sujet.tex +++ b/photo numérique/activité_décryptage_image/sujet.tex @@ -82,9 +82,9 @@ Chacune de ces informations a un nom et une valeur : \hline SOF0 & « Start Of Frame », il indique les dimensions, le nombre de couleurs et la profondeur des couleurs & 4 valeurs : L,H,N,P = largeur, hauteur, nombre de couleurs, profondeur des couleurs\\ \hline - DHT & Define Huffman Table & Informations de compression codées en base64 \\ + DHT & Define Huffman Table & Informations non utilisées codées en base64 \\ \hline - DRI & Define Quantization Table & Informations de compression codées en hexadécimal \\ + DRI & Define Quantization Table & Informations non utilisées codées en hexadécimal \\ \hline SOS & « Start Of Scan », indique le début de la description des pixels & Une suite de chiffres contenant les couleurs de chaque pixels \\ \hline @@ -196,10 +196,19 @@ Chacune de ces informations a un nom et une valeur : \newcommand{\picHeartrot}{0°} \newcommand{\picExclamation}{\R\K\G\B\W\R\K\G\B\W\\\R\K\G\B\W\R\R\G\W\W\\\R\K\G\B\W} % Deux points d’exclamation \newcommand{\picExclamationrot}{0°} + \newcommand{\picFirst}{\K\B\B\B\R\K\K\B\R\R\\\W\W\B\W\W\R\R\B\B\K\\\R\R\B\K\K} % Un 1 \newcommand{\picFirstrot}{180°} +\newcommand{\picFour}{\K\W\K\K\K\K\B\K\K\K\\\K\G\G\G\K\K\R\K\R\K\\\K\W\K\W\K} % Un 4 +\newcommand{\picFourrot}{180°} \newcommand{\picSixth}{\G\B\B\B\G\W\B\W\W\W\\\G\B\B\B\G\W\B\W\B\W\\\G\B\B\B\G} % Un 6 \newcommand{\picSixthrot}{0°} +\newcommand{\picSeven}{\R\R\K\K\K\B\G\B\G\B\\\G\R\K\K\K\B\R\K\K\K\\\R\R\K\K\K} % Un 7 +\newcommand{\picSevenrot}{-90°} +\newcommand{\picEight}{\G\B\W\B\G\K\K\K\K\K\\\K\R\K\R\K\K\K\K\K\K\\\G\B\W\B\G} % Un 8 +\newcommand{\picEightrot}{90°} +\newcommand{\picFourteen}{\R\R\R\R\R\K\W\K\W\K\\\W\K\G\G\G\K\W\G\B\B\\\G\G\G\G\G} % Un 14 +\newcommand{\picFourteenrot}{90°} \newcommand{\picFiveteen}{\G\R\G\G\G\G\R\G\W\G\\\G\G\G\W\G\R\R\R\W\W\\\B\B\B\B\B} % Un 15 \newcommand{\picFiveteenrot}{-90°} \newcommand{\picSeventeen}{\K\G\K\K\K\K\W\G\W\K\\\K\G\G\G\K\K\W\G\W\K\\\K\G\G\G\K} % Un 17 @@ -215,11 +224,35 @@ Chacune de ces informations a un nom et une valeur : \image{\picV}{\datefour}{\latfour}{\longfour}{\picVrot}{\^} \image{\picE}{\datefive}{\latfive}{\longfive}{\picErot}{3} \image{\picSecond}{\datesix}{\latsix}{\longsix}{\picSecondrot}{sec} -\image{\picFirst}{\dateseven}{\latseven}{\longseven}{\picFirstrot}{first} -\image{\picSixth}{\dateseven}{\latseven}{\longseven}{\picSixthrot}{sixth} -\image{\picFiveteen}{\dateseven}{\latseven}{\longseven}{\picFiveteenrot}{fifteenth} -\image{\picSeventeen}{\dateseven}{\latseven}{\longseven}{\picSeventeenrot}{seventeenth} -\image{\picEighteen}{\dateseven}{\latseven}{\longseven}{\picEighteenrot}{eighteenth} +\image{\picI}{\dateone}{\latone}{\longone}{\picIrot}{i} +\image{\picL}{\datetwo}{\lattwo}{\longtwo}{\picLrot}{l} +\image{\picO}{\datethree}{\latthree}{\longthree}{\picOrot}{0} +\image{\picV}{\datefour}{\latfour}{\longfour}{\picVrot}{\^} +\image{\picE}{\datefive}{\latfive}{\longfive}{\picErot}{3} +\image{\picSecond}{\datesix}{\latsix}{\longsix}{\picSecondrot}{sec} +\image{\picI}{\dateone}{\latone}{\longone}{\picIrot}{i} +\image{\picL}{\datetwo}{\lattwo}{\longtwo}{\picLrot}{l} +\image{\picO}{\datethree}{\latthree}{\longthree}{\picOrot}{0} +\image{\picV}{\datefour}{\latfour}{\longfour}{\picVrot}{\^} +\image{\picE}{\datefive}{\latfive}{\longfive}{\picErot}{3} +\image{\picSecond}{\datesix}{\latsix}{\longsix}{\picSecondrot}{sec} +\image{\picI}{\dateone}{\latone}{\longone}{\picIrot}{i} +\image{\picL}{\datetwo}{\lattwo}{\longtwo}{\picLrot}{l} +\image{\picO}{\datethree}{\latthree}{\longthree}{\picOrot}{0} +\image{\picV}{\datefour}{\latfour}{\longfour}{\picVrot}{\^} +\image{\picE}{\datefive}{\latfive}{\longfive}{\picErot}{3} +\image{\picSecond}{\datesix}{\latsix}{\longsix}{\picSecondrot}{sec} +%\image{\picFirst}{\dateseven}{\latseven}{\longseven}{\picFirstrot}{first} +\image{\picFour}{\dateseven}{\latseven}{\longseven}{\picFourrot}{kat} +%\image{\picSixth}{\dateseven}{\latseven}{\longseven}{\picSixthrot}{sixth} +\image{\picSeven}{\dateseven}{\latseven}{\longseven}{\picSevenrot}{cet} +\image{\picEight}{\dateseven}{\latseven}{\longseven}{\picEightrot}{uit} +\image{\picFourteen}{\dateseven}{\latseven}{\longseven}{\picFourteenrot}{qtrz} +%\image{\picFiveteen}{\dateseven}{\latseven}{\longseven}{\picFiveteenrot}{fifteenth} +%\image{\picSeventeen}{\dateseven}{\latseven}{\longseven}{\picSeventeenrot}{seventeenth} +%\image{\picEighteen}{\dateseven}{\latseven}{\longseven}{\picEighteenrot}{eighteenth} +\image{\picHeart}{\dateeight}{\lateight}{\longeight}{\picHeartrot}{k} +\image{\picExclamation}{\datenine}{\latnine}{\longnine}{\picExclamationrot}{punct} \image{\picHeart}{\dateeight}{\lateight}{\longeight}{\picHeartrot}{k} \image{\picExclamation}{\datenine}{\latnine}{\longnine}{\picExclamationrot}{punct} \end{document} diff --git a/photo numérique/activité_décryptage_image/test_tp_adrian.py b/photo numérique/activité_décryptage_image/test_tp_adrian.py new file mode 100644 index 0000000..3e5ac6c --- /dev/null +++ b/photo numérique/activité_décryptage_image/test_tp_adrian.py @@ -0,0 +1,89 @@ +# -*- coding: cp1252 -*- +import subprocess +import os +import re + +couleurs = {"K": "black","R": "red","G": "green","B": "blue","W": "white"} + +text = """ +\newcommand{\picI}{\K\B\B\B\K\W\K\G\K\W\\\K\W\G\W\K\W\K\G\K\W\\\K\R\R\R\K} % Un I +% La seconde est sa rotation +\newcommand{\picIrot}{180�} +\newcommand{\picL}{\B\R\G\G\G\B\K\G\G\G\\\B\R\G\G\G\B\K\G\G\G\\\B\R\K\R\G} % Un L +\newcommand{\picLrot}{0�} +\newcommand{\picO}{\K\B\G\R\K\K\W\W\W\K\\\W\B\G\R\W\K\W\W\W\K\\\K\B\G\R\K} % Un O +\newcommand{\picOrot}{90�} +\newcommand{\picV}{\B\G\B\G\B\R\G\R\G\R\\\K\G\K\G\K\R\G\R\G\R\\\B\B\G\B\B} % Un V +\newcommand{\picVrot}{0�} +\newcommand{\picE}{\K\K\K\K\K\W\W\W\W\W\\\W\R\W\R\W\W\R\R\R\W\\\R\R\B\R\R} % Un E +\newcommand{\picErot}{90�} +\newcommand{\picSecond}{\W\W\W\B\W\B\K\W\K\B\\\W\W\W\B\K\W\K\B\K\B\\\W\W\W\B\K} % Un 2 +\newcommand{\picSecondrot}{0�} +\newcommand{\picHeart}{\K\R\K\R\K\R\G\R\G\R\\\R\G\W\G\R\K\R\G\R\K\\\K\K\R\K\K} % Un c�ur +\newcommand{\picHeartrot}{0�} +\newcommand{\picExclamation}{\R\K\G\B\W\R\K\G\B\W\\\R\K\G\B\W\R\R\G\W\W\\\R\K\G\B\W} % Deux points d�exclamation +\newcommand{\picExclamationrot}{0�} + +\newcommand{\picFirst}{\K\B\B\B\R\K\K\B\R\R\\\W\W\B\W\W\R\R\B\B\K\\\R\R\B\K\K} % Un 1 +\newcommand{\picFirstrot}{180�} +\newcommand{\picFour}{\K\W\K\K\K\K\B\K\K\K\\\K\G\G\G\K\K\R\K\R\K\\\K\W\K\W\K} % Un 4 +\newcommand{\picFourrot}{180�} +\newcommand{\picSixth}{\G\B\B\B\G\W\B\W\W\W\\\G\B\B\B\G\W\B\W\B\W\\\G\B\B\B\G} % Un 6 +\newcommand{\picSixthrot}{0�} +\newcommand{\picSeven}{\R\R\K\K\K\B\G\B\G\B\\\G\R\K\K\K\B\R\K\K\K\\\R\R\K\K\K} % Un 7 +\newcommand{\picSevenrot}{-90�} +\newcommand{\picEight}{\G\B\W\B\G\K\K\K\K\K\\\K\R\K\R\K\K\K\K\K\K\\\G\B\W\B\G} % Un 8 +\newcommand{\picEightrot}{90�} +\newcommand{\picFourteen}{\R\R\R\R\R\K\W\K\W\K\\\W\K\G\G\G\K\W\G\B\B\\\G\G\G\G\G} % Un 14 +\newcommand{\picFourteenrot}{90�} +\newcommand{\picFiveteen}{\G\R\G\G\G\G\R\G\W\G\\\G\G\G\W\G\R\R\R\W\W\\\B\B\B\B\B} % Un 15 +\newcommand{\picFiveteenrot}{-90�} +\newcommand{\picSeventeen}{\K\G\K\K\K\K\W\G\W\K\\\K\G\G\G\K\K\W\G\W\K\\\K\G\G\G\K} % Un 17 +\newcommand{\picSeventeenrot}{0�} +\newcommand{\picEighteen}{\R\R\R\R\R\K\W\K\W\K\\\G\G\G\G\G\G\B\G\B\G\\\G\G\G\G\G} % Un 18 +\newcommand{\picEighteenrot}{90�} +""" + +dir_path = os.path.dirname(os.path.realpath(__file__)) +#firefox_path = 'D:/Program Files/Mozilla Firefox/firefox.exe' +firefox_path = 'firefox' + +def openFirefoxWithHtml(html) : + if os.path.exists('tmp.html'): + os.remove('tmp.html') + with open('tmp.html', 'w', encoding = 'utf8') as f: + f.write(html) + subprocess.run([firefox_path, 'file://'+dir_path+'/tmp.html']) + +def imageInTab(image): + string = '<table style="border-collapse: collapse; border: 1px solid black; display: inline-block; margin: 50px">' + for i in range(0,5) : + string += '<tr>' + for j in range(0,5) : + string += getPixelImage(image[i*5+j]) + string += '</tr>' + string += '</table>' + return string + +def getPixelImage(pixel): + return '<td style="width: 50px; height:50px; background-color:' + couleurs[pixel] + '"></td>' + +def test(tab): + string = '' + for image in tab: + string += imageInTab(image) + openFirefoxWithHtml(string) + +def text_to_list(text): + res = [] + p = re.compile('(\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW]\\\\[RGBKW])') + for line in text.split('\n'): + found = p.search(line) + if not found: + continue + res.append(list(found.group(0).replace('\\', ''))) + return res + + +test(text_to_list(text)) +