Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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
  1 Kommentar
Walter Roberson
Walter Roberson am 24 Jan. 2018
You have
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
Every iteration of j, you write over all of the C matrix, so at the end, C is just going to be the result of executing the last i and last j

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 24 Jan. 2018
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
  1 Kommentar
teja jayavarapu
teja jayavarapu am 24 Jan. 2018
I have tried that way it works,but when quantification is done we will get 16 different values of X how to store those X values such as (X1,X2..) in G

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by