Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Curl of Gaussian image derivatives matlab

  1. Jan 20, 2012 #1
    Hi guys, I am trying to create a magnetic field from an image contour and an attempt to create an active contour model. I have a function which takes the image derivative via a Guassian:

    Code (Text):
        function J=ImageDerivatives2D(I,sigma,type)
      % Gaussian based image derivatives
      %  J=ImageDerivatives2D(I,sigma,type)
      % inputs,
      %   I : The 2D image
      %   sigma : Gaussian Sigma
      %   type : 'x', 'y', 'xx', 'xy', 'yy'
      % outputs,
      %   J : The image derivative
    % Make derivatives kernels
        case 'x'
        case 'y'
        case 'xx'
            DGauss = 1/(2*pi*sigma^4) * (x.^2/sigma^2 - 1) .* exp(-(x.^2 + y.^2)/(2*sigma^2));
        case {'xy','yx'}
            DGauss = 1/(2*pi*sigma^6) * (x .* y)           .* exp(-(x.^2 + y.^2)/(2*sigma^2));
        case 'yy'
            DGauss = 1/(2*pi*sigma^4) * (y.^2/sigma^2 - 1) .* exp(-(x.^2 + y.^2)/(2*sigma^2));
    J = conv2(I,DGauss,'same');
    and now i need to take the curl of those image derivatives to get the pseudo magnetic field. having a bit of trouble with that though:

    Code (Text):
       % Squared magnitude of force field
      Fx= Fext(:,:,1);
      Fy= Fext(:,:,2);
    % Calculate magnitude
    sMag = Fx.^2+ Fy.^2;
    % Set new vector-field to initial field
    u=Fx;  v=Fy;
    for i=1:Iterations,
      % First order image derivatives
        % Compute curl and update vector field
        u = u + cross(Uxx,Uyy,3);
        v = v + cross(Vxx,Vyy,3);
    Fext(:,:,1) = u;
    Fext(:,:,2) = v;
    anyone have any tips as the second script does not work. i can to the divergence and laplacian easily as they are just first and second derivatives, but the curl is proving a bit of a problem. Any help would be great thanks!
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads for Curl Gaussian image
MATLAB Highlight an object in an image?