필터 지우기
필터 지우기

histogram of a video file

조회 수: 3 (최근 30일)
Deep P
Deep P 2017년 10월 9일
댓글: Walter Roberson 2019년 7월 26일
Hello,
Is it possible to plot a histogram of a video file? Please give me inputs.

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 9일
Use videoreader to open the video file, and readFrame() to read each frame. Process each frame to extract the information you want to take the histogram of. Calculate the histogram. Display it. Use drawnow() so it shows up. Proceed to the next frame.
  댓글 수: 2
Deep P
Deep P 2017년 10월 10일
편집: Walter Roberson 2017년 10월 10일
can u give the sample code please. Also I was referring to examples given in matlab documentation. https://www.mathworks.com/help/matlab/import_export/read-video-files.html can you please explain why we have to create a struct s and what is cdata and colormap there?
Also how to plot histogram of individual frame?
Thank you.
Walter Roberson
Walter Roberson 2017년 10월 10일
That example code is creating an in-memory "movie" to be played. It happens that the in-memory movie display routine, movie(), works with a structure array of movie frames, where each frame independently can be RGB or grayscale or pseudocolor. The field named cdata is used to store the actual numeric frame data, and the field named colormap is used to store the pseudocolor colormap that applies to that one frame. When an rgb entry is being provided, the colormap field can be left as []
You do not have the same needs: you are not displaying images like that, you are displaying histograms.
Example:
filename = 'rhinos.avi';
obj = VideoReader(filename);
fig = figure();
ax = axes('Parent', fig);
while hasFrame(obj)
thisframe = readFrame(obj);
imhist(thisframe);
drawnow();
end

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

sohab azhar
sohab azhar 2019년 7월 25일
following code is showing eror in the line imhist(thisframe).
  댓글 수: 3
sohab azhar
sohab azhar 2019년 7월 26일
i want histgram of an video , i have tried many codes but all codes have some problems.
Walter Roberson
Walter Roberson 2019년 7월 26일
So if I understand correctly, you need a program with the following properties:
  • must handle every possible kind of video in the world
  • must solve all of the bugs inherent in those formats, and all of the bugs from every program in the world that writes those videos
  • must have unlimited ability to create histograms from the videos, including being able to operate on all possible colorspaces
  • the program must already exist, or at the very least be available within a day from now, without you having to write any of the code
Good luck on that.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by