0

I want to create a field in python that will accept mouse drawings and convert it into 28x28 pixels image:

field like this

I want to use this image result to predict the output using a model that i have already trained, the model is of hand writing recognition where each image is of 28x28 pixels

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87

1 Answers1

1

You can use Tkinter along with PIL (Python Imaging Library) to perform your task.

I came across THIS QUESTION which solves the problem of saving drawings on a canvas as an image.

I modified the existing code to resize the image to dimension of 28 x 28 and saved the result.

Follow the code in the link and in the save() just the resize() function before saving the image:

def save(self):
    filename = "C:/Users/Desktop/my_drawing.jpg"
    self.image = self.image.resize((28, 28), 1)
    self.image.save(filename)
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87