how to divide an image into 2x2 blocks and then work on each block seperately pixel by pixel?
Show older comments
in each block , I want to check that if a single pixel is colored (if r ,g and b components of that pixel come to be equal then its a grayscale otherwise that will be colored ) then the rest of the three pixels should get the value of that pixel and if 2 pixels are colored then their average should be given to all the 4 pixels.
1 Comment
Walter Roberson
on 19 Jul 2011
Duplicate with less information is at http://www.mathworks.com/matlabcentral/answers/11894-how-to-traverse-an-image-in-2x2-block-wise-wayand-then-check-suitable-conditions
Answers (2)
Sean de Wolski
on 19 Jul 2011
alleq = all(bsxfun(@eq,I(:,:,1),I(:,:,2:3)),3); %find equal planes
blkproc(alleq,[2 2],@(x)any(x(:))) %traverse em'
lola
on 29 Dec 2011
I = imread('tire.tif');
f = @(x) uint8(round(mean2(x)*ones(size(x))));
I2 = blkproc(I,[2 2],f);
imshow(I)
figure, imshow(I2);
if you need any other rgb images you need to convert it first to gray(rgb2gray)
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!