How to update the image title automatically with the corresponding file name?
2 次查看(过去 30 天)
显示 更早的评论
I have a file for eg: patient 101232-1, which is used to create an image and I have 100 files with tags: 101232\position-%d. How can I update the file name on the image title without inputting the patient number twice, I.e in dlm read line and image title line everytime i run the code. (please see the code below).
nfiles = input('Number of tissue files available: ');
for j = 1:nfiles
*DataC = dlmread(sprintf('%s%d%s','\\homes\Dec-30Days-2013\30-days-SI\128765(40db)\position-',j,'.txt'));*
*imageTitle=sprintf('Colour-128765-%d',j);*
Z=(Imagedata(Y,X));
figure('name',imageTitle,'numbertitle','off')
imagesc(SS*X,Depth,Z);
title(['Amplitude max = ' num2str(amp)]);
0 个评论
采纳的回答
Image Analyst
2013-1-23
That is not very robust code. You should really review the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F You create a filename, and just assume it exists - very bad practice. You should use exist() to check that it exists, or just use dir() before the loop to get only files that do exists. Then when you get the name you can use fullfile() and fileparts() to get the type of name you want - the full file name (folder plus base file name plus extension), or just the base filename. Then use sprintf() to construct a title/caption for your displayed image and use title() to send the caption to the GUI.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!