error with my code

hi all ... I've encountered an error with this code .. especially with the imread part ... pls clear this ..
vid = videoinput('winvideo', 1 , 'RGB24_320x240');
preview(vid);
for i= 1:3
frame1=getsnapshot(vid);
imwrite(frame1,sprintf('image%d.jpg',i));
fname=save(C:\MATLAB7\work\NewFolder1);
I = imread('image%d.jpg');
J=rgb2gray(I);
figure,imshow(I),figure,imshow(J);
BW1=edge(J,'sobel');
BW2=edge(J,'canny');
figure,imshow(BW1),figure,imshow(BW2);
pause(1)
end

댓글 수: 1

Andreas Goser
Andreas Goser 2012년 1월 30일
You help yourself by including the error message...

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

 채택된 답변

David Young
David Young 2012년 1월 30일

0 개 추천

Have a look at the names of the files: you'll find that there isn't one called 'image%d.jpg', so imread cannot find such a file. (The files you create have names like image1.jpg, image2.jpg, ...)
Maybe you want to read back in the image that you have just written. If so, this should do it:
I = imread(sprintf('image%d.jpg',i));
However, if that is what you need, it will be much faster to use
I = frame1;
You do not need to write the images to disk at all, unless you want to refer to them later.

추가 답변 (0개)

태그

질문:

2012년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by