Trying to use Mono16
AnsweredHello! I'm trying to convert an image from my Blackfly S USB3 to a numpy array in Python. However, because my exposure is so low, the values of this array are usually only in the range of 0 to 7 out of 256 (for 8 bit values). I'd like more granularity in these values, so I'm trying to use 16 bit instead of 8. But when I try to use the PixelFormat_Mono16 instead of Mono8 in "image_converted = processor.Convert(image_result, PySpin.PixelFormat_Mono16)" in the acquisition.py example file, I get a lot of issues. Can somebody please help me resolve this, or point me to somebody who can? Thanks! - Nate
-
Official comment
Hi Nathaniel,
You could reference ImageFormatControl.py example code for more details of how to set pixel format to mono12p/packed:
node_pixel_format = PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat'))
if PySpin.IsReadable(node_pixel_format) and PySpin.IsWritable(node_pixel_format):# Retrieve the desired entry node from the enumeration node
node_pixel_format_mono12p = PySpin.CEnumEntryPtr(node_pixel_format.GetEntryByName('Mono12p'))
if PySpin.IsReadable(node_pixel_format_mono12p):# Retrieve the integer value from the entry node
pixel_format_mono12p = node_pixel_format_mono12p.GetValue()# Set integer as new value for enumeration node
node_pixel_format.SetIntValue(pixel_format_mono12p)However, 12-bit is packed pixel format and require to unpack before retrieving numpy array. With our sdk, user could unpack to 16-bit without affecting the actual resolution:
image_converted = processor.Convert(image_result_in_12bit_packed, PySpin.PixelFormat_Mono16)
Please let me know if this information answered your question.
Regards,
Ifeanyi
-
Hello Nathaniel,
If I understood very well, it seems you are trying to convert 8-bit pixel format to 16-bit format. Our sdk does not support such image processing and enlargement.
One approach is to set image pixel format to 16-bit and retrieve numpy array of grabbed image directly. Another approach is to set pixel format to 12-bit packed, unpack the raw image to 16-bit using 'processor.Convert', and then retrieve numpy array of resultant image.
I hope the provided information help to resolve this issue.
Regards,
Ifeanyi
0 -
Hello Ifeanyi,
Thanks for your response! It looks like the camera only goes up to 12 bits, so that's my goal I guess. But yes, I would really like to directly retrieve a numpy array of the image in 12 bit (I never need it to be in 8-bit), but I am not sure how to do this. Is there an extra line I need to add to make sure that the image is in Mono12?
Thanks,
Nate
0
Please sign in to leave a comment.
Comments
3 comments