简体   繁体   中英

How do I convert normal UIImage into corresponding NES palette color?

I want to convert UIImage into 8 bit NES colors. The problem is, i couldn't find any algorithm on internet which can perform such operation. I don't want to use openCV for this. Is there any method to do so? Any help is appreciated.

I found the answer for this. The solution is as follows: For every pixel of CGImage calculate the nearest color from the NES palette. Distance between two colors can be calculated using the vector distance between them. Vector distance can be calculated using math function sqrt( (R1-R2) (R1-R2) + (G1-G2) (G1-G2) + (B1-B2)*(B1-B2)), where, R,G,B indicates the values of the color components.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM