DEV Community

Berkay AKÇAY
Berkay AKÇAY

Posted on • Originally published at Medium on

4

Image Processing MATLAB Mean ve Median Algoritması (Örnek)

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

Görüntü ve sinyal işleme konularında, gürültü temizlemek için kullanılan yöntemlerdir. Amaç parazitleri kaldırmaktır. Filtre uygulandıktan sonra resimde bulunan ve komularından belirgin şekilde ayrılan piksel’leri tespit edilerek temizlenmesi sağlanır.

more1…

more2…

Mean Filter Algoritması

Amacımız;

  • Resminizi pixel pixel okumak.
  • Her pixel’in etrafında bulunan n kadar uzaklıktaki pixellerin değerleri toplamının ortalamasını almak.
  • Yeni resimde aynı konumdaki pixele bulduğumuz ortalamayı atamak.
clc; clear; close all;
I= imread('p.jpg');
I = rgb2gray(I);
[R,C] = size(I);
SI = uint8(zeros(R,C));
for r=1:R
for c=1:C
ListOfValues = 1:9;
counter = 0;
for i=-1:1
for j=-1:1
counter = counter + 1;
if(((r+i)>0) && ((c+j)>0) && ((r+i)<=R) && ((c+j)<=C))
ListOfValues(counter) = I(r+i,c+j);
end
end
end
SI(r,c) = median(ListOfValues);
ListOfValues = [];
end
end
imshow(I);
figure;
imshow(SI);

Median Filter Algoritma

Amacımız;

  • Resminizi pixel pixel okumak.
  • Her pixel’in etrafında bulunan n kadar uzaklıktaki pixellerin median değerini bulmak.
  • Yeni resimde aynı konumdaki pixele bulduğumuz median değerini atamak.
clc; clear; close all;
I= imread('p.jpg');
I = rgb2gray(I);
[R,C] = size(I);
SI = uint8(zeros(R,C));
for r=1:R
for c=1:C
total = 0.0;
counter = 0;
for i=-1:1
for j=-1:1
if(((r+i)>0) && ((c+j)>0) && ((r+i)<=R) && ((c+j)<=C))
total = total + double(I(r+i,c+j));
counter = counter + 1;
end
end
end
SI(r,c)= total/counter;
end
end
imshow(I);
figure;
imshow(SI);

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay