DEV Community

Berkay AKÇAY
Berkay AKÇAY

Posted on • Originally published at Medium on

1 1

Image Processing MATLAB Laplacian Algoritması

Örneğimizde 3×3 filter, ve siyah beyaz bir resim kullanılmıştır.

Laplacian Algoritması

Amacımız;

  • Resminizi pixel pixel okumak.
  • Her pixel’in etrafında bulunan n kadar uzaklıktaki pixellerin değerleri belirlediğimiz kernel matrisi ile çarpmak.(Kenar çizgilerini içe doğru veya dışa doğru çizmek için amaca uygun olarak pozitif veya negatif kernel kullanılabilir)
  • Yeni resimde aynı konumdaki pixele bulduğumuz ortalamayı atamak.
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);

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay