FOR loop in matlab

sir,
i want to run a loop and display images(subplots) for the threshold value changing from 0.1 to 0.9. and apply to canny edge detector. i tried like this:
for thresh=0;thresh<1;thresh=thresh+0.1;
BW=edge(ip,'canny',thresh);
imshow(BW)
end
when i run this program the output i am getting is the image with thresh=0.1 .
And i tried by
{
BW=edge(ip,'canny',thresh);
imshow(BW)
}
Error comes as "the expression to the left of the equal sign is not a valid target for an assignment" . CAn anyone help me for the same???

Respuestas (1)

Walter Roberson
Walter Roberson el 1 de Abr. de 2013

1 voto

for thresh = 0:0.1:1
BW=edge(ip,'canny',thresh);
imshow(BW);
drawnow();
end

4 comentarios

rakesh r
rakesh r el 2 de Abr. de 2013
Editada: Walter Roberson el 2 de Abr. de 2013
thank u sir.
But when i used this error is coming as threshold should be less than 1and displaying i of thresh=1 only. So i tried like this
k=1;
th=.1;
for i=1:10
BW=edge(ip,'canny',th);
subplot(5,2,k);
imshow(BW);
k=k+1;
th=th+0.1;
title('image');
end
and this worked.
Now sir how can i give the title for each image their correspoding value of th.
Walter Roberson
Walter Roberson el 2 de Abr. de 2013
title( sprintf('th = %g', th) )
rakesh r
rakesh r el 2 de Abr. de 2013
thanku sir it works. Now as a next step computer should ask which value to select and we will enter the value andwith that value progrm should go to next step. I tried like this: th=input('enter th'); bw=edge(ip,'canny',th); imshow(bw) but error is coming as invalid input arguements,error in edge. Plz help.
rakesh r
rakesh r el 2 de Abr. de 2013
sir how can we make the command enter threshold to come oas a seperate window and we can enter the value der itself instead of coming it in command window.

Iniciar sesión para comentar.

Preguntada:

el 1 de Abr. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by