<jupyter_start><jupyter_text>Test libutils.cpp - Image 3D<jupyter_code>%load_ext autoreload
%autoreload 2
import numpy as np
np.random.seed(0)
bool_img = np.random.randint(0, 2, (20,20,20), dtype=bool)
neigh1 = np.random.randint(0, 2, (3,3,3), dtype=bool)
neigh2 = np.random.randint(0, 2, (3,3,3), dtype=bool)
img = np.random.randint(0, 256, (10,10,10), dtype=int)
from nice.utils import print_dir
from nice.plot import matplotlib_plot, imshow_colorspace
import euchar.cppbinding.utils as u<jupyter_output><empty_output><jupyter_text>***<jupyter_code>u.sum_bool_3d(bool_img) == np.sum(bool_img)
cpp_pad = np.array(u.pad_3d(img, 256))
new_img = np.full(np.array(img.shape)+2, 256)
new_img[1:-1,1:-1,1:-1] = img
print((new_img == cpp_pad).all())
(np.array(u.threshold_image_3d(img, 120)) == (img <= 120)).all()
(np.array(u.elementwise_AND_3d(neigh1, neigh2)) == np.logical_and(neigh1, neigh2)).all()
I, J, K = 3, 3, 3
slice_img = img[I-1:I+2, J-1:J+2, K-1:K+2]
print(((slice_img< 100) == np.array(u.binary_neigh_voxel_3d(img, I, J, K, 100))).all())<jupyter_output>True
{'fraction_non_alphanumeric': 0.19418386491557224, 'fraction_numerical': 0.07129455909943715, 'mean_word_length': 6.788321167883212, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '89390', 'license': 'MIT', 'n_tokens_mistral': 521, 'n_tokens_neox': 484, 'n_words': 81, 'path': 'notebooks/test_utils_image_3d.ipynb', 'repo_name': 'gbeltramo/euchar', 'size': '1066'}