Azzera filtri
Azzera filtri

Problem with structure in image processing

1 visualizzazione (ultimi 30 giorni)
I have a structure of images and I want to make some processing on them. I put them on a list but when I try to save each one of them(I'm using a for loop to make the processing) the code reads the first element of the structure and then it goes straight to the end without reading the rest. Here's my code
imglist=dir('*.tif'); %list of the .tif images
for i=1,length(imglist)
name=getfield(imglist(i),'name');
A=imread(name);
level(i)=graythresh(A); %level of the threshold for Otsu method
BI=im2bw(A,level(i)); %converts the grayscale image to a binary image
thresh(:,:,i)=BI; %save the thresh image
BIedge=edge(BI,'Canny'); %edge detection with Canny method
imshow(BIedge)
edges_canny(:,:,i)=BIedge;
f=figure;
imshow(BI);
saveas(f,sprintf('thresh8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000%d.tif',i))
f=figure;
imshow(imfill(edges_canny(:,:,i),'holes'));
saveas(f,sprintf('canny8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000%d.tif',i))
end
Anyone for help?

Risposta accettata

Stephen23
Stephen23 il 12 Set 2016
You need to use a colon, not a comma:
for i = 1:numel(imglist)

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by