Forum

Author Topic: Image alignment with brightness adjusted images  (Read 4362 times)

nik

  • Newbie
  • *
  • Posts: 7
    • View Profile
Image alignment with brightness adjusted images
« on: October 08, 2021, 07:40:58 AM »
Dear all,

I am processing helicopter borne RGB images over snow covered arctic sea ice. I found when employing the same dataset with different brightness corrections different matches are found when aligning the images. When applying both datasets, e.g. the original one and the brightness corrected one considerably more images can be aligned than with just one of the datasets. So the idea is to use both datasets for the final image alignment. This is working quite well in the GUI but somehow I cannot get it running in the python API. Here is my code which in its current form only uses the second dataset in the alignment:

Code: [Select]
...
Images = glob.glob(AerialImagesPattern)
chunk.addPhotos(Images)

crs = Metashape.CoordinateSystem("EPSG::4326")
chunk.importReference(path=OrientationFile, format=Metashape.ReferenceFormatCSV, columns='nyxzabc', crs = crs, delimiter=';', create_markers=False,skip_rows=1)
user_calib = Metashape.Calibration()
user_calib.load(CalibFile)
for sensor in chunk.sensors:
sensor.user_calib = user_calib
sensor.fixed = False
chunk.matchPhotos(reference_preselection = True)
chunk.alignCameras(adaptive_fitting=True)
chunk.optimizeCameras(adaptive_fitting=True)
doc.save()

for camera in chunk.cameras:
camera.photo.path = "/".join(["RAW/Lin_corr", camera.photo.path.rsplit("/",1)[1]])
chunk.matchPhotos(keep_keypoints=True,reset_matches=True)
chunk.alignCameras(reset_alignment=False,adaptive_fitting=True)
chunk.buildDepthMaps(filter_mode=Metashape.AggressiveFiltering)
doc.save()

when I set reset_matches=False I get "Warning: Can't resume matching without keypoints" and only the first dataset is used for the image alignment. What am I missing?

Cheers,

Nik

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15406
    • View Profile
Re: Image alignment with brightness adjusted images
« Reply #1 on: October 09, 2021, 04:41:55 PM »
Hello Nik,

using reset_matches = False means that you have some pre-aligned cameras in the active chunk and the key points have been also saved in the project. With that newly added images will be matched and aligned to the existing alignment.

Do you actually need to align one sub-set to another or it's sufficient just to run the image matching and alignment for both sub-sets in the single chunk?
Best regards,
Alexey Pasumansky,
Agisoft LLC

nik

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Image alignment with brightness adjusted images
« Reply #2 on: October 10, 2021, 12:41:59 AM »
Dear Alexey,

thank you for your reply. Basically I am happy with the output from the GUI approach which I try to reproduce with the python API. I have the feeling that the align photos tab in the GUI seems to combine the matchPhotos step and the alignCameras step in the python API? In the GUI I run the image alignment on the "dark" images (42 images get aligned) and re-run the image alignment on the same but brighter images with the reset current alignment switch turned on (110 images get aligned). I think that the matches from the first alignment are also used in the second alignment as not all of the 42 aligned images get aligned when solely aligning the brighter images. This is what me made think to set reset_matches = False. If you are willing to take a closer look I am happy to share the project.

All the Best,

Nik