How to assign a numeric value to a picture file?
5 views (last 30 days)
Show older comments
ok so im having a problem with converting a file to numeric value. i have used str2num and has given me no luck. what i want to do is basically make a picture file for example x.gif equal to 1. I have multiple .gif files and want to assign values to each .gif file. how would i do this? thanks.
0 Comments
Accepted Answer
Image Analyst
on 23 Apr 2014
Jack, we're not sure what you want. So you read in your gif file
myGif = imread('x.gif');
Now you have all the pixels in the myGif array. So what do you want to do with that? Assign all the values to 1?
myGif(:) = 1; % Assign all pixels a value of 1, erasing previous values.
Why would you want to do that???
To process a sequence of files, see the FAQ for code samples: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
2 Comments
Image Analyst
on 24 Apr 2014
Jack, regarding your "Answer" how about this:
filenames = dir('*.gif')
for k = 1 : length(filenames)
filenames(k).number = k;
end
Now every filename has a number associated with it. Of course it's just the same as the index so it's totally unnecessary, but it seems like that's what you want for some reason.
More Answers (2)
See Also
Categories
Find more on File Operations 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!