Last active
October 12, 2016 02:24
-
-
Save samehmohamed88/45753854c0728d0ed88156b762bb72ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xe | |
sudo apt-get -y update | |
sudo apt-get install -y tk8.6-dev libssl-dev sqlite3 libsqlite3-dev \ | |
gcc g++ make libpng-dev libxml2 \ | |
libxml2-dev libxslt1-dev python-dev \ | |
zlib1g-dev libbz2-dev \ | |
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev | |
curl -o /tmp/Python-2.7.11.tgz https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz | |
tar -xf /tmp/Python-2.7.11.tgz -C /tmp | |
cd /tmp/Python-2.7.11 && ./configure --prefix=/opt --enable-unicode=ucs4 && make && sudo make altinstall | |
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo /opt/bin/python2.7 | |
sudo /opt/bin/easy_install-2.7 pip | |
sudo /opt/bin/pip2.7 install virtualenv | |
cd ~ | |
/opt/bin/virtualenv --distribute --no-site-packages venv | |
source venv/bin/activate | |
pip install -v matplotlib Pillow | |
cat <<EOF>> ./example.py | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
import numpy as np | |
#reading in the image and printing out some stats | |
image = mpimg.imread('test.jpg') | |
print('This image is: ',type(image), | |
'with dimensions:', image.shape) | |
#grabbing the x and y size and making a copy of the image | |
ysize = image.shape[0] | |
xsize = image.shape[1] | |
color_select = np.copy(image) | |
#defining our color selection criteria | |
red_threshold = 0 | |
green_threshold = 0 | |
blue_threshold = 0 | |
rgb_threshold = [red_threshold, green_threshold, blue_threshold] | |
#using a "bitwise or" to identify pixels below the threshold | |
thresholds = (image[:,:,0] < rgb_threshold[0]) \ | |
| (image[:,:,1] < rgb_threshold[1]) \ | |
| (image[:,:,2] < rgb_threshold[2]) | |
color_select[thresholds] = [0,0,0] | |
#displaying the image | |
plt.ion() | |
plt.imshow(color_select) | |
plt.show(block=True) | |
EOF | |
curl -O https://d17h27t6h515a5.cloudfront.net/topher/2016/August/57b4b3ff_test/test.jpg | |
ipython --gui=gkt3 example.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment