|
From: Herton R. K. <he...@us...> - 2005-07-13 01:29:29
|
Update of /cvsroot/kimageprocess/kimageprocess/src/methods/glcm/features/kurtosis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14026/kurtosis Added Files: Makefile.am kimageprocess_glcm_kurtosis.desktop kurtosis.cpp kurtosis.h Log Message: - Added kurtosis glcm texture feature. --- NEW FILE: kurtosis.cpp --- /*************************************************************************** * Copyright (C) 2005 by * * Gustavo Pichorim Boiko <gus...@kd...> * * Herton Ronaldo Krzesinski <he...@my...> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "kurtosis.h" #include <kgenericfactory.h> #include <kaction.h> #include <klocale.h> #include <kdebug.h> #include <ktimage.h> #include <ktfeaturemanager.h> #include <ktmethod.h> K_EXPORT_COMPONENT_FACTORY( kimageprocess_glcm_kurtosis, KGenericFactory<KTGLCMkurtosis>( "kimageprocess_glcm_kurtosis" ) ) KTGLCMkurtosis::KTGLCMkurtosis(QObject *parent, const char* name, const QStringList&) : KTFeature("glcm") { Q_UNUSED(parent); Q_UNUSED(name); //check dependencies m_featureName = i18n("kurtosis"); m_longName = i18n("Kurtosis"); } KTGLCMkurtosis::~KTGLCMkurtosis() { } float KTGLCMkurtosis::_calculate(KTImage *img, int direction) { int glcmSize = method()->dataSize(); float **glcm = (float**) method()->data(direction); float deviation = m_deviation->calculate(img, direction); float mean = m_mean->calculate(img, direction); float result = 0.0; int i, j; for (i = 0; i < glcmSize; ++i) for (j = 0; j < glcmSize; ++j) result += (i - mean) * (i - mean) * (i - mean) * (i - mean) * (glcm[i][j] - 3); result *= 1 / (deviation * deviation * deviation * deviation); return result; } void KTGLCMkurtosis::resolveDeps() { m_deviation = manager()->getFeature("glcm", "Deviation"); m_mean = manager()->getFeature("glcm", "Mean"); } #include "kurtosis.moc" --- NEW FILE: Makefile.am --- INCLUDES = $(all_includes) -I$(srcdir)/../../../../libkimageprocess METASOURCES = AUTO kde_module_LTLIBRARIES = kimageprocess_glcm_kurtosis.la kimageprocess_glcm_kurtosis_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) noinst_HEADERS = kurtosis.h kimageprocess_glcm_kurtosis_la_SOURCES = kurtosis.cpp kde_services_DATA = kimageprocess_glcm_kurtosis.desktop kimageprocess_glcm_kurtosis_la_LIBADD = $(top_builddir)/src/libkimageprocess/libkimageprocess.la \ -lkdeui --- NEW FILE: kurtosis.h --- /*************************************************************************** * Copyright (C) 2005 by * * Gustavo Pichorim Boiko <gus...@kd...> * * Herton Ronaldo Krzesinski <he...@my...> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef KIMAGEPROCESS_GLCM_KURTOSIS_H #define KIMAGEPROCESS_GLCM_KURTOSIS_H #include <ktfeature.h> class KAction; class KTImage; /** * kurtosis calculation * @author Gustavo Pichorim Boiko * */ class KTGLCMkurtosis : public KTFeature { Q_OBJECT public: KTGLCMkurtosis(QObject *parent, const char *name, const QStringList&); ~KTGLCMkurtosis(); float _calculate(KTImage *img, int direction); void resolveDeps(); private: KTFeature *m_deviation; KTFeature *m_mean; }; #endif --- NEW FILE: kimageprocess_glcm_kurtosis.desktop --- [Desktop Entry] Name=kurtosis Comment=Kurtosis calculation over GLCM ServiceTypes=KImageProcess/Feature Type=Service X-KDE-Library=kimageprocess_glcm_kurtosis X-Category=glcm |