Pastebin

Paste #1023: matlab billedbehandling

< previous paste - next paste>

Pasted by tdn

Download View as text

  1 % /usr/local/image/src/INTRO/TIFFIM/calob.tiff
  2 % /usr/local/image/src/INTRO/TIFFIM/agerup.tiff
  3
  4 function result=opgave1(I,n)
  5
  6   img=imread(I);
  7
  8   [N,M] = size(img);
  9
 10   gradients = zeros(N,M,2);
 11
 12   image(img)
 13   hold on
 14   for x=1:N
 15     for y=1:M
 16       if(x-1 == 0 || x+1 > N || y-1 == 0 || y+1 > M)
 17         gradients(x,y,1) = 0;
 18         gradients(x,y,2) = 0;
 19       else
 20         gradients(x,y,1) = 0.5*(img(x+1,y) - img(x-1,y));
 21         gradients(x,y,2) = 0.5*(img(x,y+1) - img(x,y-1));
 22         plot(gradients(x,y,1), gradients(x,y,2))
 23       end;
 24     end;
 25   end;
 26
 27   result = gradients;
 28

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.