Un problema reale: Shot detection detection
Transcript
Un problema reale: Shot detection detection
http://imagelab ing unimo it http://imagelab.ing.unimo.it Dispense del corso di Elaborazione di Immagini e Audio Digitali Un problema reale: Shot detection Prof. Roberto Vezzani Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Un esempio di elaborazione di video • In questa lezione affrontiamo un problema reale di elaborazione l b i di un video id • Dato un problema da risolvere, vedremo diverse strategie per affrontarlo ff t l e i metodi t di per valutarne l t le l prestazioni t i i Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Cosa è la “Shot Detection”? • Problem definition – shot detection: given a video V consisting of n shots, find the beginning and end of each shot. • Also known as shot boundary detection or transition detection. • It is fundamental to any kind of video analysis and video application since it enables segmentation of a video into its basic components: the shots. shots Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Struttura di un video Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Classificazione delle scene (Pattern recognition) recognition) Esempio: classificazione di shot in un video preso da telegiornale Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Classificazione delle transizioni • Hard cuts: A cut is an instantaneous transition from one scene to the next. next • Fades: A fade is a gradual transition between a scene and a constant image (fade-out) (fade out) or between a constant image and a scene (fade-in). • Dissolves: A dissolve is a ggradual transition from one scene to another, in which the first scene fades out and the second scene fades in. • Wipe Wi Wipe: another h common scene break b k is i a wipe, i in i which a line moves across the screen, with the new scene appearing behind the line. line Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Fades • During a fade, images have their intensities multiplied b some value by l α. During D i a ffade-in, d i α increases i ffrom 0 to 1, while during a fade-out α decreases from 1 to 0. Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Dissolvenza • Combinazione di fade-in e fade-out. Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Cut Detection • Normalmente i frame di un video derivano dal campionamento i temporale l di una funzione f i continua. i Se S il framerate è sufficientemente alto, le variazioni interframe devono essere “piccole” piccole • Serie temporale delle dissimilarità: f(n). • n = numero del frame, frame N numero totale di frames. frames • Suppose we use function d(x,y) to measure the dissimilarity between frame x and y. y The discontinuity feature value for frame n is f(n)=d(n-1,n). • Pick the cuts position from f(n) based on some threshold techniques. Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Esempio Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Misure di dissimilarità • Intensity/color histogram d H ( f ), ) H (g) 255 2 H ( f )( i ) H ( g )( i ) i 0 Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia The Edge Change Ratio ECR(n, k) Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia imd1 = rgb2gray(im1); Imd2 = rgb2gray(im2); % black background image bw1 = edge(imd1, g ( , 'sobel'); ); bw2 = edge(imd2, 'sobel'); % invert image to white background ibw2 = 1-bw2; ibw1 = 1-bw1; 1 bw1; s1 = size(find(bw1),1); s2 = size(find(bw1),1); % dilate se = strel('square',3); dbw1 = imdilate(bw1, se); dbw2 = imdilate(bw2, se); imIn = dbw1 & ibw2; imOut = dbw2 & ibw1; ECRIn = size(find(imIn),1)/s2; ( ( ), ) ; ECROut = size(find(imOut),1)/s1; ECR = max(ECRIn, ECROut); Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Thresholding – come calcolare la soglia • Global threshold A hard h d cut is i declared d l d each h time i the h discontinuity di i i value l f(n) surpasses a global thresholds. • Adaptive threshold A hard cut is detected based on the difference of the current feature values f(n) ( ) from its local neighborhood. g Generally this kind of method has 2 criteria for a hard cut declaration: - F(n) F( ) ttakes k the th maximum i value l inside i id the th neighborhood. i hb h d - The difference between f(n) and its neighbors’ feature values is bigger than a given threshold. threshold Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Thresholding – come calcolare la soglia • • • • Metodi empirici Metodi manuali Modellazione matematica del sistema Modellazione probabilistica del sistema Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Metodi probabilistici: formule base Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Thresholding – come calcolare la soglia Use a slide window with size 2w+1. The middle frame in the window is detected as a cut if: - Its feature value is the maximum in the window. - Its feature value is greater than max( left Td left , right Td right ) where Td is a p parameter g given a value of 5 in this experiment. Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia The statistics model is based on following g assumption: p The dissimilarity feature values f(n) for a frame comes from two distributions: one for shot boundaries(S) and one for “not“not-a-shotshot-boundary”(N). In general, S has as a co considerably s de ab y larger a ge mean ea a and d sta standard da d de deviation at o tthan a N. Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Experiments • Input: a lot of frames… • Dissimilarity function - Intensity histogram - Edge change ratio (ECR) • Thresholding - Adaptive threshold based on statistics model. Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Results • Intensity histogram dissimilarity + adaptive thresholding Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Results(cont.) • ECR dissimilarity + adaptive thresholding Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Analisi delle prestazioni • Precision and Recall Pr ecision Re call correttame nte _ identifica ti correttame nte _ identifica ti falsi _ allarmi correttame nte _ identifica ti correttame nte _ identifica ti identifica zioni _ perse F 2 * Pr ecision * Re call Pr ecision Re call • Curve ROC: coppie (Precision-Recall) per diversi valori di eventuali soglie o parametri Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Curva ROC - Receiver operating characteristic (da wikipedia) Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia Problemi correlati • Estrazione dei keyframes • Uso dei keyframes nel video editing Roberto Vezzani - Imagelab – Università di Modena e Reggio Emilia