reading multiple images from a folder?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I have about 88 image of 10 patients, number of images for each patient is not equal. I want to read images for each patient from 2 different folders and do some operations then save the results in third folder. How to do this process in a loop? and how to save the results with respect to images' names (Ex: image1: Adel_No_Post1.bmp, image2: Adel_No_Frangi1 ...
how to save the result, result_image: Adel_No_Filtered1)
%folder path E:\Aneurysms_CBIR\Aneu_Post_Contrast
Post_Im=imread('E:\Aneurysms_CBIR\Aneu_Post_Contrast\Adel_No_Post1.bmp');
% folder path E:\Aneurysms_CBIR\Aneu_Frangi_Images
Frangi_Im=imread('E:\Aneurysms_CBIR\Aneu_Frangi_Images\Adel_No_Frangi1.bmp');
% do some operations
h = fspecial('gaussian', [3 3], 0.5);
imf=imfilter(Frangi_Im, h);
imsub=Post_Im-imf;
%save result with name " Adel_No_Filtered1" to a new folder, path:E:\Aneurysms_CBIR\Aneu_Filtered
imwrite(imsub, ['E:\Aneurysms_CBIR\Aneu_Filtered\ Adel_No_Filtered1' '.bmp'], 'bmp');
채택된 답변
Walter Roberson
2015년 6월 17일
0 개 추천
One thing you did not define for us is how to match file names to individual patients. Or does it not matter, that each number before the .bmp in on directory corresponds to one file in the second directory that has the same number and you just need to pair them?
댓글 수: 13
Nisreen Sulayman
2015년 6월 17일
편집: Nisreen Sulayman
2015년 6월 17일
I have 88 images in a folder (F1) for 10 patients AND I have another 88 images in a second Folder (F2) for the same patients
I want to read the images from both folders ... do some operations and save the result in a new folder with a new variable name. The new variable name should match parts of the images:
Ex: image1 from first folder: Adel_No_Post1.bmp should underwent some operations with image1 from second folder (for the same patinet) image1: Adel_No_Frangi1 I should save the result for this patient in name related to patient name like: result_Image=Adel_No_Filtered1
************** Yes, the number is important ... It indecates how many images for each patient I have.
Nisreen Sulayman
2015년 6월 17일
편집: Nisreen Sulayman
2015년 6월 17일
Mr. Roberson,
Thank you for your answer,
BUT
I don't have the same number of images for each patient.
First patinet has 6 images, three ones in each folder
Second patiebt has 14 images, seven ones in each folder
and so one...
Nisreen Sulayman
2015년 6월 17일
편집: Nisreen Sulayman
2015년 6월 18일
Would you Please ...
How to read the names of the88 image and save their names in a cell array like this:
names_Post={'Adel_Post1','Adel_Post2','Adel_Post3','Dalal_Post','Fatma_Post1','Fatma_Post2', ...};
Walter Roberson
2015년 6월 18일
편집: Walter Roberson
2015년 6월 24일
dinfo = dir('*.bmp');
numfiles = length(dinfo);
names_Post = cell(numfiles,1);
for K = 1 : numfiles
thisfile = dinfo(K).name;
[pathstr, basestr, ext] = fileparts(thisfile);
names_Post{K} = basestr;
end
How do you know that Adel_No_Post1.bmp goes with Adel_No_Frangi1.bmp ? Is the patient name the "Adel_No" part, and for the first directory the images for each patient end in _Post* whereas in the second directory the images for each patient end in _Fragni* ? Or is the patient name the part before the first underscore, "Adel" and the "No_Post" and "No_Fragi" are the constant parts?
You right Mr. Roberson ...
at the first directory the images for each patient end in _Post* whereas in the second directory the images for each patient end in _Fragni*
and the number indicates how many images for each patient are there.
Nisreen Sulayman
2015년 6월 23일
편집: Walter Roberson
2015년 6월 24일
Thank you for answering ...
What is wrong in "Selecting only the largest structure" code
filePattern = fullfile('E:\Aneurysms_CBIR\Aneurysms\Aneu_Frangi_Images', '*.bmp');
bmpFiles = dir(filePattern);
names = {bmpFiles.name};
for i = 1 : length(names)
% do some processing
bw{i}=im2bw(imf{i}); % convert imgae to binary
%Select only the largest structure\component
L{i} = bwlabel(bw{i});
Props{i} = regionprops(L{i}, 'Area');
Area{i} = [Props(:).Area{i}];
LabelNo{i} = find(Area{i} == max(Area{i}));
%bw = L == LabelNo;
bw_v{i} = L{i} == LabelNo{i};
imwrite(bw_v{i},['E:\Aneurysms_CBIR\Aneurysms\Aneu_Vessel_tree_Images\' names{i} '_CusF.bmp'])
end
MatLab give the following error message
Improper index matrix reference.
Area{i} = [Props(:).Area{i}];
How can I know when you comment on the question??
Image Analyst
2015년 6월 23일
Does it not send you emails when someone Answers or Comments on your post?
I have heard that email is not sent for Comments.
Area{i} = [Props(:).Area];
where is the variable {i} in the input statement?
Area{i} = [Props{i}.Area];
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
