Skip to content

Instantly share code, notes, and snippets.

View alfredplpl's full-sized avatar

Alfred Increment alfredplpl

View GitHub Profile
cv::Mat image=cv::imread("./image.png",-1);
cv::Mat trans=cv::imread("./trans.png",0);
cv::Rect rect1(startColumn1,startRow1,trans.cols,trans.rows);
cv::Mat subdst1=dst(rect1);
trans.convertTo(subdst1,subdst1.type(),alpha);//double alphaは透過率[0.0, 1.0]
cv::Rect rect2(startColumn2,startRow2,image.cols,image.rows);
cv::Mat subdst2=dst(rect2);
image.copyTo(subdst2);
cv::Mat image=cv::imread("./image.png",-1);
cv::Mat image_mask=cv::imread("./mask.png",0);
cv::Rect rect(startColumn,startRow,image.cols,image.rows);
cv::Mat subdst=dst(rect);
image.copyTo(subdst,image_mask);
@alfredplpl
alfredplpl / bofTest.py
Created October 17, 2013 08:04
Test for BagOfFeatures.py
# -*- coding: utf-8 -*-
#BoF(SIFT)により一般物体認識を行うサンプルコード
#今回はイルカと象を識別
#評価用のデータセットとしてCaltech 101を使用
#see also: http://www.vision.caltech.edu/Image_Datasets/Caltech101/
import cv2
import numpy as np
from sklearn import svm
from sklearn import cross_validation
@alfredplpl
alfredplpl / resultBofTest.py
Created October 17, 2013 08:08
The result of bofTest.py
Ave. score(BagOfFeatures):70.492308[%]
Ave. score(BagOfFeaturesGMM):71.323077[%]
@alfredplpl
alfredplpl / hashLikeList.R
Created October 27, 2013 01:43
Its behavior is like hash (associative array).
#Its behavior is like hash (associative array).
hash.test=list("square"=function(x){x**2},
"pi"=3.1415926535)
hash.test[["square"]](2)
hash.test[["pi"]]
#probability that a random selected number is a prime number.
6/hash.test[["square"]](hash.test[["pi"]])
@alfredplpl
alfredplpl / resultOfHash.R
Created October 27, 2013 01:45
the result of hashLikeList.R
> hash.test[["square"]](2)
[1] 4
> hash.test[["pi"]]
[1] 3.141593
>
> #probability that a random selected number is a prime number.
> 6/hash.test[["square"]](hash.test[["pi"]])
[1] 0.6079271
#過去の解答を読み込む
examH25<-read.csv("C:/center_kokugo - H25.csv",header=T)
examH24<-read.csv("C:/center_kokugo - H24.csv",header=T)
#過去問をくっつけます
exam<-rbind(examH25,examH24)
#選択肢が5個のものだけの解答を抽出します
exam5<-exam$Correct[exam$Choices==5]
> #各選択肢の出現回数を求めます
> choiceTable<-table(exam5)
> choiceTable
exam5
1 2 3 4 5
15 12 13 12 15
>
> #各選択肢に対して同じ回数出現しているかを統計的に調べます。
> #(カイ二乗検定による適合度検定)
> chisq.test(choiceTable)
No Part Correct Choices
1 1 1 5
1 2 3 5
1 3 1 5
1 4 1 5
1 5 5 5
2 6 1 5
3 7 5 5
4 8 2 5
5 9 5 5
No Part Correct Choices
1 1 3 5
1 2 2 5
1 3 5 5
1 4 3 5
1 5 5 5
2 6 4 5
3 7 5 5
4 8 1 5
5 9 3 5