OutDir = "mid-level/" + techniqueLow + "/DR2/" + techniqueMid + "/additional/" + lesion + "/"
				
				for label in ["+1","-1"]:
					# describe the normal images
					if label == "-1": lesion = "imagem-normal"
								
					lesion_en = en[lesion]
					if image == "":
						if type == "DR2" and (lesion == "hemorragia-superficial" or lesion == "hemorragia-profunda"):
							listImages = os.listdir("datasets/" + type + "-images-by-lesions/Red Lesions")
						else:
							listImages = os.listdir("datasets/" + type + "-images-by-lesions/" + lesion_en)
					else: listImages = [image]
				
					for im in listImages:
						im_special = common_functions.specialName(im)
						if os.path.exists(OutDir + im[:-3] + "hist"): continue
						
						# define the output file (histogram)
						OutFile = OutDir + im[:-3] + "hist"
						f = open(OutFile,"wb")
					
						# get the points of interest
						PoIsTemp = open(PoIsDir + im[:-3] + "key","rb").readlines()
						PoIs = []
						for i in range(2,len(PoIsTemp),2):
							PoIs.append([ float(p) for p in PoIsTemp[i].split() ])
						PoIs = numpy.asarray(PoIs)				
									
						sys.stdout.write(". ")
						sys.stdout.flush()
示例#2
0
					OutDir = "mid-level/" + techniqueLow + "/DR2/" + techniqueMid + "/additional/" + lesion + "/"
				
				for label in ["+1","-1"]:
					# describe the normal images
					if label == "-1": lesion = "imagem-normal"
								
					lesion_en = en[lesion]
					if image == "":
						if type == "DR2" and (lesion == "hemorragia-superficial" or lesion == "hemorragia-profunda"):
							listImages = os.listdir("datasets/" + type + "-images-by-lesions/Red Lesions")
						else:
							listImages = os.listdir("datasets/" + type + "-images-by-lesions/" + lesion_en)
					else: listImages = [image]
				
					for im in listImages:
						im_special = common_functions.specialName(im)
						if os.path.exists(OutDir + im[:-3] + "hist"): continue
						
						# define the output file (histogram)
						OutFile = OutDir + im[:-3] + "hist"
						f = open(OutFile,"wb")
					
						# get the points of interest
						PoIsTemp = open(PoIsDir + im[:-3] + "key","rb").readlines()
						PoIs = []
						for i in range(2,len(PoIsTemp),2):
							PoIs.append([ float(p) for p in PoIsTemp[i].split() ])
						PoIs = numpy.asarray(PoIs)				
									
						sys.stdout.write(". ")
						sys.stdout.flush()
    else: print "\n\nTest images -", type

    for lesion in lesions:
        if type == "DR2" and (lesion == "hemorragia-superficial"
                              or lesion == "hemorragia-profunda"):
            continue
        lesion_en = en[lesion]
        print lesion_en
        listImages = os.listdir("datasets/" + type + "-images-by-lesions/" +
                                lesion_en)

        start = timeit.default_timer()
        for im in listImages:
            sys.stdout.write(". ")
            sys.stdout.flush()
            im_special = common_functions.specialName(im)

            for technique in techniques:
                if os.path.exists(directory + technique + "/" + type + "/" +
                                  im[:-3] + "key"):
                    continue
                fAux = open(
                    directory + technique + "/" + type + "/" + im[:-3] + "key",
                    "wb")

                if technique == "sparse":
                    sparseExtraction(
                        im_special, technique, type,
                        "datasets/" + type + "-images-by-lesions/" +
                        common_functions.specialName(lesion_en))
                    common_functions.organizeFileSurfToDescriptor(directory +
print "################################################"
for type in [train,test]:
	if type == train: print "Training images -", type
	else: print "\n\nTest images -", type

	for lesion in lesions:
		if type == "DR2" and (lesion == "hemorragia-superficial" or lesion == "hemorragia-profunda"): continue
		lesion_en = en[lesion]
		print lesion_en
		listImages = os.listdir("datasets/" + type + "-images-by-lesions/" + lesion_en)
		
		start = timeit.default_timer()
		for im in listImages:
			sys.stdout.write(". ")
			sys.stdout.flush()
			im_special = common_functions.specialName(im)
			
			for technique in techniques:
				if os.path.exists(directory + technique + "/" + type + "/" + im[:-3] + "key"): continue
				fAux = open(directory + technique + "/" + type + "/" + im[:-3] + "key","wb")
								
				if technique == "sparse":
					sparseExtraction(im_special, technique, type, "datasets/" + type + "-images-by-lesions/" + common_functions.specialName(lesion_en))
					common_functions.organizeFileSurfToDescriptor(directory + technique + "/" + type + "/" + im[:-3] + "key")
					common_functions.filterPoints(type, technique, im)
				else:
					denseExtraction(im, im_special, technique, type, "datasets/" + type + "-images-by-lesions/" + common_functions.specialName(lesion_en))
					common_functions.organizeFileSurfToDescriptor(directory + technique + "/" + type + "/" + im[:-3] + "key")
			
		stop = timeit.default_timer()
		sys.stdout.write(common_functions.convertTime(stop - start) + "\n")