Skip to content

Commit

Permalink
feat: add gaussian noise to image (#430)
Browse files Browse the repository at this point in the history
Closes #381 

### Summary of Changes

Images can now be modified with "gaussian noise".

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
Co-authored-by: Lars Reimann <mail@larsreimann.com>
  • Loading branch information
3 people committed Jul 13, 2023
1 parent d71303d commit 925a505
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 23 deletions.
Binary file removed docs/tutorials/data/boy.png
Binary file not shown.
Binary file added docs/tutorials/data/plane.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 36 additions & 16 deletions docs/tutorials/image_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
"source": [
"from safeds.data.image.containers import Image\n",
"\n",
"boy = Image.from_png_file(\"data/boy.png\")\n",
"boy"
"plane = Image.from_png_file(\"data/plane.png\")\n",
"plane"
]
},
{
"cell_type": "markdown",
"source": [
"## Process the image\n",
"\n",
"1. Resize the `Image` to have the width 300 and height 250:"
"1. Resize the `Image` to have the width 284 and height 160:"
],
"metadata": {
"collapsed": false
Expand All @@ -52,7 +52,7 @@
"metadata": {},
"outputs": [],
"source": [
"boy.resize(200,170)"
"plane.resize(284, 160)"
]
},
{
Expand All @@ -69,7 +69,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.convert_to_grayscale()\n"
"plane.convert_to_grayscale()\n"
],
"metadata": {
"collapsed": false
Expand All @@ -78,7 +78,7 @@
{
"cell_type": "markdown",
"source": [
"3. Crop the `Image` to be 200x200 with the top-left corner being at (250, 130):"
"3. Crop the `Image` to be 200x200 with the top-left corner being at (255, 30):"
],
"metadata": {
"collapsed": false
Expand All @@ -89,7 +89,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.crop(250, 130, 200, 200)\n"
"plane.crop(x=255, y=30, width=200, height=200)\n"
],
"metadata": {
"collapsed": false
Expand All @@ -109,7 +109,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.flip_horizontally()\n"
"plane.flip_horizontally()\n"
],
"metadata": {
"collapsed": false
Expand All @@ -131,7 +131,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.adjust_brightness(1.5)\n"
"plane.adjust_brightness(1.5)\n"
],
"metadata": {
"collapsed": false
Expand All @@ -153,7 +153,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.adjust_contrast(1.5)\n"
"plane.adjust_contrast(1.5)\n"
],
"metadata": {
"collapsed": false
Expand All @@ -175,7 +175,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.adjust_color_balance(0.5)"
"plane.adjust_color_balance(0.5)"
],
"metadata": {
"collapsed": false
Expand All @@ -198,7 +198,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.blur(5)\n"
"plane.blur(5)\n"
],
"metadata": {
"collapsed": false
Expand All @@ -220,7 +220,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.sharpen(5)\n"
"plane.sharpen(5)\n"
],
"metadata": {
"collapsed": false
Expand All @@ -240,7 +240,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.invert_colors()\n"
"plane.invert_colors()\n"
],
"metadata": {
"collapsed": false
Expand All @@ -260,7 +260,7 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.rotate_right()\n"
"plane.rotate_right()\n"
],
"metadata": {
"collapsed": false
Expand All @@ -280,7 +280,27 @@
"execution_count": null,
"outputs": [],
"source": [
"boy.find_edges()\n"
"plane.find_edges()\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"13. Add gaussian noise to the `Image`. A higher `standard_deviation` will result in a noisier `Image`:\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"plane.add_gaussian_noise(standard_deviation=0.1)\n"
],
"metadata": {
"collapsed": false
Expand Down

0 comments on commit 925a505

Please sign in to comment.