need to make a function which reads each pixel in a 2x2 block of an image

1 visualizzazione (ultimi 30 giorni)
I have actually tried to divide my image into 2x2 blocks. After retreiving each block, have run a loop upto the total number of 2x2 blocks. Now , in each block, i need to call a function which is going to read all 4 pixels , one by one so that i can apply conditions accordingly..

Risposte (1)

Titus Edelhofer
Titus Edelhofer il 20 Lug 2011
Hi Ankita,
the simplest would be to loop on all blocks
A = ... % your image
lastRow = 2 * (floor(size(A,1)-1)/2);
lastCol = 2 * (floor(size(A,2)-1)/2);
for i=1:2:lastRow
for j=1:2:lastCol
yourBlock = A([i i+1], [j j+1]);
end
end
There are probably more elegant ways to do the same, but that should be a good (and simple) start ... Titus

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by