<jupyter_start><jupyter_text>`Convolution` Example Import the `Convolution` module.<jupyter_code>from Ardi.cv import Convolution<jupyter_output><empty_output><jupyter_text>Initialize a `Convolution` object with random kernel.<jupyter_code>convolution = Convolution(kernel='random', random_state=77)<jupyter_output><empty_output><jupyter_text>Below is how the kernel that we are going to apply to an image looks like.<jupyter_code>convolution.kernel<jupyter_output><empty_output><jupyter_text>Load the image using `load_image()` function. Here I also reduce the image resolution by 90% (by setting the `resolution` parameter to 0.1).<jupyter_code>convolution.load_image('dataset_test/flower.jpg', resolution=0.1)<jupyter_output><empty_output><jupyter_text>Displaying the original image in grayscale using `show_original()` function.<jupyter_code>convolution.show_original()<jupyter_output><empty_output><jupyter_text>Displaying the resized image using `show_resized()` function. Notice that even though the image look almost exactly the same, yet the xticks and yticks values emphasizes that the resized image is way smaller than the original image. In fact, such a reduction in image dimension makes the convolution process more effective (since our kernel is relatively small as well).<jupyter_code>convolution.show_resized()<jupyter_output><empty_output><jupyter_text>Displaying the zero-padded image using `show_zero_padded()` function. The resulting image might look very similar to the one obtained using `show_resized()` function because the zero-padding only gives an additional dimension of 1 on each side. This basically means that if you take a very close look to the image, then there will be an extremely thin black frame around the image.<jupyter_code>convolution.show_zero_padded()<jupyter_output><empty_output><jupyter_text>Start the convolution process by calling `convolve()` method. Note that the value displayed in the progress bar below is the image height.<jupyter_code>convolution.convolve()<jupyter_output>100%|███████████████████████████████████████████████████████████████████████████████| 326/326 [00:00<00:00, 434.67it/s]<jupyter_text>Below is how the convolved image looks like.<jupyter_code>convolution.show_convolved()<jupyter_output><empty_output><jupyter_text>Below is another example. The steps are exactly the same except the kernel type.<jupyter_code>convolution2 = Convolution(kernel='vertical_edge')
convolution2.load_image('dataset_test/flower.jpg', resolution=0.1)
convolution2.convolve()
convolution2.show_convolved()<jupyter_output>100%|███████████████████████████████████████████████████████████████████████████████| 326/326 [00:00<00:00, 428.95it/s]
{'fraction_non_alphanumeric': 0.1400445765230312, 'fraction_numerical': 0.021916790490341752, 'mean_word_length': 8.792727272727273, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 39, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '575158', 'license': 'MIT', 'n_tokens_mistral': 969, 'n_tokens_neox': 831, 'n_words': 230, 'path': 'Documentation/Convolution Example.ipynb', 'repo_name': 'MuhammadArdiPutra/test_package', 'size': '2692'}