summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a539cb)
raw | patch | inline | side by side (parent: 8a539cb)
author | ishmal <ishmal@users.sourceforge.net> | |
Thu, 27 Jul 2006 09:12:36 +0000 (09:12 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Thu, 27 Jul 2006 09:12:36 +0000 (09:12 +0000) |
src/trace/siox.cpp | patch | blob | history | |
src/trace/siox.h | patch | blob | history | |
src/trace/trace.cpp | patch | blob | history | |
src/trace/trace.h | patch | blob | history |
diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp
index ff894a48c542cbddd383cc7a6c379cbf5a627f08..84f3b39d287849e599fa9f38fd2ce7b9b6c19bcb 100644 (file)
--- a/src/trace/siox.cpp
+++ b/src/trace/siox.cpp
if (!_clab_inited_)
{
cbrt_table[0] = pow(float(1)/float(ROOT_TAB_SIZE*2), 0.3333);
- qn_table[0] = pow(float(1)/float(ROOT_TAB_SIZE*2), 0.2);
+ qn_table[0] = pow(float(1)/float(ROOT_TAB_SIZE*2), 0.2);
for(int i = 1; i < ROOT_TAB_SIZE +1; i++)
{
cbrt_table[i] = pow(float(i)/float(ROOT_TAB_SIZE), 0.3333);
Tupel(float minBgDistArg, long indexMinBgArg,
float minFgDistArg, long indexMinFgArg)
{
- minBgDist = minBgDistArg;
- indexMinBg = indexMinBgArg;
- minFgDist = minFgDistArg;
- indexMinFg = indexMinFgArg;
+ minBgDist = minBgDistArg;
+ indexMinBg = indexMinBgArg;
+ minFgDist = minFgDistArg;
+ indexMinFg = indexMinFgArg;
}
Tupel(const Tupel &other)
{
- minBgDist = other.minBgDist;
- indexMinBg = other.indexMinBg;
- minFgDist = other.minFgDist;
- indexMinFg = other.indexMinFg;
+ minBgDist = other.minBgDist;
+ indexMinBg = other.indexMinBg;
+ minFgDist = other.minFgDist;
+ indexMinFg = other.indexMinFg;
}
Tupel &operator=(const Tupel &other)
{
- minBgDist = other.minBgDist;
- indexMinBg = other.indexMinBg;
- minFgDist = other.minFgDist;
- indexMinFg = other.indexMinFg;
- return *this;
+ minBgDist = other.minBgDist;
+ indexMinBg = other.indexMinBg;
+ minFgDist = other.minFgDist;
+ indexMinFg = other.indexMinFg;
+ return *this;
}
virtual ~Tupel()
{}
if (cmdata) delete[] cmdata;
}
+/**
+ * Error logging
+ */
+void SioxImage::error(char *fmt, ...)
+{
+ char msgbuf[256];
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(msgbuf, 255, fmt, args);
+ va_end(args) ;
+#ifdef HAVE_GLIB
+ g_warning("SioxImage error: %s\n", msgbuf);
+#else
+ fprintf(stderr, "SioxImage error: %s\n", msgbuf);
+#endif
+}
+
+
/**
* Returns true if the previous operation on this image
* was successful, else false.
unsigned int y,
unsigned int pixval)
{
- if (x > width || y > height)
+ if (x >= width || y >= height)
+ {
+ error("setPixel: out of bounds (%d,%d)/(%d,%d)",
+ x, y, width, height);
return;
+ }
unsigned long offset = width * y + x;
pixdata[offset] = pixval;
}
unsigned int g,
unsigned int b)
{
- if (x > width || y > height)
+ if (x >= width || y >= height)
+ {
+ error("setPixel: out of bounds (%d,%d)/(%d,%d)",
+ x, y, width, height);
return;
+ }
unsigned long offset = width * y + x;
unsigned int pixval = ((a << 24) & 0xff000000) |
((r << 16) & 0x00ff0000) |
*/
unsigned int SioxImage::getPixel(unsigned int x, unsigned int y)
{
- if (x > width || y > height)
+ if (x >= width || y >= height)
+ {
+ error("getPixel: out of bounds (%d,%d)/(%d,%d)",
+ x, y, width, height);
return 0L;
+ }
unsigned long offset = width * y + x;
return pixdata[offset];
}
unsigned int y,
float confval)
{
- if (x > width || y > height)
+ if (x >= width || y >= height)
+ {
+ error("setConfidence: out of bounds (%d,%d)/(%d,%d)",
+ x, y, width, height);
return;
+ }
unsigned long offset = width * y + x;
cmdata[offset] = confval;
}
*/
float SioxImage::getConfidence(unsigned int x, unsigned int y)
{
- if (x > width || y > height)
+ if (x >= width || y >= height)
+ {
+ g_warning("getConfidence: out of bounds (%d,%d)/(%d,%d)",
+ x, y, width, height);
return 0.0;
+ }
unsigned long offset = width * y + x;
return cmdata[offset];
}
*/
void Siox::normalizeMatrix(float *cm, int cmSize)
{
- float max = *std::max(cm, cm + cmSize);
+ float max= -1000000.0f;
+ for (int i=0; i<cmSize; i++)
+ if (max<cm[i] > max)
+ max=cm[i];
+ //good to use STL, but max() is not iterative
+ //float max = *std::max(cm, cm + cmSize);
if (max<=0.0 || max==1.0)
return;
diff --git a/src/trace/siox.h b/src/trace/siox.h
index 67c3902e955b259703a35373a47c4deb53559118..8f6f90ff9887438771db1d88e87f32be08201016 100644 (file)
--- a/src/trace/siox.h
+++ b/src/trace/siox.h
* Confidence matrix data
*/
float *cmdata;
+
+private:
+
+ /**
+ * Error logging
+ */
+ void error(char *fmt, ...);
+
};
diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp
index 3173d057eb60ace164a9553f2d74ab9f48d2ab7e..6e5e0d171ba3f2e366e486f826a9d0240ed9eee8 100644 (file)
--- a/src/trace/trace.cpp
+++ b/src/trace/trace.cpp
-/*
+/**
* A generic interface for plugging different
* autotracers into Inkscape.
*
}
else
{
+ //g_message("miss!\n");
//dumpMap->setPixelLong(dumpMap, col, row,
// simage.getPixel(col, row));
simage.setConfidence(col, row,
diff --git a/src/trace/trace.h b/src/trace/trace.h
index 02290436ad7a96e49da27a36880394ce6fdb2c2d..1341e3d464871883b69015e13af1171acbddf4db 100644 (file)
--- a/src/trace/trace.h
+++ b/src/trace/trace.h
-/*
+/**
* A generic interface for plugging different
* autotracers into Inkscape.
*
* Authors:
* Bob Jamison <rjamison@titan.com>
*
- * Copyright (C) 2004 Bob Jamison
+ * Copyright (C) 2004-2006 Bob Jamison
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/