## Key Frames Extraction in a Video

### G-ONE (view profile)

on 13 Nov 2012
Latest activity Commented on by abhishek patel

### abhishek patel (view profile)

on 6 Apr 2015

Hello Everyone

I am working on a assignment "key frames extraction in a video sequence" Method that i am using as follows

```   ->extracts frames one by one
->histogram difference between two consecutive frames using imhist() and
imabsdiff()
->calculate mean and standard deviation of difference and threshold
->continue till end of video
->again extracts frames one by one
->histogram difference between two consecutive frames using imhist() and
imabsdiff()
->compare this difference with threshold and if it is greater than threshold
select it as a key frame
->continue till end of video```

is this method correct??

if anyone have good solution plz help me with the code

my simple code

```   vid = 'Wildlife 00_00_20-00_00_30.avi';
`   for k=1:  readerobj.NumberOfFrames`
```           I=read(readerobj,k);
sss=absdif(I,J);
X(k)=sss;
end```
`   end`
```   mean=mean2(X)
std=std2(X)
threshold=std+mean*4```
`   for k=1: readerobj.NumberOfFrames`
`       I =  read(readerobj,k);`
`       if(k~=readerobj.NumberOfFrames)`
`        J=   read(readerobj,k+1);`
`        sss=absdif(I,J);`
`        if(sss>mean)`
`            imwrite(J,strcat('D:\',Names{k+1}));`
`       end`
`   end`

% absdif function

`   function [ res ] = absdif( I,J )`
```       k=rgb2gray(I);
l=rgb2gray(J);
m=imhist(k);
n=imhist(l);
dif=imabsdiff(m,n);
res=sum(dif);```
`   end`

msp

### msp (view profile)

on 29 Apr 2013

thank you sir.

on 12 Mar 2015

"threshold=std+mean*4 " for this how can we identify that it should be 4..and can we give global threshold?

abhishek patel

### abhishek patel (view profile)

on 6 Apr 2015

i m geting error in following line X(k)=sss.... Subscripted assignment dimension mismatch.