Borrar filtros
Borrar filtros

How to update the image title automatically with the corresponding file name?

2 visualizaciones (últimos 30 días)
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)]);

Respuesta aceptada

Image Analyst
Image Analyst el 23 de En. de 2013
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.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by