• da_cow (she/her)@feddit.org
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    17 hours ago

    Edit: I fucked up, the similarity ins in fact 0.7780982999075259 so this means, that 203973 pixels are identical. Originally I forgot to adjust the dimensions in the code.

    I had the same thought and did this, I was lazy and just used OpenCV do tho this. The similarity is 0.4024264539258554

    The images have a size of 512x512 pixels, so 262144 Pixels in total. So based on the similarity calculated by OpenCV 105493 are identical.

    I also have to admit, that doing coding while being stoned is fucking hard.

    I used this code:

    import cv2
    
    width = 512
    height = 512
    
    A  = cv2.imread("Lion.png", cv2.IMREAD_COLOR)
    B  = cv2.imread("house.png", cv2.IMREAD_COLOR)
    
    
    errorL2 = cv2.norm(A, B, cv2.NORM_L2)
    similarity = 1 - errorL2 / (height * width)
    print("Similarity = ", similarity)