|
34 | 34 | {
|
35 | 35 | "cell_type": "code",
|
36 | 36 | "execution_count": null,
|
37 |
| - "metadata": {}, |
| 37 | + "metadata": { |
| 38 | + "scrolled": false |
| 39 | + }, |
38 | 40 | "outputs": [],
|
39 | 41 | "source": [
|
40 | 42 | "import os, glob\n",
|
41 | 43 | "import micasense.capture as capture\n",
|
42 | 44 | "%matplotlib inline\n",
|
| 45 | + "from pathlib import Path\n", |
| 46 | + "import matplotlib.pyplot as plt\n", |
| 47 | + "plt.rcParams[\"figure.facecolor\"] = \"w\"\n", |
43 | 48 | "\n",
|
44 | 49 | "panelNames = None\n",
|
45 | 50 | "\n",
|
46 |
| - "# # This is an older RedEdge image without RigRelatives\n", |
47 |
| - "# imagePath = os.path.join(os.path.abspath('.'),'data','0000SET','000')\n", |
48 |
| - "# imageNames = glob.glob(os.path.join(imagePath,'IMG_0001_*.tif'))\n", |
49 |
| - "# panelNames = glob.glob(os.path.join(imagePath,'IMG_0000_*.tif'))\n", |
50 |
| - "\n", |
51 |
| - "# # Image from the example RedEdge imageSet (see the ImageSet notebook) without RigRelatives.\n", |
52 |
| - "# imagePath = os.path.expanduser(os.path.join('~','Downloads','RedEdgeImageSet','0000SET'))\n", |
53 |
| - "# imageNames = glob.glob(os.path.join(imagePath,'000','IMG_0013_*.tif'))\n", |
54 |
| - "# panelNames = glob.glob(os.path.join(imagePath,'000','IMG_0000_*.tif'))\n", |
| 51 | + "imagePath = Path(\"./data/ALTUM\")\n", |
55 | 52 | "\n",
|
56 |
| - "# This is an altum image with RigRelatives and a thermal band\n", |
57 |
| - "imagePath = os.path.join('.','data','ALTUM1SET','000')\n", |
58 |
| - "imageNames = glob.glob(os.path.join(imagePath,'IMG_0245_*.tif'))\n", |
59 |
| - "panelNames = glob.glob(os.path.join(imagePath,'IMG_0000_*.tif'))\n", |
| 53 | + "# these will return lists of image paths as strings \n", |
| 54 | + "imageNames = list(imagePath.glob('IMG_0021_*.tif'))\n", |
| 55 | + "imageNames = [x.as_posix() for x in imageNames]\n", |
60 | 56 | "\n",
|
| 57 | + "panelNames = list(imagePath.glob('IMG_0000_*.tif'))\n", |
| 58 | + "panelNames = [x.as_posix() for x in panelNames]\n", |
61 | 59 | "\n",
|
62 | 60 | "# Allow this code to align both radiance and reflectance images; bu excluding\n",
|
63 | 61 | "# a definition for panelNames above, radiance images will be used\n",
|
|
76 | 74 | " if panelCap.panel_albedo() is not None:\n",
|
77 | 75 | " panel_reflectance_by_band = panelCap.panel_albedo()\n",
|
78 | 76 | " else:\n",
|
79 |
| - " panel_reflectance_by_band = [0.67, 0.69, 0.68, 0.61, 0.67] #RedEdge band_index order\n", |
| 77 | + " panel_reflectance_by_band = [0.49, 0.49, 0.49, 0.49, 0.49] #RedEdge band_index order\n", |
80 | 78 | " panel_irradiance = panelCap.panel_irradiance(panel_reflectance_by_band) \n",
|
81 | 79 | " img_type = \"reflectance\"\n",
|
82 | 80 | " capture.plot_undistorted_reflectance(panel_irradiance)\n",
|
|
130 | 128 | "warp_mode = cv2.MOTION_HOMOGRAPHY # MOTION_HOMOGRAPHY or MOTION_AFFINE. For Altum images only use HOMOGRAPHY\n",
|
131 | 129 | "pyramid_levels = 0 # for images with RigRelatives, setting this to 0 or 1 may improve alignment\n",
|
132 | 130 | "\n",
|
133 |
| - "print(\"Alinging images. Depending on settings this can take from a few seconds to many minutes\")\n", |
| 131 | + "print(\"Aligning images. Depending on settings this can take from a few seconds to many minutes\")\n", |
134 | 132 | "# Can potentially increase max_iterations for better results, but longer runtimes\n",
|
135 | 133 | "warp_matrices, alignment_pairs = imageutils.align_capture(capture,\n",
|
136 | 134 | " ref_index = match_index,\n",
|
|
155 | 153 | "metadata": {},
|
156 | 154 | "outputs": [],
|
157 | 155 | "source": [
|
158 |
| - "cropped_dimensions, edges = imageutils.find_crop_bounds(capture, warp_matrices, warp_mode=warp_mode)\n", |
| 156 | + "cropped_dimensions, edges = imageutils.find_crop_bounds(capture, warp_matrices, warp_mode=warp_mode, reference_band=match_index)\n", |
| 157 | + "print(cropped_dimensions)\n", |
159 | 158 | "im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, match_index, img_type=img_type)"
|
160 | 159 | ]
|
161 | 160 | },
|
|
288 | 287 | "\n",
|
289 | 288 | "if im_aligned.shape[2] == 6:\n",
|
290 | 289 | " filename = filename + \"t\" #thermal\n",
|
291 |
| - "outRaster = driver.Create(filename+\".tiff\", cols, rows, im_aligned.shape[2], gdal.GDT_UInt16)\n", |
| 290 | + "outRaster = driver.Create(filename+\"B.tiff\", cols, rows, im_aligned.shape[2], gdal.GDT_UInt16)\n", |
292 | 291 | "\n",
|
293 | 292 | "normalize = (img_type == 'radiance') # normalize radiance images to fit with in UInt16\n",
|
294 | 293 | "\n",
|
|
559 | 558 | ],
|
560 | 559 | "metadata": {
|
561 | 560 | "kernelspec": {
|
562 |
| - "display_name": "Python 3", |
| 561 | + "display_name": "Python 3 (ipykernel)", |
563 | 562 | "language": "python",
|
564 | 563 | "name": "python3"
|
565 | 564 | },
|
|
573 | 572 | "name": "python",
|
574 | 573 | "nbconvert_exporter": "python",
|
575 | 574 | "pygments_lexer": "ipython3",
|
576 |
| - "version": "3.7.3" |
| 575 | + "version": "3.7.12" |
577 | 576 | },
|
578 | 577 | "toc": {
|
579 | 578 | "nav_menu": {},
|
|
0 commit comments