image and video process

5 visualizzazioni (ultimi 30 giorni)
Ali alshamrani
Ali alshamrani il 3 Ago 2021
Risposto: Prachi Kulkarni il 13 Ago 2021
Hi all,
I have a video of about 400 frames(.AVI), first I changed the brightness, then cropped the images to focus on interesting areas. After that, I converted the cropped image to a binary image. In the end, I saved both binary and original images which should be the same size.
I already did this only for one frame (image) but I have no idea how to do these steps for the entire video...
Here is what I did>>>
clear;
img = imread('3217.tif');
img = imadjust(img);
I = imcrop(img,[120,280,1990,980]);
[rows,columns,ch] = size(img);
if (ch > 1)
img = img(:,:,3);
end
close all;
img1 = I < 120;
disp(img1(1,1));
disp(nnz(img1));
total = nnz(img1);
% figure(1) ; imshow(img)
%
% figure(2) ; imshow(I)
% figure(3) ; imshow(img1) ;
imwrite(I, 'F:\Herder\collective obstacles\process\PIV\No obstacle\cropped\3217.tif');
imwrite(img1, 'F:\Herder\collective obstacles\process\PIV\No obstacle\cropped\binary\3217.tif');

Risposte (1)

Prachi Kulkarni
Prachi Kulkarni il 13 Ago 2021
Hi,
Sample code for processing every frame in a video-
vidObj = VideoReader(filename); % filename (string): name of video file with extension
while hasFrame(vidObj)
vidFrame = readFrame(vidObj);
% The code for processing each frame can go here
end
For more details, please refer to the following documentation-

Community Treasure Hunt

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

Start Hunting!

Translated by