<jupyter_start><jupyter_text>Preview a default image<jupyter_code>plt.imshow(img, cmap='gray')
# convert image into a numpy array
img = np.asarray(img).astype('int32')<jupyter_output><empty_output><jupyter_text>Image encode<jupyter_code>def encode_image(image):
    result = np.zeros_like(image)
    for x in range(len(image)):
        for y in range(len(image[x])):
            if x-1 < 0 or y-1 < 0:
                result[x][y] = image[x][y]
                continue
            diff = (image[x-1][y] + image[x][y-1] - image[x-1][y-1])
            result[x][y] = image[x][y] - diff
            
    return result
img_encoded = encode_image(img)
plt.imshow(img_encoded, cmap='gray')<jupyter_output><empty_output><jupyter_text>Image decode<jupyter_code>def decode_image(image):
    result = np.zeros_like(image)
    for x in range(len(image)):
        for y in range(len(image[x])):
            if x-1 < 0 or y-1 < 0:
                result[x][y] = image[x][y]
                continue
            diff = (result[x-1][y] + result[x][y-1] - result[x-1][y-1])
            result[x][y] = image[x][y] + diff
            
    return result
img_decoded = decode_image(img_encoded)
plt.imshow(img_decoded, cmap='gray')<jupyter_output><empty_output><jupyter_text>Image entropy  Initial image<jupyter_code>Image.fromarray(img).entropy()<jupyter_output><empty_output><jupyter_text>Encoded image<jupyter_code>Image.fromarray(img_encoded).entropy()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1492842535787321, 'fraction_numerical': 0.012269938650306749, 'mean_word_length': 3.369047619047619, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '312342', 'license': 'MIT', 'n_tokens_mistral': 554, 'n_tokens_neox': 541, 'n_words': 85, 'path': 'Image-Encode.ipynb', 'repo_name': 'emukans/image-processing', 'size': '1467'}