Esempio n. 1
0
def vglLoadImage(img, filename=""):
	if( img.filename == "" ):
		if( filename == "" ):
			print("vglImage: vglLoadImage Error: Image file path not defined! Empty string received!")
			exit()
		else:
			img.filename = filename
	try:
		img.ipl = io.imread(img.filename)
		vl.vglAddContext(img, vl.VGL_RAM_CONTEXT())
	except FileNotFoundError as fnf:
		print("vglImage: vglLoadImage Error: loading image from file:", img.filename)    
		print(str(fnf))
		exit()
	except Exception as e:
		print("vglImage: vglLoadImage Error: Unrecognized exception was thrown.")
		print(str(e))
		exit()
	
	if( isinstance(img.ipl, np.ndarray) ):
		#print("vglImage: Image loaded! VGL_RAM_CONTEXT.")

		vl.create_vglShape(img)

		img.depth = img.getVglShape().getNFrames()
		img.nChannels = img.getVglShape().getNChannels()
Esempio n. 2
0
def vglClDownload(img):
    if (vl.vglIsInContext(img, vl.VGL_CL_CONTEXT())):
        if (img.clForceAsBuf == vl.IMAGE_CL_OBJECT()):
            vglClImageDownload(img)
        elif (img.clForceAsBuf == vl.IMAGE_ND_ARRAY()):
            vglClNdImageDownload(img)

        vl.vglAddContext(img, vl.VGL_RAM_CONTEXT())
    else:
        print("vglClDownload: Error: image context is not in VGL_CL_CONTEXT.")
        exit()
Esempio n. 3
0
"""
if __name__ == "__main__":
	
	vl.vglClInit()

	msg = ""

	# INPUT IMAGE
	img_input = vl.VglImage(sys.argv[1], None, vl.VGL_IMAGE_2D_IMAGE(), vl.IMAGE_ND_ARRAY())
	vl.vglLoadImage(img_input)
	vl.vglClUpload(img_input)

	# OUTPUT IMAGE
	img_output = vl.create_blank_image_as(img_input)
	img_output.set_oclPtr( vl.get_similar_oclPtr_object(img_input) )
	vl.vglAddContext(img_output, vl.VGL_CL_CONTEXT())

	# STRUCTURANT ELEMENT
	window = vl.VglStrEl()
	window.constructorFromTypeNdim(vl.VGL_STREL_CROSS(), 2)

	inicio = t.time()
	vglClNdCopy(img_input, img_output)
	fim = t.time()
	vl.vglCheckContext(img_output, vl.VGL_RAM_CONTEXT())
	vl.vglSaveImage("img-vglNdCopy.jpg", img_output)
	msg = msg + "Tempo de execução do método vglClNdCopy:\t" +str( round( (fim-inicio), 9 ) ) +"s\n"

	inicio = t.time()
	vglClNdConvolution(img_input, img_output, window)
	fim = t.time()