Skip to content
Snippets Groups Projects
Commit 7abf2807 authored by Antoine Lorence's avatar Antoine Lorence
Browse files

[plugins] Add missing plugins files

parent 4a1a538c
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,6 @@ add_subdirectory(core)
include_directories(core)
# Too much compile errors, have to be fixed:
# add_subdirectory(plugins)
add_subdirectory(plugins)
add_subdirectory(app)
......@@ -5,4 +5,12 @@ set(SRCS
plugin.cpp
Segmentation/segmentation.cpp
)
add_library(eiimage_plugins ${SRCS})
# add_library(segmentation SHARED Segmentation/segmentation.cpp)
add_library(segmentation SHARED SegmentationTest/segmentation.cpp)
add_library(entropy SHARED Entropy/Entropy.cpp)
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include "Image.h"
#include "Converter.h"
#include "Operation.h"
#include "Plugin.h"
#include "ImgParam.h"
#include "IntParam.h"
#include "PlugOperation.h"
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
using namespace imagein;
class EntropyOp : public PlugOperation {
public:
EntropyOp() : PlugOperation("Entropy") {
addParam(CurrentImg(), &EntropyOp::img);
// addParam(IntParam("Entier", 0, 255, 127), &Entropy::threshold);
//this->addParam(ImgParam("Image"), &Entropy::img);
}
void operation() {
double entropy = 0.;
// for each image channel
for(unsigned int c = 0; c < img.getNbChannels(); ++c) {
Histogram histo = img.getHistogram(c);
// A MODIFIER !!!!!
// histo est un tableau
//img.getWidth() et img.getHeight() peuvent tre pratiques pour trouver les dimensions de l'image...
}
entropy = - entropy / log(2);
// this->outImage(result);
char buffer[255];
sprintf( buffer, "Entropy of the image = %.2f bpp", entropy );
string s = buffer ;
outText(s);
}
private:
Image img;
};
extern "C" Plugin* loadPlugin() {
Plugin* plugin = new Plugin("Entropy");
plugin->addOperation(new EntropyOp());
return plugin;
}
extern "C" void unloadPlugin(Plugin* plugin) {
delete plugin;
}
//
//extern "C" Plugin* getPlugin() {
// Plugin* myPlugin = new MyPlugin("ImageRef");
// return myPlugin;
//}
//
//class MyOperation : public Operation {
// public:
// MyOperation(string name) : Operation(name) {
// //this->addParam(ImgParam("image"), &MyOperation::image);
// //this->addParam(CurrentImg(), &MyOperation::img);
// //this->addParam(IntParam("Entier", 0, 255, 127), &MyOperation::n);
// }
//
// void operation() {
// cout << "n = " << n << endl;
//
// Image* res = generateRefImg();
//
// this->addOutput(ImgOutput("ImageRef", *res));
// }
// private:
// int n;
// Image img;
//};
//
//class MyPlugin : public Plugin {
// public:
// MyPlugin(string name) : Plugin(name) {
// try {
// MyOperation* op = new MyOperation("Gnrer image");
// this->addOperation(op);
// //this->addOperation(new Identity("Identit"));
// /*MyOperation* op2 = new MyOperation("Dilatation");
// this->addOperation(op2);*/
// }
// catch(const char* msg) {
// std::cerr << msg << std::endl;
// }
// }
//};
//
//
//extern "C" Plugin* getPlugin() {
// Plugin* myPlugin = new MyPlugin("ImageRef");
// return myPlugin;
//}
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include "Image.h"
#include "Converter.h"
#include "Operation.h"
#include "Plugin.h"
#include "ImgParam.h"
#include "IntParam.h"
#include "PlugOperation.h"
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
using namespace imagein;
class EntropyOp : public PlugOperation {
public:
EntropyOp() : PlugOperation("Entropy") {
addParam(CurrentImg(), &EntropyOp::img);
// addParam(IntParam("Entier", 0, 255, 127), &Entropy::threshold);
//this->addParam(ImgParam("Image"), &Entropy::img);
}
void operation() {
double entropy = 0.;
// for each image channel
for(unsigned int c = 0; c < img.getNbChannels(); ++c) {
Histogram histo = img.getHistogram(c);
// A MODIFIER !!!!!
for(int i = 0; i < 256; ++i) {
if(histo[i] > 0) {
double p = (double)histo[i] / img.getWidth() /img.getHeight();
entropy += p * log(p);
}
}
}
entropy = - entropy / log(2);
// this->outImage(result);
char buffer[255];
sprintf( buffer, "Entropy of the image = %.2f bpp", entropy );
string s = buffer ;
outText(s);
}
private:
Image img;
};
extern "C" Plugin* loadPlugin() {
Plugin* plugin = new Plugin("Entropy");
plugin->addOperation(new EntropyOp());
return plugin;
}
extern "C" void unloadPlugin(Plugin* plugin) {
delete plugin;
}
//
//extern "C" Plugin* getPlugin() {
// Plugin* myPlugin = new MyPlugin("ImageRef");
// return myPlugin;
//}
//
//class MyOperation : public Operation {
// public:
// MyOperation(string name) : Operation(name) {
// //this->addParam(ImgParam("image"), &MyOperation::image);
// //this->addParam(CurrentImg(), &MyOperation::img);
// //this->addParam(IntParam("Entier", 0, 255, 127), &MyOperation::n);
// }
//
// void operation() {
// cout << "n = " << n << endl;
//
// Image* res = generateRefImg();
//
// this->addOutput(ImgOutput("ImageRef", *res));
// }
// private:
// int n;
// Image img;
//};
//
//class MyPlugin : public Plugin {
// public:
// MyPlugin(string name) : Plugin(name) {
// try {
// MyOperation* op = new MyOperation("Gnrer image");
// this->addOperation(op);
// //this->addOperation(new Identity("Identit"));
// /*MyOperation* op2 = new MyOperation("Dilatation");
// this->addOperation(op2);*/
// }
// catch(const char* msg) {
// std::cerr << msg << std::endl;
// }
// }
//};
//
//
//extern "C" Plugin* getPlugin() {
// Plugin* myPlugin = new MyPlugin("ImageRef");
// return myPlugin;
//}
#include "main.h"
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
/* To use this exported function of dll, include this header
* in your project.
*/
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
#include "main.h"
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
/* To use this exported function of dll, include this header
* in your project.
*/
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include "Image.h"
#include "Algorithm/Binarization.h"
#include "Algorithm/Otsu.h"
#include "Algorithm/Dithering.h"
#include "Converter.h"
#include "Operation.h"
#include "Plugin.h"
#include "ImgParam.h"
#include "IntParam.h"
#include "Input.h"
#include "Parameter.h"
using namespace std;
using namespace imagein;
class Thresholding : public PlugOperation {
public:
Thresholding() : PlugOperation("Thresholding") {
addParam(CurrentImg(), &Thresholding::img);
addParam(IntParam("Entier", 0, 255, 127), &Thresholding::threshold);
}
void operation() {
algorithm::Binarization_t<depth_default_t> thresholding(threshold);
GrayscaleImage* grayImg = imagein::Converter<GrayscaleImage>::convert(img);
GrayscaleImage* result = thresholding(grayImg);
outImage(result);
}
private:
int threshold;
Image img;
};
class Otsu : public PlugOperation {
public:
Otsu() : PlugOperation("Otsu") {
this->addParam(CurrentImg(), &Otsu::img);
}
void operation() {
algorithm::Otsu_t<depth_default_t> otsu;
GrayscaleImage* grayImg = imagein::Converter<GrayscaleImage>::convert(img);
GrayscaleImage* result = otsu(grayImg);
outImage(result);
}
private:
Image img;
};
class Dithering : public PlugOperation {
public:
Dithering() : PlugOperation("Dithering") {
this->addParam(CurrentImg(), &Dithering::img);
// this->addParam(ImgParam("Image"), &Dithering::img);
}
void operation() {
algorithm::Dithering_t<depth_default_t> dithering;
Image* result = dithering(&img);
this->outImage(result);
this->outText("test");
}
private:
Image img;
};
extern "C" Plugin* loadPlugin() {
Plugin* plugin = new Plugin("Binarization");
plugin->addOperation(new Thresholding());
plugin->addOperation(new Otsu());
plugin->addOperation(new Dithering());
return plugin;
}
extern "C" void unloadPlugin(Plugin* plugin) {
delete plugin;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment