reconstruct_from_patches_2d#
- sklearn.feature_extraction.image.reconstruct_from_patches_2d(patches, image_size)[源代码]#
Reconstruct the image from all of its patches.
假设斑块重叠,图像是通过从左到右、从上到下填充斑块并对重叠区域进行平均来构建的。
阅读更多的 User Guide .
- 参数:
- patches形状的nd数组(n_patches、patch_height、patch_宽度)或 (n_patches、patches_height、patch_宽度、n_channels)
完整的补丁集。如果补丁包含颜色信息,则通道沿最后一个维度进行索引:RGB补丁将具有
n_channels=3
.- image_sizeint(Image_height,Image_root)或 (图像_高度、图像_宽度、n_通道)
将重建的图像的大小。
- 返回:
- image形状图片大小的nd数组
重建的图像。
示例
>>> from sklearn.datasets import load_sample_image >>> from sklearn.feature_extraction import image >>> one_image = load_sample_image("china.jpg") >>> print('Image shape: {}'.format(one_image.shape)) Image shape: (427, 640, 3) >>> image_patches = image.extract_patches_2d(image=one_image, patch_size=(10, 10)) >>> print('Patches shape: {}'.format(image_patches.shape)) Patches shape: (263758, 10, 10, 3) >>> image_reconstructed = image.reconstruct_from_patches_2d( ... patches=image_patches, ... image_size=one_image.shape ... ) >>> print(f"Reconstructed shape: {image_reconstructed.shape}") Reconstructed shape: (427, 640, 3)