imwrite through step() to snapshot a video saves red images why?

I'm getting snapshots of a video using imwrite to write a frame captured by step() the images that are saved to the folder are red and with low quality
why is that? and how do I avoid it?
Thank you

답변 (2개)

David Tarkowski
David Tarkowski 2013년 5월 13일

1 개 추천

It looks like you are using a YCbCr format of your camera. When you are previewing or writing to disk, the toolbox converts the frame to RGB since display and disk logging require RGB data. When you use step or getsnapshot, the toolbox does not, by default, convert the image to RGB since there arr easons why you might actually want the YCbCr data.
You can set the ReturnedColorSpace property of your videoinput or imaq.VideoDevice object to 'RGB' which will cause the toolbox to convert the frame to RGB before it returns it. You could also use the ycbcr2rgb function to do the conversion.
Image Analyst
Image Analyst 2013년 5월 12일

0 개 추천

Is the camera white balanced? Does the image look like that in your GUI before you save it to disk and recall it? What does your call to imwrite() look like?

댓글 수: 6

Yes and No the image looks full colored RGB on my GUI clearer and sharper
FRAME = step(Cam);
imwrite(FRAME, sprintf('MotionDetected%.3d.jpeg', Imno));
Thank you for your time
I don't know. If it didn't look red when you did imshow(), then it should not show up as red when you do imwrite(). Call the Mathworks.
Thank you It's a snapshot of a video while running, would the fact that this video frames are edge detected be the reason?
Image Analyst
Image Analyst 2013년 5월 13일
편집: Image Analyst 2013년 5월 13일
What you do with the image after you take it, display it, and save it to disk does not matter. If you're saving a uint8 image, then it should/will look the same on disk as it does in the image buffer, as long as you didn't use a colormap. What is the step() function? I don't use that. I use getsnapshot().
Lobna
Lobna 2013년 5월 13일
편집: Lobna 2013년 5월 13일
I use getsnapshot() as well but when I use it in this particular code it gives me the "Too many output arguments." error message
You forgot to show your code, or answer my question.

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

질문:

2013년 5월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by