Help with matlab, structures and movies

Click For Summary
SUMMARY

The discussion revolves around converting MATLAB structure files containing movie frames back into their original 200 by 200 matrix format. The user created a movie using the imagesc function and encountered issues with the resulting structure files, which are 1 by 600 in size and contain cdata formatted as <343x435x3 uint8>. The user is confused about the scaling of values in cdata, specifically why ones appear in the data when the original matrix only contained zeros and ones. The code snippet provided indicates that the imagesc function scales the original matrix, leading to discrepancies in expected values.

PREREQUISITES
  • Understanding of MATLAB structure arrays
  • Familiarity with the getframe function in MATLAB
  • Knowledge of image data representation in MATLAB
  • Basic concepts of RGB color representation in images
NEXT STEPS
  • Research how to extract data from MATLAB structure arrays
  • Learn about the im2frame function in MATLAB for better frame handling
  • Explore the colormap function and its effects on image data
  • Investigate the implications of scaling in imagesc and how it affects data representation
USEFUL FOR

MATLAB users, data analysts, and developers working with image processing and movie frame analysis who need to manipulate and convert structure files back to matrix formats.

Fert
Messages
6
Reaction score
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
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.
 
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K