Image to patches for local features extraction
1 view (last 30 days)
Show older comments
Hi All,
I have an image and I need to extract local features,so I divided it to 32 * 32 patches and size of each patch =16 *16 pixels and extract that three color histograms features locally from each patch, now I need to :
1-Store these features in the descriptor x like in figure:
2-Store these feature discroptors in the X like in figure:
3-Store these X's in the global matrix called G like in figure:
I tried this code :
patches_counter=1;
for g=1:32
for u=1:32
if nom_ones>area_of_patch_by_two
patch_h=h_seg_image_cell{g,u} ;
patch_s=s_seg_image_cell{g,u} ;
patch_v=v_seg_image_cell{g,u} ;
% Describe each patch by 3 color histograms features
[patch_h_ftr1,xh]=imhist(patch_h);
[patch_s_ftr2,xs]=imhist(patch_s);
[patch_v_ftr3,xv]=imhist(patch_v);
end
% Create features vector
x=[patch_h_ftr1;patch_s_ftr2;patch_v_ftr3];
X(:,patches_counter) = x(patches_counter);
patches_counter=patches_counter+1;
end
end
But I got this ERROR
In an assignment A(I) = B, the number of elements
in B and I must be the same.
Error in my_im2blocks1 (line 72)
X_image_vector(patches_counter) =
x_featurs_vector_patch;
Hint : Don't care about this condition
if nom_ones>area_of_patch_by_two
It works well.
Please make any correction and thanks in advance.
0 Comments
Answers (2)
Image Analyst
on 28 Feb 2014
Capital X is undefined in the code you gave and it may not like you to poof it into existence like that. Also, before that line do
whos X
whos x
whos patches_counter
and make sure that the number of rows in X matches the length of patches_counter.
6 Comments
Image Analyst
on 1 Mar 2014
You never followed my suggestion of doing "whos" and you didn't attach your m-file. It's difficult for me to try to figure this out without being able to run it, because you have variables that are just suddenly there (like h_seg_image_cell{g,u}, etc.), and variables change names, etc. So I think the best bet is for you to step through this in the debugger. Don't you agree?
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!