I would like to read an image pixel by pixel and store how many of each pixel value there are (grayscale 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
How can i allocate an array with 256 places?
grayArrayaszeros(1,256). But see my solution, which is much faster than using two loops