我想逐像素读取图像并存储每个像素值有多少(灰度0-255):
img = imread('jetplaneCor.jpg');
imgGray = rgb2gray(img);
sizex = size(imgGray,1);
sizey = size(imgGray,2);
grayArray = [0:0:255]; %Not working
for i=0:1:sizex
for j=0:1:sizey
pixelValue = imgGray(i,j);
grayArray(pixelValue)=grayArray(pixelValue)+1;
end
end
如何分配一个有 256 个位置的数组?