how to divide rgb image into blocks using for loop and find the rgb value for each block
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
vasantha malairamar
am 8 Mär. 2017
Kommentiert: vasantha malairamar
am 22 Mär. 2017
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
0 Kommentare
Akzeptierte Antwort
KSSV
am 8 Mär. 2017
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Denoising and Compression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!