RafidMehda commited on
Commit
9c3522c
·
verified ·
1 Parent(s): fe2b868

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -17,7 +17,7 @@ def encrypt_image(image, key):
17
  h, w, c = image.shape
18
  size = h * w * c
19
  chaotic_sequence = logistic_map(size, key).reshape(h, w, c)
20
- encrypted_image = (image + chaotic_sequence) % 256 # Element-wise encryption
21
  return encrypted_image.astype(np.uint8)
22
 
23
  # Streamlit app
@@ -30,7 +30,7 @@ def main():
30
  if uploaded_file is not None:
31
  # Display the uploaded image
32
  input_image = Image.open(uploaded_file)
33
- st.image(input_image, caption="Uploaded Image", use_column_width=True)
34
 
35
  # Convert the image to numpy array
36
  input_image_np = np.array(input_image)
@@ -43,7 +43,7 @@ def main():
43
  encrypted_image = Image.fromarray(encrypted_image_np)
44
 
45
  # Display the encrypted image
46
- st.image(encrypted_image, caption="Encrypted Image", use_column_width=True)
47
 
48
  # Save encrypted image to a buffer
49
  buffer = io.BytesIO()
 
17
  h, w, c = image.shape
18
  size = h * w * c
19
  chaotic_sequence = logistic_map(size, key).reshape(h, w, c)
20
+ encrypted_image = np.mod(image + chaotic_sequence, 256) # Element-wise encryption
21
  return encrypted_image.astype(np.uint8)
22
 
23
  # Streamlit app
 
30
  if uploaded_file is not None:
31
  # Display the uploaded image
32
  input_image = Image.open(uploaded_file)
33
+ st.image(input_image, caption="Uploaded Image", use_container_width=True)
34
 
35
  # Convert the image to numpy array
36
  input_image_np = np.array(input_image)
 
43
  encrypted_image = Image.fromarray(encrypted_image_np)
44
 
45
  # Display the encrypted image
46
+ st.image(encrypted_image, caption="Encrypted Image", use_container_width=True)
47
 
48
  # Save encrypted image to a buffer
49
  buffer = io.BytesIO()