How to assign a numeric value to a picture file?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jack
am 23 Apr. 2014
Kommentiert: Jack
am 28 Apr. 2014
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 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 Kommentare
Image Analyst
am 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.
Weitere Antworten (2)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!