<jupyter_start><jupyter_text>mmdlithDetect defects in a microelectronic circuit.  DescriptionThe input image is a gray-scale image of a microelectronic circuit. The relevant objects in this image are vertical metal stripes. These stripes have some irregularities that should be detected. Our procedure takes the residues of a gray-scale closing and filter (by size) the threshold of the residues.<jupyter_code>import numpy as np
from PIL import Image
import ia870 as ia
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>ReadingThe gray scale image to be processed is read.<jupyter_code>a_pil = Image.open('data/r4x2_256.tif').convert('L')
a = np.array (a_pil)
a_surf = ia.iagsurf(a)

(fig, axes) = plt.subplots(nrows=1, ncols=2,figsize=(10, 5))
axes[0].set_title('a')
axes[0].imshow(a, cmap='gray')
axes[0].axis('off')
axes[1].set_title('a_surf')
axes[1].imshow(a_surf, cmap='gray')
axes[1].axis('off')<jupyter_output><empty_output><jupyter_text>ClosingClosing of the image by a vertical line of length 25 pixels. Then subtract it from the original. The sequence closing-subtraction is called closing top-hat. (This could be executed in a single command: c= mmcloseth (a, mmseline (25,90));).<jupyter_code>b = ia.iaclose(a,ia.iaseline(25,90));
b_surf = ia.iagsurf(b)

(fig, axes) = plt.subplots(nrows=1, ncols=2,figsize=(10, 5))
axes[0].set_title('b')
axes[0].imshow(b, cmap='gray')
axes[0].axis('off')
axes[1].set_title('b_surf')
axes[1].imshow(b_surf, cmap='gray')
axes[1].axis('off')<jupyter_output><empty_output><jupyter_text>SubtractionSubtraction of the closing from the original is called closing top-hat. It shows the discrepancies of the image where the structuring element cannot fit the surface. In this case, it highlights vertical depression with length longer than 25 pixels.<jupyter_code>c = ia.iasubm(b,a);
c_surf = ia.iagsurf(c)

(fig, axes) = plt.subplots(nrows=1, ncols=2,figsize=(10, 5))
axes[0].set_title('c')
axes[0].imshow(c, cmap='gray')
axes[0].axis('off')
axes[1].set_title('c_surf')
axes[1].imshow(c_surf, cmap='gray')
axes[1].axis('off')<jupyter_output><empty_output><jupyter_text>Thresholding and Area OpenThreshold on the residues image. Elimination of the small objects by area open.<jupyter_code>d = ia.iacmp(c,'>=',50);
e = ia.iaareaopen(d,5);

(fig, axes) = plt.subplots(nrows=1, ncols=2,figsize=(10, 5))
axes[0].set_title('d')
axes[0].imshow(d, cmap='gray')
axes[0].axis('off')
axes[1].set_title('e')
axes[1].imshow(e, cmap='gray')
axes[1].axis('off')<jupyter_output><empty_output><jupyter_text>Final displayOverlay the detected defects over the original image, and over the surface display.<jupyter_code>(fig, axes) = plt.subplots(nrows=1, ncols=2,figsize=(10, 5))
axes[0].set_title('a, e')
axes[0].imshow(ia.iagshow(a, e).transpose(1, 2, 0))
axes[0].axis('off')
axes[1].set_title('a_surf, e')
axes[1].imshow(ia.iagshow(a_surf, e).transpose(1, 2, 0))
axes[1].axis('off')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15737926376224248, 'fraction_numerical': 0.028368794326241134, 'mean_word_length': 7.273743016759776, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '149559', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1132, 'n_words': 266, 'path': 'dlith.ipynb', 'repo_name': 'robertoalotufo/ia870p3', 'size': '2961'}