courbe de suivie des pixels dans les images

1 回表示 (過去 30 日間)
Amal Felhi
Amal Felhi 2021 年 4 月 16 日
コメント済み: Amal Felhi 2021 年 4 月 17 日
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 17 日
ep = uigetdir;
It looks like one letter got dropped, and that should be
rep = uigetdir;

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2021 年 4 月 17 日
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 17 日
Do not call figure() then. But you will need hold on
Amal Felhi
Amal Felhi 2021 年 4 月 17 日
thank u it works

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 4 月 17 日
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 17 日
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.
Amal Felhi
Amal Felhi 2021 年 4 月 17 日
okay I will try

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by