Manage photos and Python Scikit Learn
If you need to convert images, use the popular free open-source https://imagemagick.org
NOTE: Content here are my personal opinions, and not intended to represent any employer (past or present). “PROTIP:” here highlight information I haven’t seen elsewhere on the internet because it is hard-won, little-know but significant facts based on my personal research and experience.
Install using HomeBrew (instead of downloading, gunzip, variables, etc.):
brew install imagemagick
Because ImageMagick depends on Ghostscript fonts, install them as well:
brew install ghostscript
https://www.pluralsight.com/courses/building-features-image-data Building Features from Image Data Aug 13, 2019 by Janani Ravi
In a Jupyter Notebook:
Install (within venv) from https://scikit-image.org/
pip3 install -U scikit-image
To improve CNN network performance:
- Crop for uniform Aspect Ratio (square, 16:9 HD)
- uniform Image size (downscaling to smaller image or upscaling to larger image)
- Mean and Perturbed images (detect faces and put them in the center of the image)
- Dimenionality reduction
Data augmentation (scaling, rotation, affine transforms to preserve collinearity (i.e., all points lying on a line initially still lie on a line after transformation) and ratios of distances (e.g., the midpoint of a line segment remains the midpoint after transformation). Also called an affinity.
- Normalized impage outputs around mean
To convert a file (such as a pdf) into a high-resolution image, use Imagemagick’s convert command:
convert -density 300 test.pdf -depth 8 -strip -background white -alpha off out.tiff
The last parameter is the output file.
This also takes off Alpha channels and outputs to a TIFF format file.
Alternative parameters are “-monochrome” to convert to black-and-white. These have a single “channel” whereas color images have 3 channels (Red, Green, Blue).
Images seen reflected on a mirror or on a traditional letterpress need to be flipped (left to right). Sample scikit-learn code:
image_mirror_fliplr = np.fliplr(img_mirror)
This is one of a series on AI, Machine Learning, Deep Learning, Robotics, and Analytics:
- AI Ecosystem
- Machine Learning
- Microsoft’s AI
- Microsoft’s Azure Machine Learning Algorithms
- Microsoft’s Azure Machine Learning tutorial
- Python installation
- Image Processing
- Tessaract OCR using OpenCV
- Multiple Regression calculation and visualization using Excel and Machine Learning
- Tableau Data Visualization