Question: Loop With more than one line

Hello

I have some problem with " For loop". If i add more then one expression the, i recieve an error. Could you please help me to solve it? I have attached my file. Thank you.


restart 

with(ImageTools):NULL

with(FileTools):NULLNULL

Input Section

 

``

filelocation := "C:\\Users\\Mohammad\\Desktop\\ExerciseII\\1.jpg":

k := 3:``

 

zimage := Read(filelocation):

 

zwidth := Width(zimage):``

kernell := VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1):NULLNULL

kerneld := `~`[`*`](Array(1 .. kernell, 1 .. kernell, 1), 1/kernell^2):

imheight := Height(zimage):NULL

imwidth := Width(zimage):````

Width(zimage, lower):

Width(zimage, upper):

View(zimage):NULL

new1zpic := Convolution(zimage, kerneld):

View(new1zpic)NULL``

aa := zimage(1 .. (), 1 .. (), 1):

bb := zimage(1 .. (), 1 .. (), 2):

cc := zimage(1 .. (), 1 .. (), 3):NULL

subimage := Matrix(VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1), VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1), 0):

newaa := aa:

"for i from k+1 to (RowDimension(aa)-k-1) do     for j from k+1 to (ColumnDimension(aa)-k-1) do     subimage:=aa(i-k..i+k,j-k..j+k).~kerneld     newaa(i,j):=add(add(subimage(m,n),m=1..(2 .k+1),n=1..(2*k+1))) end do; end do;"

Error, unterminated loop

"for i from k+1 to (RowDimension(aa)-k-1) do     for j from k+1 to (ColumnDimension(aa)-k-1) do  subimage:=aa(i-k..i+k,j-k..j+k).~kerneld    newaa(i,j):=add(add(subimage(m,n),m=1..(2 .k+1),n=1..(2*k+1))) end do; end do;"

 

 

``


Download pak2.mw

Please Wait...