More tiff learnings
First, the acknowledgements:
Joaquim Luis 's cvlib_mex
and
MATLAB's rtifc.c code (its a utility that uses tifflib to read tiff images)
The problem:
Read many tiff images at a time, while applying a filter on each frame.
It was taking for ever to do this in MATLAB. Essentially I was reading the images in the tiff file in a loop, and then applying a mean filter on each image. It was a real pain - there were 1 GB's worth of image data (about 5000 frames) in each file and using MATLAB's native code was impracticle.
The solution:
I hacked the rtifc.c code to write tiffread_filter.c This essentially reads a grayscale image, n images at a time and filters each.
I used tifflib and opencv for this project. To compile I used gnumex. What I wanted to share here is the compile file. This is inspired from Joaquim Luis make file. Here is my version
Joaquim Luis 's cvlib_mex
and
MATLAB's rtifc.c code (its a utility that uses tifflib to read tiff images)
The problem:
Read many tiff images at a time, while applying a filter on each frame.
It was taking for ever to do this in MATLAB. Essentially I was reading the images in the tiff file in a loop, and then applying a mean filter on each image. It was a real pain - there were 1 GB's worth of image data (about 5000 frames) in each file and using MATLAB's native code was impracticle.
The solution:
I hacked the rtifc.c code to write tiffread_filter.c This essentially reads a grayscale image, n images at a time and filters each.
I used tifflib and opencv for this project. To compile I used gnumex. What I wanted to share here is the compile file. This is inspired from Joaquim Luis make file. Here is my version
function compile2()
% complie the tiffread file
%
% Adjust for your own path
INCLUDE_CV = 'C:\progra~1\OpenCV\cv\include';
INCLUDE_CXCORE = 'C:\progra~1\OpenCV\cxcore\include';
LIB_CV = 'C:\progra~1\OpenCV\lib\cv.lib';
LIB_CXCORE = 'C:\progra~1\OpenCV\lib\cxcore.lib';
INCLUDE_TIFF = ['"' pwd '\tifflib\include' '"'];
LIB_TIFF = ['"' pwd '\tifflib\lib\libtiff.lib' '"'];
% -----------------------------------------------------
include_cv = ['-I' INCLUDE_CV ' -I' INCLUDE_CXCORE ' -I' INCLUDE_TIFF];
library_cv = [LIB_CV ' ' LIB_CXCORE ' ' LIB_TIFF ];
if (ispc)
opt_cv = '-O -DWIN32 -DDLL_CV110 -DDLL_CXCORE110 -DDLL_LIBTIFF3';
else
opt_cv = '-O';
end
cmd = ['mex -v tiffread_filter.c' ' ' include_cv ' ' library_cv ' ' opt_cv];
eval(cmd)
