A tiny Python program to convert picture to chars, get hog features from picture's areas and using char with most similiar hog feathre to represident it, finally convert a picture to a list of chars.
- Python 2.7
- OpenCV 3
- Numpy
- Movie-py
python pic2char.py <source> <max(width, height)> <target_file> [<channels> [<to_txt_file> [<trim_txt_file>]]]
- source: source file, can be picture, gif or video file (gif and video consume huge amount time)
- max(width, height): max width or height of output file, choose the longer one
- target_file: The file you want to export, you can export to any file if you set
to_txt_file
to 1, but you need to choose right fiel type otherwise, picture to picture, gif to gif, video to video - channels: the channels use to extract features, 3 or 1. * to_txt_file: ONLY WORKS IN PICTURE, 1 means output to txt file, otherwise to pictures * trim_txt_file: ONLY WORKS IN PICTURE, 1 means skip blank in line end
Sample Picture (Get from pixabay):
-
To TXT File: (The origin file is located in txt.txt)
You can edit some params defined at the top of pic2char.py, the area's width or height, the chars to use, the gray values.