How to assign a numeric value to a picture file?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2014년 4월 23일
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
Image Analyst
2014년 4월 24일
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.
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!