def getFeatures(path, img=None, display=False):
    if img is None:
        img = mpimg.imread(path)
    img = preproc.preproc(path, display=display)
    '''img = cv2.imread('bw_image.png')
	img = np.array(img, dtype=np.uint8)
	gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
	a=[]
	x_coor=[]
	indices = np.where(gray == [0])
	print (indices)
	coordinates = zip(indices[0], indices[1])
	print (coordinates)
	a=list(zip(indices[0], indices[1]))
	print(len(a))
	print(a[0])
	for j in range(len(a)):  # this loop makes a list of all x coordinates
        x_coor.append((a[j][0]))
	print(x_coor)
	with open("file.txt", "w") as output:
		output.write(str(a))'''
    ratio = features.Ratio(img)
    centroid = features.Centroid(img)
    eccentricity, solidity = features.EccentricitySolidity(img)
    skewness, kurtosis = features.SkewKurtosis(img)
    retVal = (ratio, centroid, eccentricity, solidity, skewness, kurtosis)
    return retVal
Example #2
0
def getFeatures(path, img=None, display=False):
    if img is None:
        img = mpimg.imread(path)
    img = preproc.preproc(path, display=display)
    ratio = features.Ratio(img)
    centroid = features.Centroid(img)
    eccentricity, solidity = features.EccentricitySolidity(img)
    skewness, kurtosis = features.SkewKurtosis(img)
    retVal = (ratio, centroid, eccentricity, solidity, skewness, kurtosis)
    return retVal
Example #3
0
def getFeatures(path, img=None, display=False):
    if img is None:
        img = mpimg.imread(path)
    # print("(ann)")
    img = preproc.preproc(path, display=display)
    ratio = features.Ratio(img)
    centroid = features.Centroid(img)
    eccentricity, solidity = features.EccentricitySolidity(img)
    skewness, kurtosis = features.SkewKurtosis(img)
    # print("(svm)")
    aspect_ratio, bounding_rect_area, hull_area, contour_area = features.get_contour_features(
        img, display=display)
    retVal = (ratio, centroid, eccentricity, solidity, skewness, kurtosis,
              aspect_ratio, hull_area / bounding_rect_area,
              contour_area / bounding_rect_area)
    return retVal
Example #4
0
    des_list = []
    for im in genuine_image_features[i]:
        image_path = genuine_image_paths + "/" + im['name']
        preprocessed_image = preprocess_image(image_path)
        hash = imagehash.phash(Image.open(image_path))

        aspect_ratio, bounding_rect_area, convex_hull_area, contours_area = \
            features.get_contour_features(preprocessed_image.copy(), display=False)

        hash = int(str(hash), 16)
        im['hash'] = hash
        im['aspect_ratio'] = aspect_ratio
        im['hull_area/bounding_area'] = convex_hull_area / bounding_rect_area
        im['contour_area/bounding_area'] = contours_area / bounding_rect_area

        im['ratio'] = features.Ratio(preprocessed_image.copy())
        im['centroid_0'],im['centroid_1']=features.Centroid(preprocessed_image.copy())
        
        im['eccentricity'],im['solidity']=features.EccentricitySolidity(preprocessed_image.copy())
        (im['skewness_0'],im['skewness_1']),(im['kurtosis_0'],im['kurtosis_1']) = features.SkewKurtosis(preprocessed_image.copy())
        
        # im_contour_features.append([hash, aspect_ratio, convex_hull_area / bounding_rect_area, contours_area / bounding_rect_area])
        im_contour_features.append([aspect_ratio, convex_hull_area / bounding_rect_area, contours_area / bounding_rect_area, im['ratio'],im['centroid_0'],im['centroid_1'],im['eccentricity'],im['solidity'],im['skewness_0'],im['skewness_1'],im['kurtosis_0'],im['kurtosis_1']])

        des_list.append(sift(preprocessed_image.copy(), image_path))
        # print(len(des_list))


    for im in forged_image_features[i]:
        image_path = forged_image_paths + "/" + im['name']
        preprocessed_image = preprocess_image(image_path)