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
// numeric.jsを使用 | |
// データ点を配列で渡す 例: points = [[x0,y0],[x1,y1],[x2,y2],[x3,y3]]; | |
// y=c[0]*x+c[1] で近似し係数cを配列で返す | |
function leastSquare(points) { | |
var A=numeric.rep([2, 2], 0); | |
var b=numeric.rep([2], 0); | |
for(var i=0; i<points.length; ++i) { | |
A[0][0]+=points[i][0]*points[i][0]; | |
A[0][1]+=points[i][0]; | |
A[1][0]+=points[i][0]; |
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
// jacobi法による実対称行列の対角化 | |
// numeric.jsが必要 | |
// 他の関数との依存性排除ver | |
// size: 行列サイズ | |
// intputA: 対角化される入力行列 ※対称行列でなければならない | |
// 返り値 {DiagonalMatrix:A, OrthodonalMatrix:P}; | |
// A(入力時) = P A(対角化後) P.transpose が成り立つ | |
function jacobiDiagonalization(size, inputA, maxIteration, threshold) { | |
var A=numeric.clone(inputA); |
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
#include <iostream> | |
#include <fstream> | |
#include <list> | |
#include <math.h> | |
#define N 2000 | |
#define PI 3.141592 | |
using namespace std; |
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 contourDetection(contextIn, contextOut, width, height) { | |
var imgData=contextIn.getImageData(0, 0, width, height); | |
// 読み取り用ピクセルデータ(書き換えない) | |
var pixelData = new Array(width); | |
for(var i=0; i<width; ++i) { | |
pixelData[i] = new Array(height); | |
for(var j=0; j<height; ++j) { | |
pixelData[i][j] = imgData.data[4*(width*j+i)]; | |
} |
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
// 二値化 | |
// canvasコンテキスト contextIn を閾値 threshold の元で二値化して contextOut に書き出す | |
// 入力画像はグレースケール画像であることを想定している(RGB値がすべて同じ) | |
// アルファ値が 0 のピクセルは閾値に関わらず白にする | |
function binarization(contextIn, contextOut, width, height, threshold) { | |
var imgData = contextIn.getImageData(0, 0, width, height); | |
var gray; | |
for(var i=0; i<imgData.width*imgData.height; ++i) { | |
if(imgData.data[4*i+3]==0) { | |
imgData.data[4*i] = 255; |
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
// グレースケール化 | |
// canvasコンテキスト contextIn をグレースケール化して contextOut に書き出す | |
// ただしアルファ値が 0 のピクセルはそのままにする | |
function grayScale(contextIn, contextOut, width, height) { | |
var imgData = contextIn.getImageData(0, 0, width, height); | |
var gray; | |
for(var i=0; i<imgData.width*imgData.height; ++i) { | |
if(imgData.data[4*i+3]!=0) { | |
gray = 0.299*imgData.data[4*i]+0.587*imgData.data[4*i+1]+0.114*imgData.data[4*i+2]; | |
gray = Math.floor(gray); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<meta charset="utf-8"> | |
<title>logistic</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<meta charset="utf-8"> | |
<title>logistic</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
var canvas = document.getElementById('myCanvas'); |
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
/* | |
* main.cu | |
* | |
* Created on: 2014/11/05 | |
* Author: sase | |
*/ | |
/* | |
* tbbTest.cpp |
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
/* | |
* tbbTest.cpp | |
* | |
* Created on: 2014/11/05 | |
* Author: sase | |
*/ | |
#include <iostream> | |
#include <math.h> | |
#include <sys/time.h> |