reworked images

This commit is contained in:
Jakob Krause
2018-05-09 12:03:40 +02:00
parent fcd436d3b6
commit 69a50713f5

View File

@@ -17,7 +17,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -27,7 +27,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@@ -58,17 +58,26 @@
"\n", "\n",
"Qualify the noise and sharpness in the images. Make a plot images, noise\n", "Qualify the noise and sharpness in the images. Make a plot images, noise\n",
"\n", "\n",
"Please download sample picture from [here](http://www.imageprocessingplace.com/downloads_V3/root_downloads/image_databases/standard_test_images.zip)" "Please download sample picture from [here](http://sipi.usc.edu/database/misc.zip)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# Load the pictures here\n", "# Load the pictures here\n",
"sample_images = None" "sample_images = []\n",
"direc = 'misc/' # directory of the sample pictures realtivly to your notebook\n",
"for number in [1,3,5,6]:\n",
" sample_images.append(\n",
" np.array(Image.open(direc+'4.2.0'+str(number)+'.tiff'))\n",
" )\n",
"for name in ['house', 'ruler.512']:\n",
" sample_images.append(\n",
" np.array(Image.open(direc+name+'.tiff'))\n",
" )"
] ]
}, },
{ {
@@ -117,15 +126,13 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"def jpeg_enocde(img, quality):\n", "def jpeg_enocde(img, quality):\n",
" pil_img = Image.fromarray(img)\n", " pil_img = Image.fromarray(img)\n",
" buffer = BytesIO()\n", " buffer = BytesIO()\n",
" im1.save(buffer, \"JPEG\", quality=quality)\n", " pil_img.save(buffer, \"JPEG\", quality=quality)\n",
" return buffer\n", " return buffer\n",
"\n", "\n",
"def jpeg_decode(buffer):\n", "def jpeg_decode(buffer):\n",
@@ -137,15 +144,6 @@
" return jpeg_decode(as_jpeg)" " return jpeg_decode(as_jpeg)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"len(images_for_jpeg)"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -169,7 +167,7 @@
" # your code\n", " # your code\n",
" return random.randint(0, 10)\n", " return random.randint(0, 10)\n",
"\n", "\n",
"for i, img in enumerate(images_for_jpeg):\n", "for i, img in enumerate(sample_images):\n",
" print(i)\n", " print(i)\n",
" compressed_images = [images10[i], images50[i], images80[i]]\n", " compressed_images = [images10[i], images50[i], images80[i]]\n",
" plt.bar(range(len(compressed_images)),\n", " plt.bar(range(len(compressed_images)),\n",
@@ -180,9 +178,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [] "source": []
} }