4
$\begingroup$

I want to make a distorted square shape in 2D data set from a rectangular function.

enter image description here

Here is my code to draw a square shape(Field length : 10, Square length: 5, Data num : 101).

x1 = ArrayReshape[Transpose[Tuples[Range[-(10/2), 10/2, .1], 2]][[1]], {101, 101}]; y1 = ArrayReshape[Transpose[Tuples[Range[-(10/2), 10/2, .1], 2]][[2]], {101, 101}]; rect[A_] := (UnitStep[x1 + A/2] - UnitStep[x1 - A/2]) (UnitStep[y1 + A/2] - UnitStep[y1 - A/2]); ArrayPlot[rect[5], ColorFunction -> "BlueGreenYellow"] 

Thanks in advance.

$\endgroup$
1
  • $\begingroup$ See ImageTransformation. $\endgroup$ Commented Jul 12, 2023 at 17:22

1 Answer 1

8
$\begingroup$

Here is an example how to distort images (cushion or barrel):

grid = Table[{i, j}, {i, -10, 10}, {j, -10, 10}]; grid = Join[grid, Transpose[grid]]; distor[p_, dis_] := p/(1 - dis Norm[p]^2); Manipulate[ Graphics[Line /@ Map[distor[#, dis] &, grid, {2}]] , {{dis, 0}, -.003, .003}] 

enter image description here

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.