Le lundi 30 janvier 2023 à 14:00:04 UTC+1, ptilou a écrit : > Slt, Bonjour
> > https://www.dropbox.com/scl/fo/peusccr349foy6qqgvxvq/h?dl=0&rlkey=neeo1v54e420pkkyvuhc3jcpy > > > Est ce que quelqu’un peut me dire ce que donne ca (sur les fichier dans la > dropbox ? : > > from skimage.metrics import structural_similarity > import cv2 > import numpy as np > > first = cv2.imread('clownfish_1.jpeg') > second = cv2.imread('clownfish_2.jpeg') > > # Convert images to grayscale > first_gray = cv2.cvtColor(first, cv2.COLOR_BGR2GRAY) > second_gray = cv2.cvtColor(second, cv2.COLOR_BGR2GRAY) > > # Compute SSIM between two images > score, diff = structural_similarity(first_gray, second_gray, full=True) > print("Similarity Score: {:.3f}%".format(score * 100)) > > # The diff image contains the actual image differences between the two images > # and is represented as a floating point data type so we must convert the > array > # to 8-bit unsigned integers in the range [0,255] before we can use it with > OpenCV > diff = (diff * 255).astype("uint8") > > # Threshold the difference image, followed by finding contours to > # obtain the regions that differ between the two images > thresh = cv2.threshold(diff, 0, 255, cv2.THRESH_BINARY_INV | > cv2.THRESH_OTSU)[1] > contours = cv2.findContours(thresh, cv2.RETR_EXTERNAL, > cv2.CHAIN_APPROX_SIMPLE) > contours = contours[0] if len(contours) == 2 else contours[1] > > # Highlight differences > mask = np.zeros(first.shape, dtype='uint8') > filled = second.copy() > > for c in contours: > area = cv2.contourArea(c) > if area > 100: > x,y,w,h = cv2.boundingRect(c) > cv2.rectangle(first, (x, y), (x + w, y + h), (36,255,12), 2) > cv2.rectangle(second, (x, y), (x + w, y + h), (36,255,12), 2) > cv2.drawContours(mask, [c], 0, (0,255,0), -1) > cv2.drawContours(filled, [c], 0, (0,255,0), -1) > > cv2.imshow('first', first) > cv2.imshow('second', second) > cv2.imshow('diff', diff) > cv2.imshow('mask', mask) > cv2.imshow('filled', filled) > cv2.waitKey() > Je vois que je ne suis pas le seul, comme opencv a ete ecrit en #C par intel, je me dis quels interets de passer par python, pourquoi ne pas appeler directement la librairie en bash, un script ? Je piose la question le scripting dans bash, c’est pas l’equivalent du bon vieu basic de Microsoft ? > > ( je veux faire un script pour me gerer du hdr dans une data base, mais je > cherche comment detecter les images similaire, j’ai lance un fil sur gid hup > mais je dois pas etre claire il propose une cles de hash par fichier !) > > D’apres MikeRobinson : > > convert -append `counter=0; for x in in-*; do if [[ $(($counter % 2)) == 0 > ]]; then echo $x; fi; counter=$((counter + 1)); done` out.jpg > Je ne vois pas dans ce script ou les image rentre en in, donc si quelqu’un sait , bon sinon du stack, peut etre comme mots cles est plus a proprie ? > Pour le script avec imagemagick, y a des script pour assemblee les images > d’etoiles ! Mais peut etre quelqu’un connait mieux ? > > Merci > > — > — Ptilou

