필터 지우기
필터 지우기

Using imfill on multiple images

조회 수: 5 (최근 30일)
Ahmed Ismail
Ahmed Ismail 2016년 6월 8일
답변: Ahmed Ismail 2016년 6월 9일
myPath= 'E:\conduit_stl(smooth contour)\Collagen Contour Slices\';
fileNames = dir(fullfile(myPath, '*.tif'));
C = cell(length(fileNames), 1);
for k = 1:length(fileNames)
filename = fileNames(k).name;
C{k} = im2bw(imread(filename));
filled = imfill(C,'holes');
end
I have this code to import multiple images from a folder into MATLAB. Though now I would like to perform a fill on all the images. However, when attempting this, an error stating: "Expected input number 1, I1 or BW1, to be one of these types: double, ... etc" I tried converting the images into double precision, though that just resulted in: "Conversion to double from cell is not possible."
This is most likely due to the structure type, the images are 'housed' in, but I have no idea concerning that.
Help on this would be greatly appreciated.

채택된 답변

Ahmed Ismail
Ahmed Ismail 2016년 6월 9일
C(256,256,length(fileNames)) = uint8(0);
C_filled = C;
se = strel('disk', 2, 0);
for k = 1:length(fileNames)
C(:,:,k) = im2bw(imread(fileNames(k).name));
C_filled(:,:,k) = imfill(imclose(C(:,:,k), se),'holes');
end

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by