how to get the output form the .mat format.
4 views (last 30 days)
Show older comments
I have record a short vedio from the kinect,and it store as the format of G1.mat,when I open the G1.mat,there has three name in it,one is M with value of struct,another is ans with value of struct,the last one is fps with the value of 2.0481. And now I want to imshow the frame of the vedio I record, however,I have no idea how to operate it.Actually,there has two part of the frame,one is about color,and another is about depth. Please help! Thank you very much.
0 Comments
Accepted Answer
Walter Roberson
on 12 Oct 2011
Probably M is the important part. Check
fieldnames(M)
and see what it reports. If it reports the field names as 'cdata' and 'map' then try
movie(M, 1, fps)
2 Comments
Walter Roberson
on 12 Oct 2011
I am not sure what you mean about "depth", but I will guess that when the movie was created, the information being represented was depth information.
If so, then what was the original range of depth values? Unless it was strictly 0 to 1 with a resolution of 1/256 at most, or unless it was small integers in the range 0 to 255, then the original depth information is gone. Movies, unless specially created, are stored internally as 8 bits (integers 0 to 255) or 8 bits per pixel (R, G, B, each integers 0 to 255.)
You need to check
size(M(1).colormap)
and see if it is empty. If it is, then
size(M(1).cdata)
for a color image will show the height then the width then 3 (the number of color channels.) If the colormap is empty, then the cdata for each frame already contains all the information stored for each pixel.
If the colormap is _not_ empty, then size(M(1).cdata) should show just a height and a width, with _no_ 3 afterwards. Those images are "indexed images", and each pixel is an index in to the colormap. If that is the case, then
ind2rgb(M(K).cdata, M(K).colormap)
will return the RGB (3 channel) version of the frame.
If you _do_ have indexed images, then there is a possibility that the index values might hold some meaning: an index of 0 might represent the lowest possible depth range, an index of 1 might represent the depth range right above that, and so on. *If* the images were constructed in that way, and *if* you can get information about what the depth range was and about how it was mapped in to indices (e.g., perhaps a change of 1 in the index corresponds to a change of 10 meters in depth), then you could use the .cdata field to map back to an approximate depth for each pixel.
If the frames are _not_ indexed, if they already have R, G, and B channels, then in order to map back to depth information, you would need to know in detail what the original mapping was between depth and chosen color. This is, at best, more tedious to code... but it isn't so bad if you know the exact colormap that was in force at the time and know the minimum and maximum depth... or equivalent information.
The cdata and colormap do not, by themselves, have enough information to reconstruct the data values that were being plotted, but sometimes you only need a little more information (and sometimes you need a lot more.)
More Answers (0)
See Also
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!