Skip to content

Commit

Permalink
Fix some issues in Python code and notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Courroux committed Feb 6, 2024
1 parent 1340440 commit 738d629
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 85 deletions.
33 changes: 8 additions & 25 deletions Alignment-10Band.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
Expand Down Expand Up @@ -137,18 +135,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"\n",
"cropped_dimensions, edges = imageutils.find_crop_bounds(capture, warp_matrices, warp_mode=warp_mode)\n",
"im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, match_index, img_type=img_type)\n",
"display(im_aligned)\n",
"print(\"fff\")\n",
"im_aligned = capture.create_aligned_capture(warp_matrices=warp_matrices, motion_type=warp_mode, img_type=img_type, match_index=match_index)\n",
"display(im_aligned)"
"im_aligned = capture.create_aligned_capture(warp_matrices=warp_matrices, motion_type=warp_mode, img_type=img_type)"
]
},
{
Expand All @@ -163,9 +156,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# figsize=(30,23) # use this size for full-image-resolution display\n",
Expand Down Expand Up @@ -334,9 +325,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from micasense import plotutils\n",
Expand Down Expand Up @@ -395,9 +384,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# Compute Normalized Difference Red Edge Index from the NIR(3) and RedEdge(4) bands\n",
Expand Down Expand Up @@ -438,9 +425,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"x_band = red_band\n",
Expand Down Expand Up @@ -469,9 +454,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"print(warp_matrices)"
Expand Down
29 changes: 7 additions & 22 deletions Alignment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import os, glob\n",
"import micasense.capture as capture\n",
"%matplotlib inline\n",
"from pathlib import Path\n",
Expand Down Expand Up @@ -111,9 +108,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
Expand Down Expand Up @@ -170,9 +165,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# figsize=(30,23) # use this size for full-image-resolution display\n",
Expand Down Expand Up @@ -355,9 +348,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from micasense import plotutils\n",
Expand Down Expand Up @@ -416,9 +407,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# Compute Normalized Difference Red Edge Index from the NIR(3) and RedEdge(4) bands\n",
Expand Down Expand Up @@ -508,9 +497,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"x_band = red_band\n",
Expand Down Expand Up @@ -539,9 +526,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"print(warp_matrices)"
Expand Down
8 changes: 3 additions & 5 deletions Captures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"capture.plot_vignette();\n",
"capture.plot_undistorted_radiance();\n",
"capture.plot_vignette()\n",
"capture.plot_undistorted_radiance()\n",
"capture.plot_panels()"
]
},
Expand Down
38 changes: 14 additions & 24 deletions MicaSense Image Processing Tutorial 1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"\n",
"## Overview\n",
"\n",
"This tutorial assumes you have gone through the basic setup [here](./MicaSense Image Processing Setup.html) and your system is set up and ready to go.\n",
"This tutorial assumes you have gone through the basic setup [here](./MicaSense Image Processing Setup.ipynb) and your system is set up and ready to go.\n",
"\n",
"In this tutorial, we will walk through how to convert RedEdge data from raw images to radiace and then to reflectance. We will cover the tools required to do this, and walk through some of the basic image processing and radiometric conversions. \n",
"In this tutorial, we will walk through how to convert RedEdge data from raw images to radiance and then to reflectance. We will cover the tools required to do this, and walk through some of the basic image processing and radiometric conversions. \n",
"\n",
"### Opening an image with pyplot\n",
"\n",
Expand All @@ -20,16 +20,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import os,glob\n",
"import math\n",
"import os\n",
"%matplotlib inline\n",
"\n",
"imagePath = os.path.join('.','data','REDEDGE-MX')\n",
Expand Down Expand Up @@ -95,7 +91,7 @@
"if os.name == 'nt':\n",
" exiftoolPath = os.environ.get('exiftoolpath')\n",
"# get image metadata\n",
"meta = metadata.Metadata(imageName, exiftoolPath=exiftoolPath)\n",
"meta = metadata.Metadata(imageName, exiftool_path=exiftoolPath)\n",
"cameraMake = meta.get_item('EXIF:Make')\n",
"cameraModel = meta.get_item('EXIF:Model')\n",
"firmwareVersion = meta.get_item('EXIF:Software')\n",
Expand Down Expand Up @@ -174,18 +170,16 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import micasense.utils as msutils\n",
"radianceImage, L, V, R = msutils.raw_image_to_radiance(meta, imageRaw)\n",
"plotutils.plotwithcolorbar(V,'Vignette Factor');\n",
"plotutils.plotwithcolorbar(R,'Row Gradient Factor');\n",
"plotutils.plotwithcolorbar(V*R,'Combined Corrections');\n",
"plotutils.plotwithcolorbar(L,'Vignette and row gradient corrected raw values');\n",
"plotutils.plotwithcolorbar(radianceImage,'All factors applied and scaled to radiance');"
"plotutils.plotwithcolorbar(V,'Vignette Factor')\n",
"plotutils.plotwithcolorbar(R,'Row Gradient Factor')\n",
"plotutils.plotwithcolorbar(V*R,'Combined Corrections')\n",
"plotutils.plotwithcolorbar(L,'Vignette and row gradient corrected raw values')\n",
"plotutils.plotwithcolorbar(radianceImage,'All factors applied and scaled to radiance')"
]
},
{
Expand All @@ -202,9 +196,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"markedImg = radianceImage.copy()\n",
Expand Down Expand Up @@ -278,9 +270,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# correct for lens distortions to make straight lines straight\n",
Expand Down Expand Up @@ -323,7 +313,7 @@
"\n",
"In future tutorials, we will introduce the Downwelling Light Sensor (DLS) information into the calibration process in order to account for changing irradiance over time (e.g. such as clouds). However, since the panel method is straightforward and repeatable under constant illumination conditions, and is the standard scientific calibration method of surface reflectance, this process is useful and sufficient for many calibration needs.\n",
"\n",
"Looking for more? Try the second tutorial [here](./MicaSense%20Image%20Processing%20Tutorial%202.html)."
"Looking for more? Try the second tutorial [here](./MicaSense%20Image%20Processing%20Tutorial%202.ipynb)."
]
},
{
Expand Down
8 changes: 3 additions & 5 deletions MicaSense Image Processing Tutorial 2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Tutorial 2 - MicaSense library\n",
"\n",
"This tutorial assumes you have gone through the [basic setup](./Micasense Image Processing Setup.html) and builds on the basic radiance, irradiance, and reflectance concepts and code covered in the [first tutorial](./MicaSense Image Processing Tutorial 1.html). \n",
"This tutorial assumes you have gone through the [basic setup](./Micasense Image Processing Setup.ipynb) and builds on the basic radiance, irradiance, and reflectance concepts and code covered in the [first tutorial](./MicaSense Image Processing Tutorial 1.ipynb). \n",
"\n",
"In this tutorial, we will cover usage of the MicaSense python library to access images and groups of images. Most of the processing details are hidden away in the library, but the library code is open and available in the git repository. \n",
"\n",
Expand Down Expand Up @@ -53,7 +53,7 @@
"\n",
"Metadata for each image is available in the `Image.meta` parameter. This object is a `micasense.Metadata` object and can be accessed directly for image specific metadata extraction. Below, we print the same metadata values as we did in Tutorial #1, but using direct access to the `Metadata` object parameters.\n",
"\n",
"A notebook for experimenting with the `Image` class can be found [here](Images.html)."
"A notebook for experimenting with the `Image` class can be found [here](Images.ipynb)."
]
},
{
Expand Down Expand Up @@ -160,9 +160,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import os, glob\n",
Expand Down
8 changes: 4 additions & 4 deletions MicaSense Image Processing Tutorial 3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"source": [
"# Remote Sensing Theory\n",
"\n",
"In [Tutorial 1](./MicaSense%20Image%20Processing%20Tutorial%201.html) we covered conversion of the image radiance to reflecance using the average radiance from an area of a specially made lambertian reflectance panel. As we did not get very far into remote sensing theory, we will cover that some here as we move on to the more complex problem of using the data from the RedEdge Downwelling Light Sensor (DLS). To get started, we will review some of the fundamental measurements in remote sensing.\n",
"In [Tutorial 1](./MicaSense%20Image%20Processing%20Tutorial%201.ipynb) we covered conversion of the image radiance to reflecance using the average radiance from an area of a specially made lambertian reflectance panel. As we did not get very far into remote sensing theory, we will cover that some here as we move on to the more complex problem of using the data from the RedEdge Downwelling Light Sensor (DLS). To get started, we will review some of the fundamental measurements in remote sensing.\n",
"\n",
"## Definition of Terms\n",
"\n",
Expand Down Expand Up @@ -101,8 +101,8 @@
"import os, glob\n",
"import micasense.capture as capture\n",
"\n",
"images_path = os.path.join('.','data','REDEDGE-P')\n",
"image_names = glob.glob(os.path.join(images_path,'IMG_0000_*.tif'))\n",
"images_path = os.path.join('.', 'data', 'REDEDGE-MX')\n",
"image_names = glob.glob(os.path.join(images_path, 'IMG_0001_*.tif'))\n",
"cap = capture.Capture.from_filelist(image_names)"
]
},
Expand Down Expand Up @@ -169,7 +169,7 @@
"plt.scatter(center_wavelengths,dls_irradiances)\n",
"plt.xlabel('Wavelength (nm)')\n",
"plt.ylabel('Irradiance ($W/m^2/nm$)')\n",
"plt.show();\n",
"plt.show()\n",
"\n",
"cap.plot_undistorted_reflectance(dls_irradiances)"
]
Expand Down

0 comments on commit 738d629

Please sign in to comment.