I am trying to write code. Helps me in my biology. The concept of the code is to analyze the video file of contracting cells in the tissue.
Example 1
Example 2: youtube.com/watch?v=uG_WOdGw6Rk
And write down the following:
- The number of beats per minute.
- Severity beat
- Regular beatings
And so I wrote Matlab code that will scroll the video and compare each frame with the one that follows it, and see if there were any changes in the frames and draw these changes on the curve.
Example of my code Results 
I wrote the core of the current code:
for i=2:totalframes compared=read(vidObj,i); ref=rgb2gray(compared);%% convert to gray level=graythresh(ref);%% calculate threshold compared=im2bw(compared,level);%% convert to binary differ=sum(sum(imabsdiff(vid,compared))); %% get sum of difference between 2 frames if (differ ~=0) && (any(amp==differ)==0) %%0 is = no change happened so i dont wana record that ! amp(end+1)=differ; % save difference to array amp wi time(end+1)=i/framerate; %save to time array with sec's, used another array so i can filter both later. vid=compared; %% save current frame as refrence to compare the next frame against. end end figure,plot(amp,time);
======================
So, this is my code, but is there any way to improve it so that I can get better results?
because I get that imabsdiff is not quite what I should use, because my video contains a lot of noise and that greatly affects my results, and I think that all the data from my amplifier is really faked!
In addition, I can actually only get the beat rate from this by counting the peaks, but how can I improve my code to be able to extract all the necessary data from it?
thanks also really appreciate your help, this is a small part of the code, if you need more information, please let me know. thanks