Outils pour utilisateurs

Outils du site


openexr

OpenExr est un format permettant de stocker des images avec un nombre variables de canaux stockés sous des types différents (dont flottant 16 et 32bits), avec gestion des régions d'intérêt (ROI). La documentation du format: http://www.openexr.com/TechnicalIntroduction.pdf

Installation depuis les paquets Ubuntu

C'est la façon conseillée car j'ai eu des problème pour compiler OpenCV3.1 avec la version installée à la main

apt-cache search exr | grep open
  libopenexr-dev - Fichiers de développement pour la bibliothèque d'images OpenEXR
  libopenexr22 - Fichiers d'exécution pour la bibliothèque d'images OpenEXR
  openexr-doc - documentation and examples for the OpenEXR image format
  libopenimageio-dev - Bibliothèque pour lire et écrire des images - développement
  libopenimageio1.6 - Bibliothèque pour lire et écrire des images - binaires
  openexr - command-line tools for the OpenEXR image format
  openexr-viewers - visualiseur pour images au format OpenEXR
  openimageio-tools - Library for reading and writing images - command line tools
  libopenimageio-doc - Library for reading and writing images - documentation
  python-openimageio - Library for reading and writing images - Python bindings
sudo apt-get install libopenexr-dev  libopenexr22 openexr-doc openexr  openexr-viewers

Installation à la main

dépendances

pas obligatoire cg de nvidia:

sudo apt-get install libcg libcggl 

obligatoire openGL:

sudo apt-get install  mesa-utils mesa-common-dev freeglut3-dev

librairie

tar xvf openexr-2.2.0.tar.gz 
cd openexr-2.2.0/
./configure 
make -j4
sudo make install

application viewer

tar xvf openexr_viewers-2.2.0.tar.gz 
cd openexr_viewers-2.2.0
./configure 
make -j4

il manque le -lGl pour l'édition des liens (qui foire car il n'a pas trouvé cg), saisir à la main:

cd exrdisplay/
g++ -pipe -g -O2 -o exrdisplay main.o ImageView.o loadImage.o scaleImage.o applyCtl.o GlWindow3d.o -DHAVE_CTL_INTERPRETER=0 -DHAVE_CTL_INTERPRETER=0 -Wl,-Bsymbolic-functions  -L/usr/local/lib /usr/local/lib/libIlmImf.so -lz -lImath -lHalf -lIex -lIexMath -lIlmThread -lpthread -lfltk_gl -lfltk -lX11 -lGL

/exrdisplay ../../scene_synthetique/openEXR_depth/image_depth/out.exr0001.exr ./exrdisplay ../../scene_synthetique/openEXR_depth/image_depth/Image0001.exr image qui marche mais il faut réduire le slider exposure à 6.5

le plan le plus proche est à 6.9

 ./exrdisplay ../../scene_synthetique/openEXR_depth/Image0001.exr 

doc sur l'utilisation de la librairie (exemples...)

evince ~/Téléchargements/blenderjessica/openexr-2.2.0/doc/ReadingAndWritingImageFiles.pdf 

programme de test simple

test.cpp
#include <ImfRgbaFile.h>
#include <ImfTiledRgbaFile.h>
#include <ImfArray.h>
#include <stdio.h>
#include <assert.h>
 
 
using namespace OPENEXR_IMF_NAMESPACE;
using namespace std;
using namespace IMATH_NAMESPACE;
 
struct Rgbap
{
half r;
half g;
half b;
half a;
};
 
void writeRgba1 (const char fileName[],const Rgbap *pixels,int width,int height)
{
RgbaOutputFile file (fileName, width, height, WRITE_RGBA);
file.setFrameBuffer (( Rgba *)pixels, 1, width);
file.writePixels (height);
}
void readRgba1 (const char fileName[],Array2D<Rgba> &pixels,int &width,int &height)
{
RgbaInputFile file (fileName);
Box2i dw = file.dataWindow();
width = dw.max.x - dw.min.x + 1;
height = dw.max.y - dw.min.y + 1;
pixels.resizeErase (height, width);
file.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
file.readPixels (dw.min.y, dw.max.y);
}
 
 
int main (int argc, char *argv[])
{
  int width=1920;
 int height=1080;
//Rgbap pixels[ height* width]; // ->segfault
Rgbap* pixels=new Rgbap[ width*height];
 
for (int u=0;u<width;u++)
for (int v=0;v<height;v++)
{
pixels[u+v*width].r=(half)u;
pixels[u+v*width].g=(half)v;
pixels[u+v*width].b=(half)0;
pixels[u+v*width].a=(half)0;
}
 
Array2D<Rgba> pixelsA(height,width);
 
//lit une image
 readRgba1 ("../scene_synthetique/openEXR_depth/Image0001.exr",pixelsA,width,height);
 
//recopie le canal r et génère un dégradé sur le canal g
for (int u=0;u<width;u++)
for (int v=0;v<height;v++)
{
pixels[u+v*width].r=pixelsA[v][u].r;
pixels[u+v*width].g=(half)v;
pixels[u+v*width].b=(half)0;
pixels[u+v*width].a=(half)0;
}
//affiche dans la console la valeur du pixel central
cout <<"val: "<< pixelsA[1080/2][1920/2].r << endl;
//écrit le fichier modifié
writeRgba1 ("titi.exr",pixels,width,height );
}

pour compiler

rm test
g++ -o test.o -c  test.cpp -I /usr/include/OpenEXR/
g++ -o test test.o -L/usr/lib/x86_64-linux-gnu/ -lIlmImf -lHalf
../openexr_viewers-2.2.0/exrdisplay/exrdisplay ./titi.exr 

Gestion des fichiers exr avec matlab

openexr.txt · Dernière modification : 2021/02/19 21:20 de 127.0.0.1