Skip to content

Commit

Permalink
Fix function imcrop_tosquare() when extra pixels to crop is an odd nu…
Browse files Browse the repository at this point in the history
…mber
  • Loading branch information
is3D-1 committed Jan 8, 2017
1 parent 84a09ba commit ce2bf9a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions session-0/session-0.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -807,13 +807,13 @@
" if extra % 2 == 0:\n",
" crop = img[extra // 2:-extra // 2, :]\n",
" else:\n",
" crop = img[max(0, extra // 2 - 1):min(-1, -extra // 2), :]\n",
" crop = img[max(0, extra // 2 + 1):min(-1, -(extra // 2)), :]\n",
" elif img.shape[1] > img.shape[0]:\n",
" extra = (img.shape[1] - img.shape[0])\n",
" if extra % 2 == 0:\n",
" crop = img[:, extra // 2:-extra // 2]\n",
" else:\n",
" crop = img[:, max(0, extra // 2 - 1):min(-1, -extra // 2)]\n",
" crop = img[:, max(0, extra // 2 + 1):min(-1, -(extra // 2))]\n",
" else:\n",
" crop = img\n",
" return crop"
Expand Down Expand Up @@ -1078,8 +1078,9 @@
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
Expand All @@ -1093,7 +1094,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.0"
"version": "3.5.2"
}
},
"nbformat": 4,
Expand Down

0 comments on commit ce2bf9a

Please sign in to comment.