Пример #1
0
def compare(comparator_type, sample_url):
    from improc.features.comparator import ChiSquaredComparator, \
        EuclideanComparator, ManhattanComparator, ChebyshevComparator, \
        CosineComparator, HammingComparator
    import improc.features.query as feature_query

    if comparator_type == "euclidean":
        comparator = EuclideanComparator()
    elif comparator_type == "manhattan":
        comparator = ManhattanComparator()
    elif comparator_type == "chisquared":
        comparator = ChiSquaredComparator()
    elif comparator_type == "hamming":
        comparator = HammingComparator()
    elif comparator_type == "chebsy":
        comparator = ChebyshevComparator()
    elif comparator_type == "cosine":
        comparator = CosineComparator()

    else:
        raise Exception(comparator_type)

    result_harlick = feature_query.do(sample_harlick, items["harlick"],
                                      comparator)

    detail_result(comparator_type, "harlick", sample_url, result_harlick)

    result_rgb_histogram = feature_query.do(sample_rgb_histogram,
                                            items["rgb_histogram"], comparator)

    detail_result(comparator_type, "rgb_histogram", sample_url,
                  result_rgb_histogram)

    result_zernike = feature_query.do(sample_zernike, items["zernike"],
                                      comparator)

    detail_result(comparator_type, "zernite", sample_url, result_zernike)
Пример #2
0
def compare(comparator_type, sample_url):
    from improc.features.comparator import ChiSquaredComparator, \
        EuclideanComparator, ManhattanComparator, ChebyshevComparator, \
        CosineComparator, HammingComparator
    import improc.features.query as feature_query

    if comparator_type == "euclidean":
        comparator = EuclideanComparator()
    elif comparator_type == "manhattan":
        comparator = ManhattanComparator()
    elif comparator_type == "chisquared":
        comparator = ChiSquaredComparator()
    elif comparator_type == "hamming":
        comparator = HammingComparator()
    elif comparator_type == "chebsy":
        comparator = ChebyshevComparator()
    elif comparator_type == "cosine":
        comparator = CosineComparator()

    else:
        raise Exception(comparator_type)

    result_harlick = feature_query.do(
        sample_harlick, items["harlick"], comparator)

    detail_result(comparator_type, "harlick", sample_url, result_harlick)

    result_rgb_histogram = feature_query.do(
        sample_rgb_histogram, items["rgb_histogram"], comparator)

    detail_result(comparator_type, "rgb_histogram", sample_url,
                  result_rgb_histogram)

    result_zernike = feature_query.do(
        sample_zernike, items["zernike"], comparator)

    detail_result(comparator_type, "zernite", sample_url, result_zernike)
Пример #3
0
def test_dataset(key, total):
    descriptor_info = load_dataset("datasets/%s" % key, samples_info[0])

    for i, x in enumerate(samples_info):
        sample_image = cv2.imread(x["sample_name"])
        image_key = "%s_%s" % (key, x["sample_name"][:-10])
        methodToCall = getattr(descriptor_definitions, key)
        descriptor = methodToCall()

        plt.subplot(len(dd.items()), len(samples_info), i + total + 1), plt.imshow(descriptor.do_preprocess(sample_image), 'gray')
        # plt.title("%s_%s" % (key[0], image_key))

        sample_description = descriptor.describe(sample_image)
        res = do(sample_description, descriptor_info["data"],
                 EuclideanComparator())

        process_results(res, x, key, descriptor)

    return i + total
Пример #4
0
def test_dataset(key, total):
    descriptor_info = load_dataset("datasets/%s" % key, samples_info[0])

    for i, x in enumerate(samples_info):
        sample_image = cv2.imread(x["sample_name"])
        image_key = "%s_%s" % (key, x["sample_name"][:-10])
        methodToCall = getattr(descriptor_definitions, key)
        descriptor = methodToCall()

        plt.subplot(len(dd.items()), len(samples_info),
                    i + total + 1), plt.imshow(
                        descriptor.do_preprocess(sample_image), 'gray')
        # plt.title("%s_%s" % (key[0], image_key))

        sample_description = descriptor.describe(sample_image)
        res = do(sample_description, descriptor_info["data"],
                 EuclideanComparator())

        process_results(res, x, key, descriptor)

    return i + total
Пример #5
0
for doc in docs:
    for i in doc["detail"]["images"]:
        path = "/Users/rdefeo/Development/getter/detail/data/images/%s" % i["path"]
        key = "%s_%s" % (str(doc["_id"]["_id"]), str(i["_id"]))
        img = mh.imread(path)
        # img = cv2.resize(img, size)
        items[key] = descriptor.describe(img)

name = "536f5a1ea26d15820c9211cb.jpg"
base_path = "/Users/rdefeo/Development/getter/detail/data/images/%s" % name
print base_path
base = mh.imread(base_path)
# base = cv2.resize(base, size)
sample = descriptor.describe(base)

result = feature_query.do(sample, items, ChiSquaredComparator())

for x in result["results"][:10]:

    print x

# f = mh.imread('test_data/1.jpg', as_grey=True)#mh.demos.load('luispedro', as_grey=True)
# img = mahotas.imread('test_data/1.jpg')
# d = mahotas.features.haralick(img).mean(0)
#
#

# # import numpy as np
# # import mahotas
# # import pylab as p
# #
Пример #6
0
    for i in doc["detail"]["images"]:
        path = "/Users/rdefeo/Development/getter/detail/data/images/%s" % i[
            "path"]
        key = "%s_%s" % (str(doc["_id"]["_id"]), str(i["_id"]))
        img = mh.imread(path)
        # img = cv2.resize(img, size)
        items[key] = descriptor.describe(img)

name = "536f5a1ea26d15820c9211cb.jpg"
base_path = "/Users/rdefeo/Development/getter/detail/data/images/%s" % name
print base_path
base = mh.imread(base_path)
# base = cv2.resize(base, size)
sample = descriptor.describe(base)

result = feature_query.do(sample, items, ChiSquaredComparator())

for x in result["results"][:10]:

    print x

# f = mh.imread('test_data/1.jpg', as_grey=True)#mh.demos.load('luispedro', as_grey=True)
# img = mahotas.imread('test_data/1.jpg')
# d = mahotas.features.haralick(img).mean(0)
#
#

# # import numpy as np
# # import mahotas
# # import pylab as p
# #