i am taking image as input to the code.But image are not proper.

3 views (last 30 days)
This is my code
clc;
close all;
clear all;
obj = videoinput('winvideo', 1);
set(obj, 'SelectedSourceName', 'input1');
src_obj = getselectedsource(obj);
get(src_obj);
preview(obj);
frame = getsnapshot(obj);
image(frame);
delete(obj);
Its simple image from videoinput.....But i am attaching picture that matlab shows me....Is there any kind of setting need while using this code....Code is correct at has been taking from library file of videoinput() function.I have changed two camera. Check out attachment of image.

Accepted Answer

Image Analyst
Image Analyst on 27 Dec 2013
Is it color or black and white? What function are you using to display it, imshow(), image(), or imagesc()?
  13 Comments
Image Analyst
Image Analyst on 31 Dec 2013
Edited: Image Analyst on 31 Dec 2013
Oh bummer. You have one of those cameras that doesn't have an RGB mode. All is not lost though. There is an option of videoinput() that lets you set the returned video mode to convert it into an RGB image. Check out this link by David Tarkowski, the developer of this toolbox at the Mathworks: http://www.mathworks.com/matlabcentral/answers/5634#answer_8178
vid = videoinput('winvideo', 1);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
imshow(img)

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 27 Dec 2013
It appears to me that you are getting something that is not in RGB colorspace. Use
imaqfind
  3 Comments
Walter Roberson
Walter Roberson on 28 Dec 2013
imaqfind() does not change the image format, it shows you the available image formats. You then have to pick an appropriate one and add it to the videoinput() call.
ravi
ravi on 20 Feb 2014
use obj.ReturnedColorSpace='rgb'; just after obj = videoinput('winvideo', 1);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!