]> AND Private Git Repository - Cipher_code.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
authorRaphaël Couturier <raphael.couturier@univ-fcomte.fr>
Sun, 27 Jun 2021 09:44:05 +0000 (11:44 +0200)
committerRaphaël Couturier <raphael.couturier@univ-fcomte.fr>
Sun, 27 Jun 2021 09:44:05 +0000 (11:44 +0200)
measure_energy_iot/image_compression.py [new file with mode: 0644]

diff --git a/measure_energy_iot/image_compression.py b/measure_energy_iot/image_compression.py
new file mode 100644 (file)
index 0000000..3000f67
--- /dev/null
@@ -0,0 +1,55 @@
+from PIL import Image
+import time
+import cv2
+
+import sys
+
+quality=int(sys.argv[1])
+print("quality ",quality)
+
+im=Image.open("lena.jpg")
+elapsed_time=0
+
+for i in range(100):
+    t = time.process_time()
+    im.save("lena2.jpg",quality=quality)
+    elapsed_time += time.process_time() - t
+
+print("time pil",elapsed_time)
+
+
+
+
+
+elapsed_time=0
+for i in range(100):
+    t = time.process_time()
+    im2=im.resize((256, 256))
+    im2.save("lena3.jpg",quality=quality)
+    elapsed_time += time.process_time() - t
+
+print("time resize + pil",elapsed_time)
+
+
+
+
+img = cv2.imread('lena.jpg')
+elapsed_time=0
+
+
+for i in range(100):
+    t = time.process_time()
+    cv2.imwrite("lena4.jpg", img,[int(cv2.IMWRITE_JPEG_QUALITY), quality])
+    elapsed_time += time.process_time() - t
+
+print("time cv2",elapsed_time)
+
+
+
+for i in range(100):
+    t = time.process_time()
+    resized = cv2.resize(img, (256,256), interpolation=cv2.INTER_LINEAR)
+    cv2.imwrite("lena5.jpg", resized,[int(cv2.IMWRITE_JPEG_QUALITY), quality])
+    elapsed_time += time.process_time() - t
+
+print("time resize + cv2",elapsed_time)