DEV Community

Philip Purwoko
Philip Purwoko

Posted on

How To Process These Image in Python Using OpenCV

Hello, I was working on number detection app. I use the MNIST data for the model training. Then I want to deploy in website using FLask. Then I create drawing app using canvas Javascript. I transform the image from canvas using base64 image to flask server, but the image didn't what I was expected, so the model is working (no error) but it cannot predict the value correctly. How to process these image in python using OpenCV (cv2) or Pillow

This is the image from base64 (Image size (280, 280)). I want to transform from this.
Raw Image

To this. Image size (28, 28). The same looking as the MNIST data from training process.
Processed Image

You can also check my Github repository for the codes (https://github.com/PhilipPurwoko/NumberRecognition). I really appreciate all of your responses. Thank you

Discussion (1)

Collapse
philippurwoko profile image
Philip Purwoko Author

[SOLVED] I use this

image = cv2.resize(image, (28, 28), interpolation=cv2.INTER_LINEAR)
Enter fullscreen mode Exit fullscreen mode