-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a14fc3
commit da610c8
Showing
52 changed files
with
667 additions
and
635 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
frontend/core/blocks/apply-gaussian-blur-20241223-163019-869/requirements.txt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
frontend/core/blocks/apply-gaussian-blur-20250115-142408-732/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numpy==1.26.4 | ||
opencv-python-headless==4.10.0.84 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
frontend/core/blocks/convert-colored-image-to-grayscale-20241223-163032-427/requirements.txt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
frontend/core/blocks/convert-colored-image-to-grayscale-20250115-142427-862/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numpy==1.26.4 | ||
opencv-python-headless==4.10.0.84 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
frontend/core/blocks/convert-image-to-binary-20241223-163041-154/requirements.txt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
32 changes: 20 additions & 12 deletions
32
...inary-20241223-163041-154/computations.py → ...inary-20250115-142445-780/computations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,52 @@ | ||
|
||
def compute(image_path, threshold): | ||
''' | ||
Convert a grayscale image to a binary image using a specified threshold. | ||
Parameters: | ||
image_path (str): The file path to the grayscale image that needs to be converted to binary. | ||
threshold (int): The threshold value used to convert the image to binary. Pixel values above this threshold will be set to 255, and those below will be set to 0. | ||
threshold (int): The threshold value used to convert the grayscale image to binary. Pixel values greater than or equal to this threshold will be set to white, otherwise black. | ||
Returns: | ||
dict: A dictionary with the key 'binary_image_path' and the value as the file path to the resulting binary image after conversion. | ||
dict: A dictionary with the key 'binary_image_path' and the value being the file path to the resulting binary image after conversion. | ||
''' | ||
import cv2 | ||
import os | ||
|
||
# Read the grayscale image | ||
image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE) | ||
|
||
# Apply the threshold to convert the image to binary | ||
# Check if image is loaded | ||
if image is None: | ||
raise ValueError('Image not found or unable to load.') | ||
|
||
# Convert the image to binary using the threshold | ||
_, binary_image = cv2.threshold(image, threshold, 255, cv2.THRESH_BINARY) | ||
# Define the output path for the binary image | ||
|
||
# Create the output file path | ||
base, ext = os.path.splitext(image_path) | ||
binary_image_path = f"{base}_binary{ext}" | ||
|
||
# Save the binary image | ||
cv2.imwrite(binary_image_path, binary_image) | ||
|
||
return {'binary_image_path': binary_image_path} | ||
|
||
def generate_fake_image(): | ||
import numpy as np | ||
import cv2 | ||
|
||
# Create a fake grayscale image using a numpy array | ||
fake_image = np.random.randint(0, 256, (100, 100), dtype=np.uint8) | ||
|
||
# Create a 10x10 grayscale image with random values | ||
fake_image = np.random.randint(0, 256, (10, 10), dtype=np.uint8) | ||
|
||
# Save it to a temporary location | ||
fake_image_path = 'fake_image.png' | ||
cv2.imwrite(fake_image_path, fake_image) | ||
return fake_image_path | ||
|
||
|
||
def test_compute(): | ||
image_path = generate_fake_image() | ||
threshold = 128 | ||
output = compute(image_path, threshold) | ||
print(output) | ||
result = compute(image_path, threshold) | ||
print(result) # To verify the output |
2 changes: 2 additions & 0 deletions
2
frontend/core/blocks/convert-image-to-binary-20250115-142445-780/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numpy==1.26.4 | ||
opencv-python-headless==4.10.0.84 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
frontend/core/blocks/crop-image-region-20241223-163051-184/computations.py
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.