Forum

Author Topic: Mask defocus area works then un-works  (Read 1543 times)

hairyfreak

  • Newbie
  • *
  • Posts: 28
    • View Profile
Mask defocus area works then un-works
« on: December 30, 2021, 02:00:20 PM »
Hi. 

After not having. much luck with the generate masks command, I've tried again and watching more closely.

Except.

When I run the command, I will see a mask appear on the image, that looks right.  Before it then disappears and is replaced by a mask that follows only the outside bounds of the mesh. Not the focus area that was initially selected.

Changing the defocus area vlaue, will change the shape of the initial mask that appears briefly, but not the version that it leaves me at the end.

I've tried values from 0.1 to 4 with the same result.

Has anyone else encountered this, have I missed a setting or is it strange behaviour?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14014
    • View Profile
Re: Mask defocus area works then un-works
« Reply #1 on: December 30, 2021, 03:35:48 PM »
Hello hairyfreak,

Does it only happens, when you try to generate masks for a few cameras from the bigger dataset?
Best regards,
Alexey Pasumansky,
Agisoft LLC

hairyfreak

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Mask defocus area works then un-works
« Reply #2 on: December 30, 2021, 08:13:38 PM »
Hi Alexey,

Yes, I had just been doing one or two.

Just tried it on all cameras and that seemed to work.  So yes.

Thanks.

Andreas1206

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Mask defocus area works then un-works
« Reply #3 on: December 31, 2021, 09:10:21 PM »
Hello,

I have noticed the same issue. When generating defocus masks for single images ("current photo" selected) first the seemingly correct defocus mask appears and then it switches to the mask for the whole area of the model. When generating the masks for the whole set of images it mainly works, except that on some images completely blurry parts are sometimes not masked, while the crisp in focus areas are masked out. In general I find the results of the "defocus mask" tool quite unpredictable.

best regards,
Andreas

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14014
    • View Profile
Re: Mask defocus area works then un-works
« Reply #4 on: January 13, 2022, 08:17:56 PM »
By default defocus masking automatically extends the masks, if after the mask generation operation there are blind zones on the mesh surface that are not seen by any camera (providing that before masking the area has been covered by at least one camera). At the moment such behavior cannot be disabled via GUI, but the corresponding parameter is available, if masks are generated using Python scripting (fix_coverage=False).
Best regards,
Alexey Pasumansky,
Agisoft LLC

roberta.ravanelli@uniroma

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Mask defocus area works then un-works
« Reply #5 on: July 28, 2022, 09:32:48 PM »
@Alexei: can you please share an example script which uese  Fix_coverage=False
Thanks,
Roberta

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14014
    • View Profile
Re: Mask defocus area works then un-works
« Reply #6 on: August 24, 2022, 08:07:38 PM »
Hello Roberta,

The analogue of Generate Masks command (defocus masking, but with fix_coverage=False) is below:
Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk
task = Metashape.Tasks.GenerateMasks()
task.masking_mode = Metashape.MaskingModeModel
task.blur_threshold = 3.0
task.depth_threshold = 0.0
task.mask_defocus = True
task.fix_coverage = False
task.apply(chunk)
Best regards,
Alexey Pasumansky,
Agisoft LLC

Andreas1206

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Mask defocus area works then un-works
« Reply #7 on: August 31, 2022, 05:30:59 PM »
Thank you for this script Alexey, how would I have to change it in order to apply it only to a selected image ("current image")?

best regards, Andreas

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14014
    • View Profile
Re: Mask defocus area works then un-works
« Reply #8 on: August 31, 2022, 06:31:12 PM »
Hello Andreas,

If you add the following line to the code (after task assignment line and before task.apply), it will apply Generate Masks task to the selected cameras only:
Code: [Select]
task.cameras = [c.key for c in chunk.cameras if c.selected and c.type == Metashape.Camera.Type.Regular]
Best regards,
Alexey Pasumansky,
Agisoft LLC

Andreas1206

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Mask defocus area works then un-works
« Reply #9 on: September 01, 2022, 08:14:21 PM »
Perfect - thank you very much!
Andreas