How can I make mean filter for color image?
Show older comments
I am trying to do something like this for a color image:
I was trying to use plockproc function but kept getting an error; it is my first time working with an image in matlab but i feel like it should not be hard to do. Can anyone help please?
Accepted Answer
More Answers (2)
Image Analyst
on 19 Dec 2018
0 votes
See attached blockproc demo, which does this.
1 Comment
Gleb Bulatovskiy
on 20 Dec 2018
X = RGBimage; % 2D matrix, 3D RGB array or any other array
V = 100; % Block size for 1st dim
W = 100; % and for 2nd dim
S = size(X);
M = S(1) - mod(S(1), V);
N = S(2) - mod(S(2), W);
MV = M / V;
NW = N / W;
% Cut and reshape input such that the 1st and 3rd dimension have the lengths V
% and W:
XM = reshape(X(1:M, 1:N, :), V, MV, W, NW, []);
Y = sum(sum(XM, 1), 3) ./ (V * W);
% Remove singleton dimensions:
S(1) = MV;
S(2) = NW;
Y = reshape(Y, S);
Categories
Find more on Image Processing Toolbox 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!