Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why is am I getting an error when adding 2 images?

I am trying to add the laplacian of the image to the original image to enhance the details in the image, but I am getting the following error.

cv2.error: /io/opencv/modules/core/src/arithm.cpp:683: error: (-5) When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified in function arithm_op

Pls help I'm a begginer in image processing.

from pylab import *
from PIL import Image
import cv2
import numpy as np
from matplotlib import pyplot as plt

image=cv2.imread('./Desktop/whale train/train/0a0b2a01.jpg',0)
laplacian = cv2.Laplacian(image,cv2.CV_64F)
tu=cv2.add(laplacian,image)
plt.subplot(1,1,1),plt.imshow(tu,cmap = 'gray')
plt.title('Laplacian'), plt.xticks([]), plt.yticks([])
plt.show()