I'm trying to write a code The helps me in my biology work. Concept of code is to analyze a video file of contracting cells in a tissue
Example 2: youtube.com/watch?v=uG_WOdGw6Rk
And plot out the following:
- Count of beats per min.
- Strenght of Beat
- Regularity of beating
And so i wrote a Matlab code that would loop through a video and compare each frame vs the one that follow it, and see if there was any changes in frames and plot these changes on a curve.
Example of My code Results
Core of Current code i wrote:
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 thats my code, but is there a way i can improve it so i can get better results ?
because i get fealing that imabsdiff is not exactly what i should use because my video contain alot of noise and that affect my results alot, and i think all my amp data is actually faked !
Also i actually can only extract beating rate out of this, by counting peaks, but how can i improve my code to be able to get all required data out of it ??
thanks also really appreciate your help, this is a small portion of code, if u need more info please let me know. thanks