ajout images crop

This commit is contained in:
François Pelletier 2015-09-26 16:05:40 -04:00
parent 9111da909a
commit 358dd91c04
13 changed files with 324 additions and 37 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 KiB

View file

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 28,
"metadata": {
"collapsed": true
},
@ -14,14 +14,14 @@
"\n",
"from skimage import feature\n",
"from scipy import misc\n",
"fimg = misc.imread(\"contourV1.png\")\n",
"fimg = misc.imread(\"contourV1-cropped.png\")\n",
"\n",
"from skimage import measure"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 29,
"metadata": {
"collapsed": false
},
@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 30,
"metadata": {
"collapsed": false
},
@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 31,
"metadata": {
"collapsed": false
},
@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 32,
"metadata": {
"collapsed": false
},

View file

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 26,
"metadata": {
"collapsed": true
},
@ -13,18 +13,18 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 27,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"fimg = misc.imread(\"contourV1.png\")"
"fimg = misc.imread(\"contourV1-cropped.png\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 28,
"metadata": {
"collapsed": true
},
@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 29,
"metadata": {
"collapsed": true
},
@ -46,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 30,
"metadata": {
"collapsed": true
},
@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 31,
"metadata": {
"collapsed": true
},
@ -72,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 32,
"metadata": {
"collapsed": false
},
@ -80,10 +80,10 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f3b9eaa60d0>]"
"[<matplotlib.lines.Line2D at 0x7f3bb2307910>]"
]
},
"execution_count": 24,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
@ -103,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 33,
"metadata": {
"collapsed": false
},

View file

@ -1,6 +0,0 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 0
}

View file

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 28,
"metadata": {
"collapsed": true
},
@ -14,14 +14,14 @@
"\n",
"from skimage import feature\n",
"from scipy import misc\n",
"fimg = misc.imread(\"contourV1.png\")\n",
"fimg = misc.imread(\"contourV1-cropped.png\")\n",
"\n",
"from skimage import measure"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 29,
"metadata": {
"collapsed": false
},
@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 30,
"metadata": {
"collapsed": false
},
@ -63,18 +63,18 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"contours = measure.find_contours(gimg, 0.8)"
"contours = measure.find_contours(gimg, 0.9)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 32,
"metadata": {
"collapsed": false
},

View file

@ -0,0 +1,146 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy import misc"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"fimg = misc.imread(\"contourV1-cropped.png\")"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from skimage import color"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"gimg = color.colorconv.rgb2grey(fimg)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from skimage import measure\n",
"contours = measure.find_contours(gimg, 0.8)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
" \n",
"for n, contour in enumerate(contours):\n",
" plt.plot(contour[:, 1], contour[:, 0], linewidth=2)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f3bb2307910>]"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from skimage.draw import ellipse\n",
"from skimage.measure import find_contours, approximate_polygon, subdivide_polygon\n",
" \n",
"contour = contours[0]\n",
"new_s = contour.copy()\n",
"appr_s = approximate_polygon(new_s, tolerance=0.8)\n",
" \n",
"fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(9, 4))\n",
"ax2.plot(contour[:, 0], contour[:, 1])\n",
"ax1.plot(appr_s[:, 0], appr_s[:, 1])"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB