Hamming Embedding 내장 Binary Signature의 matlab 프로그램 코드 생성
% This code generates 128-bit hamming code "bs" for SIFT features %128-D % "bs": binary signature
%
% Bug fixed by Liang Zheng on 01/26/2015.
%% load previous data
feat_file = '100000.siftgeo'; % folder of holidays features %holidays
word_file = '100000_word.mat'; % holidays visual word %visual_word:3*1125 double
P = importdata('projection_matrix_128bits.mat');% load projection matrix % %P:128*128 double %mat ??
thres = importdata('thres_20k_128bits.mat');% load median matrix %thres:128*20000 double
% a matrix for converting 01 strings into 0-255 uint8 data % 01 -> 0~255 % uint8
% uint8 data
nbits = 128; %nbits:number of bits for SIFT feature
m = 2.^(0:7); %m = [1 2 4 8 ... 128] % (0:7) [0, 1, 2, 3, 4, 5, 6, 7]
M = m; % [1 2 4 8 ... 128]
for i = 2:nbits/8 %2~128/8 % 2~16 % 15 , <16,(8*16)> <16, 128>
% , , size(m, 2)=8 , m, 0
M = blkdiag (M, m); %Block diagonal concatenation of matrix input arguments
end
bin2compactbin = M;
% for each image, calculate the HE signatures of its features HE
% signature
[data, meta] = siftgeo_read(feat_file); % load features %feat_file = '100000.siftgeo'; data: n*128
data = data'; % ,data:128*n
% rootSIFT
sum_val = sum(data); %sum_val: 1*128 %1、
for i = 1:128
data(i, :) = data(i, :)./sum_val; %2、 ./
end
data = single(sqrt(data)); %3、 , single
visual_word = importdata(word_file); % load visual word %word_file = '100000_word.mat'; %visual_word:3*1125 % descriptors visual words
nsift = size(visual_word, 2); %nsift = 1125, 1125 sift keypoints,size(visual_word, 1) MA(kNN),size(visual_word, 2) sift descriptors
%% feature projection and binarization %
temp_data = P*data; % projected feature %data RootSIFT %% P = importdata('projection_matrix_128bits.mat');
kNN = 3; % number of visual words assigned to each SIFT feature %visual word index, SIFT feature visual words
hamming_data = zeros(128, nsift*kNN);% note, multiple assignment is implied here. kNN = 3. % MA = kNN = 3, feature 3 visual words, hamming_data:128*(nsift*kNN)
if ~isempty(visual_word) %
for i = 1:kNN %1~3
vw_index = visual_word(i, :); %visual_word:3*1125, i,vw_index: 1*1125
thresh = thres(:,vw_index); %thres = importdata('thres_20k_128bits.mat'); thres:128*20000, thres , thres:128*1125
IDX = i:3:((nsift-1)*3+i); %nsift rootSFIT ,1125, i:3:(1124*3+i)
hamming_data(:, IDX) = temp_data - thresh; % projected data minus median matrix
end
hamming_data(hamming_data > 0) = 1; %hamming_data > 0 1, 0
hamming_data(hamming_data <=0 ) = 0;
% bs: binary signature
bs = uint8 (bin2compactbin*hamming_data); % convert 01 strings into uint8 data %bin2compactbin = M;
else %visual_word
bs = [];
end
% save file. bs is used as the binary signature of SIFT features
write_file = '100000_he.txt';
fid = fopen(write_file, 'w'); % 100000_he.txt
fwrite(fid, bs, 'uint8'); % binary signature 100000_he.txt
fclose(fid);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【MATLAB】변수를 스크립트에 저장MATLAB에서 계산 결과를 저장할 때 MAT 파일, Excel 등의 파일에 저장하는 것이 좋을 것이라고 생각하지만 변수의 유형에 따라 스크립트에 내보낼 수 있습니다. MATLAB을 사용해 10년 정도가 됩니다만, ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.