Forum

Author Topic: How to get pixel value for different band?  (Read 2729 times)

dobedobedo

  • Newbie
  • *
  • Posts: 31
    • View Profile
How to get pixel value for different band?
« 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
Code: [Select]
camera.photo.image().cnIt appears to have only one channel. And if I access the pixel value by
Code: [Select]
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!
« Last Edit: November 23, 2017, 10:22:18 AM by dobedobedo »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: How to get pixel value for different band?
« Reply #1 on: November 23, 2017, 11:27:06 AM »
Hello dobedobedo,

Please try the following to access the same pixel on all the bands for multispectral camera:

Code: [Select]
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().
Best regards,
Alexey Pasumansky,
Agisoft LLC

dobedobedo

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: How to get pixel value for different band?
« Reply #2 on: November 27, 2017, 02:21:13 AM »
Thanks Alexey. This method works! Though all of the camera labels are the same, which is a little bit confused.