Image to patches for local features extraction
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Image Analyst
2014년 2월 28일
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
Image Analyst
2014년 3월 1일
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?
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!