Matlab Motion Estimation Code
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
Can somebody please explain what the code I have pasted below does, which can be found from the Link - Algorithms
for i = 0:30
imgINumber = i;
imgPNumber = i+2;
if imgINumber < 10
imgIFile = sprintf('./%s/gray/%s00%d.ras',imageName, imageName, imgINumber);
elseif imgINumber < 100
imgIFile = sprintf('./%s/gray/%s0%d.ras',imageName, imageName, imgINumber);
end
if imgPNumber < 10
imgPFile = sprintf('./%s/gray/%s00%d.ras',imageName, imageName, imgPNumber);
elseif imgPNumber < 100
imgPFile = sprintf('./%s/gray/%s0%d.ras',imageName, imageName, imgPNumber);
end
I want to perform some of the motion estimation algorithms using my own mpeg video, but I need to know what this code does. It would be very much appreciated, as it will help me with my final year project.
0 commentaires
Réponses (2)
bym
le 14 Juil 2011
it creates a string based upon the image name & number. It pads the number with zeros to get a string with a consistent number of characters
0 commentaires
Walter Roberson
le 14 Juil 2011
It is code for selecting file names from a directory relative to the current directory. The subdirectory involved is indicated by imageName and then the 'gray' subdirectory of that. The file names involved will start with that same name, followed by a 3 digit number, followed by '.ras'. For any one pass of the for loop over "i", two files are selected, one using i as the number, and the other using i+2
The code could be replaced with
for i = 0:30
imgIFile = sprintf('./%s/gray/%s%03d.ras', imageName, imageName, i);
imgPfile = sprintf('./%s/gray/%s%03d.ras', imageName, imageName, i+2);
2 commentaires
Walter Roberson
le 14 Juil 2011
'./%s/gray/%s%03d.ras' is an sprintf format string. It means that the output string is to start with a period, then a slash, then the next parameter (the 2nd to the call) should be interpreted as a string and placed in the buffer, followed by a slash and the literal word 'gray', followed by a slash, then the next parameter (the 3rd to the call) should be interpreted as a string and placed in the buffer, followed by a slash, then the next parameter (the 4th to the call) should be interpreted as a string and placed in the buffer, then the next parameter (the 5th to the call) should be converted to be a 3 digit integer with leading zeroes, and finally that a literal period and 'ras' should be added to the buffer.
If all the images are in a folder called gray that is a subdirectory of your current directory, then the code would look like:
for i = 0:30
imgIFile = sprintf('./gray/%s%03d.ras', imageName, i);
imgPfile = sprintf('./gray/%s%03d.ras', imageName, i+2);
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!