- #1

- 10

- 0

## Main Question or Discussion Point

I want to calculate the magnetic field from a given image using biot savarts law. For example if I have a picture of a triangle, I say that this triangle forms a closed wire carrying current. Using image derivatives I can get the co-ordinates and direction of the current (normals included). I am struggling implementing this...need a bit of help with logic too. Here is what I have:

--------------------------------------------------------

Img = imread('littletriangle.bmp');

Img = Img(:,:,1);

Img = double(Img);

[x,y] = size(Img);

[Ix, Iy] = gradient(Img);

biot savart equation is:

--------------------------------------------------------

b = mu/4*pi sum(Idl x rn / r^2)

where mu/4pi is const, I is current magnitude, rn distance unit vector between a pixel and current, r^2 is the squared magnitude of the displacement between a pixel and the current.

So just to start off, I read the image in, turn it into a binary and then take the image gradient. This gives me the location and orientation of the 'current'. I now need to calculate the magnetic field from this 'current' at every pixel in the image. I am only interested in getting the magnetic field in the x-y plane. anything just to start me off would be brilliant!

--------------------------------------------------------

Img = imread('littletriangle.bmp');

Img = Img(:,:,1);

Img = double(Img);

[x,y] = size(Img);

[Ix, Iy] = gradient(Img);

biot savart equation is:

--------------------------------------------------------

b = mu/4*pi sum(Idl x rn / r^2)

where mu/4pi is const, I is current magnitude, rn distance unit vector between a pixel and current, r^2 is the squared magnitude of the displacement between a pixel and the current.

So just to start off, I read the image in, turn it into a binary and then take the image gradient. This gives me the location and orientation of the 'current'. I now need to calculate the magnetic field from this 'current' at every pixel in the image. I am only interested in getting the magnetic field in the x-y plane. anything just to start me off would be brilliant!