Who do I read different images from my disk?
1 次查看(过去 30 天)
显示 更早的评论
My program have to read an image has a reference, then take 7 frehand ROIs of it, and then with the same coordinates crop the same 7 ROIs to the other 20 images from the same folder. The images are dicom, so insted of imread for reading them I have to use dicomread as a function (this is the ony difference)
I = dicomread('REFERENCEIMMAGE')
% define these somehow
numberofimages = numel(21); % I have 21 image
numberofroi = 7; %in each images I have to perform 7 ROIs with the same coordinates
% show the reference image
imshow(I)
% use imcrop to get rectangle coordinates
R = zeros(numberofroi,4);
for nr = 1:numberofroi
[~,R(nr,:)] = imcrop(gca);
end
% crop corresponding ROIs from each non-reference image
roibasket = cell(numberofroi,numberofimages);
for ni = 1:numberofimages
for nr = 1:numberofroi
thisimage = strcat('C:\Users\agnes\Pictures\pp4 tgc-med rd20\ni.dcm'); % I don't know how to read from my disk
roibasket{nr,ni} = imcrop(thisimage,R(nr,:));
end
end
% after I have to perform the mean of the ROIs
7 个评论
Walter Roberson
2021-9-25
I suspect that the .dcm is part of the file name.
info=dicominfo(strcat(pathname,filename));
You do not use info so there is no point assigning to it.
srcFile = dir('C:\Users\agnes\Pictures\pp4 tgc-med rd20\*.dcm');
You do not use that, so no point in assigning to it.
filename=(num2str(ni));
I suspect that there is a ".dcm" as part of the name, but that you have not configured to show extensions. I could be wrong about that.
采纳的回答
Walter Roberson
2021-9-25
projectdir = 'C:\Users\agnes\Pictures\pp4 tgc-med rd20';
thisimage_name = fullfile(projectdir, ni + ".dcm");
thisimage = dicomread(thisimage_name);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!