User`s guide
Working with Image Data in MATLAB Workspace
7-19
Manual Conversion
The camera in this example has a Bayer sensor. The GigE Vision™ standard allows
cameras to inform applications that the data is Bayer encoded and provides enough
information for the application to convert the Bayer pattern into a color image. In this
case the toolbox automatically converts the Bayer pattern into an RGB image.
1
Create a video object vid using the GigE Vision adaptor and the designated video
format.
vid = videoinput('gige', 1, 'BayerGB8_640x480');
2
View the default color space used for the data.
vid.ReturnedColorSpace
ans =
rgb
3
Create a one-frame image img using the getsnapshot function.
img = getsnapshot(vid);
4
View the size of the acquired image.
size(img)
ans =
480 640 3
5
Sometimes you might not want the toolbox to automatically convert the Bayer
pattern into a color image. For example, there are a number of different algorithms
to convert from a Bayer pattern into an RGB image and you might wish to specify a
different one than the toolbox uses or you might want to further process the raw data
before converting it into a color image.
% Set the color space to grayscale.
vid.ReturnedColorSpace = 'grayscale';
% Acquire another image frame.
img = getsnapshot(vid);
% Now check the size of the new frame acquired using grayscale.
size(img)