Features
Support
Community
Downloads
Buy
About
Forum
Home
Search
Login
Register
Agisoft Metashape
»
Agisoft Metashape
»
Python and Java API
»
How to use createDifferenceMask command?
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to use createDifferenceMask command? (Read 9353 times)
lmg
Newbie
Posts: 30
How to use createDifferenceMask command?
«
on:
April 24, 2014, 06:57:51 PM »
I wish to make automatic masks using always the same background color (blue) positioned on the back of the subjects.
I have seen in the python api the command "createDifferenceMask", that could create a mask from a pair of images or an image and specified color.
Please, could you explain and/or give an example on the use of the following parameters:
• image (Image) – Image to be masked.
• background (Image or color tuple) – Background image or color value.
• tolerance (int) – Tolerance value.
• fit_colors (boolean) – Enables white balance correction.
Do I need to create a template image with having only the background ("blutemplate.ipg") and then subtract this image from the subject image ("subject.ipg")? How to write in a python api this task?
Logged
Alexey Pasumansky
Agisoft Technical Support
Hero Member
Posts: 15354
Re: How to use createDifferenceMask command?
«
Reply #1 on:
April 25, 2014, 11:52:09 AM »
Dear lmg,
You can use a tuple of three numbers to define the background color instead of using artificially generated background image. The color should be represented as follows (R, G, B), where each color is in 0 - 255 interval.
Logged
Best regards,
Alexey Pasumansky,
Agisoft LLC
lmg
Newbie
Posts: 30
Re: How to use createDifferenceMask command?
«
Reply #2 on:
April 25, 2014, 09:34:22 PM »
I have written 2 python scripts. The first one (prova_mask1.py) works with 1 camera and it works fine.
The second one (prova_mask4.py) works with 4 cameras, but in the chunk only last camera is included.
Alexey, Could you tell me where is the mistake in the scripts?
Thank you very much.
Logged
Alexey Pasumansky
Agisoft Technical Support
Hero Member
Posts: 15354
Re: How to use createDifferenceMask command?
«
Reply #3 on:
April 25, 2014, 11:39:41 PM »
I think that happens since
photo
variable is not reset after each photo import step, so I suggest that photo = PhotoScan.Photo() line should be added prior to photo.open() function in the current implementation. But it would be better to use
for
statement reducing the code size.
Logged
Best regards,
Alexey Pasumansky,
Agisoft LLC
lmg
Newbie
Posts: 30
Re: How to use createDifferenceMask command?
«
Reply #4 on:
April 26, 2014, 01:19:01 PM »
Thank you Alexey,
problem solved. I have added the line photo = PhotoScan.Photo() prior to each photo.open() function, and now the script works well.
Bye
Logged
Print
Pages: [
1
]
« previous
next »
Agisoft Metashape
»
Agisoft Metashape
»
Python and Java API
»
How to use createDifferenceMask command?
Features
Support
Community
Downloads
Buy
About
Features
Support
Community
Downloads
Buy
About
Metashape presentation
(PDF, 5 Mb)