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

RGB image? #4

Open
ng0323 opened this issue Jan 26, 2018 · 2 comments
Open

RGB image? #4

ng0323 opened this issue Jan 26, 2018 · 2 comments

Comments

@ng0323
Copy link

ng0323 commented Jan 26, 2018

Hi, it seems to work for grayscale images only? I get an error for RGB images.

@nahliabdelwahed
Copy link

is it really can support RGB image ?

@zzhuolun
Copy link

zzhuolun commented Aug 13, 2019

@ng0323
the error about RGB images is due to that convolutions are done through scipy.signal.conv2d, which only takes in inputs (kernel and image) of 2 dimensions. RGB images have 3 dimensions so cannot be processed by scipy.signal.conv2d.
I used cv2.filter2D to due with RGB imges. So e.g, changing the LinearMotionBlur(img, dim, angle, linetype) in pyblur/LinearMotionBlur.py as follows can do motion blur with RGB images:

def LinearMotionBlur(img, dim, angle, linetype):
    imgarray = np.array(img)
    imgarray=cv2.cvtColor(imgarray, cv2.COLOR_RGB2BGR)
    kernel = LineKernel(dim, angle, linetype)
    convolved=cv2.filter2D(imgarray, -1, kernel)
    convolved = cv2.cvtColor(convolved, cv2.COLOR_BGR2RGB)
    # convolved = convolve2d(imgarray, kernel, mode='same', fillvalue=255.0).astype("uint8")
    img = Image.fromarray(convolved)
    return img

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants