Python cv2.bitwise_xor() Examples

The following are 3 code examples of cv2.bitwise_xor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cv2 , or try the search function .
Example #1
Source File: picam.py    From PiCamNN with MIT License 7 votes vote down vote up
def movement(mat_1,mat_2):
    mat_1_gray     = cv2.cvtColor(mat_1.copy(),cv2.COLOR_BGR2GRAY)
    mat_1_gray     = cv2.blur(mat_1_gray,(blur1,blur1))
    _,mat_1_gray   = cv2.threshold(mat_1_gray,100,255,0)
    mat_2_gray     = cv2.cvtColor(mat_2.copy(),cv2.COLOR_BGR2GRAY)
    mat_2_gray     = cv2.blur(mat_2_gray,(blur1,blur1))
    _,mat_2_gray   = cv2.threshold(mat_2_gray,100,255,0)
    mat_2_gray     = cv2.bitwise_xor(mat_1_gray,mat_2_gray)
    mat_2_gray     = cv2.blur(mat_2_gray,(blur2,blur2))
    _,mat_2_gray   = cv2.threshold(mat_2_gray,70,255,0)
    mat_2_gray     = cv2.erode(mat_2_gray,np.ones((erodeval,erodeval)))
    mat_2_gray     = cv2.dilate(mat_2_gray,np.ones((4,4)))
    _, contours,__ = cv2.findContours(mat_2_gray,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    if len(contours) > 0:return True #If there were any movements
    return  False                    #if not


#Pedestrian Recognition Thread 
Example #2
Source File: logical_xor.py    From plantcv with MIT License 7 votes vote down vote up
def logical_xor(bin_img1, bin_img2):
    """Join two images using the bitwise XOR operator.

    Inputs:
    bin_img1   = Binary image data to be compared to bin_img2
    bin_img2   = Binary image data to be compared to bin_img1

    Returns:
    merged     = joined binary image

    :param bin_img1: numpy.ndarray
    :param bin_img2: numpy.ndarray
    :return merged: numpy.ndarray
    """

    params.device += 1
    merged = cv2.bitwise_xor(bin_img1, bin_img2)
    if params.debug == 'print':
        print_image(merged, os.path.join(params.debug_outdir, str(params.device) + '_xor_joined.png'))
    elif params.debug == 'plot':
        plot_image(merged, cmap='gray')
    return merged 
Example #3
Source File: LogicalOperation.py    From Finger-Detection-and-Tracking with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def main():
    basePath = "../data/"

    imageFileOne = basePath + "4.1.04.tiff"
    imageFileTwo = basePath + "4.1.05.tiff"

    imageOne = cv2.imread(imageFileOne, 1)
    imageTwo = cv2.imread(imageFileTwo, 1)

    imageOneRGB = cv2.cvtColor(imageOne, cv2.COLOR_BGR2RGB)
    imageTwoRGB = cv2.cvtColor(imageTwo, cv2.COLOR_BGR2RGB)

    negativeImage = cv2.bitwise_not(imageOneRGB)
    andImage = cv2.bitwise_and(imageOneRGB, imageTwoRGB)
    orImage = cv2.bitwise_or(imageOneRGB, imageTwoRGB)
    xorImage = cv2.bitwise_xor(imageOneRGB, imageTwoRGB)

    imageNames = [imageOneRGB, imageTwoRGB, negativeImage, andImage, orImage, xorImage]
    imageTitles = ["Image One", "Image Two", "Negative", "AND", "OR", "XOR"]

    for i in range(6):
        plt.subplot(2, 3, i + 1)
        plt.imshow(imageNames[i])
        plt.title(imageTitles[i])
        plt.xticks([])
        plt.yticks([])

    plt.show()