Filter löschen
Filter löschen

Demosaic VS ReturnedColorspace bayer

1 Ansicht (letzte 30 Tage)
Jeff
Jeff am 23 Sep. 2011
I have a 1920 x 1080 color camera that uses a bayer filter. I get the image with a NI camera link frame grabber.
If I get the image my taking a snap shot and applying a demosaic, the resulting image is correct.
If I try to set the .ReturnedColorspace = 'bayer', I get an image that has two additonal ghosts images (one above, one below) and the image appears to have an internlace misalignment.
Can anyone tell me why these give different results? Better yet, can anyone tell me how to set the videoinput properties to allow the ReturnedColorspace to work? I want the ReturnedColorspace technique to work since I would then be able to use the Preview command on the videoinput, vid.
clear all;
clc;
%%Demosaic
vid = videoinput('ni', 2, 'img0_Port1');
I = getsnapshot(vid);
J = demosaic(I, 'grbg');
figure;
imshow(J);
delete(vid);
clear vid;
%%Bayer Filter
vid = videoinput('ni', 2, 'img0_Port1');
vid.ReturnedColorspace = 'bayer';
vid.BayerSensorAlignment = 'grbg';
K = getsnapshot(vid);
figure;
imshow(K);
delete(vid);
clear vid;
  2 Kommentare
Walter Roberson
Walter Roberson am 23 Sep. 2011
Maybe asking for bayer makes the camera shake??
(I would add a wink to show I'm not serious, but... well, it _could_ happen.)
Jeff
Jeff am 28 Sep. 2011
It works fine when the camera resolution is incorrectly set at 1000 x 1000, so that rules out any physical vibration.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 23 Sep. 2011
Is the image monochrome? Is it possible that it's giving you the separate (raw) images? If it's color, maybe it's doing that but tinting the green image green, the red image red, and the blue image blue so that it looks color even though it's not - it's just the raw mosaiced image. Just guessing... Is it possible you could upload an image somewhere? Sorry I don't have a web cam on this computer or else I'd try your code.
  6 Kommentare
Jeff
Jeff am 27 Sep. 2011
I found those properties by watching the session log within the imaqtool toolbox. I haven't found much information on those properties either. I am using the same National Instruments adapter for both techniques.
To add to the confusion, I believe the colorspace method worked properly when the resolution was incorretly set to 1000 x 1000?
Jeff
Jeff am 27 Sep. 2011
I want the ReturnedColorspace technique to work since I would then be able to use the Preview command on the videoinput, vid. Is there a way to Preview or show realtime a demoasiced image?

Melden Sie sich an, um zu kommentieren.


Jeff
Jeff am 30 Sep. 2011
I found thru additional testing the problem with .ReturnedColorspace = 'bayer' is related to the aspect ratio being non-square. 1000 x 1000 - Works 1080 x 1080 - Works 1079 x 1080 - Problem 1920 x 1080 - Problem
Demosaic does not have issues with non-square aspect ratios.
A workaround is to use vid.ROIPosition = [420 0 1080 1080]; during preview(vid) and use the full ROI when collecting data.
I still don't know why the .ReturnedColorSpace can't handle non-square aspect ratios.

Community Treasure Hunt

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

Start Hunting!

Translated by