Skip to content
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

Fix the gray image checking error #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions opencv_transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def resize(img, size, interpolation=cv2.INTER_LINEAR):
output = cv2.resize(img, dsize=(ow, oh), interpolation=interpolation)
else:
output = cv2.resize(img, dsize=size[::-1], interpolation=interpolation)
if img.shape[2]==1:
if img.ndim==2:
return(output[:,:,np.newaxis])
else:
return(output)
Expand Down Expand Up @@ -555,4 +555,4 @@ def to_grayscale(img, num_output_channels=1):
elif num_output_channels==3:
# much faster than doing cvtColor to go back to gray
img = np.broadcast_to(cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)[:,:,np.newaxis], img.shape)
return img
return img