<jupyter_start><jupyter_text>Area open  Descriptioniaareaopen removes any grain (i.e., connected component) with area less than a of a binary image f. The connectivity is given by the structuring element Bc. This operator is generalized to gray-scale images by applying the binary operator successively on slices of f taken from higher threshold levels to lower threshold levels. For a faster implementation use iamxtareaopen<jupyter_code>import numpy as np
import ia870 as mm
from PIL import Image<jupyter_output><empty_output><jupyter_text>Numeric binary example<jupyter_code>f = np.array([
    [1, 1, 0, 0, 0, 0, 1],
    [1, 0, 1, 1, 1, 0, 1],
    [0, 0, 0, 0, 1, 0, 0]],bool)
y = mm.iaareaopen(f, 4, mm.iasecross())
print(y * 1)<jupyter_output>[[0 0 0 0 0 0 0]
 [0 0 1 1 1 0 0]
 [0 0 0 0 1 0 0]]<jupyter_text>Numeric gray-level example<jupyter_code>f = np.array([
    [10,   11,   0,    0,   0,   0,  20],
    [10,    0,   5,    8,   9,   0,  15],
    [10,    0,   0,    0,  10,   0,   0]])
y = mm.iaareaopen(f, 4, mm.iasecross())
print(y)<jupyter_output>[[10 10  0  0  0  0  0]
 [10  0  5  5  5  0  0]
 [10  0  0  0  5  0  0]]<jupyter_text>Binary image example<jupyter_code>a_pil = Image.open('../data/form-1.tif')
a_pil
a = np.array(a_pil) > 0
b = mm.iaareaopen(a,500)
Image.fromarray(b.astype(np.uint8)*255)<jupyter_output><empty_output><jupyter_text>Gray-level image exampleThis example uses gray scale area open.<jupyter_code>a_pil = Image.open('../data/bloodcells.tif').convert('L') # must read as grayscale
a_pil
a = np.array(a_pil)
b = mm.iaareaopen(a,500,mm.iasecross())
Image.fromarray(b)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1329656862745098, 'fraction_numerical': 0.06924019607843138, 'mean_word_length': 3.8892215568862274, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, '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': '392093', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 730, 'n_tokens_neox': 655, 'n_words': 199, 'path': 'notebooks/areaopen.ipynb', 'repo_name': 'rdenadai/ia870p3', 'size': '1632'}