Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Different channel shift values at different image channels #18

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 3 additions & 4 deletions keras_preprocessing/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def apply_channel_shift(x, intensity, channel_axis=0):
x = np.rollaxis(x, channel_axis, 0)
min_x, max_x = np.min(x), np.max(x)
channel_images = [
np.clip(x_channel + intensity,
np.clip(x_channel + np.random.uniform(-intensity, intensity),
min_x,
max_x)
for x_channel in x]
Expand All @@ -190,7 +190,7 @@ def random_channel_shift(x, intensity_range, channel_axis=0):
# Returns
Numpy image tensor.
"""
intensity = np.random.uniform(-intensity_range, intensity_range)
intensity = intensity_range
return apply_channel_shift(x, intensity, channel_axis=channel_axis)


Expand Down Expand Up @@ -1049,8 +1049,7 @@ def get_random_transform(self, img_shape, seed=None):

channel_shift_intensity = None
if self.channel_shift_range != 0:
channel_shift_intensity = np.random.uniform(-self.channel_shift_range,
self.channel_shift_range)
channel_shift_intensity = self.channel_shift_range

brightness = None
if self.brightness_range is not None:
Expand Down