|
自分の勉強した内容(プログラミング等)
に関するメモなどを綴る日記
× [PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
画像処理の授業で書いているprocessingのソース
画像を分割して、各部分ごとに異なる比率でコンボりゅーションをしようとしているのですが、今のところ上手くいってないんですよね 来週までにどうにかせねば・・・ import processing.video.*; int fream = 3; int offset = 0; Capture video; PImage [] img = new PImage[fream]; PImage result; float[][] c_matrix = {{0,-1,0}, {0,1,0}, {0,0,0}}; void setup(){ size(640,480); colorMode(RGB); video = new Capture(this,width,height,10); for(int i=0;i img[i] = createImage(width,height,RGB); } result = createImage(width,height,RGB); } void draw(){ if(video.available()){ offset++; if(offset == fream){ offset=0; } video.read(); result.loadPixels(); for (int y = 0; y < video.height; y++) { for (int x = 0; x < video.width; x++) { img[offset].pixels[y*video.width + x] = video.pixels[y*video.width + x]; } } for (int y = 0; y < video.height; y++) { for (int x = 0; x < video.width; x++) { float r_sum = 0.0,g_sum = 0.0,b_sum = 0.0; for(int w = 0; w< 3;w++){ for(int h = 0;h < 3;h++){ int tmp_x = x + h -1; int tmp_y = y + w -1; int tmp = img[offset].width * tmp_y + tmp_x; tmp = constrain(tmp,0,img[offset].pixels.length-1); r_sum += (red(img.pixels[tmp]) * c_matrix[w][h]); g_sum += (green(img.pixels[tmp]) * c_matrix[w][h]); b_sum += (blue(img.pixels[tmp]) * c_matrix[w][h]); } } r_sum = constrain(r_sum,0,255); g_sum = constrain(g_sum,0,255); b_sum = constrain(b_sum,0,255); color c = color(255-r_sum,255-g_sum,255-b_sum); int tmp = x + y * img.width; result.pixels[tmp] = c; if((offset+1+y*frame_num/480) } } PR
|
カレンダー
フリーエリア
最新トラックバック
プロフィール
HN:
矢部竜太
性別:
非公開
ブログ内検索
|