Swift-AI / Swift-AI

The Swift machine learning library.
MIT License
6.03k stars 554 forks source link

Convert UIImage to [[Float]] #39

Closed rosensts closed 8 years ago

rosensts commented 8 years ago

Hey folks,

Does anybody have a concise way to convert a UIImage to an array of Floats? I have tried to use a variant of the scanImage() function from the HandwritingViewController in the iOS examples but all of my images are coming out to be exactly the same. I have been stuck on this for a few days, not sure where I am going wrong. Any help would be greatly appreciated.

Take care y'all

Jxrgxn commented 8 years ago

I'm not quite sure if it's possible via Swift off the top of my head but I know that you can convert a UIImage to NSData to Float. I don't know much APKit might affect the original function's operation, however. Hopefully @collinhundley can give a clear answer.

rosensts commented 8 years ago

I figured it out. I used UIImageToPNGRepresentation and it worked great. My problem was actually in the structure of the FFNN. I was using waaaay to many hiddle nodes. @KacheFlowe thanks for the help