Exemplo n.º 1
0
def apply_algorithms(filename):
    data = bf.load_image(filename)  # load image
    grey = an.get_grey_level_array(data)  # grey-level array
    text = an.get_texture_analysis(data)  # texture analysis
    shape = an.get_shape_analysis(data, False)  # shape analysis
    finalArray = {"grey": grey, "texture": text, "shape": shape}

    return finalArray
Exemplo n.º 2
0
def showOptions():
    os.chdir(VALIDATION_SET_PATH)
    validation_images = glob.glob("*.h5")
    images = []
    for image in validation_images:
        image_data = bf.load_image(image)
        images.append(image_data)
    bf.show_images(images)
    os.chdir(BACK_TO_ROOT_REF)
Exemplo n.º 3
0
def searchQuery():
    global TRAIN_DATA, CHECK_DATA
    if not TRAIN_DATA:
        if not fetchTrainData():
            print("Could Not Search due to possible Network Error")
    query_image_id = int(input("Enter Search Image Id: "))
    os.chdir(VALIDATION_SET_PATH)
    validation_images = glob.glob("*.h5")
    source_image_name = validation_images[query_image_id]
    source_image_data = bf.load_image(source_image_name)
    sourceFinalArray = process.apply_algorithms(source_image_name)
    os.chdir(BACK_TO_ROOT_REF)

    match_image_name = compare(sourceFinalArray)
    if CHECK_DATA == 1:
        os.chdir(TRAIN_SET_PATH)
        match_image_data = bf.load_image(match_image_name)
        os.chdir(BACK_TO_ROOT_REF)
        matchImageData = {'image': match_image_data, 'name': match_image_name}
        sourceImageData = {
            'image': source_image_data,
            'name': source_image_name
        }
        bf.show_result(sourceImageData, matchImageData,
                       "Result by Original Algorithm")
    elif CHECK_DATA == 0:
        print("Best Match Image (By Original Algorithm): ", match_image_name)

    match_image_name = compareNew(sourceFinalArray)
    if CHECK_DATA == 1:
        os.chdir(TRAIN_SET_PATH)
        match_image_data = bf.load_image(match_image_name)
        os.chdir(BACK_TO_ROOT_REF)
        matchImageData = {'image': match_image_data, 'name': match_image_name}
        sourceImageData = {
            'image': source_image_data,
            'name': source_image_name
        }
        bf.show_result(sourceImageData, matchImageData,
                       "Result by Improved Matching Algorithm")
    elif CHECK_DATA == 0:
        print("Best Match Image (By Improved Matching Algorithm): ",
              match_image_name)
Exemplo n.º 4
0
def main():
    data = bf.load_image("test2.h5")
    thres = np.quantile(data.ravel(), 0.65)
    bindata = data // thres
    op_selem = disk(6)
    close_selem = disk(12)
    opened = opening(bindata, op_selem)
    closed = closing(opened, close_selem)
    peri = perimeter(closed)
    area = np.count_nonzero(closed == 1)
    compact = 4 * np.pi * area / (peri**2)
    print(peri, area, compact)
    bf.show_images([data, bindata, opened, closed, canny(closed)])
Exemplo n.º 5
0
def main():
    parser = argparse.ArgumentParser(
        description='Process Image through CloudNine Algorithm')
    parser.add_argument("image_path",
                        metavar="image_path",
                        type=str,
                        help="Path to HDF5 Image to process as per algorithm")
    args = parser.parse_args()
    filename = args.image_path
    data = bf.load_image(filename)
    bf.get_image_information(filename)

    bf.plot_hist_bin(data, 16)

    grey = an.get_grey_level_array(data)

    text = an.get_texture_analysis(data)

    shape = an.get_shape_analysis(data, False)
    #print(shape)

    finalArray = {"grey": grey, "texture": text, "shape": shape}

    print("Feature Array: ", finalArray)