1

I have a two-level array that represent an image. How can I get a circular subimage from this image at given x and y positions using radius r?

If I wanted a quadrilateral subimage I could use this:

image[x-(r/2),x+(r/2):y-(r/2),y+(r/2)]

By a circular subimage I mean a regular matrix with some elements set to 0 leaving a circular "non-zero" part.

Example matrix:

12 42 92 82 33 23 43 21 23 43 98 73
32 32 42 13 98 67 24 54 19 32 43 54
13 32 98 78 67 30 92 48 21 38 83 45
12 42 92 82 33 23 43 21 23 43 98 73
32 32 42 13 98 67 24 54 19 32 43 54
13 32 98 78 67 30 92 48 21 38 83 45
12 42 92 82 33 23 11 21 23 43 98 73
32 32 42 13 98 67 24 54 19 32 43 54
13 32 98 78 67 30 92 48 21 38 83 45
12 42 92 82 33 23 43 21 23 43 98 73
32 32 42 13 98 67 24 54 19 32 43 54
13 32 98 78 67 30 92 48 21 38 83 45

Let's say x = 6, y = 5 and r = 2 then this would be an acceptable result:

 0  0 24  0  0
 0 30 92 48  0
33 23 11 21 23
 0 67 24 54  0
 0  0 92  0  0
William
  • 2,695
  • 1
  • 21
  • 33
Frederico Schardong
  • 1,946
  • 6
  • 38
  • 62

0 Answers0