courbe de suivie des pixels dans les images
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Amal Felhi
el 16 de Abr. de 2021
Comentada: Amal Felhi
el 17 de Abr. de 2021
hi , I have 25 MRI images (dicom) as input. I select 6 fixed point (x, y) and I keep the location of these pixels for the other images. I want to plot the progression curve of these pixels in the 25 images.
I want to display the curve of each image in the same plot but by different colors .how to program that?
i use this code :
rep = uigetdir;
Imgs = dir(rep);
thisname = Imgs(3).name;
[path,name,ext]=fileparts(thisname);
ext=strcat('*',ext);
chemin = fullfile(rep,ext);
list = dir(chemin);
nbr_images= numel(list);
for n=1:25
k=dicomread(fullfile(rep, list(n).name));
end;
IM=double(k);
axes(handles.axes1);imshow(IM,[]);
impixelinfo;
[xi,yi]=getpts
IM=dicomread(fullfile(rep, list(1).name))
IM(1,1,numel(list))=0; %extend array to fit all slices
for n=2:numel(list)
IM(:,:,n)=dicomread(fullfile(rep, list(n).name));
end
for k=1:6
for n=1:25
column= round(xi(k));
row= round(yi(k));
intensityProfile(k)=squeeze(IM(column,row));
axes(handles.axes2);plot(intensityProfile,'b*-');
end
end
1 comentario
Walter Roberson
el 17 de Abr. de 2021
ep = uigetdir;
It looks like one letter got dropped, and that should be
rep = uigetdir;
Respuesta aceptada
Image Analyst
el 17 de Abr. de 2021
Pass in the color of the line:
plotColors = 'rgbcmyk'; % Whatever you want.
for k = 1 : 6
plot(intensityProfile, '*-', 'Color', plotColors(k), 'LineWidth', 3);
end
6 comentarios
Más respuestas (1)
Walter Roberson
el 17 de Abr. de 2021
for n=1:25
k=dicomread(fullfile(rep, list(n).name));
end;
Why do you read all of them but immediately throw all of them away except the last of them?
IM(1,1,numel(list))=0; %extend array to fit all slices
you use numel(list) repeatedly, but you already assigned
nbr_images= numel(list);
It is not clear why you do not use the variable instead of numel(list) later ?
intensityProfile(k)=squeeze(IM(column,row));
n should be part of your indexing, probably on both sides. And you probably should hold off the plot at that point until after the for k loop.
3 comentarios
Walter Roberson
el 17 de Abr. de 2021
for n=1:25
Okay, you loop 25 times
k=dicomread(fullfile(rep, list(n).name));
You construct a file name, and ask dicomread to read the file. The result of reading the file overwrites all of the variable k
end;
When n = 1, you read a file and stored it in k. When n = 2, you read a file, and stored it in k, throwing away what was already in k . This just wastes time unless you are in a loop in which you are carefully testing ahead of time that all of the files are truly readable.
Ver también
Categorías
Más información sobre Read and Write Image Data from Files 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!