Commit 51485aff authored by Jefferson F. Paril's avatar Jefferson F. Paril 😁

updated to python3

parent 3ffabd85
......@@ -16,7 +16,7 @@ A suite of Bash, python, and R scripts for extracting plant health-related metri
git clone https://gitlab.com/jeffersonfparil/instaGraminoid.git
Checks for the following dependencies and installs them (This may take a while. Sorry.)
- python
- python3
- python-pip
- opencv-python
- numpy
......
......@@ -143,14 +143,14 @@ esac
### CHECK FOR REQUIRED DEPENDENCIES: ###
### ###
########################################
# check for python, python-pip and r-base in Linux (or windows subsytem for linux) and Mac
# check for python3, python3-pip and r-base in Linux (or windows subsytem for linux) and Mac
if [ $machine = Linux ]; then
for p in python pip R parallel; do
for p in python3 pip R parallel; do
if hash $p &>/dev/null; then
echo "$p exists!"
else
echo "$p does not exist!"
if [ $p = pip ]; then sudo apt install python-pip python-tk
if [ $p = pip ]; then sudo apt install python3-pip python3-tk
elif [ $p = R ]; then sudo apt install r-base
else sudo apt install $p
fi
......@@ -182,9 +182,9 @@ fi
# install python modules: opencv-python, numpy, matplotlib, scipy and seaborn
for m in opencv-python numpy matplotlib scipy seaborn; do
if [ $m = opencv-python ]; then
if [ $(python -c "import pkgutil; print(1 if pkgutil.find_loader('cv2') else 0)") = 0 ]; then pip install --user opencv-python; fi
if [ $(python3 -c "import pkgutil; print(1 if pkgutil.find_loader('cv2') else 0)") = 0 ]; then pip3 install --user opencv-python; fi
else
if [ $(python -c "import pkgutil; print(1 if pkgutil.find_loader('$m') else 0)") = 0 ]; then pip install --user $m; fi
if [ $(python3 -c "import pkgutil; print(1 if pkgutil.find_loader('$m') else 0)") = 0 ]; then pip3 install --user $m; fi
fi
done
# install R packages:
......
......@@ -59,8 +59,10 @@ def __DETECT_PLANTS__(IMAGE, THRESHOLD, COLOR_COLLAPSE="gray", PLOT=False):
kernel = np.ones((5,5),np.uint8)
mask2 = cv2.morphologyEx(mask1, cv2.MORPH_OPEN, kernel)
mask3 = cv2.morphologyEx(mask2, cv2.MORPH_CLOSE, kernel)
mask4, CONTOURS, hierarchy = cv2.findContours(mask3, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
IMAGE_EXTRACT = cv2.bitwise_and(IMAGE, IMAGE, mask=mask4)
# mask4, CONTOURS, hierarchy = cv2.findContours(mask3, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
CONTOURS, hierarchy = cv2.findContours(mask3, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# IMAGE_EXTRACT = cv2.bitwise_and(IMAGE, IMAGE, mask=mask4)
IMAGE_EXTRACT = cv2.bitwise_and(IMAGE, IMAGE, mask=mask3)
if PLOT==True:
plt.imshow(COLLAPSED_IMAGE, cmap='gray'); plt.show()
plt.imshow(mask1, cmap='gray'); plt.show()
......@@ -173,6 +175,12 @@ width_crop = sys.argv[3] #e.g. "1000,3600 or 0,4928 or 1000,3800" --> y0,y1: cro
setWhite = int(sys.argv[4]) #check 0:200, 0:200 pixel values in the cropped photographs; may range from 150 to 255
threshold = int(sys.argv[5]) #threshold falttened (grayscale) pixel value detected; usually 75% of the setWhite
### TEST: 20200108
# height_crop = "1250,2500"
# width_crop = "1000,5000"
# setWhite = 200
# threshold = round(setWhite * 0.75)
#crop
height_crop = [int(x) for x in height_crop.split(",")]
width_crop = [int(x) for x in width_crop.split(",")]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment