Thursday, 29 January 2015

Image scaling

This is a script that has been resting on my desktop for months. Basically I would like to take my knowledge of image recognition with machine learning a step further and this is a simple step towards that direction.

The basic idea behind the script is to convert the image in a 0 and 1 format which is easier to process with machine learning algorithms. After I wrote the script, I found out there is a function in sklearn that does something similar, anyway I thought I could share the piece of code I wrote, perhaps it could be useful to someone.

This the image I started with

ot

By using the following script we can convert the image in a more manageable format


This is the result we obtain, A and B respectively


f


Only numbers between 0 and 1 are used in the picture A above while the picture below uses only 0s and 1.1



For sure we loose some information, however this is just a raw script, perhaps I can do better in the future. However, this is a rather complicated image (not to mention the fact that it’s the only sample I have got) the script should yield better results with simpler images and shapes.

2 comments:

  1. I wanted to thank you for this great read and definitely enjoying every little bit of it and bookmarked to check out new stuff you post.
    Best Digital Marketing Institute in Hyderabad

    ReplyDelete

  2. Very nice job... Thanks for sharing this amazing and educative blog post!
    Data Science Course in Chandigarh

    ReplyDelete