Guest User

Untitled

a guest
Mar 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/bin/bash
  2. input="/home/pulkit/micrograph.txt"
  3. x=0;
  4. while IFS= read -r var
  5. do
  6. i=${var##*,}
  7. #echo $i
  8. a[x]=${i::-1}
  9. x=$((x+1))
  10. done < "$input"
  11. x=0;y=1;b[0]=0;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=0;b[6]=0;
  12. for file in `ls -v *.tif`
  13. do
  14. convert -crop 644x484 "$file" cropped_%d.tif
  15. rm -f cropped_1.tif
  16. mv "cropped_0.tif" "$file"
  17. convert -crop 322x242 "$file" cropped_%d.tif
  18. rm -f $file
  19. if [[ ${a[$y]} == *"spheroidite+widmanstatten"* ]]
  20. then
  21. x=4
  22. elif [[ ${a[$y]} == *"pearlite+spheroidite"* ]]
  23. then
  24. x=5
  25. elif [[ ${a[$y]} == *"pearlite+widmanstatten"* ]]
  26. then
  27. x=6
  28. elif [[ ${a[$y]} == *"pearlite"* ]]
  29. then
  30. x=0
  31. elif [[ ${a[$y]} == *"spheroidite"* ]]
  32. then
  33. x=1
  34. elif [[ ${a[$y]} == *"martensite"* ]]
  35. then
  36. x=2
  37. elif [[ ${a[$y]} == *"network"* ]]
  38. then
  39. x=3
  40. fi
  41. for file in cropped*
  42. do
  43. mv "$file" "${a[$y]}_${b[$x]}.tif"
  44. b[$x]=$((b[$x] + 1))
  45. done
  46. y=$((y + 1))
  47. done
Add Comment
Please, Sign In to add comment