SusiePHaltmann's picture
Request to upload 5.31.22 #1.5
fe25407
raw
history blame
1 kB
import streamlit as st
import numpy as np
from PIL import Image
def main():
st.title("Haltmann Diffusion Algorithm")
slider = st.slider("Slider", 0, 255, 128) # default value=128, min=0, max=255
algo = np.array([[0, 0, 0], [0, 1/3, 1/3], [0, 1/3, 2/3]])
image = Image.open('image.png') # your image here
pixels = np.array(image)
for i in range(pixels.shape[0]): # iterate over the rows of the image matrix (height) for j in range(pixels.shape[1]): # iterate over the columns of the image matrix (width) for k in range(pixels.shape[2]): # iterate over the color channels (RGB) if pixels[i][j][k] > slider: pixels[i][j][k] = int((algo @ np.array([pixels[i-1][j-1][k], pixels[i-1][j+1][k], pixels[i+1][j-1][k]]).T)[2]) else: continue
new_image = Image.fromarray(pixels)
st.image(new_image , caption='Output Image', use_column_width=True) if __name__ == '__main__': main()