pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin private pastebin - collaborative debugging tool What's a private pastebin?

Posted by Willow on Thu 21st Feb 03:43
download | new post

  1. %Load image and normalise
  2. img = imread('AAngles.jpg');
  3. normImg = double(img)./255;
  4.  
  5. %Convert to greyscale
  6. greyimg = normImg(:,:,1)*0.30 + normImg(:,:,2)*0.59 + normImg(:,:,3)*0.11;
  7.  
  8. %Sobel Convolution Kernel - indepth description http://en.wikipedia.org/wiki/Sobel_operator
  9. Kx = [1 2 1 ; 0 0 0 ; -1 -2 -1]./4;
  10. Ky = Kx'; %y = xTranspose
  11.  
  12. %Perform convolution in x and y directions
  13. dx = conv2(greyimg, Kx, 'same');
  14. dy = conv2(greyimg, Ky, 'same');
  15.  
  16. %Magnitude of edges is a point on unit circle formed in a basis defined by dx and dy - use pythag
  17. %(Edge orientations therefore through atan(dy/dx) by basic trig)
  18. mag = sqrt(dx.^2 + dy.^2);
  19. imshow(mag);
  20.  
  21. %Threshold at edge magnitude = 0.15
  22. thresholded = (mag > 0.15);
  23. figure; %This simply plots the image in a new window
  24. imshow(thresholded);

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings