<jupyter_start><jupyter_text>Pairs<jupyter_code># alternative pairs

xyz_src = np.random.random([50, 3])
xyz_dst = np.zeros_like(xyz_src)
xyz_dst[:,0] = xyz_src[:,0]
xyz_dst[:,1] = xyz_src[:,2]
xyz_dst[:,2] = xyz_src[:,1]

noise = np.random.normal(size=xyz_src.shape)
xyz_src += 0.01 * noise
xyz_src[::4] += 5. * noise[::4]

noise = np.random.normal(size=xyz_src.shape)
xyz_dst += 0.01 * noise
xyz_dst[::4] += 5. * noise[::4]

xyz_src
xyz_dst
# model_robust, inliers = ransac((xyz_src[:,:2], xyz_dst[:,:2]), AffineTransform, min_samples=3,
#                                residual_threshold=2, max_trials=100)
from sklearn.linear_model import RANSACRegressor
reg = RANSACRegressor(random_state=0).fit(xyz_src, xyz_dst)<jupyter_output>C:\Users\Jirik\Miniconda3\envs\lisa3qt5\lib\site-packages\sklearn\base.py:420: FutureWarning: The default value of multioutput (not exposed in score method) will change from 'variance_weighted' to 'uniform_average' in 0.23 to keep consistent with 'metrics.r2_score'. To specify the default value manually and avoid the warning, please either call 'metrics.r2_score' directly or make a custom scorer with 'metrics.make_scorer' (the built-in scorer 'r2' uses multioutput='uniform_average').
  "multioutput='uniform_average').", FutureWarning)
C:\Users\Jirik\Miniconda3\envs\lisa3qt5\lib\site-packages\sklearn\base.py:420: FutureWarning: The default value of multioutput (not exposed in score method) will change from 'variance_weighted' to 'uniform_average' in 0.23 to keep consistent with 'metrics.r2_score'. To specify the default value manually and avoid the warning, please either call 'metrics.r2_score' directly or make a custom scorer with 'metrics.make_scorer' (the built-in scorer 'r2' uses mu[...]<jupyter_text>Affine Transform Matrix Construction<jupyter_code>reg.predict([[4,4,4]])
reg.estimator_.coef_
reg.estimator_.intercept_
tm = np.column_stack([reg.estimator_.coef_, reg.estimator_.intercept_])
tm = np.row_stack([tm, [0, 0, 0, 1]])
tm<jupyter_output><empty_output><jupyter_text>Volumetric data trasformation<jupyter_code>import numpy as np
import scipy.ndimage
import imma
import itertools
import sed3
import matplotlib.pyplot as plt

data3d = np.random.random([20, 21, 32])
data3d[:,5:15, 5:15] += 2
data3d[:,12:13,8:12, ] -= 2
data3d[:,8:10,7:9, ] -= 2
data3d[:,8:10,11:13, ] -= 2
# for i, (x,y,z) in enumerate(itertools.product([0,10], [0,10], [0,10])):
#     data3d[x:, y:, z:] += i

sed3.show_slices(data3d, slice_number=12)
plt.show()
# tmatrix = np.array([
#     [1, 0, 0, 0],
#     [0, 0.5, 0.1, 0],
#     [0, 0.1, 0.5, 0],
#     [0, 0, 0, 1],
# ])
tmatrix = tm

data3d_2 = scipy.ndimage.affine_transform(
    data3d, tmatrix, output_shape=[20,70,70]
)
sed3.show_slices(data3d_2, slice_number=12)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15230604218805863, 'fraction_numerical': 0.053271362173757594, 'mean_word_length': 5.476851851851852, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '452297', 'license': 'MIT', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1102, 'n_words': 241, 'path': 'examples/ransac_3d.ipynb', 'repo_name': 'vlukes/io3d', 'size': '2797'}