Working with gcc in windows
OK
For the past 2 days I have been struggling with finding a fast solution to processing some images that I had. I will present some things that I learnt here. Perhaps there are hundreds of other places where these things are better described by more competent people, but I am doing this anyway.
libtiff learnings
To read tiff images you need libtiff. Most tiff images are stored in strips – so say you have a 640x480 image. Then there are 2 ways to read this image
1. Use scanline – a scanline is one line of the image – 640 pixels in our case. Then you scan 480 times. (480 is imageheight, a parameter you can query using libtiff)
2. Use rawstripscan – scan strips at a time. In my case there were 19 rows in 1 strip. Thus its equivalent of doing 19 scanline calls. But you have to arrange the data in the correct image format. Thus you fill 19 rows of your 640x480 array in 1 scan. When you use scanline, you fill 1 row at a time.
gcc for windows learnings
To get gcc you have 2 options – either get gcc.exe files from somewhere or install MinGW and MSYS. I recommend the second option.
Remember to change/check the PATH setting of Windows.
Next to compile use a make file
Here is one that I made
a.exe : tiffread.o
gcc tiffread.o -ltiff.dll -LC: \Tiffread\tifflib\lib -o a.exe
tiffread.o : tiffread.c
gcc -c tiffread.c -IC: \Tiffread\tifflib\include
Note that the -l clause asks gcc to look for the library libtiff.dll.a (note the "lib" in the front and the ".a" in the back will be added by the compiler, so you need to subtract them). -L gives the directory to look for the library. The -I gives the directory for the include files.
To compile use the
C:\>make
command
gcc for matlab learnings
This is basically setting up gnumex. However if you want to add say the tiff library, the easiest way is to copy libtiff.dll.a to the lib\ directory of your gcc installation and adding the -llibtiff to the list of commands in the mexopt.bat file
set GM_ADD_LIBS=-llibmx -llibmex -llibmat –llibtiff
dlls for gcc
If you want to use say OpenCV then a .lib file ships with it. To compile your program in gcc you need to give -lcv.lib and -lcxcore.lib in gcc. Also needed is a -LC:\Progra~1\OpenCV\lib. However, if you want to use a .dll, file, then it may not work sometimes (don’t ask me why not). The work around apparently is to recompile using gcc as given here.
For the past 2 days I have been struggling with finding a fast solution to processing some images that I had. I will present some things that I learnt here. Perhaps there are hundreds of other places where these things are better described by more competent people, but I am doing this anyway.
libtiff learnings
To read tiff images you need libtiff. Most tiff images are stored in strips – so say you have a 640x480 image. Then there are 2 ways to read this image
1. Use scanline – a scanline is one line of the image – 640 pixels in our case. Then you scan 480 times. (480 is imageheight, a parameter you can query using libtiff)
2. Use rawstripscan – scan strips at a time. In my case there were 19 rows in 1 strip. Thus its equivalent of doing 19 scanline calls. But you have to arrange the data in the correct image format. Thus you fill 19 rows of your 640x480 array in 1 scan. When you use scanline, you fill 1 row at a time.
gcc for windows learnings
To get gcc you have 2 options – either get gcc.exe files from somewhere or install MinGW and MSYS. I recommend the second option.
Remember to change/check the PATH setting of Windows.
Next to compile use a make file
Here is one that I made
a.exe : tiffread.o
gcc tiffread.o -ltiff.dll -LC: \Tiffread\tifflib\lib -o a.exe
tiffread.o : tiffread.c
gcc -c tiffread.c -IC: \Tiffread\tifflib\include
Note that the -l clause asks gcc to look for the library libtiff.dll.a (note the "lib" in the front and the ".a" in the back will be added by the compiler, so you need to subtract them). -L gives the directory to look for the library. The -I gives the directory for the include files.
To compile use the
C:\>make
command
gcc for matlab learnings
This is basically setting up gnumex. However if you want to add say the tiff library, the easiest way is to copy libtiff.dll.a to the lib\ directory of your gcc installation and adding the -llibtiff to the list of commands in the mexopt.bat file
set GM_ADD_LIBS=-llibmx -llibmex -llibmat –llibtiff
dlls for gcc
If you want to use say OpenCV then a .lib file ships with it. To compile your program in gcc you need to give -lcv.lib and -lcxcore.lib in gcc. Also needed is a -LC:\Progra~1\OpenCV\lib. However, if you want to use a .dll, file, then it may not work sometimes (don’t ask me why not). The work around apparently is to recompile using gcc as given here.

0 Comments:
Post a Comment
<< Home