How to Partition the MaxIndex into 16 sub-images and calculate a 5-element histogram for each sub-image? How to create the 80-element Edge Histogram Descriptor EHD feature vector by concatenating the 16, 5-element histograms into one vector?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
rgb_im = imread('0002.png');
new_im=rgb2gray(im2double(rgb_im));
%extract only y component
y=double(new_im(:,:,1));
% define the filters for the 5 types of edges
f1 = zeros(3,3,5);
f1(:,:,1) = [1 2 1;0 0 0;-1 -2 -1]; %vertical
f1(:,:,2) = [-1 0 1;-2 0 2;-1 0 1]; %horizontal
f1(:,:,3) = [2 2 -1;2 -1 -1; -1 -1 -1];% 45 diagonal
f1(:,:,4) = [-1 2 2; -1 -1 2; -1 -1 -1];%135 diagonal
f1(:,:,5) = [-1 0 1;0 0 0;1 0 -1]; % non directional
% iterate over the posible directions
for i = 1:5
g_im(:,:,i) = filter2(f1(:,:,i),y); % apply the sobel mask
end
% calculate the max sobel gradient and index of the orientation
[m, p] = max(g_im,[],3);
%detect the edges using canny
edim = edge(y, 'canny');
%multiply edge image with the types of orientations detected by the Sobel masks
im2 =(p.*edim);
%find hisogram
edhist=hist(im2(:),5)';
0 commentaires
Réponses (2)
Walter Roberson
le 16 Juil 2017
You can use mat2cell to divide images into parts, and then you can cellfun() to do work on each part.
Or, for some calculations, you can use blockproc(). You would be more likely to use blockproc when the block size is fixed than when the rule is that the image has to be divided into a certain number of parts.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!