From 9f1263345f8588042fb2c2b7e6cf46fe9e54f78c Mon Sep 17 00:00:00 2001 From: Rongze Liu Date: Fri, 10 Jan 2025 00:16:08 -0800 Subject: [PATCH] docs: updated package functions usage in README.md --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8eaf174..4511cd4 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,57 @@ $ pip install sharpedge ## Usage -- TODO +To harness the image processing magic of SharpEdge, follow these steps: + +1. Import the required functions from the package: + + ```python + from sharpedge.frame_image import frame_image + from sharpedge.modulate_image import modulate_image + from sharpedge.pca_compression import pca_compression + from sharpedge.pooling_image import pooling_image + from sharpedge.seam_carving import seam_carve + ``` + +2. Load your image as a NumPy array. +3. Process your images using the available functions: + - Add a decorative frame around the image with customizable color: + + ```python + # Add a frame around your image + framed_img = frame_image(img, h_border=30, w_border=30, inside=True, color=255) + ``` + + - Convert or manipulate image color channels: + + ```python + # Convert an RGB image to grayscale + grayscale_image = modulate_image(rgb_image, mode='gray') + ``` + + - Compress the input image using Principal Component Analysis (PCA): + + ```python + # Compress a grayscale image by retaining 80% of the variance + compressed_img = pca_compression(grayscale_img, preservation_rate=0.8) + ``` + + - Perform pooling on an image using a specified window size and pooling function: + + ```python + # Perform pooling on an image with mean pooling function + pooled_img = pooling_image(img, window_size=10, func=np.mean) + ``` + + - Resize the image using seam carving to the target dimensions: + + ```python + # Seam carve an image to resize it to the target dimensions + resized_img = seam_carve(img, target_height=300, target_width=400) + ``` ## Contributors + Archer Liu, Inder Khera, Hankun Xiao, Jenny Zhang (ordered alphabetically) ## Contributing