Created
May 27, 2019 10:36
-
-
Save berkayakcay/701bf711eba49b70c53d1fe1ef8fc021 to your computer and use it in GitHub Desktop.
Image Processing MATLAB Laplacian Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clc; clear; close all; | |
I= imread('chessboard.jpg'); | |
I = rgb2gray(I); | |
[R,C] = size(I); | |
SI = uint8(zeros(R,C)); | |
mask = 1; | |
% kernel = [-1,-1,-1;-1,8,-1;-1,-1,-1]; | |
% kernel = [1,1,1;1,-8,1;1,1,1]; | |
kernel = [0,-1,0;-1,4,-1;0,-1,0]; | |
for r=1:R | |
for c=1:C | |
values = 0; | |
for i=-mask:mask | |
for j=-mask:mask | |
if(((r+i)>0) && ((c+j)>0) && ((r+i)<=R) && ((c+j)<=C)) | |
values = values + (double(I(r+i,c+j)) * double(kernel(i+2,j+2))); | |
end | |
end | |
end | |
SI(r,c) = values; | |
end | |
end | |
subplot(1,2,1); imshow(I); subplot(1,2,2); imshow(SI); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment