Skip to content
Snippets Groups Projects
Commit c6e13c01 authored by MichaelK's avatar MichaelK
Browse files

Update: Added HOG feature extraction with visualization

parent 1183fccc
Branches
No related tags found
1 merge request!2Merge: Hog feature extraction Added
%% Example Title
% Let's use Edvard Munch's - skrik picture
image = imread("colorHistogram/Edvard_Munch_-_Despair_(1894).jpg");
img = imread("colorHistogram/Edvard_Munch_-_Despair_(1894).jpg");
% Let's also display the picture to see how it originally looks
%imshow(image);
%% edgeMap - Test of implementation
edgeImage = edgeMap(image);
%edgeImage = edgeMap(img);
imshow(edgeImage);
%imshow(edgeImage);
%% HOG - Test of implementation
% "hog" contains feature vector based on histogram of oriented gradients
% "visual" contains visualization object that can be used in plot method
[hog, visual] = histogramOrientedGradients(img);
figure,
imshow(img),
hold on,
plot(visual),
title("Hog features of image");
% Using Cellsize this time
[hog2, visual2] = histogramOrientedGradients(img, 32);
figure,
imshow(img),
hold on,
plot(visual2),
title("Hog features using Cellsize");
%% Section 2 Title
% Description of second code block
b = 2;
%Returns histogram in grayscale
function [out] = histogramGrayscale(image)
%image ideally is already grayscaled rbg2gray() if needed
%Converts image into grayscale
image = rgb2gray(image);
[x,y] = size(image);
out = zeros(1,255);
......
% Returns histogram of oriented gradients (HOG) feauture vector of an
% image and visualization object that can be used with plot method.
% Useful for training a classifier.
%
% NB! *Requires Computer Vision Toolbox Add-on*
%
function [featureVector, hogVisualization] = histogramOrientedGradients(varargin)
if nargin==1
img=varargin{1};
[featureVector, hogVisualization] = extractHOGFeatures(img);
elseif nargin==2
img=varargin{1};
size=varargin{2};
[featureVector, hogVisualization] = extractHOGFeatures(img, "Cellsize",[size size]);
else
error('histogramOrientedGradients only accepts up to 2 input arguments!')
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment