Forum

Author Topic: Scripting Rectangle Mask  (Read 2312 times)

willcodeforfoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Scripting Rectangle Mask
« on: August 31, 2016, 06:14:05 PM »
I need to mask out the edges of all the cameras in a chunk... basically only selecting the middle and excluding a 500px or so border around the edges... I've created a PNG mask, but since the images can vary in size I was wondering if it's possible to select this rectangle programmatically in a Python script rather than importing masks? And if so, would be faster than importing the mask (seems to take ~2s per 100MB image).

Thanks!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Scripting Rectangle Mask
« Reply #1 on: August 31, 2016, 06:31:57 PM »
Hello willcodeforfoo,

Unfortunately, creating the masks "manually" via Python may take even longer time, as it will be required to loop through all the pixels of the PhotoScan.Mask() class instance for every image.

As a workaround I can suggest to script the following: sort the images according to their resolution, create the mask for each group using such "manual" approach and apply to each image in the group.
Best regards,
Alexey Pasumansky,
Agisoft LLC

willcodeforfoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Scripting Rectangle Mask
« Reply #2 on: August 31, 2016, 07:01:48 PM »
Alexey: Thanks for the quick response. This is exactly the approach I've taken, seems to work pretty well. Wasn't sure if maybe there was an easier way I was overlooking

Cheers!