clc; close all; clear all; img=imread('image.jpg'); figure,imshow(img); img2=zeros(size(img)+2); newImg=zeros(size(img)); for rgb=1:3 for x=1:size(img,1) for y=1:size(img,2) img2(x+1,y+1,rgb)=img(x,y,rgb); end end end for i= 1:size(img2,1)-2 for j=1:size(img2,2)-2 window=zeros(9,1); inc=1; for x=1:3 for y=1:3 window(inc)=img2(i+x-1,j+y-1,rgb); inc=inc+1; end end kernel=[1;2;1;2;4;2;1;2;1]; % kernel=[0;1;0;1;-4;1;0;1;0]; med=window.*kernel; disp(med); med=sum(med); med=floor(med); newImg(i,j,:)=med; end end newImg=uint8(newImg); figure,imshow(newImg);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)