フィルターのクリア

how to divide rgb image into blocks using for loop and find the rgb value for each block

1 回表示 (過去 30 日間)
bs=8;
% M=zeros(96,96,3);
row=r/bs;
col=c/bs;
a=1;
k=0;
l=0;
b=1;
p=1;
noofp=96;
mR=zeros(768,768);
mG=zeros(768,768);
mB=zeros(768,768);
while(p<=noofp)
for i=1:row
for j=1:col
M{p}=re(8*k+1:8*a,8*l+1:8*b,:);
mR=M{p}(i,j,1);
mG=M{p}(i,j,2);
mB=M{p}(i,j,3);
d=[mR mG mB];
p=p+1;
l=l+1;
b=b+1;
end
k=k+1;
a=a+1;
l=0;
b=1;
% figure,imshow(M{p});
end

採用された回答

KSSV
KSSV 2017 年 3 月 8 日
bs=8;
M=rand(768,768,3);
[r,c,p] = size(M) ;
row=r/bs;
col=c/bs;
mR=M(:,:,1);
mG=M(:,:,2) ;
mB=M(:,:,3) ;
idx = 1:bs:r+bs ;
pos = [idx(1:end-1)' idx(2:end)'-1] ;
iwant = zeros(bs,bs,row) ;
for i = 1:row
iwant(:,:,i) = mR(pos(i,1):pos(i,2),pos(i,1):pos(i,2)) ;
end
  7 件のコメント
vasantha malairamar
vasantha malairamar 2017 年 3 月 22 日
whether 96 represents the pixel value or the band??

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by