dslinux/user/pixil/packages/dvdview/dvdview/oldlibgfx/libvideogfx/graphics/visualize .cvsignore Makefile.am markblks.cc markblks.hh motionfield.cc motionfield.hh regions.cc regions.hh
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:55 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/oldlibgfx/libvideogfx/graphics/visualize
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/oldlibgfx/libvideogfx/graphics/visualize
Added Files:
.cvsignore Makefile.am markblks.cc markblks.hh motionfield.cc
motionfield.hh regions.cc regions.hh
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: markblks.hh ---
/*********************************************************************
libvideogfx/graphics/visualize/markblks.hh
purpose:
Mark some blocks.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
University Mannheim, Dept. Circuitry and Simulation
B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany
modifications:
30.Nov.1999 - Dirk Farin - first revision
*********************************************************************/
#ifndef LIBVIDEOGFX_GRAPHICS_VISUALIZE_MARKBLKS_HH
#define LIBVIDEOGFX_GRAPHICS_VISUALIZE_MARKBLKS_HH
#include "libvideogfx/graphics/datatypes/motionfield.hh"
#include "libvideogfx/graphics/basic/image.hh"
class BlockMarker
{
public:
BlockMarker() : d_color(255), d_size_h(16), d_size_v(16), d_inverse(false) { }
void SetLumaVal(Pixel p) { d_color=p; }
void SetSize(int h,int v) { d_size_h=h; d_size_v=v; }
void InverseMarkers(bool flag=true) { d_inverse=flag; }
void Overlay(Image_YUV<Pixel>&,const Bitmap<bool>&) const;
private:
Pixel d_color;
int d_size_h,d_size_v;
bool d_inverse;
};
#endif
--- NEW FILE: .cvsignore ---
Makefile
Makefile.in
*.lo
_libs
.libs
.deps
libvideogfx-graphics-visualize.la
--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/libvideogfx/graphics/visualize
noinst_LTLIBRARIES = libvideogfx-graphics-visualize.la
libvideogfx_graphics_visualize_la_SOURCES = \
markblks.cc \
markblks.hh \
motionfield.cc \
motionfield.hh \
regions.cc \
regions.hh
INCLUDES = \
-I$(top_srcdir)
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done
--- NEW FILE: motionfield.hh ---
/*********************************************************************
libvideogfx/graphics/visualize/motionfield.hh
purpose:
Overlay of motion vector field.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
University Mannheim, Dept. Circuitry and Simulation
B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany
modifications:
1999/Oct/29 - Dirk Farin - first revision
*********************************************************************/
#ifndef LIBVIDEOGFX_GRAPHICS_VISUALIZE_MOTIONFIELD_HH
#define LIBVIDEOGFX_GRAPHICS_VISUALIZE_MOTIONFIELD_HH
#include "libvideogfx/graphics/datatypes/motionfield.hh"
#include "libvideogfx/graphics/basic/image.hh"
class MotionFieldVisualizer
{
public:
MotionFieldVisualizer() : d_vectorcolor(255), d_drawarrows(false), d_scale(1.0) { }
void SetLumaVal(Pixel p) { d_vectorcolor=p; }
void DrawArrows(bool flag) { d_drawarrows=flag; }
void SetScale(double s) { d_scale=s; }
void Overlay(Image_YUV<Pixel>&,const MotionVectorField&,const Bitmap<bool>* colored=NULL) const;
private:
Pixel d_vectorcolor;
bool d_drawarrows;
double d_scale;
};
#endif
--- NEW FILE: markblks.cc ---
/*
* markblks.cc
*/
#include <iostream.h>
#include "markblks.hh"
#include "libvideogfx/graphics/draw/draw.hh"
void BlockMarker::Overlay(Image_YUV<Pixel>& img,const Bitmap<bool>& markerbm) const
{
Bitmap<Pixel>& bm = img.AskBitmap(Image<Pixel>::Bitmap_Y);
const bool*const* markp = markerbm.AskFrame_const();
ImageSpec_YUV spec;
img.GetParam(spec);
int w = markerbm.AskWidth();
int h = markerbm.AskHeight();
cout << spec.width << " " << d_size_h << " " << w << endl;
//352 8 22
assert(spec.width > (d_size_h*(w-1)) &&
spec.width <= (d_size_h* w ));
assert(spec.height > (d_size_v*(h-1)) &&
spec.height <= (d_size_v* h ));
for (int y=0;y<h;y++)
for (int x=0;x<w;x++)
{
if (markp[y][x] != d_inverse)
{
int x0 = x*d_size_h;
int y0 = y*d_size_v;
int x1 = x0+d_size_h-1;
int y1 = y0+d_size_v-1;
DrawLine(bm,x0,y0,x1,y0, d_color);
DrawLine(bm,x0,y1,x1,y1, d_color);
DrawLine(bm,x0,y0,x0,y1, d_color);
DrawLine(bm,x1,y0,x1,y1, d_color);
}
}
}
--- NEW FILE: regions.hh ---
/*********************************************************************
libvideogfx/graphics/visualize/regions.hh
purpose:
Create false color image of segmentation regions.
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
University Mannheim, Dept. Circuitry and Simulation
B 6,26 EG, room 0.10 / D-68131 Mannheim / Germany
modifications:
1999/Nov/02 - Dirk Farin - rewritten because original source
was lost :(((
*********************************************************************/
#ifndef LIBVIDEOGFX_GRAPHICS_VISUALIZE_REGIONS_HH
#define LIBVIDEOGFX_GRAPHICS_VISUALIZE_REGIONS_HH
#include "libvideogfx/graphics/basic/image.hh"
class Regions2FalseColors
{
public:
Regions2FalseColors();
void DrawRegions(const Bitmap<int>&,Image_RGB<Pixel>&);
private:
static const int c_InitialNRegions = 100;
static const int c_Increment = 100;
struct Color { Pixel r,g,b; };
Color* d_regioncolor;
int d_nRegions; // Region 0 is background, other regions: [1 ... d_nRegions].
void AssignColors(int from,int to);
};
class Regions2BoundaryImage
{
public:
void DrawRegions(const Bitmap<int>&,Image_YUV<Pixel>&);
};
template <class Pel,class APel> void OverlayAlphaMask(Bitmap<Pel>& bm,const Bitmap<APel>& alphamap,
Pixel val);
#endif
--- NEW FILE: motionfield.cc ---
/*
* motionfield.cc
*/
#include "motionfield.hh"
#include "libvideogfx/graphics/draw/draw.hh"
void MotionFieldVisualizer::Overlay(Image_YUV<Pixel>& img,const MotionVectorField& mvfld,const Bitmap<bool>* coloredbm) const
{
const MotionVector*const* mvptr = mvfld.mv.AskFrame_const();
Bitmap<Pixel>& bm = img.AskBitmap(Image<Pixel>::Bitmap_Y);
const bool*const* cbm;
if (coloredbm) cbm = coloredbm->AskFrame_const();
else cbm=NULL;
ImageSpec_YUV spec;
img.GetParam(spec);
assert(spec.width > (mvfld.blksize_h*(mvfld.nblks_h-1)) &&
spec.width <= (mvfld.blksize_h* mvfld.nblks_h ));
assert(spec.height > (mvfld.blksize_v*(mvfld.nblks_v-1)) &&
spec.height <= (mvfld.blksize_v* mvfld.nblks_v ));
for (int y=0;y<mvfld.nblks_v;y++)
for (int x=0;x<mvfld.nblks_h;x++)
{
int x0 = x*mvfld.blksize_h+mvfld.blksize_h/2;
int y0 = y*mvfld.blksize_v+mvfld.blksize_v/2;
double dx = mvptr[y][x].h;
double dy = mvptr[y][x].v;
dx *= d_scale;
dy *= d_scale;
double x1= x0+dx;
double y1= y0+dy;
Pixel color=d_vectorcolor;
if (cbm && !cbm[y][x]) color=0;
DrawLine(bm,x0,y0,(int)x1,(int)y1, color);
if (d_drawarrows && (abs(mvptr[y][x].h)>0 || abs(mvptr[y][x].v)>0))
{
double len = sqrt(dx*dx+dy*dy);
dx /= len;
dy /= len;
DrawLine(bm,x0,y0, (int)(x0+dy*3+dx*3),(int)(y0-dx*3+dy*3), color);
DrawLine(bm,x0,y0, (int)(x0-dy*3+dx*3),(int)(y0+dx*3+dy*3), color);
}
}
}
--- NEW FILE: regions.cc ---
/*
* regions.cc
*/
#include <stdlib.h>
#include "regions.hh"
Regions2FalseColors::Regions2FalseColors()
{
d_regioncolor = new Color[c_InitialNRegions+1];
d_nRegions=c_InitialNRegions;
d_regioncolor[0].r =
d_regioncolor[0].g =
d_regioncolor[0].b = 0;
AssignColors(1,c_InitialNRegions);
}
void Regions2FalseColors::DrawRegions(const Bitmap<int>& bm,Image_RGB<Pixel>& img)
{
const int*const* reg = bm.AskFrame_const();
ImageSpec spec;
spec.width = bm.AskWidth();
spec.height = bm.AskHeight();
spec.halign = 8;
img.Create(spec);
Pixel*const* rp = img.AskFrameR();
Pixel*const* gp = img.AskFrameG();
Pixel*const* bp = img.AskFrameB();
for (int y=0;y<spec.height;y++)
for (int x=0;x<spec.width;x++)
{
int region = reg[y][x];
if (region<0) region=0;
if (region > d_nRegions)
{
int nNewRegions = region+c_Increment;
Color* newmap = new Color[nNewRegions+1];
// keep old colors
for (int i=0;i<=d_nRegions;i++)
newmap[i] = d_regioncolor[i];
// assign new colors to new entries
delete[] d_regioncolor;
d_regioncolor = newmap;
AssignColors(d_nRegions+1,nNewRegions);
d_nRegions = nNewRegions;
}
rp[y][x] = d_regioncolor[region].r;
gp[y][x] = d_regioncolor[region].g;
bp[y][x] = d_regioncolor[region].b;
}
}
void Regions2FalseColors::AssignColors(int from,int to)
{
for (int i=from;i<=to;i++)
{
d_regioncolor[i].r = rand()&255;
d_regioncolor[i].g = rand()&255;
d_regioncolor[i].b = rand()&255;
}
}
void Regions2BoundaryImage::DrawRegions(const Bitmap<int>& regions,Image_YUV<Pixel>& img)
{
const int*const* sp = regions.AskFrame_const();
ImageSpec_YUV spec;
spec.width = regions.AskWidth();
spec.height = regions.AskHeight();
spec.nocolor = true;
spec.halign = 8;
img.Create(spec);
Pixel*const* dp = img.AskFrameY();
for (int y=0;y<spec.height-1;y++)
for (int x=0;x<spec.width-1;x++)
{
if (sp[y][x] != sp[y+1][x]) dp[y][x]=0; else
if (sp[y][x] != sp[y][x+1]) dp[y][x]=0; else dp[y][x]=255;
}
int x,y;
x=spec.width-1;
for (y=0;y<spec.height-1;y++)
{
if (sp[y][x] != sp[y+1][x]) dp[y][x]=0; else dp[y][x]=255;
}
y=spec.height-1;
for (int x=0;x<spec.width-1;x++)
{
if (sp[y][x] != sp[y][x+1]) dp[y][x]=0; else dp[y][x]=255;
}
// draw image border
for (int x=0;x<spec.width;x++)
dp[0][x]=dp[spec.height-1][x]=0;
for (int y=0;y<spec.height;y++)
dp[y][0]=dp[y][spec.width-1]=0;
}
template <class Pel,class APel> void OverlayAlphaMask(Bitmap<Pel>& bm,const Bitmap<APel>& alphamap,
Pixel val)
{
Pel*const* p = bm.AskFrame();
const APel*const* ap = alphamap.AskFrame_const();
assert(bm.AskWidth() ==alphamap.AskWidth());
assert(bm.AskHeight()==alphamap.AskHeight());
for (int y=0;y<bm.AskHeight();y++)
for (int x=0;x<bm.AskWidth();x++)
{
if (ap[y][x]<128 && ((x+y)%4)==0)
{ p[y][x]=val; }
else if (x>0 && ap[y][x] != ap[y][x-1])
{
if (ap[y][x]<ap[y][x-1]) p[y][x]=val; else p[y][x-1]=val;
}
else if (y>0 && ap[y][x] != ap[y-1][x])
{
if (ap[y][x]<ap[y-1][x]) p[y][x]=val; else p[y-1][x]=val;
}
}
}
template void OverlayAlphaMask(Bitmap<Pixel>&,const Bitmap<Pixel>&,Pixel);
//template class Bitmap<int>;
//#include "libvideogfx/graphics/basic/bitmap.cc"
More information about the dslinux-commit
mailing list