Ejemplo n.º 1
0
	Positions.append([Position[0], Position[1]])
	return canvas.create_oval(Position[0]-Radius, Position[1]-Radius, Position[0]+Radius, Position[1]+Radius, tags=("circle"))

print "Select your image through the file explorer."

# open an file browsing dialogue
currdir = os.getcwd()
ImagePath = tkFileDialog.askopenfilename(parent=root, initialdir=currdir, title='Select an Image File.')

# the unprocessed image is the original
# put it in greyscale
UnprocessedImage = Image.fromarray(cv2.imread(ImagePath)).convert('L')
UnprocessedImagePixels = UnprocessedImage.load()

# save image which has outlines of letter, which automatically converts it to greyscale
ImageProcessing.Outlines(cv2.imread(ImagePath), "Processed/" + FullFilename)

OriginalImage = Image.open("Processed/" + FullFilename)
OriginalImagePixels = OriginalImage.load()

# resize the image so that the height is 400
Multiplier = 600.0 / OriginalImage.size[1] 
TextImage = OriginalImage.resize((int(OriginalImage.size[0] * Multiplier), int(OriginalImage.size[1] * Multiplier)), Image.ANTIALIAS)
TextImagePixels = TextImage.load()

# set the canvas size to match the image
canvas = Tkinter.Canvas(root, width=TextImage.size[0], height=TextImage.size[1])
# draw the image to the canvas
photo = ImageTk.PhotoImage(TextImage)
canvas.create_image(0, 0, image=photo, anchor="nw")