diff --git a/Structure Tensor/StructureTensor2D_exercise.ipynb b/Structure Tensor/StructureTensor2D_exercise.ipynb index 2173a0b4c504d48860e784b6e20a215d0288e573..7821ea3dd25629782a381740a603676f49ae981a 100644 --- a/Structure Tensor/StructureTensor2D_exercise.ipynb +++ b/Structure Tensor/StructureTensor2D_exercise.ipynb @@ -119,10 +119,9 @@ "This first part will guide you through the implementation of your first analysis using structure tensor. You are going to write code to:\n", "1. Compute the structure tensor matrix and the orientation vectors.\n", "> Use the `st2d` functions described above\n", - "2. Calculate the orientation angles and reshape angles back to an image.\n", - "> - Compute the angles[°] from the components of the dominant orientation (__vec__). <br>\n", - ">> Use np.pi and one of the trigonometric functions: `np.arccos()`, `np.arcsin()` or `np.arctan2()`. Look at the figure above.\n", - "> - Reshape your output with `output.reshape(img.shape)`" + "2. Calculate the orientation angles\n", + "> - Compute the angles[rad] from the components of the dominant orientation (__vec__). <br>\n", + ">> Look at the figure above and use a trigonometric function: `np.arccos()`, `np.arcsin()` or `np.arctan2()`. \n" ] }, { @@ -167,7 +166,7 @@ "# Compute the structure tensor\n", "### USER INPUT HERE ### (≈ 2 lines of code)\n", "S = # compute structure tensor matrix S\n", - "val,vec = # compute dominant orientation vector (vec) and principal orientation weights (val)\n", + "val, vec = # compute dominant orientation vector (vec) and principal orientation weights (val)\n", "### END USER INPUT ### \n", "\n", "print(f'Structure tensor information is carried in a {S.shape} array.')\n", @@ -176,9 +175,12 @@ "# Compute orientation angles\n", "### USER INPUT HERE ### (≈ 1 line of code)\n", "angle = # compute angles\n", - "orientation_image = # shape as an image\n", "### END USER INPUT ### \n", "\n", + "# Prepare the angles to show as image \n", + "angle /= np.pi #scale from 0 to 1\n", + "orientation_image = angle.reshape(image.shape) # shape as an image\n", + "\n", "# Visualise the results\n", "figsize = (10,5)\n", "fig, ax = plt.subplots(1, 2, figsize=figsize, sharex=True, sharey=True)\n", @@ -330,7 +332,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "9348b6dffa2740ecb647efda73075c06", + "model_id": "ba20135d4767480c838913a395d806ce", "version_major": 2, "version_minor": 0 }, @@ -382,7 +384,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c63d444ec078465c9b9e0226c3149043", + "model_id": "dc0b06199211481ca9c3adc7700b37ea", "version_major": 2, "version_minor": 0 }, @@ -430,7 +432,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "60c02737b9554f67915bde19d5a431df", + "model_id": "9cce53c47d8f498fbcfe26212f4b317e", "version_major": 2, "version_minor": 0 }, diff --git a/Structure Tensor/StructureTensor2D_exercise_solutions.ipynb b/Structure Tensor/StructureTensor2D_exercise_solutions.ipynb index 425380e2554b6c7d16862bd57cfcada8132fcc2b..6c1271d8dc7d9c37650f6f55c24a19ed1be0acca 100644 --- a/Structure Tensor/StructureTensor2D_exercise_solutions.ipynb +++ b/Structure Tensor/StructureTensor2D_exercise_solutions.ipynb @@ -119,10 +119,9 @@ "This first part will guide you through the implementation of your first analysis using structure tensor. You are going to write code to:\n", "1. Compute the structure tensor matrix and the orientation vectors.\n", "> Use the `st2d` functions described above\n", - "2. Calculate the orientation angles and reshape angles back to an image.\n", - "> - Compute the angles[°] from the components of the dominant orientation (__vec__). <br>\n", - ">> Use np.pi and one of the trigonometric functions: `np.arccos()`, `np.arcsin()` or `np.arctan2()`. Look at the figure above.\n", - "> - Reshape your output with `output.reshape(img.shape)`" + "2. Calculate the orientation angles\n", + "> - Compute the angles[rad] from the components of the dominant orientation (__vec__). <br>\n", + ">> Look at the figure above and use a trigonometric function: `np.arccos()`, `np.arcsin()` or `np.arctan2()`. \n" ] }, { @@ -175,10 +174,13 @@ "\n", "# Compute orientation angles\n", "### USER INPUT HERE ### (≈ 1 line of code)\n", - "angle = np.arctan2(vec[1], vec[0])/np.pi # compute angles\n", - "orientation_image = angle.reshape(image.shape) # shape as an image\n", + "angle = np.arctan2(vec[1],vec[0]) # compute angles\n", "### END USER INPUT ### \n", "\n", + "# Prepare the angles to show as image \n", + "angle /= np.pi #scale from 0 to 1\n", + "orientation_image = angle.reshape(image.shape) # shape as an image\n", + "\n", "# Visualise the results\n", "figsize = (10,5)\n", "fig, ax = plt.subplots(1, 2, figsize=figsize, sharex=True, sharey=True)\n", @@ -330,7 +332,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "9348b6dffa2740ecb647efda73075c06", + "model_id": "ba20135d4767480c838913a395d806ce", "version_major": 2, "version_minor": 0 }, @@ -382,7 +384,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "c63d444ec078465c9b9e0226c3149043", + "model_id": "dc0b06199211481ca9c3adc7700b37ea", "version_major": 2, "version_minor": 0 }, @@ -430,7 +432,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "60c02737b9554f67915bde19d5a431df", + "model_id": "9cce53c47d8f498fbcfe26212f4b317e", "version_major": 2, "version_minor": 0 },