Narzędzia użytkownika

Narzędzia witryny


notatki:autofocus

Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

Poprzednia rewizja po obu stronachPoprzednia wersja
Nowa wersja
Poprzednia wersja
notatki:autofocus [2025/05/21 20:32] – [Wyostrzanie poprzez kontrast (pasywne)] administratornotatki:autofocus [2025/05/21 20:44] (aktualna) administrator
Linia 51: Linia 51:
 <code python get_diff_pixel.py> <code python get_diff_pixel.py>
 from PIL import Image from PIL import Image
-import os 
-import sys 
  
 def main(): def main():
-    img_path os.path.join(os.getcwd(), "greyscale.png") +    img Image.open("greyscale.png").convert("L")
- +
-    if not os.path.isfile(img_path): +
-        print(f"Error: File not found: {img_path}"+
-        sys.exit(1) +
- +
- +
-    img = Image.open(img_path).convert('L')+
     pixels = list(img.getdata())     pixels = list(img.getdata())
     n = len(pixels)     n = len(pixels)
Linia 70: Linia 61:
         pi = pixels[i]         pi = pixels[i]
         for j in range(i + 1, n):         for j in range(i + 1, n):
-            total += pi - pixels[j]+            total += abs(pi - pixels[j])
  
-    print(f"Loaded: {img_path}"+    print(f"Pixels read: {n}"
-    print(f"Total pixels: {n}"+    print(f"Sum of abs diffs over all pairs: {total}")
-    print(f"Sum of abs differences over all pairs: {total}")+
  
 if __name__ == "__main__": if __name__ == "__main__":
     main()     main()
 +
 </code> </code>
 +
 +===== Wyniki dla obrazka wyostrzonego =====
 +
 +{{.:pasted:20250521-204417.png}}
 +
 +<code>
 +Pixels read: 11970
 +Sum of abs diffs over all pairs: 4496510654
 +</code>
 +
 +===== Wyniki dla obrazka niewyostrzonego =====
 +
 +{{.:pasted:20250521-204252.png}}
 +
 +<code>
 +Pixels read: 11970
 +Sum of abs diffs over all pairs: 3223391491
 +</code>
 +
 +
 +
 +
 +
  
  
notatki/autofocus.1747852378.txt.gz · ostatnio zmienione: przez administrator