0

My goal is to take any image and break it down to obtain its time-varying equations so it can be redrawn and store the picture as two equations. One for $x$ and one for $y$.

As I understand, MATLAB's Discrete Fourier Transform breaks down images into their Fourier coefficients, so for a circle it would be easier to just synthesize using the equation based on the referenced origin, the point $[h,k]$ and the radius $r$. I want to apply this method to any shape, not just a circle.

The important part is for me to get the equations rather than just the transform.

Understanding how it works for a circle would help me understand how it would work for other shapes.

Say I have a black and white picture of a circle on a 255x255 pixel grid. Something like this:

enter image description here

The circle equation is of the form: $$ (x-h)^2+(y-k)^2=r^2 $$

and it is related to the parametric form of $$x=r\sin(t)+h$$ $$y=r\cos(t)+k$$

I want to extract the Fourier series or coefficients that would allow me to reconstruct the circle if I were to calculate the $x$ coordinates and the $y$ coordinates.

So the end goal is to get something as follows:

plot(fourierseries_x,fourierseries_y)

Which should be able to reconstruct the circle.

where fourierseries_x is the fourier series of the $x$ coordinates

and fourierseries_y is the fourier series of the $y$ coordinates

Is this possible through Matlab's fft function? Is the Fourier series the correct approach to this?

Jdip
  • 5,980
  • 3
  • 7
  • 29
  • You say "my goal", but follow it up with a pretty "this is the bark on the tree" sort of description. What's your forest look like? I.e., what are you really trying to accomplish in the end? It sounds like you're trying for image compression, but for all but simple shapes, I don't think that you'll get there with the technique you're proposing. – TimWescott Nov 06 '22 at 23:19
  • Hello Tim, I am not sure how I wasn't clear. I am trying to describe images using equations which can compute the coordinate values for that image in the xy discrete pixel plane. I provided a tangible example using circle as the shape. I noted the ways this circle could be constructed without using any fourier transform, which is not my goal. Basically what I want at the end flows like this: Input image>extract equation for x and y points in discrete pixels. The input image would be any shape varying from simple to complex. – ijustwannalearnrobot Nov 06 '22 at 23:37
  • @ijustwannalearnrobot two things: using the Fourier transform on anything but periodic functions is mathematically forced to require uncountably infinitely many coefficients. Using anything that is not made from finitely many sine/cosine waves (like, say, a square wave to do any shape with a corner) is going to need countably infinite, but still infinite, coefficients. Are you sure that's useful for shape representations? – Marcus Müller Nov 07 '22 at 08:55
  • @ijustwannalearnrobot second thing: your end flow is: input image>extract equation for x and y points in discrete pixels How is the Fourier transform coming into play here, at all? – Marcus Müller Nov 07 '22 at 08:56
  • a, the third of my two things: You say "Fourier transform", and use continuous-time equations to describe your circle. But your title says "FFT": Notice how you're missing the step from continuous to discrete space here! – Marcus Müller Nov 07 '22 at 08:57
  • Closing because this sounds very similar to the question that Scott Howard indicated was similar. If you don't think it is, feel free to ping me with a follow-up comment indicating why your question is different and I'll reopen. – Peter K. Nov 07 '22 at 15:01
  • You are asking for Vector files. Adobe and Autodesk have been using the image coding you are asking for. Reading these 2 may help : 1. https://www.adobe.com/creativecloud/design/discover/vector-file.html 2. https://www.designpresentation.com/blog/cad-file-formats/ – John Bofarull Guix Nov 27 '22 at 09:29

2 Answers2

1

I believe this is the same: How to get Fourier coefficients to draw any shape using DFT?

It can be done, but it's going to be tricky coding. You'll first have to represent your image as a single closed line drawing (that's the hardest part, actually). If you have that, finding the equation is "easy" in that it's just computing the epicycles. For example, see https://www.myfourierepicycles.com

Scott Howard
  • 150
  • 5
0

Sorry, can't be done.

You can only derive equations for a small number of well defined shapes but if you take a close-up picture of the oak tree in my back yard, all bets are off. It will look mostly noise like in the spatial domain and it will look mostly like noise in the spatial frequency domain as well. No equations can describe this accurately on either domain.

The spatial frequency domain can be useful for data compression: In the pixel domain the energy is often fairly uniformly distributed across the picture. That's less the case in the spatial frequency domain. So if you need to truncate or allocate bits, you can do it there.

Hilmar
  • 44,604
  • 1
  • 32
  • 63