当我尝试通过计算 4 个像素的平均值来获得一个像素来调整图像大小时,我遇到了一个问题,下面是我的代码,请帮助我,这让我发疯
a=imread('c:\black and white.jpg');
[rows,columns,phases]=size(a);
i=1;j=1;k=1;
c=zeros(rows/2,columns/2,phases);
c=uint8(c);
for x=1:2:rows-1;
for y=1:2:columns;
for z=1:phases;
c(i,j,k)=1/4*(a(x,y,z)+a(x,y+1,z)+a(x+1,y,z)+a(x+1,y+1,z));
k=k+1;
end
j=j+1;
k=1;
end
i=i+1;
j=1;
k=1;
end
figure, imshow(a)
figure, imshow(c)