How to divide color image into blocks and calculate mean and std of each block.

1 回表示 (過去 30 日間)
anu
anu 2016 年 12 月 15 日
回答済み: KSSV 2016 年 12 月 15 日
I want to divide color image into 5 * 5 blocks. For each block I want to calculate mean and std. How to do it?

回答 (1 件)

KSSV
KSSV 2016 年 12 月 15 日
I = rand(100,100,3); % be your image after imread..
R = I(:,:,1) ; G = I(:,:,2) ; B = I(:,:,3) ;
I1 = reshape(I,5,5,[]) ;
G1 = reshape(G,5,5,[]) ;
B1 = reshape(B,5,5,[]) ;
But be careful that, when you reshape into 5x5 the number of columns and rows must be divisible by 5. If not, you have to either change 5x5 to desired divisible number of dimensions or take 5X5 and last one block will not have 5X5.

Community Treasure Hunt

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

Start Hunting!

Translated by