This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [a,b]=computer_discs() | |
b1=21; | |
a1=15; | |
b2=85+35; | |
a2=85; | |
[t1,s1]=computer_st_square(a1,b1); | |
[t2,s2]=computer_st_square(a2,b2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function y=ep1(n) | |
%exhaustive method to computer the sum of multiples of 3 or 5 which is below n | |
y=0; | |
for i=1:n-1, | |
if mod(i,3)==0 || mod(i,5)==0, | |
y=y+i; | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function y=ep2(n) | |
%exhaustive method | |
a=1; | |
b=2; | |
y=2; | |
c=a+b; | |
a=b; | |
b=c; | |
while c<=n, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%This is simple script to do orthogonal projection in 2-dimesion space | |
function doOrthProj(X,u) | |
%plot data | |
x1=X(1,:); | |
x2=X(2,:); | |
plot(x1,x2,'r.','MarkerSize',15); | |
axis([0,round(max(x1))+5,0,round(max(x2))+5]); | |
xlabel('x1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
close all; | |
clear; | |
clc; | |
X=[]; | |
for i=1:10, | |
x=imread([int2str(i) '.pgm']); | |
[w,h]=size(x); | |
x=reshape(x,w*h,1); | |
x=double(x); | |
X=[X x]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%============================= | |
%颜色特征提取,hsv颜色空间,使用颜色直方图,采用非均匀量化 | |
%============================= | |
function fc=color(imgname) | |
%tic | |
img=imread(imgname); | |
hsv=rgb2hsv(img); | |
%将hsv特征进行非均匀的量化 | |
[height,width,dim]=size(hsv); | |
len=256; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%========================== | |
% 纹理特征提取,采用灰度共生矩阵 | |
%========================== | |
function ft=glcm(imgname) | |
%tic | |
img=imread(imgname); | |
gimg=rgb2gray(img); | |
% 量化 | |
gl=16; | |
gimg=gimg/(256/gl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%use in computer the lbp descriptor | |
j = bitset(bitshift(i,1,samples),1,bitget(i,samples)) %rotate left; cyclic shift | |
numt = sum(bitget(bitxor(i,j),1:samples)) %number of 1->0 and | |
%0->1 transitions | |
%in binary string | |
%x is equal to the | |
%number of 1-bits in | |
%XOR(x,Rotate left(x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = X./( ones(size(X)) * diag(sum(abs(X))) ); %L1-normalization | |
X = X./( ones(size(X)) * sqrt(diag(diag(X'*X))) ); %L2-normalization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mkdir_p(path): | |
try: | |
os.makedirs(path) | |
except OSError as exc: # Python >2.5 | |
if exc.errno == errno.EEXIST and os.path.isdir(path): | |
pass | |
else: raise |
OlderNewer