dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/visualize Makefile.am Makefile.in 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:43 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/visualize
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/libvideogfx/libvideogfx/graphics/visualize

Added Files:
	Makefile.am Makefile.in 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: 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: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.


SHELL = @SHELL@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

DESTDIR =

pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@

top_builddir = ../../..

ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@

NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
LIBTOOL = @LIBTOOL@
LIBVIDEOGFX_BINARY_AGE = @LIBVIDEOGFX_BINARY_AGE@
LIBVIDEOGFX_INTERFACE_AGE = @LIBVIDEOGFX_INTERFACE_AGE@
LIBVIDEOGFX_MAJOR_VERSION = @LIBVIDEOGFX_MAJOR_VERSION@
LIBVIDEOGFX_MICRO_VERSION = @LIBVIDEOGFX_MICRO_VERSION@
LIBVIDEOGFX_MINOR_VERSION = @LIBVIDEOGFX_MINOR_VERSION@
LIBVIDEOGFX_VERSION = @LIBVIDEOGFX_VERSION@
LN_S = @LN_S@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
X_LDFLAGS = @X_LDFLAGS@

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)

mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../../config.h
CONFIG_CLEAN_FILES = 
LTLIBRARIES =  $(noinst_LTLIBRARIES)


DEFS = @DEFS@ -I. -I$(srcdir) -I../../..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libvideogfx_graphics_visualize_la_LDFLAGS = 
libvideogfx_graphics_visualize_la_LIBADD = 
libvideogfx_graphics_visualize_la_OBJECTS =  markblks.lo motionfield.lo \
regions.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON =  Makefile.am Makefile.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = gtar
GZIP_ENV = --best
DEP_FILES =  .deps/markblks.P .deps/motionfield.P .deps/regions.P
SOURCES = $(libvideogfx_graphics_visualize_la_SOURCES)
OBJECTS = $(libvideogfx_graphics_visualize_la_OBJECTS)

all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .lo .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
	cd $(top_srcdir) && $(AUTOMAKE) --gnu libvideogfx/graphics/visualize/Makefile

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
	cd $(top_builddir) \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status


mostlyclean-noinstLTLIBRARIES:

clean-noinstLTLIBRARIES:
	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)

distclean-noinstLTLIBRARIES:

maintainer-clean-noinstLTLIBRARIES:

.s.o:
	$(COMPILE) -c $<

.S.o:
	$(COMPILE) -c $<

mostlyclean-compile:
	-rm -f *.o core *.core

clean-compile:

distclean-compile:
	-rm -f *.tab.c

maintainer-clean-compile:

.s.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.S.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs

distclean-libtool:

maintainer-clean-libtool:

libvideogfx-graphics-visualize.la: $(libvideogfx_graphics_visualize_la_OBJECTS) $(libvideogfx_graphics_visualize_la_DEPENDENCIES)
	$(CXXLINK)  $(libvideogfx_graphics_visualize_la_LDFLAGS) $(libvideogfx_graphics_visualize_la_OBJECTS) $(libvideogfx_graphics_visualize_la_LIBADD) $(LIBS)
.cc.o:
	$(CXXCOMPILE) -c $<
.cc.lo:
	$(LTCXXCOMPILE) -c $<

tags: TAGS

ID: $(HEADERS) $(SOURCES) $(LISP)
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	here=`pwd` && cd $(srcdir) \
	  && mkid -f$$here/ID $$unique $(LISP)

TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
	tags=; \
	here=`pwd`; \
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)

mostlyclean-tags:

clean-tags:

distclean-tags:
	-rm -f TAGS ID

maintainer-clean-tags:

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = libvideogfx/graphics/visualize

distdir: $(DISTFILES)
	here=`cd $(top_builddir) && pwd`; \
	top_distdir=`cd $(top_distdir) && pwd`; \
	distdir=`cd $(distdir) && pwd`; \
	cd $(top_srcdir) \
	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu libvideogfx/graphics/visualize/Makefile
	@for file in $(DISTFILES); do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    cp -pr $$d/$$file $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done

DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)

-include $(DEP_FILES)

mostlyclean-depend:

clean-depend:

distclean-depend:
	-rm -rf .deps

maintainer-clean-depend:

%.o: %.c
	@echo '$(COMPILE) -c $<'; \
	$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.c
	@echo '$(LTCOMPILE) -c $<'; \
	$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp

%.o: %.cc
	@echo '$(CXXCOMPILE) -c $<'; \
	$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.cc
	@echo '$(LTCXXCOMPILE) -c $<'; \
	$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am

install-data-am:
install-data: install-data-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:


mostlyclean-generic:

clean-generic:

distclean-generic:
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*

maintainer-clean-generic:
mostlyclean-am:  mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
		mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
		mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am:  clean-noinstLTLIBRARIES clean-compile clean-libtool \
		clean-tags clean-depend clean-generic mostlyclean-am

clean: clean-am

distclean-am:  distclean-noinstLTLIBRARIES distclean-compile \
		distclean-libtool distclean-tags distclean-depend \
		distclean-generic clean-am
	-rm -f libtool

distclean: distclean-am

maintainer-clean-am:  maintainer-clean-noinstLTLIBRARIES \
		maintainer-clean-compile maintainer-clean-libtool \
		maintainer-clean-tags maintainer-clean-depend \
		maintainer-clean-generic distclean-am
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean


.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

--- 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