MATLAB: I have an image and I need to extract local features,so I divided it to 16 blocks and size of each block =64 *64 pixels and extract that three color histograms features locally from each block, now I need to

histogramimage processingImage Processing Toolbox

tic
disp('query')
[filename, pathname]=uigetfile({'*.jpg'},'queryimage');
img=strcat(pathname,filename);
a=imread(img);
subplot(4,5,3)
imshow(img)
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
[r, c, numOfBands] = size(a);
%dividing image into 8x8 subblocks
bs=64;%block size
nob=(r/bs)*(c/bs);%Total no of blocks
k=0;
for i=1:(r/bs)
for j=1:(c/bs)
T=k+j;
T=num2str(T);
C=strcat(b,T);
col1=bs*(j-1)+1;
row1=bs*(i-1)+1;
col2=bs*(j-1)+bs;
row2=bs*(i-1)+bs;
C=imcrop(a,[col1 row1 col2 row2]);
end
k=k+(r/bs);
end
b = rgb2hsv(b);
% split image into h, s & v planes
h = b(:, :, 1);
s = b(:, :, 2);
v = b(:, :, 3);
% Create the histogram quantized into 8×3×3 bins
X= zeros(8, 3, 3);
for k = 1 : numel(h)
indexH = floor(8 * h(k)) + 1;
indexS = floor(3 * s(k)) + 1;
indexV = floor(3 * v(k)) + 1;
if indexH > 8
indexH = 8;
end
if indexS > 3
indexS = 3;
end
if indexV > 3
indexV = 3;
end
X(indexH, indexS, indexV) = X(indexH, indexS, indexV) + 1;
end
#so, i want to quantify each block in the above manner i want to do for every block and store the 16 blocks matrices into resultant matrix G, how i do that

Best Answer

Try
k = 1;
for i=1:(r/bs)
for j=1:(c/bs)
% code snipped....
C{k} = imcrop(a,[col1 row1 col2 row2]);
k = k + 1;
end
end