Help with matlab, structures and movies

In summary, the conversation is about a user who has created an m-file to output movies made from images of a 200 by 200 matrix. They are trying to input these movies into a second program to analyze each frame, but are having trouble converting the structure files back to the original matrix. The structure files are 1 by 600 and contain cdata which is a <343x435x3 uint8> file and an empty matrix 'colormap'. The user is unsure of how the cdata file represents a matrix and why it contains zeros, ones, and 255s. The second program is another m-file and the user wants to use the movie as input, but the structure files are not the expected size of
  • #1
Fert
6
0
Hi, I made an m-file which which outputs movies at the end. The movie frames are made from images of a 200 by 200 matrix. I wanted to input the movies into a second program which then analyzes each frame. The problem is the frames are structure files and I don't know how to convert the frame back to the 200 by 200 matrix. I've read through the MATLAB help files on structures but I still don't understand what is in the structure file.

The files are 1 by 600 structure files. If I take one frame out it is a 1 by 1 structure file which contains cdata which is a <343x435x3 uint8> file and an empty matrix 'colormap'. I don't understand how the cdata file represents a matrix or how to convert cdata back to the original data.

When looking at parts of the cdata file it contains zeros, ones and 255's, where my original matrix was all zeros and ones.

In case it matters how I made the movie, this is the code I used:

in a loop:
(A is the matrix)
imagesc(A,'colourmap','gray')
F(i)=getframe;
end

I know the imagesc scales the original matrix but shouldn't zero stay zero and ones get scaled to 255? If so why is there ones in cdata?

Any help would be greatly appreciated.

Thank you
 
Physics news on Phys.org
  • #2
What does your second program take in? Video files? Image files? MATLAB files? Their own proprietary format? MATLAB's capable of exporting just about anything.
 
  • #3
Thanks for the reply. The second program is another m-file and I wanted to use the movie as the input. The program was supposed to count the number of zeros and ones in each row and average them for each frame. The problem is instead of a 200 by 200 matrix the structure files are 343x435x3. I get why its size mxnx3 because its an 8-bit rgb truecolour image, but I don't understand why its not a 200x200x3. Also I don't understand why the structure file contains zeros ones and 255s. I thought white would be (255,255,255) and black is (0,0,0) so there should be no ones in the cdata file.
 

What is Matlab?

Matlab is a programming language and interactive environment used by scientists, engineers, and researchers for numerical computing, data analysis, and visualization.

How can I use structures in Matlab?

Structures in Matlab are data containers that allow you to store and access multiple pieces of related data in a single variable. They can be created using the "struct" function and accessed using dot notation.

What are movies in Matlab?

In Matlab, movies are a series of images or frames that are displayed in a sequence to create the illusion of motion. They are often used for visualizing and analyzing data over time.

How can I create a movie in Matlab?

To create a movie in Matlab, you can use the "movie" or "implay" functions. These functions take in a series of images or frames and play them back at a specified frame rate to create the movie.

How can I add structures to a movie in Matlab?

You can add structures to a movie in Matlab by creating a structure array that contains the data for each frame of the movie. Then, you can use a for loop to access each frame and add it to the movie using the "addframe" function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
126
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Astronomy and Astrophysics
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top