Spaces:
Running
Running
Update utils.py
Browse files
utils.py
CHANGED
@@ -64,8 +64,6 @@ class WatermarkProcessor:
|
|
64 |
except Exception as e:
|
65 |
return im_name, f"Error adding watermark: {str(e)}"
|
66 |
|
67 |
-
# utils.py의 encode와 decode 메서드만 수정
|
68 |
-
|
69 |
def encode(self, image_path, watermark_text, metadata=None):
|
70 |
"""Encode watermark using simple LSB steganography"""
|
71 |
try:
|
@@ -97,8 +95,12 @@ class WatermarkProcessor:
|
|
97 |
for j in range(image.shape[1]):
|
98 |
for k in range(3):
|
99 |
if data_index < len(binary_data):
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
102 |
data_index += 1
|
103 |
else:
|
104 |
break
|
@@ -161,7 +163,6 @@ class WatermarkProcessor:
|
|
161 |
except Exception as e:
|
162 |
return f"Error in decoding: {str(e)}"
|
163 |
|
164 |
-
|
165 |
def analyze_quality(self, original_path, watermarked_path):
|
166 |
"""Analyze watermark quality"""
|
167 |
try:
|
|
|
64 |
except Exception as e:
|
65 |
return im_name, f"Error adding watermark: {str(e)}"
|
66 |
|
|
|
|
|
67 |
def encode(self, image_path, watermark_text, metadata=None):
|
68 |
"""Encode watermark using simple LSB steganography"""
|
69 |
try:
|
|
|
95 |
for j in range(image.shape[1]):
|
96 |
for k in range(3):
|
97 |
if data_index < len(binary_data):
|
98 |
+
pixel = int(image[i, j, k])
|
99 |
+
# Clear the LSB
|
100 |
+
pixel = pixel & 0xFE # Clear last bit
|
101 |
+
# Set the LSB according to our data
|
102 |
+
pixel = pixel | (int(binary_data[data_index]) & 1)
|
103 |
+
image[i, j, k] = np.uint8(pixel)
|
104 |
data_index += 1
|
105 |
else:
|
106 |
break
|
|
|
163 |
except Exception as e:
|
164 |
return f"Error in decoding: {str(e)}"
|
165 |
|
|
|
166 |
def analyze_quality(self, original_path, watermarked_path):
|
167 |
"""Analyze watermark quality"""
|
168 |
try:
|