예제 #1
0
argprse.add_argument("-d", "--dataset", required = True,
	help = "FilePath to the folder that has target images to be indexed")
argprse.add_argument("-c", "--hsv", required = True,
	help = "File Path where the computed hsv index is saved")
argprse.add_argument("-t", "--texture", required = True,
	help = "File Path where the computed texture index is saved")
argprse.add_argument("-b", "--btree", required = True,
	help = "File Path where the computed tree index is saved")
argprse.add_argument("-q", "--query", required = True,
	help = "File Path to the query image")
argmnts = vars(argprse.parse_args())

# loading the query image and describing its color, texture and tree features
query_img = cv2.imread(argmnts["query"])
cfeats = cdes.describe_color(copy.copy(query_img))
texture = txdes.describe_texture(copy.copy(query_img))
tree = tdes.color_tree(copy.copy(query_img))
 
# ranking the images in our dataset based on the query image
ranker = Ranker(argmnts["hsv"], argmnts["texture"], argmnts["btree"])
final_results = ranker.rank(cfeats, texture, tree)

current_path = os.path.dirname(os.path.abspath(__file__))

# iterating over the final results
for (score, resID) in final_results:
	# printing the image names in the order of increasing score
	print resID + "    "+ str(score)
	source_path = argmnts["dataset"]+"/"+ resID
	dest_path = current_path+"/result/"+resID
	shutil.copy2(source_path,dest_path)
예제 #2
0
# opening the respective output index files in write mode
clroutput = open(argmnts["hsv"], "w")
treeoutput = open(argmnts["btree"], "w")
texoutput = open(argmnts["texture"], "w")

# using glob to capture the paths of the images and iterate through them
for path in glob.glob(argmnts["dataset"] + "/*.jpg"):
    # getting the unique filenames from the image path
    imgID = path[path.rfind("/") + 1:]
    # loading the image
    image = cv2.imread(path)

    # getting the color, texture and tree features from the image
    color = cdes.describe_color(image)
    tree = tdes.color_tree(image)
    texture = txdes.describe_texture(image)

    # writing the color features to the clroutput file
    color = [str(f) for f in color]
    clroutput.write("%s,%s\n" % (imgID, ",".join(color)))

    # writing the tree features to the treeoutput file
    tree = [str(t) for t in tree]
    treeoutput.write("%s,%s\n" % (imgID, ",".join(tree)))

    # writing the texture features to the texoutput file
    texture = [str(tx) for tx in texture]
    texoutput.write("%s,%s\n" % (imgID, ",".join(texture)))

# close all the index files
clroutput.close()
예제 #3
0
    required=True,
    help="File Path where the computed texture index is saved")
argprse.add_argument("-b",
                     "--btree",
                     required=True,
                     help="File Path where the computed tree index is saved")
argprse.add_argument("-q",
                     "--query",
                     required=True,
                     help="File Path to the query image")
argmnts = vars(argprse.parse_args())

# loading the query image and describing its color, texture and tree features
query_img = cv2.imread(argmnts["query"])
cfeats = cdes.describe_color(copy.copy(query_img))
texture = txdes.describe_texture(copy.copy(query_img))
tree = tdes.color_tree(copy.copy(query_img))

# ranking the images in our dataset based on the query image
ranker = Ranker(argmnts["hsv"], argmnts["texture"], argmnts["btree"])
final_results = ranker.rank(cfeats, texture, tree)

current_path = os.path.dirname(os.path.abspath(__file__))

# iterating over the final results
for (score, resID) in final_results:
    # printing the image names in the order of increasing score
    print resID + "    " + str(score)
    source_path = argmnts["dataset"] + "/" + resID
    dest_path = current_path + "/result/" + resID
    shutil.copy2(source_path, dest_path)
예제 #4
0
# opening the respective output index files in write mode
clroutput = open(argmnts["hsv"], "w")
treeoutput = open(argmnts["btree"], "w")
texoutput = open(argmnts["texture"], "w")
 
# using glob to capture the paths of the images and iterate through them
for path in glob.glob(argmnts["dataset"] + "/*.jpg"):
	# getting the unique filenames from the image path
	imgID = path[path.rfind("/") + 1:]
	# loading the image
	image = cv2.imread(path)

	# getting the color, texture and tree features from the image
	color = cdes.describe_color(image)
	tree = tdes.color_tree(image)
	texture = txdes.describe_texture(image)

	# writing the color features to the clroutput file
	color = [str(f) for f in color]
	clroutput.write("%s,%s\n" % (imgID, ",".join(color)))
 
	# writing the tree features to the treeoutput file
	tree = [str(t) for t in tree]
	treeoutput.write("%s,%s\n" % (imgID, ",".join(tree)))

	# writing the texture features to the texoutput file
	texture = [str(tx) for tx in texture]
	texoutput.write("%s,%s\n" % (imgID, ",".join(texture)))
 
# close all the index files
clroutput.close()