mzaman

20 Reputation

5 Badges

10 years, 142 days

MaplePrimes Activity


These are replies submitted by mzaman

@Doug Meade 

Hello

Thank you for your response and helpfull guiddance.

Thank you for your response

@tomleslie 

Hello

Thanks for your response. I have attached *.mat file. How do you import it into maple?

zdata.zip

 

 

 

 

@Markiyan Hirnyk 

Thanks for your respons. But when i use this command i recieve an error message showed that the data cell values are not loaded correctly. I have attached a picture from this problem. Could you please help me to solve it? 

Thank you.

@Carl Love 

Hello

Could you please help me to learn how to use evalhf?

Thank you.

@Carl Love 

Hello

Thank you. I have converted my code to the 1D input. what should i do now?


restart:

with(ImageTools):

with(FileTools):

 

k:=3:

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

zimage:=Read(filelocation):

zwidth:=Width(zimage):

zHeight:=Height(zimage):

kernell:=2*k+1:

kerneld:=Array(1..kernell,1..kernell,1)*(1/kernell^2):

View(zimage);

new1zumage:=Convolution(zimage,kerneld):

View(new1zumage);

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

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

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

subimage:=Matrix(2*k+1,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;


Download pak_new1.mw

@Carl Love 

Thank you.

If it is possible i want to learn another procedure for solving this program from you.

1. How to break this program to 1D?

2. How to use evalhf for this situation?

 

@Carl Love 

Thanks for your response. if you see the above code you find that a put smicolon at the end of line that you say, but resieve an error. I have to write this code like this procedure. thanks for your advise.

Now could you halp me to solve this problem?

@acer 

Hello Add semicolon to each lines but still recieve an error. Thanks for your helps.

 

 

restart 

with(ImageTools)``

with(FileTools)````

Input Section

 

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

k := 3NULL

zimage := Read(filelocation)

NULL 

zwidth := Width(zimage)NULL

kernell := 2*k+1````

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

imheight := Height(zimage)``

imwidth := Width(zimage)NULLNULL

Width(zimage, lower)

Width(zimage, upper)

View(zimage)``

new1zpic := Convolution(zimage, kerneld)

View(new1zpic)``NULL

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

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

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

subimage := Matrix(2*k+1, 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, missing operator or `;`

 

 

NULL

 

Download pak2.mw

@Carl Love 

Thank you

Thank you, I changed some parameters, but recieve a new error. Could you please to help me to solve it?

thank you.

 

restart 

with(ImageTools):NULL

with(FileTools):NULLNULL

Input Section

 

``

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

k := 7:````   

zimage := Read(filelocation):

zwidth := Width(zimage):``

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

kerneld := `~`[`*`](Matrix(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``

new2zpic := zimage:

dummy := 0:

"for i from (k+1)  to (Width(zimage,upper)-k) do     for j from (k+1)  to (Height(zimage,upper)-k) do           for m from 1 to kernell  do               for n from 1 to kernell  do                         dummy:=dummy+kerneld (m, n)*new2zpic(i+m-2, j+n-2)                                         end do;              end do;                      new2zpic(i,j):=dummy:                   dummy:=0:   end do; end do;"

Error, unable to store 'Matrix(15, 15, {(1, 1) = 4.308671023965142, (1, 2) = 4.308671023965142, (1, 3) = 4.308671023965142, (1, 4) = 4.308671023965142, (1, 5) = 4.308671023965142, (1, 6) = 4.308671023965142, (1, 7) = 4.308671023965142, (1, 8) = 4.308671023965142, (1, 9) = 4.308671023965142, (1, 10) = 4.308671023965142, (1, 11) = 4.308671023965142, (1, 12) = 4.308671023965142, (1, 13) = 4.308671023965142, (1, 14) = 4.308671023965142, (1, 15) = 4.308671023965142, (2, 1) = 4.308671023965142, (2, 2) = 4.308671023965142, (2, 3) = 4.308671023965142, (2, 4) = 4.308671023965142, (2, 5) = 4.308671023965142, (2, 6) = 4.308671023965142, (2, 7) = 4.3086...

 

  ``

View(new2zpic)``

``

 

Download pak.mw

restart 

with(ImageTools):NULL

with(FileTools):NULLNULL

Input Section

 

``

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

k := 7:````   

zimage := Read(filelocation):

zwidth := Width(zimage):``

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

kerneld := `~`[`*`](Matrix(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``

new2zpic := zimage:

dummy := 0:

"for i from (k+1)  to (Width(zimage,upper)-k) do     for j from (k+1)  to (Height(zimage,upper)-k) do           for m from 1 to kernell  do               for n from 1 to kernell  do                         dummy:=dummy+kerneld (m, n)*new2zpic(i+m-2, j+n-2)                                         end do;              end do;                      new2zpic(i,j):=dummy:                   dummy:=0:   end do; end do;"

Error, unable to store 'Matrix(15, 15, {(1, 1) = 4.308671023965142, (1, 2) = 4.308671023965142, (1, 3) = 4.308671023965142, (1, 4) = 4.308671023965142, (1, 5) = 4.308671023965142, (1, 6) = 4.308671023965142, (1, 7) = 4.308671023965142, (1, 8) = 4.308671023965142, (1, 9) = 4.308671023965142, (1, 10) = 4.308671023965142, (1, 11) = 4.308671023965142, (1, 12) = 4.308671023965142, (1, 13) = 4.308671023965142, (1, 14) = 4.308671023965142, (1, 15) = 4.308671023965142, (2, 1) = 4.308671023965142, (2, 2) = 4.308671023965142, (2, 3) = 4.308671023965142, (2, 4) = 4.308671023965142, (2, 5) = 4.308671023965142, (2, 6) = 4.308671023965142, (2, 7) = 4.3086...

 

  ``

View(new2zpic)``

``

 

Download pak.mw

Thank you. i have an other problem in real condition. I have atached my file. could you please help me to solve it.

Is there any option to run "for loops" step by step?. somthing like break point in matlab.

Thanks

restart

with(ImageTools):``

with(FileTools):````

Input Section

 

NULL

filelocation := "C://Users//Mohammad//Desktop//1.jpg":

k := 1:NULL

 

zimage := Read(filelocation):

zwidth := Width(zimage):NULL

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

kernel__data := `~`[`*`](Matrix(1 .. kernel__length, 1 .. kernel__length, 1), 1/kernel__length^2):

``

``

imheight := Height(zimage):

imwidth := Width(zimage):NULLNULL

Width(zimage, lower):

Width(zimage, upper):

View(zimage):``

new1zpic := Convolution(zimage, kernel__data):

View(new1zpic)``NULL

new2zpic := zimage:

dummy := 0:

"for i from (k+1)  to (Width(zimage,upper)-k) do     for j from (k+1)  to (Height(zimage,upper)-k) do           for m from 1 to kernel[length]  do               for n from 1 to kernel[length]  do                         dummy:=dummy+kernel[data] (m, n)*new2zpic(i+m-2, j+n-2)                end do;              end do;                      new2zpic(i,j):=dummy:                   dummy:=0:   end do; end do;"

Error, unable to store 'Matrix(3, 3, {(1, 1) = 1.083030743161462, (1, 2) = 1.083030743161462, (1, 3) = 1.083030743161462, (2, 1) = 1.083030743161462, (2, 2) = 1.083030743161462, (2, 3) = 1.083030743161462, (3, 1) = 1.083030743161462, (3, 2) = 1.083030743161462, (3, 3) = 1.083030743161462}, datatype = float[8])' when datatype=float[8]

 

NULL

 

Download Exercise_II.mw

Page 1 of 1