Why specifically do we need to cast frames to double to detect movement?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2021 年 9 月 6 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!