# Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.87 KB  |  hits: 12  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. In need for imaging details
3. >> w = [-1 0 1; -1 0 1; -1 0 1];
4. >> b = imfilter(a,w);
5. >> imshow(b)
6.
7. for i < img.height, i++
8.  for j < img.width, j++
9.   rsum = pixel[i-1,j-1].R*(-1) + pixel[i-1,j+1].R*(1)
10.   rsum += pixel[i,j-1].R*(-1) + pixel[i,j+1].R*(1)
11.   rsum += pixel[i+1,j-1].R*(-1) + pixel[i+1,j+1].R*(1)
12.
13.   gsum = pixel[i-1,j-1].G*(-1) + pixel[i-1,j+1].G*(1)
14.   gsum += pixel[i,j-1].G*(-1) + pixel[i,j+1].G*(1)
15.   gsum += pixel[i+1,j-1].G*(-1) + pixel[i+1,j+1].G*(1)
16.
17.   bsum = pixel[i-1,j-1].B*(-1) + pixel[i-1,j+1].B*(1)
18.   bsum += pixel[i,j-1].B*(-1) + pixel[i,j+1].B*(1)
19.   bsum += pixel[i+1,j-1].B*(-1) + pixel[i+1,j+1].B*(1)
20.
21.   if rsum>255, rsum=255
22.   if gsum>255, gsum=255
23.   if bsum>255, bsum=255
24.
25.   if rsun<0, rsun=0
26.   if gsun<0, gsun=0
27.   if bsun<0, bsun=0
28.
29.   img.setpixel(i,j) = (rsum|gsum|bsum)
30.  end
31. end
32.
33. y[n] = SUM x[n-k] . h[k]
34.         k