Why am I unable to preview 16-bit image data from my camera?
8 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 21 Oct 2022
When I open the preview window after acquiring image data from my camera:
h = preview(vid);
Instead of the video data, a blank/black, or poor contrast white figure window is displayed.
Accepted Answer
MathWorks Support Team
on 21 Oct 2022
Edited: MathWorks Support Team
on 21 Oct 2022
The Preview window will show only show 8-bit data by default, but many cameras can return 10-, 12-, 14-, or 16-bit data. The Preview window display supports these higher bit-depth cameras. However, by default larger bit-depth data is truncated to 8-bit for the purpose of displaying previewed data.
To capture the image data in the Preview window in its full bit depth for grayscale images, set the PreviewFullBitDepth property to 'on' in MATLAB R2021a and later releases:
vid = videoinput('gige',1,'Mono16');
vid.PreviewFullBitDepth = 'on';
You can also configure the preview axes CDataMapping and CLim properties.
vid = videoinput('gige',1,'Mono16');
vid.PreviewFullBitDepth = 'on';
h = preview(vid);
a = ancestor(h, 'axes');
set(h, 'CDataMapping', 'scaled');
% Modify the following numbers to reflect the actual limits of the data
returned by the camera.
% For example the limit a 16-bit camera would be [0 65535].
set(a, 'CLim', [0 65535]);
Please ensure that the preview window remains open while setting the image properties.
Note that in MATLAB R2020b and prior releases you can use the following imaqmex command before creating the videoinput object to enable full bit-depth preview:
imaqmex('feature', '-previewFullBitDepth', true);
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!