how to take the difference of images (at once) within multiple snapshots ?

My present situation:
for i=1:10
grayImage = getsnapshot (cam);
grayImage = rgb2gray (grayImage);
imwrite (grayImage,sprintf('test_%d.jpg',i));
end
I want to see the image differences being subtracted automatically (e.g. from image 1 and 2, 3 and 4, 5 and 6 etc.) without doing it one by one like the following.
f1=imread ('test_1.jpg');
f2=imread ('test_2.jpg');
diffGray = abs (f1-f2);
And after having coded to do the operation automatically, I also want to save the differences into a folder in Binary format (to make it visible in black and white). The saving must also take place automatically rather having to use imwrite for saving each and every difference.
Please help. thank you very much.

 채택된 답변

Image Analyst
Image Analyst 2014년 12월 1일

1 개 추천

You will find it easy to adapt one of the code samples in the FAQ to subtract the (n-1)st image from the nth image. http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Let me know if you can't.

댓글 수: 7

I tried to figure out the subtraction from a series of images from the above link. but I couldn't make it. It would be much pleasing if you give the answer with relation to my question.
The code sample in the FAQ is also seemingly complex for me. Please consider.
thanks
Any updates?? Please help
Omar, I'd like to help but when I saw that the FAQ was above the threshold of complexity for you (even though it's only slightly more complicated than your for loop), I didn't really know what to do. Now that you've had a few days to study the FAQ, do you think that if I make a slight adaption inside the for loop to subtract the prior image from the current image that you'll be able to follow it? It's not much more than sticking diffImage = double(currentImage) - double(priorImage) into the for loop but I can do it for you if you want.
Omar Ahmad
Omar Ahmad 2014년 12월 8일
편집: Omar Ahmad 2014년 12월 16일
yes please.. but please make it as simple as possible
Sir, have you come up with a solution to my problem?
Please help.
See my attached demo where I get differences between frames of a video.
By the way I'll be traveling in Arizona and California from this evening through Friday so I most likely won't be able to answer anyone at all during that time.
Thank you very much Sir. Have a safe journey ahead. Thanks for everything again..

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2014년 12월 1일

댓글:

2014년 12월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by