How to use estimateFlow between two images that are not video frames

50 ビュー (過去 30 日間)
chris crowley
chris crowley 2020 年 8 月 7 日
コメント済み: Walter Roberson 2022 年 11 月 8 日
I am interested in computing optical flow between images that are not part of a video sequence using the built-in MATLAB function estimateFlow. That is, I would like to compute optical flow between two images in my workspace, Img1 and Img2. How can I do this?
Currently, I am combining the images into an array and running a for loop to obtain the optical flow:
ImgStack(:,:,1) = Img1; % combine the images to a sequence
ImgStack(:,:,2) = Img2;
reset(opticFlow); % clear previous optical flow
opticFlow = opticalFlowLKDoG; % At this point, I don't realy care what method is used
for t = 1:2
flow = estimateFlow(opticFlow,ImgStack(:,:,t));
end
This procedure is inelegant and quite cumbersome. I am doing this on a large number of images and I would like a more efficient way to do this. It would be nice if I could just do something like flow = estimateFlow(opticFlow,[Img1,Img2]).
Dose anyone know how to do this?
  2 件のコメント
Image Analyst
Image Analyst 2020 年 8 月 7 日
What do you have to start with? A bunch of arrays called Img1, Img2, Img3, etc.? Or one array ImgStack?
chris crowley
chris crowley 2020 年 8 月 8 日
This operation is nested inside of another operation within the code that only generates two images at a time. Img1 and Img2 are grayscale images of the same size. I could rewrite the code to produce an array that is all the Img1s and Img2s appended in an interlaced way into one very long array. This will limit how many images I can analyze because of memory constraints.

サインインしてコメントする。

採用された回答

Divya Gaddipati
Divya Gaddipati 2020 年 8 月 11 日
You can use opticalFlow function for this purpose.
img1 = im2double(Img1); % the images should be in double
img2 = im2double(Img2);
opflow = opticalFlow(img1, img2);
h = figure;
movegui(h);
hViewPanel = uipanel(h,'Position',[0 0 1 1],'Title','Plot of Optical Flow Vectors');
hPlot = axes(hViewPanel);
imshow(img1)
hold on
plot(opflow,'DecimationFactor',[5 5],'ScaleFactor',60,'Parent',hPlot);
hold off
For more information, refer to the documentation on opticalFlow
  3 件のコメント
Qingyuan Li
Qingyuan Li 2021 年 11 月 1 日
I would also like to know the answer of Julius's questoin.
Walter Roberson
Walter Roberson 2022 年 11 月 8 日
It depends exactly what is in the images. The images just might happen to be sensor readings from a flow meter that is directly estimating velocity at each point, perhaps using sonar or polarization techniques. The image files would have to be TIFF in order to store negative values properly...
So the call here is not definitely wrong... just likely wrong.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by