How to unpack mono12packed data images from preview

조회 수: 2 (최근 30일)
Matt
Matt 2022년 10월 19일
편집: Matt 2022년 10월 19일
Hello,
I am using the image acquisition tool to control a camera and I would like to know how to use preview properly when the camera is streaming mono12packed data.
For exemple if I set the camera to 8 bit with the following code I get nice images as shown here :
main_cam = videoinput('gige','1','Mono8');
preview(main_cam)
stoppreview(main_cam)
But if I set the camera to mono12packed I get data that seems unpacked too me :
delete(main_cam)
main_cam = videoinput('gige','1','Mono12Packed');
preview(main_cam)
stoppreview(main_cam)
I have the same unpacked data issue when using getdata like this :
main_cam = videoinput('gige','1','Mono12Packed');
start(main_cam)
[img,time_main] = getdata(main_cam,1,'double','cell');
imagesc(img{1})
Do you have ideas on how to get unpacked data from preview and getdata ?
Thank you very much !

답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 19일
  댓글 수: 1
Matt
Matt 2022년 10월 19일
편집: Matt 2022년 10월 19일
Hi,
The colorspace is by default set to 'grayscale' as it should.
The thing is that in mono12packed the value of 2 pixels is written on two consequtives bytes as explained in this link.
I would expect getdata to know how to deal with this but it seems that no. When asking getdata to get data in the native format I get unint16 data where the work to unpack data (ie for each pixel go get 8 bites in the Nth byte and 4 bites in the N+1th byte for exemple and store them in a uint16 where the 4 first bites are 0) has not been done.
getdata(main_cam,1,'native','cell') % get me uint16 data

댓글을 달려면 로그인하십시오.

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by