You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(28) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(11) |
Feb
(51) |
Mar
(219) |
Apr
(63) |
May
(7) |
Jun
(91) |
Jul
(97) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 03:19:26
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/glcm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/src/methods/glcm Modified Files: glcm.cpp Log Message: All managers classes now use self() (global instance), which is much better than being passing pointers all around Index: glcm.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/glcm/glcm.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- glcm.cpp 2 Apr 2005 20:12:10 -0000 1.7 +++ glcm.cpp 23 Jun 2005 03:18:47 -0000 1.8 @@ -98,7 +98,7 @@ if (backend != 0) { - if (m_testingPattern) + if (m_testingData) backend->parseResults(result); else backend->parseSampleResults(result, imgClass); |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 03:18:59
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/snns In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/src/plugins/snns Modified Files: snns.cpp Log Message: All managers classes now use self() (global instance), which is much better than being passing pointers all around Index: snns.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/snns/snns.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- snns.cpp 19 Jun 2005 02:03:55 -0000 1.4 +++ snns.cpp 23 Jun 2005 03:18:49 -0000 1.5 @@ -70,8 +70,8 @@ m_tempFile = new KTempFile(); m_tempFile->setAutoDelete(false); - m_input = imageManager()->activeFeaturesCount(); - m_output = imageManager()->sampleCount(); + m_input = KTImageManager::self()->activeFeaturesCount(); + m_output = KTImageManager::self()->sampleCount(); if (tmpHeaderFile.file()->isOpen() && m_tempFile->file()->isOpen()) { @@ -86,7 +86,7 @@ m_contents += "No. of output units : " + QString::number( m_output ); m_contents += "\n\n"; - QStringList names = imageManager()->activeFeatureNames(); + QStringList names = KTImageManager::self()->activeFeatureNames(); QString features; for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) { @@ -100,7 +100,7 @@ m_patterns.clear(); m_max.resize(m_input, 0); m_min.resize(m_input, 0); - imageManager()->generatePatternFile(0, this); + KTImageManager::self()->calculateSampleData(0, this); QValueList<pattern>::iterator end = m_patterns.end(); @@ -165,8 +165,8 @@ if (!dest.isEmpty()) { - m_input = imageManager()->activeFeaturesCount(); - m_output = imageManager()->sampleCount(); + m_input = KTImageManager::self()->activeFeaturesCount(); + m_output = KTImageManager::self()->sampleCount(); m_sampleImage = dest; m_patternCount = 0; @@ -183,12 +183,12 @@ m_contents += "generated at " + QDateTime::currentDateTime().toString(); m_contents += "\n\n\n"; m_contents += "No. of patterns : %1\n"; - m_contents += "No. of input units : " + QString::number( imageManager()->activeFeaturesCount() ); + m_contents += "No. of input units : " + QString::number( KTImageManager::self()->activeFeaturesCount() ); m_contents += "\n"; m_contents += "No. of output units : 0\n"; m_contents += "\n\n"; - QStringList names = imageManager()->activeFeatureNames(); + QStringList names = KTImageManager::self()->activeFeatureNames(); QString features; for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) { @@ -202,7 +202,7 @@ m_max.resize(m_input, 0); m_min.resize(m_input, 0); m_first = true; - imageManager()->generateTestPatFile(0, this); + KTImageManager::self()->calculateTestData(0, this); float dif[m_input]; for (int i=0; i < m_input; ++i) |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 03:18:58
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/src/plugins Modified Files: Makefile.am Log Message: All managers classes now use self() (global instance), which is much better than being passing pointers all around Index: Makefile.am =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.am 5 Mar 2005 21:14:04 -0000 1.5 +++ Makefile.am 23 Jun 2005 03:18:48 -0000 1.6 @@ -1,3 +1,3 @@ INCLUDES = $(all_includes) -I$(srcdir)/libkimageprocess -I$(srcdir)/libktimgview METASOURCES = AUTO -SUBDIRS = testbed snns lwnn fann +SUBDIRS = snns lwnn fann |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 03:18:57
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/lwnn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/src/plugins/lwnn Modified Files: lwnn.cpp Log Message: All managers classes now use self() (global instance), which is much better than being passing pointers all around Index: lwnn.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/lwnn/lwnn.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lwnn.cpp 27 Feb 2005 20:52:39 -0000 1.3 +++ lwnn.cpp 23 Jun 2005 03:18:48 -0000 1.4 @@ -72,8 +72,8 @@ if (m_network) delete m_network; - m_input = imageManager()->activeFeaturesCount(); - m_output = imageManager()->sampleCount(); + m_input = KTImageManager::self()->activeFeaturesCount(); + m_output = KTImageManager::self()->sampleCount(); int layers[ m_hiddenLayers + 2 ]; @@ -88,7 +88,7 @@ m_error = 0.0; //start batch training net_begin_batch(m_network); - imageManager()->generatePatternFile(0, this); + KTImageManager::self()->calculateSampleData(0, this); net_end_batch(m_network); } @@ -97,7 +97,7 @@ if (!m_network) return; - KTImage *img = imageManager()->testingImage(); + KTImage *img = KTImageManager::self()->testingImage(); m_width = img->width(); m_height = img->height(); @@ -109,7 +109,7 @@ m_colorStep = 255/(m_output-1); kdDebug() << "Color step is: " << m_colorStep << endl; - imageManager()->generateTestPatFile(0, this); + KTImageManager::self()->calculateTestData(0, this); //save the image |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 03:18:57
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/src/methods/hsvcm Modified Files: hsvcm.cpp Log Message: All managers classes now use self() (global instance), which is much better than being passing pointers all around Index: hsvcm.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/hsvcm.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- hsvcm.cpp 19 Jun 2005 02:02:43 -0000 1.10 +++ hsvcm.cpp 23 Jun 2005 03:18:47 -0000 1.11 @@ -106,7 +106,7 @@ if (backend != 0) { - if (m_testingPattern) + if (m_testingData) backend->parseResults(result); else backend->parseSampleResults(result, imgClass); |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 03:18:57
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/fann In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17877/src/plugins/fann Modified Files: fann.cpp fann.h Log Message: All managers classes now use self() (global instance), which is much better than being passing pointers all around Index: fann.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/fann/fann.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- fann.h 10 Apr 2005 20:42:58 -0000 1.2 +++ fann.h 23 Jun 2005 03:18:48 -0000 1.3 @@ -96,4 +96,4 @@ void slotClassifyImage(); }; -#endif \ No newline at end of file +#endif Index: fann.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/fann/fann.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- fann.cpp 19 Jun 2005 02:03:16 -0000 1.3 +++ fann.cpp 23 Jun 2005 03:18:48 -0000 1.4 @@ -70,8 +70,8 @@ if (m_network) fann_destroy(m_network); - m_input = imageManager()->activeFeaturesCount(); - m_output = imageManager()->sampleCount(); + m_input = KTImageManager::self()->activeFeaturesCount(); + m_output = KTImageManager::self()->sampleCount(); //create the network m_network = fann_create(m_connectionRate, m_learningRate, 3, m_input, m_input, m_output); @@ -82,7 +82,7 @@ m_error = 0.0; //start training - imageManager()->generatePatternFile(0, this); + KTImageManager::self()->calculateSampleData(0, this); struct fann_train_data tfanndata; float *tempf_outputs; @@ -150,7 +150,7 @@ if (!m_network) return; - KTImage *img = imageManager()->testingImage(); + KTImage *img = KTImageManager::self()->testingImage(); m_width = img->width(); m_height = img->height(); @@ -162,7 +162,7 @@ m_colorStep = 255/(m_output-1); kdDebug() << "Color step is: " << m_colorStep << endl; m_patterns.clear(); - imageManager()->generateTestPatFile(0, this); + KTImageManager::self()->calculateTestData(0, this); //save the image KURL dest = KFileDialog::getSaveURL(QString::null,i18n("*.pgm|PGM File"),0,i18n("Save classified image")); @@ -239,4 +239,4 @@ m_patterns.append(pat); } -#include "fann.moc" \ No newline at end of file +#include "fann.moc" |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-23 02:54:00
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/testbed In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5083 Removed Files: Makefile.am kimageprocess_testbed.desktop kimageprocess_testbed.rc testbed.cpp testbed.h Log Message: Removed useless testbed plugin --- kimageprocess_testbed.rc DELETED --- --- Makefile.am DELETED --- --- kimageprocess_testbed.desktop DELETED --- --- testbed.h DELETED --- --- testbed.cpp DELETED --- |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-19 02:04:11
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/snns In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7222 Modified Files: snns.cpp snns.h Log Message: - Save all values in memory before writing to the file - Normalize all values to get more sane results Index: snns.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/snns/snns.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- snns.cpp 26 Feb 2005 20:37:42 -0000 1.3 +++ snns.cpp 19 Jun 2005 02:03:55 -0000 1.4 @@ -69,6 +69,9 @@ tmpHeaderFile.setAutoDelete(false); m_tempFile = new KTempFile(); m_tempFile->setAutoDelete(false); + + m_input = imageManager()->activeFeaturesCount(); + m_output = imageManager()->sampleCount(); if (tmpHeaderFile.file()->isOpen() && m_tempFile->file()->isOpen()) { @@ -78,9 +81,9 @@ m_contents += "generated at " + QDateTime::currentDateTime().toString(); m_contents += "\n\n\n"; m_contents += "No. of patterns : %1\n"; - m_contents += "No. of input units : " + QString::number( imageManager()->activeFeaturesCount() ); + m_contents += "No. of input units : " + QString::number( m_input ); m_contents += "\n"; - m_contents += "No. of output units : " + QString::number( imageManager()->sampleCount() ); + m_contents += "No. of output units : " + QString::number( m_output ); m_contents += "\n\n"; QStringList names = imageManager()->activeFeatureNames(); @@ -92,8 +95,51 @@ m_contents += "#" + features + "\n\n"; m_stream.setDevice(m_tempFile->file()); + + m_first = true; + m_patterns.clear(); + m_max.resize(m_input, 0); + m_min.resize(m_input, 0); imageManager()->generatePatternFile(0, this); + QValueList<pattern>::iterator end = m_patterns.end(); + + float dif[m_input]; + for (int i=0; i < m_input; ++i) + dif[i] = m_max[i] - m_min[i]; + + for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) + { + QString line = ""; + for ( int i=0; i < m_input; ++i ) + { + line += " " + QString::number((*it).inputs[i]); + (*it).inputs[i] = ((*it).inputs[i] - m_min[i]) * 100 / dif[i]; + } + kdDebug() << line << endl; + } + + for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) + { + QString line = ""; + + for ( int i=0; i < m_input; ++i ) + line.sprintf("%s %.5f", line.ascii(), (*it).inputs[i]); + + m_stream << line.stripWhiteSpace() << endl; + + QString temp=""; + for (int j = 1; j <= m_output; j++) + if (j == (*it).sampleClass) + temp += "1 "; + else + temp += "0 "; + + m_stream << temp.stripWhiteSpace() << endl << endl; + m_patternCount++; + + } + //save the pattern file QTextStream streamHeader(tmpHeaderFile.file()); streamHeader << m_contents.arg(m_patternCount); @@ -116,9 +162,12 @@ void KTSNNSPlugin::slotGenerateTestingPattern() { KURL dest = KFileDialog::getSaveURL(QString::null,i18n("*.pat|Pattern files"),0,i18n("Save pattern")); - + if (!dest.isEmpty()) { + m_input = imageManager()->activeFeaturesCount(); + m_output = imageManager()->sampleCount(); + m_sampleImage = dest; m_patternCount = 0; KTempFile tmpHeaderFile; @@ -148,8 +197,44 @@ m_contents += "#" + features + "\n\n"; m_stream.setDevice(m_tempFile->file()); + + m_patterns.clear(); + m_max.resize(m_input, 0); + m_min.resize(m_input, 0); + m_first = true; imageManager()->generateTestPatFile(0, this); + float dif[m_input]; + for (int i=0; i < m_input; ++i) + dif[i] = m_max[i] - m_min[i]; + + QValueList<pattern>::iterator end = m_patterns.end(); + for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) + { + QString line = ""; + for ( int i=0; i < m_input; ++i ) + { + line += " " + QString::number((*it).inputs[i]); + (*it).inputs[i] = ((*it).inputs[i] - m_min[i]) * 100 / dif[i]; + } + kdDebug() << line << endl; + } + + for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) + { + QString line = ""; + + //append the count (just for debuggin purposes ) + m_stream << "#" << ++m_patternCount << endl; + + for ( int i=0; i < m_input; ++i) + line.sprintf("%s %.5f", line.ascii(), (*it).inputs[i]); + + line = line + "\n"; + m_stream << line.stripWhiteSpace() << endl << endl; + + } + //save the pattern file QTextStream streamHeader(tmpHeaderFile.file()); streamHeader << m_contents.arg(m_patternCount); @@ -175,38 +260,69 @@ void KTSNNSPlugin::parseResults(const QValueList<float> &results) { - QString line = ""; + float *inputs = new float[m_input]; + + QValueList<float>::const_iterator it; + + if (m_first) + { + for (int j = 0; j < m_input; ++j) + m_min[j] = m_max[j] = inputs[j]; + m_first = false; + } - //append the count (just for debuggin purposes - m_stream << "#" << ++m_patternCount << endl; + int i = 0; - QValueList<float>::const_iterator it; - for ( it = results.begin(); it != results.end(); ++it ) - line.sprintf("%s %.5f", line.ascii(), (*it)); + //prepare the input + for ( it = results.begin(); it != results.end(); ++it) + { + inputs[i] = (*it); + if (inputs[i] > m_max[i]) + m_max[i] = inputs[i]; + else if (inputs[i] < m_min[i]) + m_min[i] = inputs[i]; + ++i; +} + + pattern pat; + pat.inputs = inputs; + pat.sampleClass = 0; + m_patterns.append(pat); - line = line + "\n"; - m_stream << line.stripWhiteSpace() << endl << endl; } void KTSNNSPlugin::parseSampleResults(const QValueList<float> &results, int sampleClass) { - QString line = ""; - + float *inputs = new float[m_input]; + QValueList<float>::const_iterator it; - for ( it = results.begin(); it != results.end(); ++it ) - line.sprintf("%s %.5f", line.ascii(), (*it)); - m_stream << line.stripWhiteSpace() << endl; + + if (m_first) + { + for (int j = 0; j < m_input; ++j) + m_min[j] = m_max[j] = inputs[j]; + m_first = false; + } + + int i = 0; - QString temp=""; - for (int j = 1; j <= imageManager()->sampleCount(); j++) - if (j == sampleClass) - temp += "1 "; - else - temp += "0 "; + //prepare the input + for ( it = results.begin(); it != results.end(); ++it) + { + inputs[i] = (*it); + if (inputs[i] > m_max[i]) + m_max[i] = inputs[i]; + else if (inputs[i] < m_min[i]) + m_min[i] = inputs[i]; + ++i; + } + + pattern pat; + pat.inputs = inputs; + pat.sampleClass = sampleClass; + m_patterns.append(pat); - m_stream << temp.stripWhiteSpace() << endl << endl; - m_patternCount++; } Index: snns.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/snns/snns.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- snns.h 26 Feb 2005 23:35:26 -0000 1.4 +++ snns.h 19 Jun 2005 02:03:56 -0000 1.5 @@ -24,6 +24,7 @@ #include <ktclassifbackend.h> #include <qvaluelist.h> +#include <qvaluevector.h> #include <kurl.h> @@ -31,6 +32,12 @@ class KTImage; class KTempFile; +typedef struct +{ + float *inputs; + int sampleClass; +} pattern; + /** A SNNS backend plugin @author Gustavo Pichorim Boiko @@ -62,6 +69,13 @@ KTempFile *m_tempFile; QTextStream m_stream; + QValueList<pattern> m_patterns; + + int m_input; + int m_output; + QValueVector<float> m_min; + QValueVector<float> m_max; + bool m_first; private slots: void slotGenerateTrainingPattern(); |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-19 02:03:25
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/fann In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7076 Modified Files: fann.cpp Log Message: - Clear the pattern list before appending more results Index: fann.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/fann/fann.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- fann.cpp 10 Apr 2005 20:42:58 -0000 1.2 +++ fann.cpp 19 Jun 2005 02:03:16 -0000 1.3 @@ -161,7 +161,7 @@ m_img = new QImage(m_width,m_height,32); m_colorStep = 255/(m_output-1); kdDebug() << "Color step is: " << m_colorStep << endl; - + m_patterns.clear(); imageManager()->generateTestPatFile(0, this); //save the image |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-19 02:02:55
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6902 Modified Files: hsvcm.cpp Log Message: - Added code to be able to test with distance > 1 Index: hsvcm.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/hsvcm.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- hsvcm.cpp 2 Jun 2005 02:09:16 -0000 1.9 +++ hsvcm.cpp 19 Jun 2005 02:02:43 -0000 1.10 @@ -113,15 +113,15 @@ } //delete the GLCM's after calculating - for (int d=0; d < 9; d++) + for (int dir=0; dir < 9; dir++) { for (int i=0;i < m_sizeV; i++) { for (int j=0;j < m_sizeH; j++) - delete [] m_cm[d][i][j]; - delete [] m_cm[d][i]; + delete [] m_cm[dir][i][j]; + delete [] m_cm[dir][i]; } - delete m_cm[d]; + delete m_cm[dir]; } } @@ -130,15 +130,16 @@ QColor color; //initialize the matrices with zeros - for (int d=0; d < 9; d++) + for (int dir=0; dir < 9; dir++) for (int i=0; i < m_sizeV; i++) for (int j=0; j < m_sizeH; j++) for (int k=0; k < m_sizeS; k++) - m_cm[d][i][j][k] = 0; + m_cm[dir][i][j][k] = 0; int width = m_img->width(); int height = m_img->height(); - + int d = 1; // distance between pixels + // Convert all RGB to HSV struct s_hsv { @@ -161,10 +162,10 @@ for (int y = 0; y < height; ++y) { //nine directions - for (int d = 0; d < 9; d++) + for (int dir = 0; dir < 9; dir++) { int xs,ys,xv,yv; - switch (d) + switch (dir) { case 0: /** @@ -183,11 +184,11 @@ * / * V */ - xv = (x == 0 ? width-1 : x-1); - yv = (y == height-1 ? 0 : y+1); + xv = (x-d < 0 ? width-d : x-d); + yv = (y+d >= height ? d-1 : y+d); - xs = (x == width-1 ? 0 : x+1); - ys = (y == 0 ? height-1 : y-1); + xs = (x+d >= width ? d-1 : x+d); + ys = (y-d < 0 ? height-d : y-d); break; case 2: /** @@ -198,8 +199,8 @@ * V */ xs = xv = x; - yv = (y == height-1 ? 0 : y+1); - ys = (y == 0 ? height-1 : y-1); + yv = (y+d >= height ? d-1 : y+d); + ys = (y-d < 0 ? height-d : y-d); break; case 3: /** @@ -209,11 +210,11 @@ * \ * V */ - xv = (x == width-1 ? 0 : x+1); - yv = (y == height-1 ? 0 : y+1); + xv = (x+d >= width ? d-1 : x+d); + yv = (y+d >= height ? d-1 : y+d); - xs = (x == 0 ? width-1 : x-1); - ys = (y == 0 ? height-1 : y-1); + xs = (x-d < 0 ? width-d : x-d); + ys = (y-d < 0 ? height-d : y-d); break; case 4: /** @@ -222,8 +223,8 @@ * */ yv = ys = y; - xv = (x == width-1 ? 0 : x+1); - xs = (x == 0 ? width-1 : x-1); + xv = (x+d >= width ? d-1 : x+d); + xs = (x-d < 0 ? width-d : x-d); break; case 5: /** @@ -233,11 +234,11 @@ * / * S */ - xv = (x == width-1 ? 0 : x+1); - yv = (y == 0 ? height-1 : y-1); + xv = (x+d >= width ? d-1 : x+d); + yv = (y-d < 0 ? height-d : y-d); - xs = (x == 0 ? width-1 : x-1); - ys = (y == height-1 ? 0 : y+1); + xs = (x-d < 0 ? width-d : x-d); + ys = (y+d >= height ? d-1 : y+d); break; case 6: /** @@ -248,8 +249,8 @@ * S */ xs = xv = x; - yv = (y == 0 ? height-1 : y-1); - ys = (y == height-1 ? 0 : y+1); + yv = (y-d < 0 ? height-d : y-d); + ys = (y+d >= height ? d-1 : y+d); break; case 7: /** @@ -259,11 +260,11 @@ * \ * S */ - xv = (x == 0 ? width-1 : x-1); - yv = (y == 0 ? height-1 : y-1); + xv = (x-d < 0 ? width-d : x-d); + yv = (y-d < 0 ? height-d : y-d); - xs = (x == width-1 ? 0 : x+1); - ys = (y == height-1 ? 0 : y+1); + xs = (x+d >= width ? d-1 : x+d); + ys = (y+d >= height ? d-1 : y+d); break; case 8: /** @@ -272,11 +273,12 @@ * */ yv = ys = y; - xv = (x == 0 ? width-1 : x-1); - xs = (x == width-1 ? 0 : x+1); + xv = (x-d < 0 ? width-d : x-d); + xs = (x+d >= width ? d-1 : x+d); break; } - m_cm[d][hsv[xv][yv].V][hsv[x][y].H][hsv[xs][ys].S]++; + //explaining m_cm[ direction, V, H, S ] ++; + m_cm[dir][hsv[xv][yv].V][hsv[x][y].H][hsv[xs][ys].S]++; } } @@ -284,11 +286,11 @@ float max = width * height; // Normalize the matrices //kdDebug() << "Normalizing the matrices..." << endl; - for (int d=0; d < 9; d++) + for (int dir=0; dir < 9; dir++) for (int i=0; i < m_sizeV; i++) for (int j=0; j < m_sizeH; j++) for (int k=0; k < m_sizeS; k++) - m_cm[d][i][j][k] /= max; + m_cm[dir][i][j][k] /= max; } @@ -296,6 +298,7 @@ { return m_cm[direction]; } + int KTHSVCM::dataSize(int index) { switch (index) |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-02 02:11:52
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/contrast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21701/src/methods/hsvcm/features/contrast Modified Files: contrast.cpp Log Message: - Changed from cmSize[3] to cmSizeV, cmSizeH and cmSizeS (readability) Index: contrast.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/contrast/contrast.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- contrast.cpp 28 May 2005 21:29:27 -0000 1.5 +++ contrast.cpp 2 Jun 2005 02:11:39 -0000 1.6 @@ -50,64 +50,64 @@ float KTHSVCMContrast::_calculate(KTImage *img, int direction) { - int cmSize[3]; + int cmSizeH, cmSizeS, cmSizeV; float ***cm = (float***) method()->data(direction); KTMethod *m = method(); - cmSize[0] = m->dataSize(0); // v - cmSize[1] = m->dataSize(1); // h - cmSize[2] = m->dataSize(2); // s + cmSizeV = m->dataSize(0); // v + cmSizeH = m->dataSize(1); // h + cmSizeS = m->dataSize(2); // s double bigsum[3] = {0, 0, 0}; // calculating the S component - int max = MAX(cmSize[1], cmSize[0]); - for (int k=0; k < cmSize[2]; k++) + int max = MAX(cmSizeH, cmSizeV); + for (int k=0; k < cmSizeS; ++k) { float sum[max]; - for (int a=0; a < max; a++) + for (int a=0; a < max; ++a) sum[a] = 0; - for (int i=0; i < cmSize[0]; i++) - for (int j=0; j < cmSize[1]; j++) + for (int i=0; i < cmSizeV; ++i) + for (int j=0; j < cmSizeH; ++j) sum[abs(i-j)] += cm[i][j][k]; //calculate bigsum - for (int n=0; n < max; n++) + for (int n=0; n < max; ++n) bigsum[0] += sum[n] * n * n; } // calculating the H component - max = MAX(cmSize[2], cmSize[0]); - for (int j=0; j < cmSize[1]; j++) + max = MAX(cmSizeS, cmSizeV); + for (int j=0; j < cmSizeH; ++j) { float sum[max]; - for (int a=0; a < max; a++) + for (int a=0; a < max; ++a) sum[a] = 0; - for (int i=0; i < cmSize[0]; i++) - for (int k=0; k < cmSize[2]; k++) + for (int i=0; i < cmSizeV; ++i) + for (int k=0; k < cmSizeS; ++k) sum[abs(i-k)] += cm[i][j][k]; //calculate bigsum - for (int n=0; n < max; n++) + for (int n=0; n < max; ++n) bigsum[1] += sum[n] * n * n; } // calculating the V component - max = MAX(cmSize[1], cmSize[2]); - for (int i=0; i < cmSize[0]; i++) + max = MAX(cmSizeH, cmSizeS); + for (int i=0; i < cmSizeV; ++i) { float sum[max]; - for (int a=0; a < max; a++) + for (int a=0; a < max; ++a) sum[a] = 0; - for (int k=0; k < cmSize[2]; k++) - for (int j=0; j < cmSize[1]; j++) + for (int k=0; k < cmSizeS; ++k) + for (int j=0; j < cmSizeH; ++j) sum[abs(k-j)] += cm[i][j][k]; //calculate bigsum - for (int n=0; n < max; n++) + for (int n=0; n < max; ++n) bigsum[2] += sum[n] * n * n; } - float result = bigsum[0] / cmSize[2] + bigsum[1] / cmSize[1] + bigsum[2] / cmSize[0]; + float result = bigsum[0] / cmSizeS + bigsum[1] / cmSizeH + bigsum[2] / cmSizeV; //kdDebug() << "Result: " << result << endl; return result; } |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-02 02:11:48
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/entropy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21701/src/methods/hsvcm/features/entropy Modified Files: entropy.cpp Log Message: - Changed from cmSize[3] to cmSizeV, cmSizeH and cmSizeS (readability) Index: entropy.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/entropy/entropy.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- entropy.cpp 31 May 2005 03:20:02 -0000 1.4 +++ entropy.cpp 2 Jun 2005 02:11:39 -0000 1.5 @@ -51,18 +51,18 @@ float KTHSVCMEntropy::_calculate(KTImage *img, int direction) { - int cmSize[3]; + int cmSizeH, cmSizeS, cmSizeV; float ***cm = (float***) method()->data(direction); KTMethod *m = method(); - cmSize[0] = m->dataSize(0); - cmSize[1] = m->dataSize(1); - cmSize[2] = m->dataSize(2); + cmSizeV = m->dataSize(0); + cmSizeH = m->dataSize(1); + cmSizeS = m->dataSize(2); float sum = 0.; - for (int i=0; i < cmSize[0]; i++) - for (int j=0; j< cmSize[1]; j++) - for (int k=0; k < cmSize[2]; k++) + for (int i=0; i < cmSizeV; ++i) + for (int j=0; j< cmSizeH; ++j) + for (int k=0; k < cmSizeS; ++k) sum += cm[i][j][k] * log10(cm[i][j][k] + EPSILON); return sum; } |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-02 02:11:48
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21701/src/methods/hsvcm/features/correlation Modified Files: correlation.cpp Log Message: - Changed from cmSize[3] to cmSizeV, cmSizeH and cmSizeS (readability) Index: correlation.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation/correlation.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- correlation.cpp 31 May 2005 03:20:02 -0000 1.6 +++ correlation.cpp 2 Jun 2005 02:11:39 -0000 1.7 @@ -50,8 +50,8 @@ float KTHSVCMCorrelation::_calculate(KTImage *img, int direction) { - int cmSizeV, cmSizeH, cmSizeS, i, j, k; - float ***cm = (float***) method()->data(direction); + int cmSizeV, cmSizeH, cmSizeS, i, j, k; + float ***cm = (float***) method()->data(direction); KTMethod *m = method(); cmSizeV = m->dataSize(0); |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-02 02:09:26
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20364/src/methods/hsvcm Modified Files: hsvcm.cpp Log Message: - Calculate some data automatically (I'm too lazy to do that manually) Index: hsvcm.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/hsvcm.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- hsvcm.cpp 28 May 2005 21:29:22 -0000 1.8 +++ hsvcm.cpp 2 Jun 2005 02:09:16 -0000 1.9 @@ -44,13 +44,13 @@ m_longName = i18n("HSV Co-Occurrence Matrix"); //defaults - m_quantH = 20; - m_quantS = 8; - m_quantV = 8; + m_quantH = 20; // needs to divide 360 + m_quantS = 8; // needs to divide 256 + m_quantV = 8; // needs to divide 256 - m_sizeH = 18; // 360 / 20 - m_sizeS = 32; // 256 / 8 - m_sizeV = 32; // 256 / 8 + m_sizeH = 360 / m_quantH; + m_sizeS = 256 / m_quantS; + m_sizeV = 256 / m_quantV; } |
|
From: Gustavo P. B. <gb...@us...> - 2005-06-02 02:07:33
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/angsecmom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18932 Modified Files: angsecmom.cpp Log Message: - If we initialize the sum with 0 the results are much better ;) - Changed from cmSize[3] to cmSizeV, cmSizeH and cmSizeS (readability) Index: angsecmom.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/angsecmom/angsecmom.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- angsecmom.cpp 7 Apr 2005 02:07:21 -0000 1.4 +++ angsecmom.cpp 2 Jun 2005 02:07:21 -0000 1.5 @@ -48,18 +48,18 @@ float KTHSVCMAngSecMom::_calculate(KTImage *img, int direction) { - int cmSize[3]; + int cmSizeH, cmSizeS, cmSizeV; float ***cm = (float***) method()->data(direction); KTMethod *m = method(); - cmSize[0] = m->dataSize(0); - cmSize[1] = m->dataSize(1); - cmSize[2] = m->dataSize(2); + cmSizeV = m->dataSize(0); + cmSizeH = m->dataSize(1); + cmSizeS = m->dataSize(2); - double sum; - for (int i=0; i < cmSize[0]; i++) - for (int j=0; j< cmSize[1]; j++) - for (int k=0; k < cmSize[2]; k++) + float sum = 0.; + for (int i=0; i < cmSizeV; i++) + for (int j=0; j< cmSizeH; j++) + for (int k=0; k < cmSizeS; k++) sum += cm[i][j][k] * cm[i][j][k]; return sum; } |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-31 03:20:21
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1784/src/methods/hsvcm/features/correlation Modified Files: correlation.cpp Log Message: - Fixed correlation calculation Index: correlation.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation/correlation.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- correlation.cpp 28 May 2005 21:29:27 -0000 1.5 +++ correlation.cpp 31 May 2005 03:20:02 -0000 1.6 @@ -84,31 +84,28 @@ float mult; // ----- V component ------------- - //mean for (i=0; i < cmSizeV; ++i) meanv += pv[i]*i; - //variance - for (i=0; i < cmSizeV; ++i) - sum_sqrv += (i - meanv); - //standard deviation - stddevv = sqrt(sum_sqrv); - // ----- H component ------------ for (j=0; j < cmSizeH; ++j) meanh += pv[j]*j; - //variance - for (j=0; j < cmSizeH; ++j) - sum_sqrh += (j - meanh); - //standard deviation - stddevh = sqrt(sum_sqrh); - // ----- S component ------------ for (k=0; k < cmSizeS; ++k) means += pv[k]*k; + //variance - for (k=0; k < cmSizeS; ++k) - sum_sqrs += (k - means); - //standard deviation + for (i = 0; i < cmSizeV; ++i) + for (j = 0; j < cmSizeH; ++j) + for (k = 0; k < cmSizeS; ++k) + { + value = cm[i][j][k]; + sum_sqrv += value * (i-meanv) * (i-meanv); + sum_sqrh += value * (j-meanh) * (j-meanh); + sum_sqrs += value * (k-means) * (k-means); + } + + stddevv = sqrt(sum_sqrv); + stddevh = sqrt(sum_sqrh); stddevs = sqrt(sum_sqrs); //and now (finally) the correlation itself: @@ -117,7 +114,10 @@ for (j = 0; j < cmSizeH; ++j) for (k = 0; k < cmSizeS; ++k) { - tmp += (i * j * k * cm[i][j][k] - meanv * meanh * means) / (stddevv * stddevh * stddevs); + float mult = stddevv * stddevh * stddevs; + if (mult == 0) + mult = 0.000000000001; + tmp += (i * j * k * cm[i][j][k] - meanv * meanh * means) / mult; } //CHECKME: validate all this code return tmp; |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-31 03:20:20
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/entropy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1784/src/methods/hsvcm/features/entropy Modified Files: entropy.cpp Log Message: - Fixed correlation calculation Index: entropy.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/entropy/entropy.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- entropy.cpp 6 Apr 2005 04:12:54 -0000 1.3 +++ entropy.cpp 31 May 2005 03:20:02 -0000 1.4 @@ -59,7 +59,7 @@ cmSize[1] = m->dataSize(1); cmSize[2] = m->dataSize(2); - double sum = 0.; + float sum = 0.; for (int i=0; i < cmSize[0]; i++) for (int j=0; j< cmSize[1]; j++) for (int k=0; k < cmSize[2]; k++) |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-28 21:29:39
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16695/src/methods/hsvcm/features/correlation Modified Files: correlation.cpp Log Message: - Fixed contrast calculation - Changed correlation calculation (but now it is getting a `nan' result :-S Index: correlation.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation/correlation.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- correlation.cpp 24 May 2005 03:36:54 -0000 1.4 +++ correlation.cpp 28 May 2005 21:29:27 -0000 1.5 @@ -84,31 +84,32 @@ float mult; // ----- V component ------------- + //mean for (i=0; i < cmSizeV; ++i) - { - mult = pv[i]*i; - meanv += mult; - sum_sqrv += mult * i; - } - stddevv = sqrt((sum_sqrv - meanv) * (sum_sqrv - meanv)); + meanv += pv[i]*i; + //variance + for (i=0; i < cmSizeV; ++i) + sum_sqrv += (i - meanv); + //standard deviation + stddevv = sqrt(sum_sqrv); // ----- H component ------------ for (j=0; j < cmSizeH; ++j) - { - mult = ph[j]*j; - meanh += mult; - sum_sqrh += mult * j; - } - stddevh = sqrt((sum_sqrh - meanh) * (sum_sqrh - meanh)); + meanh += pv[j]*j; + //variance + for (j=0; j < cmSizeH; ++j) + sum_sqrh += (j - meanh); + //standard deviation + stddevh = sqrt(sum_sqrh); // ----- S component ------------ for (k=0; k < cmSizeS; ++k) - { - mult = ps[k]*k; - means+= mult; - sum_sqrs += mult * k; - } - stddevs = sqrt((sum_sqrs - means) * (sum_sqrs - means)); + means += pv[k]*k; + //variance + for (k=0; k < cmSizeS; ++k) + sum_sqrs += (k - means); + //standard deviation + stddevs = sqrt(sum_sqrs); //and now (finally) the correlation itself: tmp = 0; @@ -116,7 +117,7 @@ for (j = 0; j < cmSizeH; ++j) for (k = 0; k < cmSizeS; ++k) { - tmp += (i * j * k * cm[i][j][k] - meanv * means * meanv) / (stddevv * stddevh * stddevs); + tmp += (i * j * k * cm[i][j][k] - meanv * meanh * means) / (stddevv * stddevh * stddevs); } //CHECKME: validate all this code return tmp; |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-28 21:29:39
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16695/src/methods/hsvcm Modified Files: hsvcm.cpp Log Message: - Fixed contrast calculation - Changed correlation calculation (but now it is getting a `nan' result :-S Index: hsvcm.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/hsvcm.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- hsvcm.cpp 24 May 2005 03:36:54 -0000 1.7 +++ hsvcm.cpp 28 May 2005 21:29:22 -0000 1.8 @@ -280,6 +280,16 @@ } } + + float max = width * height; + // Normalize the matrices + //kdDebug() << "Normalizing the matrices..." << endl; + for (int d=0; d < 9; d++) + for (int i=0; i < m_sizeV; i++) + for (int j=0; j < m_sizeH; j++) + for (int k=0; k < m_sizeS; k++) + m_cm[d][i][j][k] /= max; + } void *KTHSVCM::data(int direction) const |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-28 21:29:36
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/contrast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16695/src/methods/hsvcm/features/contrast Modified Files: contrast.cpp Log Message: - Fixed contrast calculation - Changed correlation calculation (but now it is getting a `nan' result :-S Index: contrast.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/contrast/contrast.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- contrast.cpp 8 Apr 2005 20:02:13 -0000 1.4 +++ contrast.cpp 28 May 2005 21:29:27 -0000 1.5 @@ -66,7 +66,7 @@ { float sum[max]; for (int a=0; a < max; a++) - sum[max] = 0; + sum[a] = 0; for (int i=0; i < cmSize[0]; i++) for (int j=0; j < cmSize[1]; j++) sum[abs(i-j)] += cm[i][j][k]; @@ -82,7 +82,7 @@ { float sum[max]; for (int a=0; a < max; a++) - sum[max] = 0; + sum[a] = 0; for (int i=0; i < cmSize[0]; i++) for (int k=0; k < cmSize[2]; k++) sum[abs(i-k)] += cm[i][j][k]; @@ -92,13 +92,13 @@ bigsum[1] += sum[n] * n * n; } - // calculating the S component + // calculating the V component max = MAX(cmSize[1], cmSize[2]); - for (int i=0; i < cmSize[2]; i++) + for (int i=0; i < cmSize[0]; i++) { float sum[max]; for (int a=0; a < max; a++) - sum[max] = 0; + sum[a] = 0; for (int k=0; k < cmSize[2]; k++) for (int j=0; j < cmSize[1]; j++) sum[abs(k-j)] += cm[i][j][k]; @@ -108,7 +108,7 @@ bigsum[2] += sum[n] * n * n; } float result = bigsum[0] / cmSize[2] + bigsum[1] / cmSize[1] + bigsum[2] / cmSize[0]; - kdDebug() << "Result: " << result << endl; + //kdDebug() << "Result: " << result << endl; return result; } |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-24 03:37:03
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5817/src/methods/hsvcm/features/correlation Modified Files: correlation.cpp Log Message: - Removed unused struct - Implemented the correlation function (which still have errors when calculating but that is another story ;) Index: correlation.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/correlation/correlation.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- correlation.cpp 6 Apr 2005 04:12:53 -0000 1.3 +++ correlation.cpp 24 May 2005 03:36:54 -0000 1.4 @@ -29,6 +29,8 @@ #include <ktfeaturemanager.h> #include <ktmethod.h> +#include <math.h> + K_EXPORT_COMPONENT_FACTORY( kimageprocess_hsvcm_correlation, KGenericFactory<KTHSVCMCorrelation>( "kimageprocess_hsvcm_correlation" ) ) @@ -48,15 +50,76 @@ float KTHSVCMCorrelation::_calculate(KTImage *img, int direction) { - int cmSize[3]; + int cmSizeV, cmSizeH, cmSizeS, i, j, k; float ***cm = (float***) method()->data(direction); KTMethod *m = method(); - cmSize[0] = m->dataSize(0); - cmSize[1] = m->dataSize(1); - cmSize[2] = m->dataSize(2); + cmSizeV = m->dataSize(0); + cmSizeH = m->dataSize(1); + cmSizeS = m->dataSize(2); - return 0.0; + float pv[cmSizeV], ph[cmSizeH], ps[cmSizeS]; + float sum_sqrv=0, sum_sqrh=0, sum_sqrs=0, tmp; + float meanv=0, meanh=0, means=0, stddevv,stddevh,stddevs; + + //initializing matrices + for (i=0; i < cmSizeV; ++i) + pv[i] = 0; + for (j=0; j < cmSizeH; ++j) + ph[j] = 0; + for (k=0; k < cmSizeS; ++k) + ps[k] = 0; + + //calculate the sum for each component + float value; + for (i = 0; i < cmSizeV; ++i) + for (j = 0; j < cmSizeH; ++j) + for (k = 0; k < cmSizeS; ++k) + { + value = cm[i][j][k]; + pv[i] += value; + ph[j] += value; + ps[k] += value; + } + + float mult; + // ----- V component ------------- + for (i=0; i < cmSizeV; ++i) + { + mult = pv[i]*i; + meanv += mult; + sum_sqrv += mult * i; + } + stddevv = sqrt((sum_sqrv - meanv) * (sum_sqrv - meanv)); + + // ----- H component ------------ + for (j=0; j < cmSizeH; ++j) + { + mult = ph[j]*j; + meanh += mult; + sum_sqrh += mult * j; + } + stddevh = sqrt((sum_sqrh - meanh) * (sum_sqrh - meanh)); + + // ----- S component ------------ + for (k=0; k < cmSizeS; ++k) + { + mult = ps[k]*k; + means+= mult; + sum_sqrs += mult * k; + } + stddevs = sqrt((sum_sqrs - means) * (sum_sqrs - means)); + + //and now (finally) the correlation itself: + tmp = 0; + for (i = 0; i < cmSizeV; ++i) + for (j = 0; j < cmSizeH; ++j) + for (k = 0; k < cmSizeS; ++k) + { + tmp += (i * j * k * cm[i][j][k] - meanv * means * meanv) / (stddevv * stddevh * stddevs); + } + //CHECKME: validate all this code + return tmp; } #include "correlation.moc" |
|
From: Gustavo P. B. <gb...@us...> - 2005-05-24 03:37:02
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5817/src/methods/hsvcm Modified Files: hsvcm.cpp Log Message: - Removed unused struct - Implemented the correlation function (which still have errors when calculating but that is another story ;) Index: hsvcm.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/hsvcm.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- hsvcm.cpp 7 Apr 2005 02:07:20 -0000 1.6 +++ hsvcm.cpp 24 May 2005 03:36:54 -0000 1.7 @@ -33,12 +33,6 @@ K_EXPORT_COMPONENT_FACTORY( kimageprocess_hsvcm, KGenericFactory<KTHSVCM>( "kimageprocess_hsvcm" ) ) - -struct FloatPack2 -{ - float data[2]; -}; - KTHSVCM::KTHSVCM(QObject *parent, const char* name, const QStringList&) : KTMethod() { |
|
From: Herton R. K. <he...@us...> - 2005-04-10 20:43:22
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/fann In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2680/src/plugins/fann Modified Files: fann.cpp fann.h Log Message: - Enhancements, cleanups, cosmetics and fixes on fann plugin. Index: fann.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/fann/fann.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- fann.h 5 Mar 2005 21:14:05 -0000 1.1 +++ fann.h 10 Apr 2005 20:42:58 -0000 1.2 @@ -50,52 +50,50 @@ KTFANNPlugin(QObject *parent, const char *name, const QStringList&); ~KTFANNPlugin(); - + void setupPlugin(); - + int iterations() { return m_iterations; } void setIterations(int value) { m_iterations = value; } - + int hiddenLayers() { return m_hiddenLayers; } void setHiddenLayers(int value) { m_hiddenLayers = value; } - + // Reimplemented from KTClassifBackends void parseResults(const QValueList<float> &results); - + void parseSampleResults(const QValueList<float> &results, int sampleClass); - + private: KAction *m_trainNetwork; KAction *m_classifyImage; - + struct fann *m_network; int m_input; int m_output; float m_connectionRate; float m_learningRate; - + QImage *m_img; int m_width; int m_height; int m_colorStep; - + int m_x; int m_y; int m_iterations; int m_hiddenLayers; - + double m_error; - long m_count; - + QValueList<pattern> m_patterns; - + private slots: void slotTrainNetwork(); // for now assume we are using one test image for each project. // TODO: Fix that (will require API change) void slotClassifyImage(); - }; -#endif +#endif \ No newline at end of file Index: fann.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/fann/fann.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- fann.cpp 5 Mar 2005 21:14:05 -0000 1.1 +++ fann.cpp 10 Apr 2005 20:42:58 -0000 1.2 @@ -35,24 +35,24 @@ K_EXPORT_COMPONENT_FACTORY( kimageprocess_fann, KGenericFactory<KTFANNPlugin>( "kimageprocess_fann" ) ) - + KTFANNPlugin::KTFANNPlugin(QObject *parent, const char* name, const QStringList&) : KTClassifBackend(parent, name) { m_trainNetwork = new KAction(i18n("Train &Network"), 0, this, SLOT(slotTrainNetwork()), actionCollection(), "fann_train_network"); - + m_classifyImage = new KAction(i18n("Classify &Image"), 0, this, SLOT(slotClassifyImage()), actionCollection(), "fann_classify_image"); - + setInstance(KGenericFactory<KTFANNPlugin>::instance()); setXMLFile("kimageprocess_fann.rc"); m_network = 0; m_img = 0; - m_iterations = 10000; + m_iterations = 100000; m_hiddenLayers = 1; m_connectionRate = 1.0; @@ -66,31 +66,59 @@ } void KTFANNPlugin::slotTrainNetwork() -{ +{ if (m_network) fann_destroy(m_network); - + m_input = imageManager()->activeFeaturesCount(); m_output = imageManager()->sampleCount(); - + //create the network - m_network = fann_create(m_connectionRate, m_learningRate, 3, m_input, m_output, m_output); - - m_count = 0; + m_network = fann_create(m_connectionRate, m_learningRate, 3, m_input, m_input, m_output); + fann_set_activation_steepness_hidden(m_network, 1.0); + fann_set_activation_steepness_output(m_network, 1.0); + fann_set_activation_function_hidden(m_network, FANN_SIGMOID_SYMMETRIC_STEPWISE); + fann_set_activation_function_output(m_network, FANN_SIGMOID_SYMMETRIC_STEPWISE); m_error = 0.0; - + //start training imageManager()->generatePatternFile(0, this); - - float outputs[m_output]; - - //prepare the output - for (int i = 0; i < m_output; i++) - outputs[i] = 0; - - int print_debug = 0; + + struct fann_train_data tfanndata; + float *tempf_outputs; + int i, j; + QValueList<pattern>::size_type c_patcount; + + c_patcount = m_patterns.count(); + tempf_outputs = new float[c_patcount * m_output]; + tfanndata.num_data = c_patcount; + tfanndata.num_input = m_input; + tfanndata.num_output = m_output; + tfanndata.input = new float*[c_patcount]; + tfanndata.output = new float*[c_patcount]; + for (i = 0; i < c_patcount; i++) + { + tfanndata.output[i] = tempf_outputs + i * m_output; + for (j = 0; j < m_output; j++) + { + tfanndata.output[i][j] = 0; + } + } + j = 0; QValueList<pattern>::iterator end = m_patterns.end(); - for (int i=0; i < m_iterations; ++i) + for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) + { + tfanndata.output[j][(*it).sampleClass-1] = 1; + tfanndata.input[j] = (*it).inputs; + j++; + } + fann_init_weights(m_network, &tfanndata); + fann_train_on_data(m_network, &tfanndata, m_iterations, m_iterations / 100, 0.001); + m_error = fann_get_MSE(m_network); + + /*int print_debug = 0; + QValueList<pattern>::iterator end = m_patterns.end(); + for (i = 0; i < m_iterations; ++i) { for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) { @@ -105,40 +133,40 @@ kdDebug() << "Network output average error:" << m_error << endl; print_debug = 0; } - } - + }*/ + //clear data end = m_patterns.end(); for (QValueList<pattern>::iterator it = m_patterns.begin(); it != end; ++it) delete (*it).inputs; + delete tfanndata.input; + delete tempf_outputs; + delete tfanndata.output; m_patterns.clear(); - - } void KTFANNPlugin::slotClassifyImage() { if (!m_network) return; - + KTImage *img = imageManager()->testingImage(); - + m_width = img->width(); m_height = img->height(); m_x = m_y = 0; - + if (m_img) delete m_img; m_img = new QImage(m_width,m_height,32); m_colorStep = 255/(m_output-1); kdDebug() << "Color step is: " << m_colorStep << endl; - + imageManager()->generateTestPatFile(0, this); - + //save the image - KURL dest = KFileDialog::getSaveURL(QString::null,i18n("*.pgm|PGM File"),0,i18n("Save classified image")); - + if (!dest.isEmpty()) { KTempFile tmpImg(QString::null,".pgm"); @@ -150,15 +178,15 @@ } void KTFANNPlugin::setupPlugin() -{ -//connect signals/slots here +{ + //connect signals/slots here } void KTFANNPlugin::parseResults(const QValueList<float> &results) { float *inputs = new float[m_input]; float *outputs; - + QValueList<float>::const_iterator it; int i = 0; kdDebug() << "------------------------" << endl; @@ -168,9 +196,9 @@ kdDebug() << "inputs[" << i << "] = " << (*it) << endl; inputs[i++] = (*it); } - + outputs = fann_run(m_network, inputs); - + int maxclass = 0; float maxvalue = 0; for (i = 0; i < m_output; i++) @@ -185,30 +213,30 @@ int level = maxclass * m_colorStep; //kdDebug() << "Pixel x=" << m_x << " y=" << m_y << " is of class " << maxclass << " with value = " << maxvalue << endl; m_img->setPixel(m_x++,m_y,qRgb(level,level,level)); - + if (m_x >= m_width) { m_x = 0; m_y++; } - + } void KTFANNPlugin::parseSampleResults(const QValueList<float> &results, int sampleClass) { float *inputs = new float[m_input]; - + QValueList<float>::const_iterator it; int i = 0; + //prepare the input for ( it = results.begin(); it != results.end(); ++it) inputs[i++] = (*it); - + pattern pat; pat.inputs = inputs; pat.sampleClass = sampleClass; m_patterns.append(pat); } - -#include "fann.moc" +#include "fann.moc" \ No newline at end of file |
|
From: Gustavo P. B. <gb...@us...> - 2005-04-08 20:02:22
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/contrast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30244 Modified Files: contrast.cpp Log Message: Implemented contrast Index: contrast.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/methods/hsvcm/features/contrast/contrast.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- contrast.cpp 6 Apr 2005 04:12:53 -0000 1.3 +++ contrast.cpp 8 Apr 2005 20:02:13 -0000 1.4 @@ -29,6 +29,8 @@ #include <ktfeaturemanager.h> #include <ktmethod.h> +#define MAX(x,y) ( x > y ? x : y ) + K_EXPORT_COMPONENT_FACTORY( kimageprocess_hsvcm_contrast, KGenericFactory<KTHSVCMContrast>( "kimageprocess_hsvcm_contrast" ) ) @@ -52,11 +54,62 @@ float ***cm = (float***) method()->data(direction); KTMethod *m = method(); - cmSize[0] = m->dataSize(0); - cmSize[1] = m->dataSize(1); - cmSize[2] = m->dataSize(2); + cmSize[0] = m->dataSize(0); // v + cmSize[1] = m->dataSize(1); // h + cmSize[2] = m->dataSize(2); // s - return 0.0; + double bigsum[3] = {0, 0, 0}; + + // calculating the S component + int max = MAX(cmSize[1], cmSize[0]); + for (int k=0; k < cmSize[2]; k++) + { + float sum[max]; + for (int a=0; a < max; a++) + sum[max] = 0; + for (int i=0; i < cmSize[0]; i++) + for (int j=0; j < cmSize[1]; j++) + sum[abs(i-j)] += cm[i][j][k]; + + //calculate bigsum + for (int n=0; n < max; n++) + bigsum[0] += sum[n] * n * n; + } + + // calculating the H component + max = MAX(cmSize[2], cmSize[0]); + for (int j=0; j < cmSize[1]; j++) + { + float sum[max]; + for (int a=0; a < max; a++) + sum[max] = 0; + for (int i=0; i < cmSize[0]; i++) + for (int k=0; k < cmSize[2]; k++) + sum[abs(i-k)] += cm[i][j][k]; + + //calculate bigsum + for (int n=0; n < max; n++) + bigsum[1] += sum[n] * n * n; + } + + // calculating the S component + max = MAX(cmSize[1], cmSize[2]); + for (int i=0; i < cmSize[2]; i++) + { + float sum[max]; + for (int a=0; a < max; a++) + sum[max] = 0; + for (int k=0; k < cmSize[2]; k++) + for (int j=0; j < cmSize[1]; j++) + sum[abs(k-j)] += cm[i][j][k]; + + //calculate bigsum + for (int n=0; n < max; n++) + bigsum[2] += sum[n] * n * n; + } + float result = bigsum[0] / cmSize[2] + bigsum[1] / cmSize[1] + bigsum[2] / cmSize[0]; + kdDebug() << "Result: " << result << endl; + return result; } #include "contrast.moc" |
|
From: Herton R. K. <he...@us...> - 2005-04-08 01:16:56
|
Update of /cvsroot/kimageprocess/kimageprocess/testclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18167/testclass Modified Files: testclass.c Log Message: - Now comments are included in generated res file to be compatible with current res2pgm. Index: testclass.c =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/testclass/testclass.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- testclass.c 7 Apr 2005 06:19:56 -0000 1.15 +++ testclass.c 8 Apr 2005 01:16:48 -0000 1.16 @@ -262,10 +262,12 @@ fatal(errno); if (fprintf(pr_file, "startpattern : 1\n") < 0) fatal(errno); - if (fprintf(pr_file, "endpattern : %d\n\n", c_patData.numPatterns) < 0) + if (fprintf(pr_file, "endpattern : %d\n", c_patData.numPatterns) < 0) fatal(errno); for (npat = 0; npat < c_patData.numPatterns; npat++) { + if (fprintf(pr_file, "#%d.1\n", npat + 1) < 0) + fatal(errno); result = fann_run(tfann, c_patData.inputValues[npat]); for (c = 0; c < t_patData.numOutputUnits; c++) { |