LPX55 commited on
Commit
444ca24
·
verified ·
1 Parent(s): 52689dc

Update forensics/ela_hybrid.py

Browse files
Files changed (1) hide show
  1. forensics/ela_hybrid.py +10 -8
forensics/ela_hybrid.py CHANGED
@@ -50,12 +50,14 @@ def save_hybrid_image(hybrid_array, save_path: str):
50
  np.save(save_path, hybrid_array)
51
  print(f"Saved hybrid ELA image to {save_path}")
52
 
 
 
 
53
 
54
- def visualize_hybrid(hybrid_array: np.ndarray, split_visualize: bool = True):
55
- """Split the 6 channels into RGB and ELA for visualization."""
56
- rgb_image = (hybrid_array[:, :, :3] * 255).astype(np.uint8)
57
- ela_image = (hybrid_array[:, :, 3:] * 255).astype(np.uint8)
58
- return {
59
- "rgb": Image.fromarray(rgb_image),
60
- "ela": Image.fromarray(ela_image),
61
- }
 
50
  np.save(save_path, hybrid_array)
51
  print(f"Saved hybrid ELA image to {save_path}")
52
 
53
+ def visualize_hybrid(hybrid_array: np.ndarray):
54
+ """Return a list of 2 images: [RGB Image, ELA Map (grayscale)], as PIL Images."""
55
+ from PIL import Image
56
 
57
+ # Extract RGB (3 channels at front)
58
+ rgb_image = Image.fromarray((hybrid_array[:, :, :3] * 255).astype(np.uint8))
59
+
60
+ # Extract ELA channels (last 3)
61
+ ela_image = Image.fromarray((hybrid_array[:, :, 3:] * 255).astype(np.uint8))
62
+
63
+ return [rgb_image, ela_image]