DSPRelated.com
Forums

mapping an irregular 2D shape to represent monitor screen

Started by Elnaz October 10, 2011
Hi everyone,

I have 4 magnetic sensors at the 4 corners of a rectangle. I want to
capture the movement of a small magnet moving on the surface between
these 4 sensors. So far, with some classification algorithm I've been
able to map this my 12 dimensional input data into a (X,Y) coordinates
on a 2D screen. The problem, however, is that what I did (I can call
it a mapping) did not preserved the shape of the movements. It is a
one to one mapping but for example when the magnet moves from one
sensor to the next following the borderlines of the surface i.e. a
rectangle, I get a semi-rectangle that is shrunk in the middle (like a
pillow but worse). It's like that the sides of the rectangle are bent
inward. I need to somehow open the middle up and make the surface
homogeneous.


I appreciate your thoughts on this,
Thanks,
Elnaz
On 10/10/2011 8:03 PM, Elnaz wrote:
> Hi everyone, > > I have 4 magnetic sensors at the 4 corners of a rectangle. I want to > capture the movement of a small magnet moving on the surface between > these 4 sensors. So far, with some classification algorithm I've been > able to map this my 12 dimensional input data into a (X,Y) coordinates > on a 2D screen. The problem, however, is that what I did (I can call > it a mapping) did not preserved the shape of the movements. It is a > one to one mapping but for example when the magnet moves from one > sensor to the next following the borderlines of the surface i.e. a > rectangle, I get a semi-rectangle that is shrunk in the middle (like a > pillow but worse). It's like that the sides of the rectangle are bent > inward. I need to somehow open the middle up and make the surface > homogeneous.
It seems that you have what is called pincushion distortion. Some lenses suffer from that distortion, and programs exist to rectify the images they produce. First-order approximations to the curves that straight horizontal and vertical lines become are hyperbolas. You might find one of those programs or create your own mapping. Keywords that might help your search are rectify and rectification, pincushion (and it's opposite, barrel) and distortion.. Jerry -- Engineering is the art of making what you want from things you can get.

Elnaz wrote:

> Hi everyone, > > I have 4 magnetic sensors at the 4 corners of a rectangle. I want to > capture the movement of a small magnet moving on the surface between > these 4 sensors. So far, with some classification algorithm I've been > able to map this my 12 dimensional input data into a (X,Y) coordinates > on a 2D screen. The problem, however, is that what I did (I can call > it a mapping) did not preserved the shape of the movements. It is a > one to one mapping but for example when the magnet moves from one > sensor to the next following the borderlines of the surface i.e. a > rectangle, I get a semi-rectangle that is shrunk in the middle (like a > pillow but worse). It's like that the sides of the rectangle are bent > inward. I need to somehow open the middle up and make the surface > homogeneous.
Quit doing that bullshit with classification and mapping. Solve the system of magnetic field equations for X,Y coordinates and there is the answer. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On 10/10/2011 9:25 PM, Vladimir Vassilevsky wrote:
> > > Elnaz wrote: > >> Hi everyone, >> >> I have 4 magnetic sensors at the 4 corners of a rectangle. I want to >> capture the movement of a small magnet moving on the surface between >> these 4 sensors. So far, with some classification algorithm I've been >> able to map this my 12 dimensional input data into a (X,Y) coordinates >> on a 2D screen. The problem, however, is that what I did (I can call >> it a mapping) did not preserved the shape of the movements. It is a >> one to one mapping but for example when the magnet moves from one >> sensor to the next following the borderlines of the surface i.e. a >> rectangle, I get a semi-rectangle that is shrunk in the middle (like a >> pillow but worse). It's like that the sides of the rectangle are bent >> inward. I need to somehow open the middle up and make the surface >> homogeneous. > > Quit doing that bullshit with classification and mapping. > Solve the system of magnetic field equations for X,Y coordinates and > there is the answer.
That would certainly be more elegant, but the empirical approach also has merit. I'm puzzled by his unconcern with rotataion of the magnet probe. Jerry -- Engineering is the art of making what you want from things you can get.
Jerry Avins wrote:
> On 10/10/2011 9:25 PM, Vladimir Vassilevsky wrote: >> >> >> Elnaz wrote: >> >>> Hi everyone, >>> >>> I have 4 magnetic sensors at the 4 corners of a rectangle. I want to >>> capture the movement of a small magnet moving on the surface between >>> these 4 sensors. So far, with some classification algorithm I've been >>> able to map this my 12 dimensional input data into a (X,Y) coordinates >>> on a 2D screen. The problem, however, is that what I did (I can call >>> it a mapping) did not preserved the shape of the movements. It is a >>> one to one mapping but for example when the magnet moves from one >>> sensor to the next following the borderlines of the surface i.e. a >>> rectangle, I get a semi-rectangle that is shrunk in the middle (like a >>> pillow but worse). It's like that the sides of the rectangle are bent >>> inward. I need to somehow open the middle up and make the surface >>> homogeneous. >> >> Quit doing that bullshit with classification and mapping. >> Solve the system of magnetic field equations for X,Y coordinates and >> there is the answer. > > That would certainly be more elegant, but the empirical approach also > has merit. I'm puzzled by his unconcern with rotataion of the magnet probe. > > Jerry
Is his assumed "model" more suitable to the probe being a voltage source, the surface having a constant conductivity, and the sensors measuring current to ground? Reminds me of a sophomore EE lab I had in the 60's ;)
On 10/10/2011 10:01 PM, Richard Owlett wrote:
> Jerry Avins wrote: >> On 10/10/2011 9:25 PM, Vladimir Vassilevsky wrote: >>> >>> >>> Elnaz wrote: >>> >>>> Hi everyone, >>>> >>>> I have 4 magnetic sensors at the 4 corners of a rectangle. I want to >>>> capture the movement of a small magnet moving on the surface between >>>> these 4 sensors. So far, with some classification algorithm I've been >>>> able to map this my 12 dimensional input data into a (X,Y) coordinates >>>> on a 2D screen. The problem, however, is that what I did (I can call >>>> it a mapping) did not preserved the shape of the movements. It is a >>>> one to one mapping but for example when the magnet moves from one >>>> sensor to the next following the borderlines of the surface i.e. a >>>> rectangle, I get a semi-rectangle that is shrunk in the middle (like a >>>> pillow but worse). It's like that the sides of the rectangle are bent >>>> inward. I need to somehow open the middle up and make the surface >>>> homogeneous. >>> >>> Quit doing that bullshit with classification and mapping. >>> Solve the system of magnetic field equations for X,Y coordinates and >>> there is the answer. >> >> That would certainly be more elegant, but the empirical approach also >> has merit. I'm puzzled by his unconcern with rotataion of the magnet >> probe. >> >> Jerry > > Is his assumed "model" more suitable to the probe being a voltage > source, the surface having a constant conductivity, and the sensors > measuring current to ground? Reminds me of a sophomore EE lab I had in > the 60's ;)
A cylindrical magnet with its axis perpendicular to the surface avoids the rotation problem. From his mention of 12 dimensions, it seems that he measures the direction of the field lines at each sensor. At least with the magnet I described, the vertical component might be be enough. Jerry -- Engineering is the art of making what you want from things you can get.
Jerry Avins wrote:
> On 10/10/2011 10:01 PM, Richard Owlett wrote: >> Jerry Avins wrote: >>> On 10/10/2011 9:25 PM, Vladimir Vassilevsky wrote: >>>> >>>> >>>> Elnaz wrote: >>>> >>>>> Hi everyone, >>>>> >>>>> I have 4 magnetic sensors at the 4 corners of a rectangle. I want to >>>>> capture the movement of a small magnet moving on the surface between >>>>> these 4 sensors. So far, with some classification algorithm I've been >>>>> able to map this my 12 dimensional input data into a (X,Y) coordinates >>>>> on a 2D screen. The problem, however, is that what I did (I can call >>>>> it a mapping) did not preserved the shape of the movements. It is a >>>>> one to one mapping but for example when the magnet moves from one >>>>> sensor to the next following the borderlines of the surface i.e. a >>>>> rectangle, I get a semi-rectangle that is shrunk in the middle (like a >>>>> pillow but worse). It's like that the sides of the rectangle are bent >>>>> inward. I need to somehow open the middle up and make the surface >>>>> homogeneous. >>>> >>>> Quit doing that bullshit with classification and mapping. >>>> Solve the system of magnetic field equations for X,Y coordinates and >>>> there is the answer. >>> >>> That would certainly be more elegant, but the empirical approach also >>> has merit. I'm puzzled by his unconcern with rotataion of the magnet >>> probe. >>> >>> Jerry >> >> Is his assumed "model" more suitable to the probe being a voltage >> source, the surface having a constant conductivity, and the sensors >> measuring current to ground? Reminds me of a sophomore EE lab I had in >> the 60's ;) > > A cylindrical magnet with its axis perpendicular to the surface avoids > the rotation problem. From his mention of 12 dimensions, it seems that > he measures the direction of the field lines at each sensor. At least > with the magnet I described, the vertical component might be be enough. > > Jerry
I took "12 dimensions" as a typo where "2 dimensions" was meant. If each sensor has 3 outputs, should he .... Probaly not - I should sleep, perhaps to ......
On Oct 11, 2:17&#4294967295;am, Richard Owlett <rowl...@pcnetinc.com> wrote:
> Jerry Avins wrote: > > On 10/10/2011 10:01 PM, Richard Owlett wrote: > >> Jerry Avins wrote: > >>> On 10/10/2011 9:25 PM, Vladimir Vassilevsky wrote: > > >>>> Elnaz wrote: > > >>>>> Hi everyone, > > >>>>> I have 4 magnetic sensors at the 4 corners of a rectangle. I want to > >>>>> capture the movement of a small magnet moving on the surface between > >>>>> these 4 sensors. So far, with some classification algorithm I've been > >>>>> able to map this my 12 dimensional input data into a (X,Y) coordinates > >>>>> on a 2D screen. The problem, however, is that what I did (I can call > >>>>> it a mapping) did not preserved the shape of the movements. It is a > >>>>> one to one mapping but for example when the magnet moves from one > >>>>> sensor to the next following the borderlines of the surface i.e. a > >>>>> rectangle, I get a semi-rectangle that is shrunk in the middle (like a > >>>>> pillow but worse). It's like that the sides of the rectangle are bent > >>>>> inward. I need to somehow open the middle up and make the surface > >>>>> homogeneous. > > >>>> Quit doing that bullshit with classification and mapping. > >>>> Solve the system of magnetic field equations for X,Y coordinates and > >>>> there is the answer. > > >>> That would certainly be more elegant, but the empirical approach also > >>> has merit. I'm puzzled by his unconcern with rotataion of the magnet > >>> probe. > > >>> Jerry > > >> Is his assumed "model" more suitable to the probe being a voltage > >> source, the surface having a constant conductivity, and the sensors > >> measuring current to ground? Reminds me of a sophomore EE lab I had in > >> the 60's ;) > > > A cylindrical magnet with its axis perpendicular to the surface avoids > > the rotation problem. From his mention of 12 dimensions, it seems that > > he measures the direction of the field lines at each sensor. At least > > with the magnet I described, the vertical component might be be enough. > > > Jerry > > I took "12 dimensions" as a typo where "2 dimensions" was meant. > If each sensor has 3 outputs, should he .... > Probaly not - I should sleep, perhaps to ......
Sensor outputs are 12 dimensional i.e. each sensor provides x,y, z components of the magnetic field it measures. And, yes, the rotation of my small disk shape magnet has a huge effect on the sensors readings; however, in my case magnet is not going to rotate that much but only navigate over a flat surface for now. You're right about that solving dipole equation is more elegant and straightforward but in that case I will need more sensors and also there are some other constraints; for example in my case the positioning of the 4 sensors is not going to be unique each time. So, in a sense, it is better to come up with a black-box algorithm (signal processing) to make it work based on training data if you know what I mean. So, back to the question and the irregular quadrilateral, I have come up with something. I already have the boundary from the training data. So, I was thinking for each new (x,y) pair I can find its corresponding (x,y)s (its images) on the boundaries. And then for example: x' = K - |x - x1| , y' = K - |y - y1|; (x', y') is the new corrected point and K is a constant. This way I force the curves that are parallel to the boundary become straight lines because their absolute distance to the boundary is constant. Also, the closer to the boundaries the bigger is the bent out job which is what I want. I tried this, it almost worked, but the problem again is that the middle of the screen is gone. Basically, for example, when you move from left to right before reaching the middle the cursor jumps further to the other half of the screen missing the middle portion. Can you think of some other simple mapping to do this? Thanks, Elnaz
On 10/11/2011 9:54 PM, Elnaz wrote:
> On Oct 11, 2:17 am, Richard Owlett<rowl...@pcnetinc.com> wrote: >> Jerry Avins wrote: >>> On 10/10/2011 10:01 PM, Richard Owlett wrote: >>>> Jerry Avins wrote: >>>>> On 10/10/2011 9:25 PM, Vladimir Vassilevsky wrote: >> >>>>>> Elnaz wrote: >> >>>>>>> Hi everyone, >> >>>>>>> I have 4 magnetic sensors at the 4 corners of a rectangle. I want to >>>>>>> capture the movement of a small magnet moving on the surface between >>>>>>> these 4 sensors. So far, with some classification algorithm I've been >>>>>>> able to map this my 12 dimensional input data into a (X,Y) coordinates >>>>>>> on a 2D screen. The problem, however, is that what I did (I can call >>>>>>> it a mapping) did not preserved the shape of the movements. It is a >>>>>>> one to one mapping but for example when the magnet moves from one >>>>>>> sensor to the next following the borderlines of the surface i.e. a >>>>>>> rectangle, I get a semi-rectangle that is shrunk in the middle (like a >>>>>>> pillow but worse). It's like that the sides of the rectangle are bent >>>>>>> inward. I need to somehow open the middle up and make the surface >>>>>>> homogeneous. >> >>>>>> Quit doing that bullshit with classification and mapping. >>>>>> Solve the system of magnetic field equations for X,Y coordinates and >>>>>> there is the answer. >> >>>>> That would certainly be more elegant, but the empirical approach also >>>>> has merit. I'm puzzled by his unconcern with rotataion of the magnet >>>>> probe. >> >>>>> Jerry >> >>>> Is his assumed "model" more suitable to the probe being a voltage >>>> source, the surface having a constant conductivity, and the sensors >>>> measuring current to ground? Reminds me of a sophomore EE lab I had in >>>> the 60's ;) >> >>> A cylindrical magnet with its axis perpendicular to the surface avoids >>> the rotation problem. From his mention of 12 dimensions, it seems that >>> he measures the direction of the field lines at each sensor. At least >>> with the magnet I described, the vertical component might be be enough. >> >>> Jerry >> >> I took "12 dimensions" as a typo where "2 dimensions" was meant. >> If each sensor has 3 outputs, should he .... >> Probaly not - I should sleep, perhaps to ...... > > Sensor outputs are 12 dimensional i.e. each sensor provides x,y, z > components of the magnetic field it measures.
Hmm... X, y, and z. That's three dimensions as I see it.
> And, yes, the rotation of my small disk shape magnet has a huge effect > on the sensors readings; however, in my case magnet is not going to > rotate that much but only navigate over a flat surface for now.
If you orient the field at the magnet perpendicular to the plane, then rotation won't matter.
> You're right about that solving dipole equation is more elegant and > straightforward but in that case I will need more sensors and also > there are some other constraints; for example in my case the > positioning of the 4 sensors is not going to be unique each time. So, > in a sense, it is better to come up with a black-box algorithm (signal > processing) to make it work based on training data if you know what I > mean.
Definitely. Most instruments need to be calibrated for best accuracy. The empirical approach applies calibration automatically.
> So, back to the question and the irregular quadrilateral, I have come > up with something. I already have the boundary from the training data. > So, I was thinking for each new (x,y) pair I can find its > corresponding (x,y)s (its images) on the boundaries.
What you described below seems more complicated than need be (if I understand it) but I wouldn't knock it if it works.
> And then for example: x' = K - |x - x1| , y' = K - |y - y1|; (x', y') > is the new corrected point and K is a constant. This way I force the > curves that are parallel to the boundary become straight lines because > their absolute distance to the boundary is constant. > Also, the closer to the boundaries the bigger is the bent out job > which is what I want. > I tried this, it almost worked, but the problem again is that the > middle of the screen is gone. Basically, for example, when you move > from left to right before reaching the middle the cursor jumps further > to the other half of the screen missing the middle portion. > Can you think of some other simple mapping to do this? > > Thanks,
You're welcome. Jerry -- Engineering is the art of making what you want from things you can get.
> What you described below seems more complicated than need be (if I > understand it) but I wouldn't knock it if it works.
It doesn't work, I mean it works somewhere doesn't work somewhere else. I got straight lines around the boundaries but nothing in the middle but a sudden jump. As I mentioned the middle space is empty because |x-x1| never meets values around K. So no small (x' ,y') I'm looking for more sufisticated, robust, reliable mappings that can convert any irregular quadrilateral given that it has a known boundary to a rectangle. Any ideas?
> >What you described below seems more complicated than need be (if I >understand it)
You mean K - |x-x1| is complicated? or finding its respective pairs on the boundaries? It's only couple of lines of code. Thanks Elnaz p.s. Jerry, I like your signature sentence very much, Wise!