8000 DOC Add a docstring example for sklearn.feature_extraction.image.reconstruct_from_patches_2d by lamdang2k · Pull Request #28538 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Add a docstring example for sklearn.feature_extraction.image.reconstruct_from_patches_2d #28538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sklearn/feature_extraction/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,23 @@ def reconstruct_from_patches_2d(patches, image_size):
-------
image : ndarray of shape image_size
The reconstructed image.

Examples
--------
>>> 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)
"""
i_h, i_w = image_size[:2]
p_h, p_w = patches.shape[1:3]
Expand Down
0