function [gist, param] = LMgist(D, HOMEIMAGES, param, HOMEGIST)
%
% [gist, param] = LMgist(D, HOMEIMAGES, param);
% [gist, param] = LMgist(filename, HOMEIMAGES, param);
% [gist, param] = LMgist(filename, HOMEIMAGES, param, HOMEGIST);
%
% For a set of images:
% gist = LMgist(img, [], param);
%
% When calling LMgist with a fourth argument it will store the gists in a
% new folder structure mirroring the folder structure of the images. Then,
% when called again, if the gist files already exist, it will just read
% them without recomputing them:
%
% [gist, param] = LMgist(filename, HOMEIMAGES, param, HOMEGIST);
% [gist, param] = LMgist(D, HOMEIMAGES, param, HOMEGIST);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Modeling the shape of the scene: a holistic representation of the spatial envelope
% Aude Oliva, Antonio Torralba
% International Journal of Computer Vision, Vol. 42(3): 145-175, 2001.
if nargin==4
precomputed = 1;
% get list of folders and create non-existing ones
%listoffolders = {D(:).annotation.folder};
%for i = 1:length(D);
% f{i} = D(i).annotation.folder;
%end
%[categories,b,class] = unique(f);
else
precomputed = 0;
HOMEGIST = '';
end
% select type of input
if isstruct(D)
% [gist, param] = LMgist(D, HOMEIMAGES, param);
Nscenes = length(D);
typeD = 1;
end
if iscell(D)
% [gist, param] = LMgist(filename, HOMEIMAGES, param);
Nscenes = length(D);
typeD = 2;
end
if isnumeric(D)
% [gist, param] = LMgist(img, HOMEIMAGES, param);
Nscenes = size(D,4);
typeD = 3;
if ~isfield(param, 'imageSize')
param.imageSize = [size(D,1) size(D,2)];
end
end
param.boundaryExtension = 32; % number of pixels to pad
if nargin<3
% Default parameters
param.imageSize = 128;
param.orientationsPerScale = [8 8 8 8];
param.numberBlocks = 4;
param.fc_prefilt = 4;
param.G = createGabor(param.orientationsPerScale, param.imageSize+2*param.boundaryExtension);
else
if ~isfield(param, 'G')
param.G = createGabor(param.orientationsPerScale, param.imageSize+2*param.boundaryExtension);
end
end
% Precompute filter transfert functions (only need to do this once, unless
% image size is changes):
Nfeatures = size(param.G,3)*param.numberBlocks^2;
% Loop: Compute gist features for all scenes
gist = zeros([Nscenes Nfeatures], 'single');
for n = 1:Nscenes
g = [];
todo = 1;
% if gist has already been computed, just read the file
if precomputed==1
filegist = fullfile(HOMEGIST, D(n).annotation.folder, [D(n).annotation.filename(1:end-4) '.mat']);
if exist(filegist, 'file')
load(filegist, 'g');
todo = 0;
end
end
% otherwise compute gist
if todo==1
if Nscenes>1 disp([n Nscenes]); end
% load image
try
switch typeD
case 1
img = LMimread(D, n, HOMEIMAGES);
case 2
img = imread(fullfile(HOMEIMAGES, D{n}));
case 3
img = D(:,:,:,n);
end
catch
disp(D(n).annotation.folder)
disp(D(n).annotation.filename)
rethrow(lasterror)
end
% convert to gray scale
img = single(mean(img,3));
% resize and crop image to make it square
%img = imresizecrop(img, param.imageSize, 'bilinear');
img = imresize(img, param.imageSize, 'bilinear'); %jhhays
% scale intensities to be in the range [0 255]
img = img-min(img(:));
img = 255*img/max(img(:));
if Nscenes>1
imshow(uint8(img))
title(n)
end
% prefiltering: local contrast scaling
output = prefilt(img, param.fc_prefilt);
% get gist:
g = gistGabor(output, param);
% save gist if a HOMEGIST file is provided
if precomputed
mkdir(fullfile(HOMEGIST, D(n).annotation.folder))
save (filegist, 'g')
end
end
gist(n,:) = g;
drawnow
end
function output = prefilt(img, fc)
% ima = prefilt(img, fc);
% fc = 4 (default)
%
% Input images are double in the range [0, 255];
% You can also input a block of images [ncols nrows 3 Nimages]
%
% For color images, normalization is done by dividing by the local
% luminance variance.
if nargin == 1
fc = 4; % 4 cycles/image
end
w = 5;
s1 = fc/sqrt(log(2));
% Pad images to reduce boundary artifacts
img = log(img+1);
img = padarray(img, [w w], 'symmetric');
[sn, sm, c, N] = size(img);
n = max([sn sm]);
n = n + mod(n,2);
img = padarray(img, [n-sn n-sm], 'symmetric','post');
% Filter
[fx, fy] = meshgrid(-n/2:n/2-1);
gf = fftshift(exp(-(fx.^2+fy.^2)/(s1^2)));
gf = repmat(gf, [1 1 c N]);
% Whitening
output = img - real(ifft2(fft2(img).*gf));
clear img
% Local contrast normalization
localstd = repmat(sqrt(abs(ifft2(fft2(mean(output,3).^2).*gf(:,:,1,:)))), [1 1 c 1]);
output = output./(.2+localstd);
% Crop output to have same size than the input
output = output(w+1:sn-w, w+1:sm-w,:,:);
function g = gistGabor(img, param)
%
% Input:
% img = input image (it can be a block: [nrows, ncols, c, Nimages])
% param.w = number of windows (w*w)
% param.G = precomputed transfer functions
%
% Output:
% g: are the global features = [Nfeatures Nimages],
% Nfeatures = w*w*Nfilters*c
img = single(img);
w = param.numberBlocks;
G = param.G;
be = param.boundaryExtension;
if ndims(img)==2
c = 1;
N = 1;
[nrows ncols c] = size(img);
end
if ndims(img)==3
[nrows ncols c] = size(img);
N = c;
end
if ndims(img)==4
[nrows ncols c N] = size(img);
img = reshape(img, [nrows ncols c*N]);
N = c*N;
end
[ny nx Nfilters] = size(G);
W = w*w;
g = zeros([W*Nfilters N]);
% pad image
img = padarray(img, [be be], 'symmetric');
img = single(fft2(img));
k=0;
for n = 1:Nfilters
ig = abs(ifft2(img.*repmat(G(:,:,n), [1 1 N])));
ig = ig(be+1:ny-be, be+1:nx-be, :);
v = downN(ig, w);
g(k+1:k+W,:) = reshape(v, [W N]);
k = k + W;
drawnow
end
if c == 3
% If the input was a color image, then reshape 'g' so that one column
% is one images output:
g = reshape(g, [size(g,1)*3 size(g,2)/3]);
end
function y=downN(x, N)
%
% averaging over non-overlapping square image blocks
%
% Input
% x = [nrows ncols nchanels]
% Output
% y = [N N nchanels]
nx = fix(linspace(0,size(x,1),N+1));
ny = fix(linspace(0,size(x,2),N+1));
y = zeros(N, N, size(x,3));
for xx=1:N
for yy=1:N
v=mean(mean(x(nx(xx)+1:nx(xx+1), ny(yy)+1:ny(yy+1),:),1),2);
y(xx,yy,:)=v(:);
end
end
function G = createGabor(or, n)
%
% G = createGabor(numberOfOrientationsPerScale, n);
%
% Precomputes filter transfer functions. All computations are done on the
% Fourier domain.
%
% If you call this function without output arguments it will show the
% tiling of the Fourier domain.
%
% Input
% numberOfOrientationsPerScale = vector that contains the number of
% orientations at each scale (from HF to BF)
% n = imagesize = [nrows ncols]
%
% output
% G = transfer functions for a jet of gabor filters
Nscales = length(or);
Nfilters = sum(or);
if length(n) == 1
n = [n(1) n(1)];
end
l=0;
for i=1:Nscales
for j=1:or(i)
l=l+1;
param(l,:)=[.35 .3/(1.85^(i-1)) 16*or(i)^2/32^2 pi/(or(i))*(j-1)];
end
end
% Frequencies:
%[fx, fy] = meshgrid(-n/2:n/2-1);
[fx, fy] = meshgrid(-n(2)/2:n(2)/2-1, -n(1)/2:n(1)/2-1);
fr = fftshift(sqrt(fx.^2+fy.^2));
t = fftshift(angle(fx+sqrt(
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于MATLAB编程,用支持向量机SVM进行车祸识别,代码完整,包含数据,有注释,方便扩展应用 1,如有疑问,不会运行,可以私信, 2,需要创新,或者修改可以扫描二维码联系博主, 3,本科及本科以上可以下载应用或者扩展, 4,内容不完全匹配要求或需求,可以联系博主扩展。
资源推荐
资源详情
资源评论
收起资源包目录
基于支持向量机SVM的车祸识别,基于SVM的车祸识别(代码完整,数据齐全) (121个子文件)
29.jpg 6.82MB
9.jpg 6.65MB
16.jpg 5.91MB
34.jpg 5.61MB
45.jpg 5.61MB
50.jpg 5.48MB
38.jpg 5.48MB
35.jpg 5.31MB
24.jpg 4.99MB
23.jpg 4.84MB
2.jpg 4.74MB
28.jpg 4.36MB
11.jpg 4.35MB
30.jpg 4.07MB
4.jpg 3.66MB
37.jpg 3.55MB
27.jpg 3.32MB
39.jpg 3.32MB
31.jpg 3.22MB
7.jpg 3.19MB
5.jpg 3.09MB
25.jpg 3.06MB
4.jpg 3.06MB
50.jpg 2.69MB
1.jpg 2.63MB
10.jpg 2.49MB
20.jpg 2.49MB
22.jpg 2.49MB
12.jpg 2.43MB
48.jpg 2.42MB
42.jpg 2.23MB
26.jpg 2.11MB
6.jpg 2MB
5.jpg 1.95MB
11.jpg 1.95MB
20.jpg 1.92MB
22.jpg 1.92MB
26.jpg 1.92MB
41.jpg 1.89MB
46.jpg 1.8MB
36.jpg 1.77MB
14.jpg 1.75MB
44.jpg 1.58MB
38.jpg 1.34MB
18.jpg 1.23MB
18.jpg 1.08MB
34.jpg 1.08MB
47.jpg 1.07MB
8.jpg 1.06MB
15.jpg 1.01MB
37.jpg 1.01MB
15.jpg 1001KB
10.jpg 950KB
40.jpg 872KB
49.jpg 749KB
21.jpg 738KB
43.jpg 681KB
41.jpg 655KB
9.jpg 655KB
27.jpg 631KB
47.jpg 631KB
13.jpg 599KB
25.jpg 537KB
2.jpg 482KB
45.jpg 482KB
33.jpg 457KB
53.jpg 457KB
17.jpg 400KB
19.jpg 373KB
33.jpg 345KB
28.jpg 325KB
3.jpg 325KB
3.jpg 281KB
12.jpg 250KB
29.jpg 250KB
32.jpg 240KB
46.jpg 233KB
51.jpg 233KB
49.jpg 220KB
51.jpg 187KB
14.jpg 142KB
24.jpg 142KB
43.jpg 131KB
6.jpg 131KB
40.jpg 131KB
52.jpg 131KB
39.jpg 124KB
7.jpg 124KB
52.jpg 120KB
1.jpg 115KB
17.jpg 115KB
42.jpg 112KB
23.jpg 112KB
16.jpg 81KB
8.jpg 81KB
53.jpg 70KB
36.jpg 58KB
48.jpg 58KB
13.jpg 51KB
19.jpg 51KB
共 121 条
- 1
- 2
资源评论
神经网络机器学习智能算法画图绘图
- 粉丝: 2458
- 资源: 603
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 使用PYTHON编写一个程序,识别数字和字母的程序
- chuanghanshu.m
- 3-1same.cbp
- 电路硬件PCB设计-EMC电磁兼容PCB防干扰与防静电设计pcb电磁兼容EMC设计等文档资料合集(18个).zip
- tudou-android-release (2).apk
- 三维重建-基于NeRF实现的稳定+实时3D说话人脸生成-附项目源码-优质项目实战.zip
- oracle-10g-32bit.zip
- com.aesq.zb_v1.0.35_danji100.com.apk
- 760996331259605建立门派1.360.apk
- 下面提供一些C语言的入门示例代码,并附有注释,以帮助理解每个部分的功能 1. Hello World程序 #include
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功