Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: dobedobedo on November 23, 2017, 10:20:16 AM
-
Hi,
I just can't figure out how to get the pixel value from different band through the Python API.
My photos are Parrot Sequoia multi-spectral images, and I added them via multispectral layout. I can also manage to set the master channel to review the different bands in the photo window. However, when I access the image by
camera.photo.image().cn
It appears to have only one channel. And if I access the pixel value by
camera.photo.image()[600, 400]
It gets me something like (27680, ), which seems only contains the pixel value of the master channel.
I tried to set master_channel from 1 to 4 and access the pixel value like camera.photo.image()[600, 400] but the values are always the same. Moreover, the information from camera.sensor.bands always contains the first master channel I set up (which is Green in this case) no matter how I change the master channel later.
I'm just curious that how PhotoScan store the information of multi-spectral images and how do I access the pixel value for different bands via Python API?
It would be appreciated to have your reply!
-
Hello dobedobedo,
Please try the following to access the same pixel on all the bands for multispectral camera:
camera = chunk.cameras[0]
for band in camera.planes:
print(band.photo.image()[600,400])
So basically, you need to use camera.planes.photo.image().
-
Thanks Alexey. This method works! Though all of the camera labels are the same, which is a little bit confused.