3 x 3 mean and meadian replacement
Show older comments
Never used matlab so it is all new to me. I have to compute the mean and medain of the pixels by 3x3 neighborhoods around all the pixels. I did mean part, not sure if correct. And for the median I have no clue.
I = normrnd(128,8,[256,256]);
imshow(I,[0,255]); % Pick indices to repalce with black and white
Iv = reshape(l,[],1);
histogram(Iv);
---------------
[m,n] = size(I) ;
X = randperm(m*n,round(m*n*10/100)) ;
X1 = randsample(X,length(X)/2) ;
X2 = setdiff(X,X1);
I(X1) = 0 ; % black
I(X2) = 255 ; % white
imshow(I,[0,255])
Xv = reshape(I,[],1);
histogram(Xv); (credit to @KSSV)
-----------------
output1 = 1/3*ones(3,1);
H = output1*output1'; This is my mean attempt, not too sure if correct
imfilt = filter2(H,I);
imshow(imfilt,[0,255]);
histogram(imfilt);
------------------------------
p = medfilt2(outout1); I have tried this for the median, but i keep getting a dimension 2 error
imshow(p,[0,255]);
Accepted Answer
More Answers (0)
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!