Why specifically do we need to cast frames to double to detect movement?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
In order to detect movement from subsequent frames... My understanding is that we subtract all the pixel values from the previous or next frame and if the differences are anything other than zero then movement has taken place. But our slide says :
– diff1 = abs(frame61 – frame62).
– diff2 = abs(frame63 – frame62).
• Note: frames must first be cast to double, Otherwise, the above lines will not work.
• E.g.: frame61 = double(frame61);
I was just wondering why specifically we need to do this. It offered no explanation.
0 commentaires
Réponses (1)
Walter Roberson
le 6 Sep 2021
img = imread('cameraman.tif');
img2 = 2*fliplr(img);
imshowpair(img, img2)
Lots of differences, so you would expect that "movement" would be deteted on both the right and the left, right?
diff1 = img - img2;
imshow(diff1, [])
That's odd, almost no "movement" detected to the left ??
diff2 = double(img) - double(img2);
imshow(diff2, [])
But there it is if we used double() ... why didn't the first one work?
Well, look at this:
A = uint8(10)
B = uint8(20)
A - B
double(A) - double(A)
Subtracting a uint8 from a uint8 always has to give a uint8 result. But uint8 cannot represent negative numbers.
0 commentaires
Voir également
Catégories
En savoir plus sur Entering Commands dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!