Exemplo n.º 1
0
def guessedWrong(originalImage):
    print 'WHOOPS!'
    cont = True
    while (cont):
        correctDigit = raw_input("--> Please input the correct digit ('X' to exit): ")
        if correctDigit == 'X' or correctDigit == 'x':
            cont = False
        else:
            if utilities.isInteger(correctDigit):
                for i in range (0,10):
                    if correctDigit == "{0}".format(i):
                        saveImageToCorrectDigitFolder(originalImage,correctDigit)
                        print "Please go back to the main menu and restart the Digit Recognition program to reload the new image into the database!"
                        cont = False
                if cont:
                    print "Command must be an integer from [0,10], or 'X' to exit!"
            else:
                print "Command must be an integer from [0,10], or 'X' to exit!"
    return
Exemplo n.º 2
0
def filterFunction(originalImage):
	print 'Kernel Types:'
	for kernelIndex in range(0,len(kernels.kernels)):
		print '({0}) {1}'.format(kernelIndex, kernels.kernels[kernelIndex]['name'])
	print '({0}) ZS Thinning'.format(len(kernels.kernels))

	cont = True
	while (cont):
		command = raw_input('--> Please choose a filter: ')
		if (utilities.isInteger(command)):
			command = int(command)
			if (command >= 0 and command <= (len(kernels.kernels))):
				cont = False
			else:
				print "Must be an integer in the range [0, {0}]!".format(len(kernels.kernels))

		else:
			print "Must be an integer in the range [0, {0}]!".format(len(kernels.kernels))

	if command == len(kernels.kernels):
		print 'Thinning...'
		thinnedImage = thinningFilter(originalImage)
		thinnedImage.show()
		print 'Saving the thinned image to the output folder as thinnedImage.jpg...'
		thinnedImage.save(os.getcwd() + '/output/thinnedImage.jpg')
	else:

		multiplier = 1.0/float(kernels.kernels[command]['factor'])

		print 'Applying the filter - {0}...'.format(kernels.kernels[command]['name'])
		filteredImage = apply3x3Filter(originalImage,kernels.kernels[command]['kernel'],multiplier)
		# filteredImage = Image.fromarray(ndimage.convolve(numpy.asarray(originalImage),kernels.kernels[command]['kernel']))
		print 'Displaying the image with the applied filter - {0}...'.format(kernels.kernels[command]['name'])
		filteredImage.show()
		print 'Saving the image with the applied filter to the output folder as filteredImage.jpg...'
		filteredImage.save(os.getcwd() + '/output/filteredImage.jpg')

	return