Skip to content

Commit

Permalink
Merge pull request #653 from AndreasBugten/kikuchidev
Browse files Browse the repository at this point in the history
Add description of how to navigate RGBA images to the kikuchipy documentation
  • Loading branch information
hakonanes authored Aug 29, 2023
2 parents 3e0c8c0 + b240346 commit b7d626c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
"contributions": [
"bug"
]
},
{
"login": "AndreasBugten",
"name": "AndreasBugten",
"avatar_url": "https://avatars.githubusercontent.com/u/106192446?v=4",
"profile": "https://github.com/AndreasBugten",
"contributions": [
"doc"
]
}
]
}
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"name": "Zhou Xu",
"affiliation": "Monash Centre for Electron Microscopy"
},
{
"name": "Andreas V. Bugten",
"orcid": "0000-0003-0311-8584",
"affiliation": "Norwegian University of Science and Technology"
},
{
"name": "Magnus Nord",
"orcid": "0000-0001-7981-5293",
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AndreasBugten"><img src="https://avatars.githubusercontent.com/u/106192446?v=4?s=100" width="100px;" alt="AndreasBugten"/><br /><sub><b>AndreasBugten</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/commits?author=AndreasBugten" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ericpre"><img src="https://avatars.githubusercontent.com/u/11851990?v=4?s=100" width="100px;" alt="Eric Prestat"/><br /><sub><b>Eric Prestat</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/commits?author=ericpre" title="Code">💻</a> <a href="#maintenance-ericpre" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.ntnu.edu/employees/hakon.w.anes"><img src="https://avatars.githubusercontent.com/u/12139781?v=4?s=100" width="100px;" alt="Håkon Wiik Ånes"/><br /><sub><b>Håkon Wiik Ånes</b></sub></a><br /></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/friedkitteh"><img src="https://avatars.githubusercontent.com/u/11888052?v=4?s=100" width="100px;" alt="Lars Lervik"/><br /><sub><b>Lars Lervik</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/issues?q=author%3Afriedkitteh" title="Bug reports">🐛</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=friedkitteh" title="Code">💻</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=friedkitteh" title="Documentation">📖</a> <a href="#question-friedkitteh" title="Answering Questions">💬</a> <a href="https://github.com/pyxem/kikuchipy/pulls?q=is%3Apr+reviewed-by%3Afriedkitteh" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=friedkitteh" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.ntnu.edu/employees/magnus.nord"><img src="https://avatars.githubusercontent.com/u/1690979?v=4?s=100" width="100px;" alt="Magnus Nord"/><br /><sub><b>Magnus Nord</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/commits?author=magnunor" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/onatlandsmyr"><img src="https://avatars.githubusercontent.com/u/34620114?v=4?s=100" width="100px;" alt="Ole Natlandsmyr"/><br /><sub><b>Ole Natlandsmyr</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/commits?author=onatlandsmyr" title="Code">💻</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=onatlandsmyr" title="Documentation">📖</a> <a href="#question-onatlandsmyr" title="Answering Questions">💬</a> <a href="https://github.com/pyxem/kikuchipy/pulls?q=is%3Apr+reviewed-by%3Aonatlandsmyr" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=onatlandsmyr" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tinabe"><img src="https://avatars.githubusercontent.com/u/22915119?v=4?s=100" width="100px;" alt="Tina Bergh"/><br /><sub><b>Tina Bergh</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/commits?author=tinabe" title="Code">💻</a> <a href="https://github.com/pyxem/kikuchipy/pulls?q=is%3Apr+reviewed-by%3Atinabe" title="Reviewed Pull Requests">👀</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/IMBalENce"><img src="https://avatars.githubusercontent.com/u/2986794?v=4?s=100" width="100px;" alt="Zhou Xu"/><br /><sub><b>Zhou Xu</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/issues?q=author%3AIMBalENce" title="Bug reports">🐛</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=IMBalENce" title="Code">💻</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=IMBalENce" title="Documentation">📖</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=IMBalENce" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/IMBalENce"><img src="https://avatars.githubusercontent.com/u/2986794?v=4?s=100" width="100px;" alt="Zhou Xu"/><br /><sub><b>Zhou Xu</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/issues?q=author%3AIMBalENce" title="Bug reports">🐛</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=IMBalENce" title="Code">💻</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=IMBalENce" title="Documentation">📖</a> <a href="https://github.com/pyxem/kikuchipy/commits?author=IMBalENce" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Erlendos12"><img src="https://avatars.githubusercontent.com/u/99336047?v=4?s=100" width="100px;" alt="erlenmos"/><br /><sub><b>erlenmos</b></sub></a><br /><a href="https://github.com/pyxem/kikuchipy/issues?q=author%3AErlendos12" title="Bug reports">🐛</a></td>
</tr>
</tbody>
Expand Down
63 changes: 49 additions & 14 deletions doc/tutorials/visualizing_patterns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_rgb = vbse_imager.get_rgb_image(r=(3, 1), b=(3, 2), g=(3, 3))\n",
"vbse_rgb"
"maps_vbse_rgb = vbse_imager.get_rgb_image(r=(3, 1), b=(3, 2), g=(3, 3))\n",
"maps_vbse_rgb"
]
},
{
Expand All @@ -126,7 +126,7 @@
"metadata": {},
"outputs": [],
"source": [
"s.plot(navigator=vbse_rgb, cmap=\"viridis\")"
"s.plot(navigator=maps_vbse_rgb, cmap=\"viridis\")"
]
},
{
Expand All @@ -135,7 +135,8 @@
"source": [
"## Any image\n",
"\n",
"Images made into a [Signal2D](http://hyperspy.org/hyperspy-doc/current/api/hyperspy._signals.signal2d.html#hyperspy._signals.signal2d.Signal2D) can be used as navigators, like a quality metric map like the [image quality map](feature_maps.ipynb#Image-quality) calculated using [get_image_quality()](../reference/generated/kikuchipy.signals.EBSD.get_image_quality.rst)"
"Images made into a [Signal2D](http://hyperspy.org/hyperspy-doc/current/api/hyperspy._signals.signal2d.html#hyperspy._signals.signal2d.Signal2D) can be used as navigators.\n",
"For example a quality metric map such as the [image quality map](feature_maps.ipynb#Image-quality) calculated using [get_image_quality()](../reference/generated/kikuchipy.signals.EBSD.get_image_quality.rst)"
]
},
{
Expand All @@ -154,16 +155,16 @@
"metadata": {},
"outputs": [],
"source": [
"iq = s.get_image_quality()\n",
"s_iq = hs.signals.Signal2D(iq)\n",
"maps_iq = s.get_image_quality()\n",
"s_iq = hs.signals.Signal2D(maps_iq)\n",
"s.plot(navigator=s_iq)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can obtain an RGB signal from an RGB image using [get_rgb_navigator()](../reference/generated/kikuchipy.draw.get_rgb_navigator.rst).\n",
"We obtain an RGB signal from an RGB image using [get_rgb_navigator()](../reference/generated/kikuchipy.draw.get_rgb_navigator.rst).\n",
"Let's load an orientation map from dictionary indexing in the [pattern matching](pattern_matching.ipynb) tutorial"
]
},
Expand All @@ -173,13 +174,47 @@
"metadata": {},
"outputs": [],
"source": [
"rgb_z = plt.imread(\n",
" \"../_static/image/visualizing_patterns/ni_large_rgb_z.png\"\n",
")\n",
"rgb_z = rgb_z[..., :3] # Drop the alpha channel\n",
"s_rgb_z = kp.draw.get_rgb_navigator(rgb_z)\n",
"maps_ipfz = plt.imread(\"../_static/image/visualizing_patterns/ni_large_rgb_z.png\")\n",
"maps_ipfz = maps_ipfz[..., :3] # Drop the alpha channel\n",
"s_ipfz = kp.draw.get_rgb_navigator(maps_ipfz)\n",
"\n",
"s.plot(navigator=s_rgb_z, colorbar=False)"
"s.plot(navigator=s_ipfz, colorbar=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By overlaying the image quality map on the RGB image, we can visualize crystal directions within grains and the grain morphology in the same image"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"maps_iq_1d = maps_iq.ravel() # Flat array required by orix\n",
"maps_ipfz_1d = maps_ipfz.reshape(-1, 3)\n",
"fig = s.xmap.plot(maps_ipfz_1d, overlay=maps_iq_1d, return_figure=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By extracting the image array, we can use this map to navigate patterns in"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"maps_ipfz_iq = fig.axes[0].images[0].get_array()\n",
"s_ipfz_iq = kp.draw.get_rgb_navigator(maps_ipfz_iq)\n",
"s.plot(s_ipfz_iq)"
]
},
{
Expand Down Expand Up @@ -292,7 +327,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.11.5"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
1 change: 1 addition & 0 deletions kikuchipy/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Eric Prestat",
"Erlend Mikkelsen Østvold",
"Zhou Xu",
"Andreas V. Bugten",
"Magnus Nord",
]
license = "GPLv3+"
Expand Down

0 comments on commit b7d626c

Please sign in to comment.