Skip to content

Resolved issues generating images and blurred image option. #20

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from ops.noise import Noise
from ops.translate import Translate
from skimage.io import imread, imsave
import numpy as np
from skimage.exposure import rescale_intensity

EXTENSIONS = ['png', 'jpg', 'jpeg', 'bmp']
WORKER_COUNT = max(os.cpu_count() - 1, 1)
Expand All @@ -36,14 +38,18 @@ def build_augmented_file_name(original_name, ops):

def work(d, f, op_lists):
try:
in_path = os.path.join(d,f)
in_path = os.path.join(d, f)
for op_list in op_lists:
out_file_name = build_augmented_file_name(f, op_list)
if isfile(os.path.join(d,out_file_name)):
if isfile(os.path.join(d, out_file_name)):
continue
img = imread(in_path)
for op in op_list:
img = op.process(img)

# Convert image data type to uint8 before saving
img = rescale_intensity(img, out_range=(0, 255))
img = img.astype(np.uint8)
imsave(os.path.join(d, out_file_name), img)

counter.processed()
Expand Down
4 changes: 2 additions & 2 deletions ops/blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def __init__(self, sigma):
self.sigma = sigma

def process(self, img):
is_colour = len(img.shape)==3
return rescale_intensity(gaussian(img, sigma=self.sigma, multichannel=is_colour))
is_colour = len(img.shape) == 3
return gaussian(img, sigma=self.sigma, channel_axis=-1 if is_colour else None)

@staticmethod
def match_code(code):
Expand Down