Skip to content

Commit eeaf6e8

Browse files
author
Sebastien Courroux
committed
Add support for Panchro camera serie
1 parent 236cd23 commit eeaf6e8

File tree

176 files changed

+218676
-1588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+218676
-1588
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Add any directories, files, or patterns you don't want to be tracked by version control
22
*.pyc
33
.ipynb_checkpoints
4-
.vscode
5-
/.idea
64
__pycache__
75
/dist/
86
/*.egg-info

Alignment v2.ipynb

+853
Large diffs are not rendered by default.

Alignment-10Band.ipynb

+16-9
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
"panelNames = None\n",
4040
"paneCap = None\n",
4141
"\n",
42-
"imagePath = os.path.join('.','data','10BANDSET','000')\n",
43-
"imageNames = glob.glob(os.path.join(imagePath,'IMG_0431_*.tif'))\n",
44-
"panelNames = glob.glob(os.path.join(imagePath,'IMG_0000_*.tif'))\n",
42+
"imagePath = os.path.join('.','data','REDEDGE-MX-DUAL')\n",
43+
"imageNames = glob.glob(os.path.join(imagePath,'IMG_0007_*.tif'))\n",
44+
"panelNames = glob.glob(os.path.join(imagePath,'IMG_0001_*.tif'))\n",
4545
"\n",
4646
"# Allow this code to align both radiance and reflectance images; bu excluding\n",
4747
"# a definition for panelNames above, radiance images will be used\n",
@@ -115,7 +115,7 @@
115115
"warp_mode = cv2.MOTION_HOMOGRAPHY # MOTION_HOMOGRAPHY or MOTION_AFFINE. For Altum images only use HOMOGRAPHY\n",
116116
"pyramid_levels = 3 # for 10-band imagery we use a 3-level pyramid. In some cases\n",
117117
"\n",
118-
"print(\"Alinging images. Depending on settings this can take from a few seconds to many minutes\")\n",
118+
"print(\"Aligning images. Depending on settings this can take from a few seconds to many minutes\")\n",
119119
"# Can potentially increase max_iterations for better results, but longer runtimes\n",
120120
"warp_matrices, alignment_pairs = imageutils.align_capture(capture,\n",
121121
" ref_index = match_index,\n",
@@ -137,11 +137,18 @@
137137
{
138138
"cell_type": "code",
139139
"execution_count": null,
140-
"metadata": {},
140+
"metadata": {
141+
"scrolled": false
142+
},
141143
"outputs": [],
142144
"source": [
145+
"\n",
143146
"cropped_dimensions, edges = imageutils.find_crop_bounds(capture, warp_matrices, warp_mode=warp_mode)\n",
144-
"im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, match_index, img_type=img_type)"
147+
"im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, match_index, img_type=img_type)\n",
148+
"display(im_aligned)\n",
149+
"print(\"fff\")\n",
150+
"im_aligned = capture.create_aligned_capture(warp_matrices=warp_matrices, motion_type=warp_mode, img_type=img_type, match_index=match_index)\n",
151+
"display(im_aligned)"
145152
]
146153
},
147154
{
@@ -269,7 +276,7 @@
269276
"\n",
270277
"sort_by_wavelength = True # set to false if you want stacks in camera-band-index order\n",
271278
" \n",
272-
"outRaster = driver.Create(filename+\".tiff\", cols, rows, bands, gdal.GDT_UInt16, options = [ 'INTERLEAVE=BAND','COMPRESS=DEFLATE' ])\n",
279+
"outRaster = driver.Create(filename+\"C.tiff\", cols, rows, bands, gdal.GDT_UInt16, options = [ 'INTERLEAVE=BAND','COMPRESS=DEFLATE' ])\n",
273280
"try:\n",
274281
" if outRaster is None:\n",
275282
" raise IOError(\"could not load gdal GeoTiff driver\")\n",
@@ -481,7 +488,7 @@
481488
],
482489
"metadata": {
483490
"kernelspec": {
484-
"display_name": "Python 3",
491+
"display_name": "Python 3 (ipykernel)",
485492
"language": "python",
486493
"name": "python3"
487494
},
@@ -495,7 +502,7 @@
495502
"name": "python",
496503
"nbconvert_exporter": "python",
497504
"pygments_lexer": "ipython3",
498-
"version": "3.7.3"
505+
"version": "3.7.12"
499506
},
500507
"toc": {
501508
"nav_menu": {},

Alignment-RigRelatives.ipynb

+21-11
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@
3838
"import os, glob\n",
3939
"import micasense.capture as capture\n",
4040
"%matplotlib inline\n",
41+
"from pathlib import Path\n",
4142
"\n",
4243
"panelNames = None\n",
4344
"\n",
44-
"# This is an altum image with RigRelatives and a thermal band\n",
45-
"imagePath = os.path.join('.','data','ALTUM1SET','000')\n",
46-
"imageNames = glob.glob(os.path.join(imagePath,'IMG_0008_*.tif'))\n",
47-
"panelNames = glob.glob(os.path.join(imagePath,'IMG_0000_*.tif'))\n",
45+
"# This is an Altum image with RigRelatives and a thermal band\n",
46+
"\n",
47+
"imagePath = Path(\"./data/ALTUM\")\n",
48+
"\n",
49+
"# these will return lists of image paths as strings \n",
50+
"imageNames = list(imagePath.glob('IMG_0021_*.tif'))\n",
51+
"imageNames = [x.as_posix() for x in imageNames]\n",
52+
"\n",
53+
"panelNames = list(imagePath.glob('IMG_0000_*.tif'))\n",
54+
"panelNames = [x.as_posix() for x in panelNames]\n",
4855
"\n",
4956
"if panelNames is not None:\n",
5057
" panelCap = capture.Capture.from_filelist(panelNames)\n",
@@ -61,7 +68,7 @@
6168
" if panelCap.panel_albedo() is not None:\n",
6269
" panel_reflectance_by_band = panelCap.panel_albedo()\n",
6370
" else:\n",
64-
" panel_reflectance_by_band = [0.67, 0.69, 0.68, 0.61, 0.67] #RedEdge band_index order\n",
71+
" panel_reflectance_by_band = [0.49, 0.49, 0.49, 0.49, 0.49] #RedEdge band_index order\n",
6572
" panel_irradiance = panelCap.panel_irradiance(panel_reflectance_by_band) \n",
6673
" img_type = \"reflectance\"\n",
6774
" capture.plot_undistorted_reflectance(panel_irradiance)\n",
@@ -97,11 +104,14 @@
97104
"import micasense.imageutils as imageutils\n",
98105
"import micasense.plotutils as plotutils\n",
99106
"\n",
107+
"reference_band = 5\n",
100108
"warp_mode = cv2.MOTION_HOMOGRAPHY\n",
101-
"warp_matrices = capture.get_warp_matrices()\n",
109+
"warp_matrices = capture.get_warp_matrices(ref_index=reference_band)\n",
110+
"\n",
111+
"cropped_dimensions,edges = imageutils.find_crop_bounds(capture,warp_matrices,reference_band=reference_band)\n",
112+
"im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, reference_band, img_type=img_type)\n",
102113
"\n",
103-
"cropped_dimensions,edges = imageutils.find_crop_bounds(capture,warp_matrices)\n",
104-
"im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, None, img_type=img_type)\n",
114+
"print(im_aligned.shape)\n",
105115
"\n",
106116
"print(\"warp_matrices={}\".format(warp_matrices))"
107117
]
@@ -128,7 +138,7 @@
128138
"cir_band_indices = [3,2,1]\n",
129139
"\n",
130140
"# Create an empty normalized stack for viewing\n",
131-
"im_display = np.zeros((im_aligned.shape[0],im_aligned.shape[1],capture.num_bands+1), dtype=np.float32 )\n",
141+
"im_display = np.zeros((im_aligned.shape[0],im_aligned.shape[1],im_aligned.shape[2]), dtype=np.float32 )\n",
132142
"\n",
133143
"im_min = np.percentile(im_aligned[:,:,0:2].flatten(), 0.1) # modify with these percentilse to adjust contrast\n",
134144
"im_max = np.percentile(im_aligned[:,:,0:2].flatten(), 99.9) # for many images, 0.5 and 99.5 are good values\n",
@@ -451,7 +461,7 @@
451461
],
452462
"metadata": {
453463
"kernelspec": {
454-
"display_name": "Python 3",
464+
"display_name": "Python 3 (ipykernel)",
455465
"language": "python",
456466
"name": "python3"
457467
},
@@ -465,7 +475,7 @@
465475
"name": "python",
466476
"nbconvert_exporter": "python",
467477
"pygments_lexer": "ipython3",
468-
"version": "3.7.3"
478+
"version": "3.7.12"
469479
},
470480
"toc": {
471481
"nav_menu": {},

Alignment.ipynb

+19-20
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,28 @@
3434
{
3535
"cell_type": "code",
3636
"execution_count": null,
37-
"metadata": {},
37+
"metadata": {
38+
"scrolled": false
39+
},
3840
"outputs": [],
3941
"source": [
4042
"import os, glob\n",
4143
"import micasense.capture as capture\n",
4244
"%matplotlib inline\n",
45+
"from pathlib import Path\n",
46+
"import matplotlib.pyplot as plt\n",
47+
"plt.rcParams[\"figure.facecolor\"] = \"w\"\n",
4348
"\n",
4449
"panelNames = None\n",
4550
"\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",
5552
"\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",
6056
"\n",
57+
"panelNames = list(imagePath.glob('IMG_0000_*.tif'))\n",
58+
"panelNames = [x.as_posix() for x in panelNames]\n",
6159
"\n",
6260
"# Allow this code to align both radiance and reflectance images; bu excluding\n",
6361
"# a definition for panelNames above, radiance images will be used\n",
@@ -76,7 +74,7 @@
7674
" if panelCap.panel_albedo() is not None:\n",
7775
" panel_reflectance_by_band = panelCap.panel_albedo()\n",
7876
" 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",
8078
" panel_irradiance = panelCap.panel_irradiance(panel_reflectance_by_band) \n",
8179
" img_type = \"reflectance\"\n",
8280
" capture.plot_undistorted_reflectance(panel_irradiance)\n",
@@ -130,7 +128,7 @@
130128
"warp_mode = cv2.MOTION_HOMOGRAPHY # MOTION_HOMOGRAPHY or MOTION_AFFINE. For Altum images only use HOMOGRAPHY\n",
131129
"pyramid_levels = 0 # for images with RigRelatives, setting this to 0 or 1 may improve alignment\n",
132130
"\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",
134132
"# Can potentially increase max_iterations for better results, but longer runtimes\n",
135133
"warp_matrices, alignment_pairs = imageutils.align_capture(capture,\n",
136134
" ref_index = match_index,\n",
@@ -155,7 +153,8 @@
155153
"metadata": {},
156154
"outputs": [],
157155
"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",
159158
"im_aligned = imageutils.aligned_capture(capture, warp_matrices, warp_mode, cropped_dimensions, match_index, img_type=img_type)"
160159
]
161160
},
@@ -288,7 +287,7 @@
288287
"\n",
289288
"if im_aligned.shape[2] == 6:\n",
290289
" 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",
292291
"\n",
293292
"normalize = (img_type == 'radiance') # normalize radiance images to fit with in UInt16\n",
294293
"\n",
@@ -559,7 +558,7 @@
559558
],
560559
"metadata": {
561560
"kernelspec": {
562-
"display_name": "Python 3",
561+
"display_name": "Python 3 (ipykernel)",
563562
"language": "python",
564563
"name": "python3"
565564
},
@@ -573,7 +572,7 @@
573572
"name": "python",
574573
"nbconvert_exporter": "python",
575574
"pygments_lexer": "ipython3",
576-
"version": "3.7.3"
575+
"version": "3.7.12"
577576
},
578577
"toc": {
579578
"nav_menu": {},

0 commit comments

Comments
 (0)