#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
| HxImageRep L_HXIMAGEREP | HxDisplayOF (HxImageRep in, int scale_x, int scale_y, double mul_x, double mul_y, int pixelsize) |
| Display of optical flow. More... | |
|
||||||||||||||||||||||||||||
|
Display of optical flow.
00252 {
00253 HxSizes sz= im.sizes();
00254
00255 HxVec3Byte bkcolor(200,200,200);
00256
00257 HxImageRep out_f = HxMakeFromValue(HXIMAGESIG2DVEC3BYTE,sz,(200,200,200));
00258 HxVec3Double color(0,0,255);
00259
00260 int fx = sz.x();
00261 int fy = sz.y();
00262 int ox = fx*pixelsize;
00263 int oy = fy*pixelsize;
00264
00265 for(int y = 0; y < fy; y += scale_y ) {
00266 for(int x = 0; x < fx; x += scale_x ) {
00267 long npix = y*fx + x;
00268 float vu = -(im.getAt(x,y).HxVec2DoubleValue().x());
00269 float vv = -(im.getAt(x,y).HxVec2DoubleValue().y());
00270
00271 int qx = mul_x*vu;
00272 int qy = mul_y*vv;
00273
00274 if(qx!=0 || qy!=0)
00275 {
00276
00277 int xn = pixelsize*x;
00278 int yn = pixelsize*y;
00279
00280 int dx = xn + qx; dx = max(dx,0); dx = min((ox-1),dx);
00281 int dy = yn + qy; dy = max(dy,0); dy = min((oy-1),dy);
00282 HxDrawLine(out_f, xn, yn, dx, dy, color);
00283
00284 int tx = dx - ((qx - qy)>>3); tx = max(tx,0); tx = min((ox-1),tx);
00285 int ty = dy - ((qy + qx)>>3); ty = max(ty,0); ty = min((oy-1),ty);
00286 HxDrawLine(out_f, dx, dy, tx, ty, HxVec3Double(255,0,0));
00287
00288 tx = dx - ((qx + qy)>>3); tx = max(tx,0); tx = min((ox-1),tx);
00289 ty = dy - ((qy - qx)>>3); ty = max(ty,0); ty = min((oy-1),ty);
00290 HxDrawLine(out_f, dx, dy, tx, ty, HxVec3Double(255,0,0));
00291 }
00292 }
00293 }
00294 return out_f;
00295 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001