Changeset 429:9033656976be


Ignore:
Timestamp:
04/07/2015 12:34:22 PM (6 years ago)
Author:
Dmitry Fedorov <fedorov@…>
Branch:
default
Phase:
public
Message:

build system update, bimread update

Files:
6 added
32 deleted
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • Makefile

    r427 r429  
    1313LIBS=libs/linux
    1414QMAKEOPTS=
     15VERSION=2.0.0
    1516
    1617all : imgcnv
     
    3940        @echo
    4041        @echo "Building libimgcnv"   
    41         (cd src_dynlib; qmake $(QMAKEOPTS) libimgcnv.pro)
    42         (cd src_dynlib; $(MAKE))
     42        (cd src_dylib; qmake $(QMAKEOPTS) libimgcnv.pro)
     43        (cd src_dylib; $(MAKE))
    4344
    4445full:
     
    148149        @echo
    149150        @echo "Building libimgcnv"   
    150         (cd src_dynlib; qmake $(QMAKEOPTS) libimgcnv.pro)
    151         (cd src_dynlib; $(MAKE))
     151        (cd src_dylib; qmake $(QMAKEOPTS) libimgcnv.pro)
     152        (cd src_dylib; $(MAKE))
    152153
    153154clean:
     
    171172realclean: clean
    172173        rm -f imgcnv
    173         rm -f imgcnv.so
     174        rm -f libimgcnv.so.$(VERSION)
     175        #rm -f libimgcnv.so
    174176
    175177
  • Makefile.linux

    r427 r429  
    1313LIBS=libs/linux
    1414QMAKEOPTS=
     15VERSION=2.0.0
    1516
    1617all : imgcnv
     
    3940        @echo
    4041        @echo "Building libimgcnv"   
    41         (cd src_dynlib; qmake $(QMAKEOPTS) libimgcnv.pro)
    42         (cd src_dynlib; $(MAKE))
     42        (cd src_dylib; qmake $(QMAKEOPTS) libimgcnv.pro)
     43        (cd src_dylib; $(MAKE))
    4344
    4445full:
     
    148149        @echo
    149150        @echo "Building libimgcnv"   
    150         (cd src_dynlib; qmake $(QMAKEOPTS) libimgcnv.pro)
    151         (cd src_dynlib; $(MAKE))
     151        (cd src_dylib; qmake $(QMAKEOPTS) libimgcnv.pro)
     152        (cd src_dylib; $(MAKE))
    152153
    153154clean:
     
    171172realclean: clean
    172173        rm -f imgcnv
    173         rm -f imgcnv.so
     174        rm -f libimgcnv.so.$(VERSION)
     175        #rm -f libimgcnv.so
    174176
    175177
  • Makefile.macx

    r427 r429  
    2020QMAKEOPTS=-spec macx-g++49
    2121MACOSX_DEPLOYMENT_TARGET=10.7
    22 
     22VERSION=2.0.0
    2323
    2424all : imgcnv
     
    4747        @echo
    4848        @echo "Building libimgcnv"   
    49         (cd src_dynlib; qmake $(QMAKEOPTS) libimgcnv.pro)
    50         (cd src_dynlib; $(MAKE))
     49        (cd src_dylib; qmake $(QMAKEOPTS) libimgcnv.pro)
     50        (cd src_dylib; $(MAKE))
    5151
    5252full:
     
    224224        @echo
    225225        @echo "Building libimgcnv"   
    226         (cd src_dynlib; qmake $(QMAKEOPTS) libimgcnv.pro)
    227         (cd src_dynlib; $(MAKE))       
     226        (cd src_dylib; qmake $(QMAKEOPTS) libimgcnv.pro)
     227        (cd src_dylib; $(MAKE))
    228228
    229229clean:
  • msvc2013/imgcnv.rc

    r342 r429  
    5252
    5353VS_VERSION_INFO VERSIONINFO
    54  FILEVERSION 1,70,0,70
    55  PRODUCTVERSION 1,70,0,70
     54 FILEVERSION 2,0,0,0
     55 PRODUCTVERSION 2,0,0,0
    5656 FILEFLAGSMASK 0x17L
    5757#ifdef _DEBUG
     
    7070            VALUE "CompanyName", "Center for BioImage Informatics, UCSB"
    7171            VALUE "FileDescription", "imgcnv - BioImage Converter"
    72             VALUE "FileVersion", "1.70.0.70"
     72            VALUE "FileVersion", "2.0.0.0"
    7373            VALUE "InternalName", "imgcnv"
    74             VALUE "LegalCopyright", "Copyright (C) 2004-2014, Dmtiry Fedorov, Center for BioImage Informatics"
     74            VALUE "LegalCopyright", "Copyright (C) 2004-2015, Dmtiry Fedorov, Center for BioImage Informatics"
    7575            VALUE "OriginalFilename", "imgcnv.exe"
    7676            VALUE "ProductName", "imgcnv - BioImage Converter"
    77             VALUE "ProductVersion", "1.70.0.70"
     77            VALUE "ProductVersion", "2.0.0.0"
    7878        END
    7979    END
  • msvc2013/imgcnv.sln

    r394 r429  
    3737EndProject
    3838Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pugixml", "..\libsrc\pugixml\projects\vc2013\pugixml.vcxproj", "{66A9709E-2AC8-48DF-B6D3-E0F9FFD7C10E}"
     39EndProject
     40Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgcnvlib", "..\msvc2013_imgcnvlib\imgcnvlib.vcxproj", "{3DA52489-3BF5-4180-AFFB-D337A667C1AE}"
     41EndProject
     42Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bimread", "..\msvc2013_bimread\bimread.vcxproj", "{2292BBEF-AD62-44FC-A2DD-9FD169C3604E}"
    3943EndProject
    4044Global
     
    442446                {66A9709E-2AC8-48DF-B6D3-E0F9FFD7C10E}.Static-Release|x64.ActiveCfg = LIB Release|x64
    443447                {66A9709E-2AC8-48DF-B6D3-E0F9FFD7C10E}.Static-Release|x64.Build.0 = LIB Release|x64
     448                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Debug|Win32.ActiveCfg = Debug|Win32
     449                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Debug|Win32.Build.0 = Debug|Win32
     450                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Debug|x64.ActiveCfg = Debug|x64
     451                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Debug|x64.Build.0 = Debug|x64
     452                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Debug|Win32.ActiveCfg = Debug|Win32
     453                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Debug|Win32.Build.0 = Debug|Win32
     454                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Debug|x64.ActiveCfg = Debug|x64
     455                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Debug|x64.Build.0 = Debug|x64
     456                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Release|Win32.ActiveCfg = Release|Win32
     457                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Release|Win32.Build.0 = Release|Win32
     458                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Release|x64.ActiveCfg = Release|x64
     459                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.DLL Release|x64.Build.0 = Release|x64
     460                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Debug|Win32.ActiveCfg = Debug|Win32
     461                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Debug|Win32.Build.0 = Debug|Win32
     462                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Debug|x64.ActiveCfg = Debug|x64
     463                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Debug|x64.Build.0 = Debug|x64
     464                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Release|Win32.ActiveCfg = Release|Win32
     465                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Release|Win32.Build.0 = Release|Win32
     466                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Release|x64.ActiveCfg = Release|x64
     467                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.LIB Release|x64.Build.0 = Release|x64
     468                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Release|Win32.ActiveCfg = Release|Win32
     469                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Release|Win32.Build.0 = Release|Win32
     470                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Release|x64.ActiveCfg = Release|x64
     471                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Release|x64.Build.0 = Release|x64
     472                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Debug|Win32.ActiveCfg = Debug|Win32
     473                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Debug|Win32.Build.0 = Debug|Win32
     474                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Debug|x64.ActiveCfg = Debug|x64
     475                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Debug|x64.Build.0 = Debug|x64
     476                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Release|Win32.ActiveCfg = Release|Win32
     477                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Release|Win32.Build.0 = Release|Win32
     478                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Release|x64.ActiveCfg = Release|x64
     479                {3DA52489-3BF5-4180-AFFB-D337A667C1AE}.Static-Release|x64.Build.0 = Release|x64
     480                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Debug|Win32.ActiveCfg = Debug|Win32
     481                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Debug|Win32.Build.0 = Debug|Win32
     482                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Debug|x64.ActiveCfg = Debug|x64
     483                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Debug|x64.Build.0 = Debug|x64
     484                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Debug|Win32.ActiveCfg = Debug|Win32
     485                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Debug|Win32.Build.0 = Debug|Win32
     486                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Debug|x64.ActiveCfg = Debug|x64
     487                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Debug|x64.Build.0 = Debug|x64
     488                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Release|Win32.ActiveCfg = Release|Win32
     489                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Release|Win32.Build.0 = Release|Win32
     490                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Release|x64.ActiveCfg = Release|x64
     491                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.DLL Release|x64.Build.0 = Release|x64
     492                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Debug|Win32.ActiveCfg = Debug|Win32
     493                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Debug|Win32.Build.0 = Debug|Win32
     494                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Debug|x64.ActiveCfg = Debug|x64
     495                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Debug|x64.Build.0 = Debug|x64
     496                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Release|Win32.ActiveCfg = Release|Win32
     497                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Release|Win32.Build.0 = Release|Win32
     498                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Release|x64.ActiveCfg = Release|x64
     499                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.LIB Release|x64.Build.0 = Release|x64
     500                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Release|Win32.ActiveCfg = Release|Win32
     501                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Release|Win32.Build.0 = Release|Win32
     502                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Release|x64.ActiveCfg = Release|x64
     503                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Release|x64.Build.0 = Release|x64
     504                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Debug|Win32.ActiveCfg = Debug|Win32
     505                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Debug|Win32.Build.0 = Debug|Win32
     506                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Debug|x64.ActiveCfg = Debug|x64
     507                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Debug|x64.Build.0 = Debug|x64
     508                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Release|Win32.ActiveCfg = Release|Win32
     509                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Release|Win32.Build.0 = Release|Win32
     510                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Release|x64.ActiveCfg = Release|x64
     511                {2292BBEF-AD62-44FC-A2DD-9FD169C3604E}.Static-Release|x64.Build.0 = Release|x64
    444512        EndGlobalSection
    445513        GlobalSection(SolutionProperties) = preSolution
    446514                HideSolutionNode = FALSE
    447515        EndGlobalSection
    448         GlobalSection(Performance) = preSolution
    449                 HasPerformanceSessions = true
    450         EndGlobalSection
    451516EndGlobal
  • msvc2013/imgcnv.vcxproj

    r374 r429  
    1 <?xml version="1.0" encoding="utf-8"?>
     1<?xml version="1.0" encoding="utf-8"?>
    22<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    33  <ItemGroup Label="ProjectConfigurations">
  • msvc2013_imgcnvlib/imgcnvlib.vcxproj

    r420 r429  
    1 <?xml version="1.0" encoding="utf-8"?>
     1<?xml version="1.0" encoding="utf-8"?>
    22<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    33  <ItemGroup Label="ProjectConfigurations">
     
    2020  </ItemGroup>
    2121  <PropertyGroup Label="Globals">
    22     <ProjectGuid>{DFA9674B-761F-48B5-A261-9C386B1F2202}</ProjectGuid>
     22    <ProjectGuid>{3DA52489-3BF5-4180-AFFB-D337A667C1AE}</ProjectGuid>
    2323    <RootNamespace>imgcnv</RootNamespace>
    2424  </PropertyGroup>
  • src_bimread/bimread.pro

    r194 r429  
    11######################################################################
    22# Manually generated !!!
    3 # bimread v 1.22 Project file
     3# BioImageConvert v 1.50 Project file
     4# run: qmake bimread.pro in order to generate Makefile for your platform
    45# Copyright (c) 2005-2010, Bio-Image Informatic Center, UCSB
    56#
     
    1415#
    1516# To generate xcode project file:
    16 #   qmake -spec macx-xcode bimread.pro 
     17#   qmake -spec macx-xcode bimread.pro
    1718#
    1819# To generate Makefile on MacOSX with binary install:
     
    2526#---------------------------------------------------------------------
    2627APP_NAME = bimread
     28TARGET = bimread
    2729
    2830TEMPLATE = lib
    2931CONFIG  += dll
    30 
    31 VERSION = 0.1.22
    32  
    33 CONFIG += console
     32VERSION = 2.0.0
     33
     34CONFIG += console
     35
    3436CONFIG += release
    3537#CONFIG += debug
     
    3739
    3840# static library config
    39 # nothing defined uses dynamic system version
    40 # defining "stat_" - uses embedded version
    41 # defining "stat_sys_" - uses static system version
    42 
    4341CONFIG += stat_libtiff
    44 #CONFIG += stat_sys_libtiff
    45 
    46 CONFIG += stat_libjpeg
    47 #CONFIG += stat_sys_libjpeg
    48 
     42#CONFIG += stat_libjpeg
     43CONFIG += stat_libjpeg_turbo # pick one or the other
    4944CONFIG += stat_libpng
    50 #CONFIG += stat_sys_libpng
    51 
    5245CONFIG += stat_zlib
    53 #CONFIG += stat_sys_zlib
    54 
    55 # lib ffmpeg at this point is forced to be local copy since the trunc changes too much
    5646CONFIG += ffmpeg
    57 #CONFIG += sys_ffmpeg
    58 
    59 #CONFIG += stat_bzlib
    6047CONFIG += sys_bzlib
    61 macx:CONFIG += sys_bzlib
    62 
    6348CONFIG += stat_exiv2
    64 #CONFIG += sys_exiv2
    65 
    6649CONFIG += stat_eigen
    67 
    68 debug: {
     50CONFIG += libraw
     51CONFIG += stat_gdcm
     52#CONFIG += dyn_gdcm
     53
     54CONFIG(debug, debug|release) {
    6955   message(Building in DEBUG mode!)
    70    DEFINES += DEBUG _DEBUG _DEBUG_
    71 }
    72 
    73 unix {
     56   DEFINES += _DEBUG _DEBUG_
     57}
     58
     59macx {
     60  QMAKE_CFLAGS_RELEASE = -m64 -fPIC -fopenmp -O3 -ftree-vectorize -msse2 -ffast-math -ftree-vectorizer-verbose=0
     61  QMAKE_CXXFLAGS_RELEASE = -m64 -fPIC -fopenmp -O3 -ftree-vectorize -msse2 -ffast-math -ftree-vectorizer-verbose=0
     62  QMAKE_LFLAGS_RELEASE = -m64 -fPIC -fopenmp -O3 -ftree-vectorize -msse2 -ffast-math -ftree-vectorizer-verbose=0
     63  QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
     64} else:unix {
    7465  QMAKE_CFLAGS_DEBUG += -pg -fPIC -ggdb
    7566  QMAKE_CXXFLAGS_DEBUG += -pg -fPIC -ggdb
    76   QMAKE_LFLAGS_DEBUG += -pg -fPIC -ggdb
    77 
    78   QMAKE_CFLAGS_RELEASE += -fPIC
    79   QMAKE_CXXFLAGS_RELEASE += -fPIC
    80   QMAKE_LFLAGS_RELEASE += -fPIC
    81 }
    82 
    83 QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
    84 
    85 # Matlab path, required!!!
    86 # Start by trying if there's MATLAB environment variable
    87 MATLAB = $$(MATLAB)
    88 MATLAB_TEST = $$MATLAB/extern/src/mexversion.c
    89 !exists( $$MATLAB_TEST ) {
    90 
    91   #some default locations
    92   unix:MATLAB = /usr/local/matlab
    93   linux-g++-64:MATLAB = /usr/local/matlab
    94   win32:MATLAB = C:\MATLAB7
    95    
    96   MATLAB_TEST = $$MATLAB/extern/src/mexversion.c
    97   !exists( $$MATLAB_TEST ) {
    98     message( "Fatal error: Cannot find Matlab on your machine!!!" )
    99     error( "Try setting MATLAB environment variable or alter bimread.pro with the right path" )
    100   }
    101 }
     67  QMAKE_LFLAGS_DEBUG += -Wl,-Bsymbolic -pg -fPIC -ggdb
     68
     69  QMAKE_CFLAGS_RELEASE += -fPIC -fopenmp -O3 -ftree-vectorize -msse2 -ffast-math -ftree-vectorizer-verbose=0
     70  QMAKE_CXXFLAGS_RELEASE += -fPIC -fopenmp -O3 -ftree-vectorize -msse2 -ffast-math -ftree-vectorizer-verbose=0
     71  QMAKE_LFLAGS_RELEASE += -Wl,-Bsymbolic -fPIC -fopenmp -O3 -ftree-vectorize -msse2 -ffast-math -ftree-vectorizer-verbose=0
     72}
     73
    10274
    10375#---------------------------------------------------------------------
     
    10577#---------------------------------------------------------------------
    10678
    107 DN_SRC  = ./
     79BIM_SRC = ../src_bimread
    10880DN_LSRC = ../libsrc
    10981DN_LIBS = ../libs
    11082DN_IMGS = ../images
     83
     84HOSTTYPE = $$(HOSTTYPE)
     85
    11186unix {
    112   DN_GENS = ../generated/$$(HOSTTYPE)
     87  DN_GENS = ../.generated/$$HOSTTYPE
    11388  # path for object files
    11489  DN_OBJ = $$DN_GENS/obj
    11590  # path for generated binary
    116   DN_BIN = ../$$(HOSTTYPE)
     91  DN_BIN = ../$$HOSTTYPE
    11792}
    11893win32 {
    119   DN_GENS = ../generated/$(PlatformName)/$(ConfigurationName)
     94  DN_GENS = ../.generated/$(PlatformName)/$(ConfigurationName)
    12095  # path for object files
    12196  DN_OBJ = $$DN_GENS
     
    141116DN_LIB_EXIV2   = $$DN_LSRC/exiv2
    142117DN_LIB_EIGEN   = $$DN_LSRC/eigen
     118DN_LIB_RAW     = $$DN_LSRC/libraw
     119BIM_LIB_GDCM   = $$DN_LSRC/gdcm
     120
     121#---------------------------------------------------------------------
     122# configuration: matlab
     123#---------------------------------------------------------------------
     124
     125# Matlab path, required!!!
     126# Start by trying if there's MATLAB environment variable
     127MATLAB = $$(MATLAB)
     128MATLAB_TEST = $$MATLAB/extern/src/mexversion.c
     129!exists( $$MATLAB_TEST ) {
     130
     131  #some default locations
     132  unix:MATLAB = /usr/local/matlab
     133  linux-g++-64:MATLAB = /usr/local/matlab
     134  win32:MATLAB = C:\MATLAB
     135   
     136  MATLAB_TEST = $$MATLAB/extern/src/mexversion.c
     137  !exists( $$MATLAB_TEST ) {
     138    message( "Fatal error: Cannot find Matlab on your machine!!!" )
     139    error( "Try setting MATLAB environment variable or alter bimread.pro with the right path" )
     140  }
     141}
    143142
    144143##################################
     
    258257
    259258win32: {
    260   DN_LIBS_PLTFM = $$DN_LIBS/vc2008
     259  BIM_LIBS_PLTFM = $$DN_LIBS/vc2008
    261260} else:macx {
    262   DN_LIBS_PLTFM = $$DN_LIBS/macosx
     261  BIM_LIBS_PLTFM = $$DN_LIBS/macosx
    263262} else:unix {
    264   DN_LIBS_PLTFM = $$DN_LIBS/linux/$$(HOSTTYPE)
     263  BIM_LIBS_PLTFM = $$DN_LIBS/linux/$$HOSTTYPE
    265264} else {
    266   DN_LIBS_PLTFM = $$DN_LIBS/linux
     265  BIM_LIBS_PLTFM = $$DN_LIBS/linux
    267266}
    268267
     
    272271    system( mkdir -p $$DN_GENS )
    273272  }
    274 }
     273  !exists( $$DN_OBJ ) {
     274    message( "Cannot find directory: $$DN_OBJ, creating..." )
     275    system( mkdir -p $$DN_OBJ )
     276  }
     277}
     278
    275279win32 {
    276280  !exists( $$DN_GENS ) {
    277281    message( "Cannot find directory: $$DN_GENS, creating..." )
    278     !exists( ../generated/Win32/Debug       ) { system( mkdir ..\\generated\\Win32\\Debug ) }
    279     !exists( ../generated/Win32/Release     ) { system( mkdir ..\\generated\\Win32\\Release ) }
    280     !exists( ../generated/Win32/ICC_Release ) { system( mkdir ..\\generated\\Win32\\ICC_Release ) }
    281     !exists( ../generated/x64/Debug         ) { system( mkdir ..\\generated\\x64\\Debug ) }
    282     !exists( ../generated/x64/Release       ) { system( mkdir ..\\generated\\x64\\Release ) }
    283     !exists( ../generated/x64/ICC_Release   ) { system( mkdir ..\\generated\\x64\\ICC_Release ) }
    284   }
    285 }
    286 
    287 unix {
    288   !exists( $$DN_OBJ ) {
    289     message( "Cannot find directory: $$DN_OBJ, creating..." )
    290     system( mkdir -p $$DN_OBJ )
    291   }
    292 }
    293 win32 {
     282    !exists( ../.generated/Win32/Debug       ) { system( mkdir ..\\.generated\\Win32\\Debug ) }
     283    !exists( ../.generated/Win32/Release     ) { system( mkdir ..\\.generated\\Win32\\Release ) }
     284    !exists( ../.generated/Win32/ICC_Release ) { system( mkdir ..\\.generated\\Win32\\ICC_Release ) }
     285    !exists( ../.generated/x64/Debug         ) { system( mkdir ..\\.generated\\x64\\Debug ) }
     286    !exists( ../.generated/x64/Release       ) { system( mkdir ..\\.generated\\x64\\Release ) }
     287    !exists( ../.generated/x64/ICC_Release   ) { system( mkdir ..\\.generated\\x64\\ICC_Release ) }
     288  }
    294289  !exists( $$DN_OBJ ) {
    295290    message( "Cannot find directory: $$DN_GENS, creating..." )
    296     !exists( ../generated/Win32/Debug   ) { system( mkdir ..\\generated\\Win32\\Debug ) }
    297     !exists( ../generated/Win32/Release ) { system( mkdir ..\\generated\\Win32\\Release ) }
    298     !exists( ../generated/x64/Debug     ) { system( mkdir ..\\generated\\x64\\Debug ) }
    299     !exists( ../generated/x64/Release   ) { system( mkdir ..\\generated\\x64\\Release ) }
    300   }
    301 }
    302 
    303 # compile ffmpeg
    304 ffmpeg {
    305   #message( "Compiling FFMPEG as requested..." )
    306   #win32 {
    307   #  message( "Attention: Cygwin and VC++2005 are required for ffmpeg windows compilation" ) 
    308   #  system( cd $$DN_LIB_FFMPEG ; sh ./build-ffmpeg-cygwin.sh ; cd ../../ )
    309   #} else:macx {
    310   #  system( cd $$DN_LIB_FFMPEG ; sh ./build-ffmpeg-macosx.sh ; cd ../../ )
    311   #} else {
    312   #  system( cd $$DN_LIB_FFMPEG ; sh ./build-ffmpeg-linux.sh ; cd ../../ ) 
    313   #} 
    314 }
    315 
    316 #---------------------------------------------------------------------
    317 # library configuration: automatic
    318 #---------------------------------------------------------------------
    319 
    320 # By default all libraries are static, we can check for existing
    321 # ones and use dynamic linking for those
    322 
    323 unix {
    324 
    325   exists( $$DN_GENS ) {
    326     #checking for libtiff... -ltiff
    327     #CONFIG -= stat_libtiff
    328   }
    329  
    330   exists( $$DN_GENS ) {
    331     #checking for libjpeg... -ljpeg
    332     #CONFIG -= stat_libjpeg
    333   }
    334  
    335   exists( $$DN_GENS ) { 
    336     #checking for libpng... -lpng -lz -lm
    337     #CONFIG -= stat_libpng
    338   }
    339 
    340   exists( $$DN_GENS ) {
    341     #checking for libz... -lz
    342     #CONFIG -= stat_zlib
    343   }
    344 
    345 }
    346 
    347 # mac os x
    348 macx {
    349   CONFIG -= stat_zlib
    350 }
    351 
    352 
    353 #---------------------------------------------------------------------
    354 # generation: fixed
     291    !exists( ../.generated/Win32/Debug   ) { system( mkdir ..\\.generated\\Win32\\Debug ) }
     292    !exists( ../.generated/Win32/Release ) { system( mkdir ..\\.generated\\Win32\\Release ) }
     293    !exists( ../.generated/x64/Debug     ) { system( mkdir ..\\.generated\\x64\\Debug ) }
     294    !exists( ../.generated/x64/Release   ) { system( mkdir ..\\.generated\\x64\\Release ) }
     295  }
     296}
     297
     298#---------------------------------------------------------------------
     299# generation: required
    355300#---------------------------------------------------------------------
    356301
     
    360305DESTDIR = $$DN_BIN
    361306OBJECTS_DIR = $$DN_OBJ
    362 
    363307INCLUDEPATH += $$DN_GENS
    364 DEPENDPATH += $$DN_GENS
    365 
    366 INCLUDEPATH += $$MATLAB_INC
    367308
    368309#---------------------------------------------------------------------
     
    370311#---------------------------------------------------------------------
    371312
    372 #Main           
    373 SOURCES += mex_bimread.cpp
    374 
    375 #---------------------------------------------------------------------
    376 #image formats library           
    377 #---------------------------------------------------------------------
     313SOURCES += $$BIM_SRC/mex_bimread.cpp
     314
     315#---------------------------------------------------------------------
     316# libbioimage
     317#---------------------------------------------------------------------
     318
     319DEFINES += BIM_USE_OPENMP
     320#DEFINES += BIM_USE_EIGEN
     321DEFINES += BIM_USE_TRANSFORMS
     322DEFINES += BIM_USE_FILTERS
    378323
    379324INCLUDEPATH += $$DN_LIB_BIO
     
    382327INCLUDEPATH += $$DN_CORE
    383328
    384 #core
    385 SOURCES += $$DN_CORE/xstring.cpp $$DN_CORE/xtypes.cpp \
    386            $$DN_CORE/tag_map.cpp $$DN_CORE/xpointer.cpp $$DN_CORE/xconf.cpp
    387 
    388 #Formats API
    389 SOURCES += $$DN_FMTS_API/dim_img_format_utils.cpp \
    390            $$DN_FMTS_API/dim_buffer.cpp \
    391            $$DN_FMTS_API/dim_histogram.cpp \
    392            $$DN_FMTS_API/bim_metatags.cpp \
    393            $$DN_FMTS_API/dim_image.cpp \
    394            $$DN_FMTS_API/dim_image_pyramid.cpp \
    395            $$DN_FMTS_API/dim_image_stack.cpp
    396            
    397 #Formats     
    398 SOURCES += $$DN_FMTS/dim_format_manager.cpp \
    399            $$DN_FMTS/meta_format_manager.cpp\
    400            $$DN_FMTS/tiff/dim_tiff_format.cpp \
    401            $$DN_FMTS/tiff/dim_xtiff.c \
    402            $$DN_FMTS/tiff/memio.c \
    403            $$DN_FMTS/dmemio.cpp \
    404            $$DN_FMTS/jpeg/dim_jpeg_format.cpp \
    405            $$DN_FMTS/biorad_pic/dim_biorad_pic_format.cpp \
    406            $$DN_FMTS/bmp/dim_bmp_format.cpp \
    407            $$DN_FMTS/png/dim_png_format.cpp \
    408            $$DN_FMTS/nanoscope/dim_nanoscope_format.cpp \
    409            $$DN_FMTS/raw/dim_raw_format.cpp \
    410            $$DN_FMTS/ibw/dim_ibw_format.cpp \
    411            $$DN_FMTS/ome/dim_ome_format.cpp\
    412            $$DN_FMTS/ole/dim_ole_format.cpp\
    413            $$DN_FMTS/ole/zvi.cpp
    414 
    415 #---------------------------------------------------------------------       
    416 #Pole
    417 
    418 D_LIB_POLE = $$DN_LSRC/pole
    419 INCLUDEPATH += $$D_LIB_POLE
    420 
    421 SOURCES += $$D_LIB_POLE/pole.cpp
    422 
    423 #---------------------------------------------------------------------       
    424 #ffmpeg
    425 
    426 ffmpeg {
    427 
    428   DEFINES  += DIM_FFMPEG_FORMAT FFMPEG_VIDEO_DISABLE_MATLAB
    429   INCLUDEPATH += $$DN_LIB_FFMPEG/include
    430   #INCLUDEPATH += $$DN_LIB_FFMPEG/ffmpeg-out/$$(HOSTTYPE)/include
    431   win32:INCLUDEPATH += $$DN_LIB_FFMPEG/include-win
    432 
    433   SOURCES += $$DN_FMT_FFMPEG/debug.cpp $$DN_FMT_FFMPEG/dim_ffmpeg_format.cpp \
    434              $$DN_FMT_FFMPEG/FfmpegCommon.cpp $$DN_FMT_FFMPEG/FfmpegIVideo.cpp \
    435              $$DN_FMT_FFMPEG/FfmpegOVideo.cpp $$DN_FMT_FFMPEG/registry.cpp
    436            
    437   win32 {   
    438     LIBS += $$DN_LIBS_PLTFM/avcodec-51.lib
    439     LIBS += $$DN_LIBS_PLTFM/avformat-52.lib
    440     LIBS += $$DN_LIBS_PLTFM/avutil-50.lib
    441     LIBS += $$DN_LIBS_PLTFM/swscale-0.lib
    442   } else {
    443     LIBS += $$DN_LIBS_PLTFM/libavformat.a
    444     LIBS += $$DN_LIBS_PLTFM/libavcodec.a
    445     LIBS += $$DN_LIBS_PLTFM/libswscale.a
    446     LIBS += $$DN_LIBS_PLTFM/libavutil.a 
    447   }
    448 } # FFMPEG           
    449 
    450  
    451 #---------------------------------------------------------------------
    452 # Now adding static libraries
    453 #---------------------------------------------------------------------
    454 
    455 #some configs first
    456 unix:DEFINES  += HAVE_UNISTD_H
    457 unix:DEFINES  -= HAVE_IO_H
    458 win32:DEFINES += HAVE_IO_H
    459 macx:DEFINES  += HAVE_UNISTD_H
    460 #macx:DEFINES  += WORDS_BIGENDIAN
    461 macx:DEFINES  -= HAVE_IO_H
    462 
    463 #---------------------------------------------------------------------
    464 #LibTiff
    465 
    466 stat_libtiff {
    467   INCLUDEPATH += $$DN_LIB_TIF
    468   SOURCES += $$DN_LIB_TIF/tif_fax3sm.c $$DN_LIB_TIF/tif_aux.c \
    469              $$DN_LIB_TIF/tif_close.c $$DN_LIB_TIF/tif_codec.c \
    470              $$DN_LIB_TIF/tif_color.c $$DN_LIB_TIF/tif_compress.c \
    471              $$DN_LIB_TIF/tif_dir.c $$DN_LIB_TIF/tif_dirinfo.c \
    472              $$DN_LIB_TIF/tif_dirread.c $$DN_LIB_TIF/tif_dirwrite.c \
    473              $$DN_LIB_TIF/tif_dumpmode.c $$DN_LIB_TIF/tif_error.c \
    474              $$DN_LIB_TIF/tif_extension.c $$DN_LIB_TIF/tif_fax3.c \
    475              $$DN_LIB_TIF/tif_flush.c $$DN_LIB_TIF/tif_getimage.c \
    476              $$DN_LIB_TIF/tif_jpeg.c $$DN_LIB_TIF/tif_luv.c \
    477              $$DN_LIB_TIF/tif_lzw.c $$DN_LIB_TIF/tif_next.c \
    478              $$DN_LIB_TIF/tif_open.c $$DN_LIB_TIF/tif_packbits.c \
    479              $$DN_LIB_TIF/tif_pixarlog.c $$DN_LIB_TIF/tif_predict.c \
    480              $$DN_LIB_TIF/tif_print.c $$DN_LIB_TIF/tif_read.c \
    481              $$DN_LIB_TIF/tif_strip.c $$DN_LIB_TIF/tif_swab.c \
    482              $$DN_LIB_TIF/tif_thunder.c $$DN_LIB_TIF/tif_tile.c \
    483              $$DN_LIB_TIF/tif_version.c $$DN_LIB_TIF/tif_warning.c \
    484              $$DN_LIB_TIF/tif_write.c $$DN_LIB_TIF/tif_zip.c
    485            
    486   unix:SOURCES  += $$DN_LIB_TIF/tif_unix.c
    487   win32:SOURCES += $$DN_LIB_TIF/tif_win32.c
    488 }
    489 
    490 !stat_libtiff {
    491   unix {
    492     stat_sys_libtiff {
    493       LIBS += /usr/lib/libtiff.a
    494     } else {
    495       LIBS += -ltiff
    496     }
    497   }
    498   win32:LIBS += $$DN_LIBS_PLTFM/libtiff.lib
    499 }
    500 
    501 #---------------------------------------------------------------------       
    502 #LibPng
    503 
    504 stat_libpng {
    505 
    506   INCLUDEPATH += $$DN_LIB_PNG
    507   # by default disable intel asm code
    508   unix:DEFINES += PNG_NO_ASSEMBLER_CODE PNG_USE_PNGVCRD
    509 
    510   # enable only for x86 machines (not x64)
    511   #message( "Enable Intel ASM code for PNG..." )
    512   win32:DEFINES -= PNG_NO_ASSEMBLER_CODE PNG_USE_PNGVCRD
    513   macx:DEFINES -= PNG_NO_ASSEMBLER_CODE PNG_USE_PNGVCRD
    514   linux-g++-32:DEFINES -= PNG_NO_ASSEMBLER_CODE PNG_USE_PNGVCRD
    515 
    516   SOURCES += $$DN_LIB_PNG/png.c $$DN_LIB_PNG/pngerror.c $$DN_LIB_PNG/pngget.c \
    517              $$DN_LIB_PNG/pngmem.c $$DN_LIB_PNG/pngpread.c $$DN_LIB_PNG/pngread.c \
    518              $$DN_LIB_PNG/pngrio.c $$DN_LIB_PNG/pngrtran.c $$DN_LIB_PNG/pngrutil.c \
    519              $$DN_LIB_PNG/pngset.c $$DN_LIB_PNG/pngtrans.c \
    520              $$DN_LIB_PNG/pngwio.c $$DN_LIB_PNG/pngwrite.c $$DN_LIB_PNG/pngwtran.c \
    521              $$DN_LIB_PNG/pngwutil.c
    522 }
    523 
    524 !stat_libpng {
    525   unix {
    526     stat_sys_libpng {
    527       LIBS += /usr/lib/libpng.a
    528     } else {
    529       LIBS += -lpng
    530     }
    531   }
    532   win32:LIBS += $$DN_LIBS_PLTFM/libpng.lib
    533 }
    534 
    535  
    536 #---------------------------------------------------------------------         
    537 #ZLib
    538 
    539 stat_zlib {
    540   INCLUDEPATH += $$DN_LIB_Z
    541   SOURCES += $$DN_LIB_Z/adler32.c $$DN_LIB_Z/compress.c $$DN_LIB_Z/crc32.c \
    542              $$DN_LIB_Z/deflate.c $$DN_LIB_Z/gzio.c $$DN_LIB_Z/infback.c \
    543              $$DN_LIB_Z/inffast.c $$DN_LIB_Z/inflate.c $$DN_LIB_Z/inftrees.c \
    544              $$DN_LIB_Z/trees.c $$DN_LIB_Z/uncompr.c $$DN_LIB_Z/zutil.c
    545 }
    546 
    547 !stat_zlib {
    548   unix {
    549     stat_sys_zlib {
    550       LIBS += /usr/lib/libz.a
    551     } else {
    552       LIBS += -lz
    553     }
    554   }
    555   win32:LIBS += $$DN_LIBS_PLTFM/zlib.lib 
    556 }
    557 
    558 #---------------------------------------------------------------------
    559 #libjpeg
    560 
    561 stat_libjpeg {
    562   INCLUDEPATH += $$DN_LIB_JPG
    563   SOURCES += $$DN_LIB_JPG/jaricom.c $$DN_LIB_JPG/jcapimin.c $$DN_LIB_JPG/jcapistd.c \
    564        $$DN_LIB_JPG/jcarith.c $$DN_LIB_JPG/jccoefct.c \
    565              $$DN_LIB_JPG/jccolor.c $$DN_LIB_JPG/jcdctmgr.c $$DN_LIB_JPG/jchuff.c \
    566              $$DN_LIB_JPG/jcinit.c $$DN_LIB_JPG/jcmainct.c $$DN_LIB_JPG/jcmarker.c \
    567              $$DN_LIB_JPG/jcmaster.c $$DN_LIB_JPG/jcomapi.c $$DN_LIB_JPG/jcparam.c \
    568              $$DN_LIB_JPG/jcprepct.c $$DN_LIB_JPG/jcsample.c $$DN_LIB_JPG/jctrans.c \
    569              $$DN_LIB_JPG/jdapimin.c $$DN_LIB_JPG/jdapistd.c $$DN_LIB_JPG/jdarith.c \
    570              $$DN_LIB_JPG/jdatadst.c $$DN_LIB_JPG/jdatasrc.c $$DN_LIB_JPG/jdcoefct.c \
    571              $$DN_LIB_JPG/jdcolor.c $$DN_LIB_JPG/jddctmgr.c $$DN_LIB_JPG/jdhuff.c \
    572              $$DN_LIB_JPG/jdinput.c $$DN_LIB_JPG/jdmainct.c $$DN_LIB_JPG/jdmarker.c \
    573              $$DN_LIB_JPG/jdmaster.c $$DN_LIB_JPG/jdmerge.c \
    574              $$DN_LIB_JPG/jdpostct.c $$DN_LIB_JPG/jdsample.c $$DN_LIB_JPG/jdtrans.c \
    575              $$DN_LIB_JPG/jerror.c $$DN_LIB_JPG/jfdctflt.c $$DN_LIB_JPG/jfdctfst.c \
    576              $$DN_LIB_JPG/jfdctint.c $$DN_LIB_JPG/jidctflt.c $$DN_LIB_JPG/jidctfst.c \
    577              $$DN_LIB_JPG/jidctint.c $$DN_LIB_JPG/jmemmgr.c \
    578              $$DN_LIB_JPG/jquant1.c $$DN_LIB_JPG/jquant2.c $$DN_LIB_JPG/jutils.c \
    579              $$DN_LIB_JPG/jmemansi.c
    580 }
    581 
    582 !stat_libjpeg {
    583   unix {
    584     stat_sys_libjpeg {
    585       LIBS += /usr/lib/libjpeg.a
    586     } else {
    587       LIBS += -ljpeg
    588     }
    589   }
    590   win32:LIBS += $$DN_LIBS_PLTFM/libjpeg.lib
    591 }   
    592 
    593 #---------------------------------------------------------------------
    594 #bzlib
    595    
    596 stat_bzlib {
    597   INCLUDEPATH += $$DN_LIB_BZ2
    598   SOURCES += $$DN_LIB_BZ2/blocksort.c $$DN_LIB_BZ2/bzlib.c $$DN_LIB_BZ2/randtable.c \
    599              $$DN_LIB_BZ2/compress.c $$DN_LIB_BZ2/crctable.c $$DN_LIB_BZ2/decompress.c $$DN_LIB_BZ2/huffman.c
    600 }
    601 
    602 sys_bzlib {
    603    unix:LIBS += -lbz2
    604    macx:LIBS += -lbz2     
    605    #win32:LIBS += $$DN_LIBS_PLTFM/libbz2.lib     
    606 }
    607  
    608 #---------------------------------------------------------------------
    609 #exiv2
    610 
    611 stat_exiv2 {
    612   INCLUDEPATH += $$DN_LIB_EXIV2
    613   INCLUDEPATH += $$DN_LIB_EXIV2/exiv2 
    614   SOURCES += $$DN_LIB_EXIV2/exiv2/basicio.cpp $$DN_LIB_EXIV2/exiv2/bmpimage.cpp \
    615           $$DN_LIB_EXIV2/exiv2/canonmn.cpp $$DN_LIB_EXIV2/exiv2/convert.cpp $$DN_LIB_EXIV2/exiv2/cr2image.cpp \
    616           $$DN_LIB_EXIV2/exiv2/crwimage.cpp $$DN_LIB_EXIV2/exiv2/datasets.cpp $$DN_LIB_EXIV2/exiv2/easyaccess.cpp \
    617           $$DN_LIB_EXIV2/exiv2/error.cpp $$DN_LIB_EXIV2/exiv2/exif.cpp $$DN_LIB_EXIV2/exiv2/futils.cpp \
    618           $$DN_LIB_EXIV2/exiv2/fujimn.cpp $$DN_LIB_EXIV2/exiv2/gifimage.cpp $$DN_LIB_EXIV2/exiv2/image.cpp \
    619           $$DN_LIB_EXIV2/exiv2/iptc.cpp $$DN_LIB_EXIV2/exiv2/jp2image.cpp $$DN_LIB_EXIV2/exiv2/jpgimage.cpp \
    620           $$DN_LIB_EXIV2/exiv2/makernote.cpp $$DN_LIB_EXIV2/exiv2/metadatum.cpp $$DN_LIB_EXIV2/exiv2/minoltamn.cpp \
    621           $$DN_LIB_EXIV2/exiv2/mrwimage.cpp $$DN_LIB_EXIV2/exiv2/nikonmn.cpp $$DN_LIB_EXIV2/exiv2/olympusmn.cpp \
    622           $$DN_LIB_EXIV2/exiv2/orfimage.cpp $$DN_LIB_EXIV2/exiv2/panasonicmn.cpp $$DN_LIB_EXIV2/exiv2/pgfimage.cpp \
    623     $$DN_LIB_EXIV2/exiv2/pngimage.cpp $$DN_LIB_EXIV2/exiv2/pngchunk.cpp $$DN_LIB_EXIV2/exiv2/preview.cpp \
    624           $$DN_LIB_EXIV2/exiv2/properties.cpp $$DN_LIB_EXIV2/exiv2/psdimage.cpp $$DN_LIB_EXIV2/exiv2/rafimage.cpp \
    625           $$DN_LIB_EXIV2/exiv2/rw2image.cpp $$DN_LIB_EXIV2/exiv2/sigmamn.cpp $$DN_LIB_EXIV2/exiv2/pentaxmn.cpp \
    626           $$DN_LIB_EXIV2/exiv2/sonymn.cpp $$DN_LIB_EXIV2/exiv2/tags.cpp $$DN_LIB_EXIV2/exiv2/tgaimage.cpp \
    627           $$DN_LIB_EXIV2/exiv2/tiffcomposite.cpp $$DN_LIB_EXIV2/exiv2/tiffimage.cpp $$DN_LIB_EXIV2/exiv2/tiffvisitor.cpp \
    628           $$DN_LIB_EXIV2/exiv2/types.cpp $$DN_LIB_EXIV2/exiv2/value.cpp $$DN_LIB_EXIV2/exiv2/version.cpp \
    629           $$DN_LIB_EXIV2/exiv2/xmp.cpp $$DN_LIB_EXIV2/exiv2/xmpsidecar.cpp
    630 }
    631 
    632 sys_exiv2 {
    633   unix:LIBS += -lexiv2
    634   win32:LIBS += $$DN_LIBS_PLTFM/libexiv2.lib
    635 
    636 
    637 #---------------------------------------------------------------------
    638 #eigen
     329unix:LIBS += -lbz2
     330unix:LIBS += -ldl
     331#SUBDIRS = $$DN_LIB_BIO/bioimage.pro
     332
     333macx {
     334  LIBS += $$BIM_LIBS_PLTFM/libfftw3.a
     335  LIBS += -lz
     336} else:unix {
     337  LIBS += -lfftw3
     338}
     339
     340PRE_TARGETDEPS = $$DN_LIB_BIO/.generated/libbioimage.a
     341LIBS += $$DN_LIB_BIO/.generated/libbioimage.a
     342
     343BimLib.target = $$DN_LIB_BIO/.generated/libbioimage.a
     344#BimLib.commands = cd $$DN_LIB_BIO && qmake bioimage.pro && make
     345BimLib.depends = $$DN_LIB_BIO/Makefile
     346QMAKE_EXTRA_TARGETS += BimLib
     347
     348
     349#---------------------------------------------------------------------
     350# eigen
     351#---------------------------------------------------------------------
    639352
    640353stat_eigen {
     
    643356
    644357#---------------------------------------------------------------------
    645 
    646 DEPENDPATH += $$INCLUDEPATH
    647 
    648 #---------------------------------------------------------------------
    649 #install target
    650 staticlib {
    651   INSTALLHEADERS.files += $$DN_FMTS/dim_format_manager.h \
    652                           $$DN_FMTS/meta_format_manager.h \
    653                           $$DN_FMTS_API/dim_img_format_interface.h \
    654                           $$DN_FMTS_API/dim_img_format_utils.h \
    655                           $$DN_FMTS_API/dim_image.h \
    656                           $$DN_FMTS_API/dim_histogram.h \
    657                           $$DN_FMTS_API/dim_buffer.h \
    658                           $$DN_CORE/tag_map.h
    659   INSTALLHEADERS.files += $$DN_LIBS_PLTFM/adler32.h \
    660                           $$DN_LIBS_PLTFM/avcodec.h $$DN_LIBS_PLTFM/avdevice.h \
    661                           $$DN_LIBS_PLTFM/avformat.h $$DN_LIBS_PLTFM/avio.h \
    662                           $$DN_LIBS_PLTFM/avstring.h $$DN_LIBS_PLTFM/avutil.h \
    663                           $$DN_LIBS_PLTFM/base64.h $$DN_LIBS_PLTFM/common.h \
    664                           $$DN_LIBS_PLTFM/crc.h $$DN_LIBS_PLTFM/fifo.h \
    665                           $$DN_LIBS_PLTFM/intfloat_readwrite.h $$DN_LIBS_PLTFM/log.h \
    666                           $$DN_LIBS_PLTFM/lzo.h $$DN_LIBS_PLTFM/mathematics.h \
    667                           $$DN_LIBS_PLTFM/md5.h $$DN_LIBS_PLTFM/mem.h \
    668                           $$DN_LIBS_PLTFM/opt.h $$DN_LIBS_PLTFM/random.h \
    669                           $$DN_LIBS_PLTFM/rational.h $$DN_LIBS_PLTFM/rgb2rgb.h \
    670                           $$DN_LIBS_PLTFM/rtspcodes.h $$DN_LIBS_PLTFM/rtsp.h \
    671                           $$DN_LIBS_PLTFM/sha1.h $$DN_LIBS_PLTFM/swscale.h
    672   INSTALLHEADERS.path = /include
    673   INSTALLS += INSTALLHEADERS
    674 
    675   INSTALLBINS.files += $$DN_BIN/lib$${TARGET}.a \
    676                        $$DN_LIBS_PLTFM/libavcodec.a \
    677                        $$DN_LIBS_PLTFM/libavformat.a \
    678                        $$DN_LIBS_PLTFM/libavutil.a \
    679                        $$DN_LIBS_PLTFM/libswscale.a
    680   INSTALLBINS.path = /lib
    681 } else {
    682   INSTALLBINS.files += $$DN_BIN/$${TARGET}
    683   INSTALLBINS.path = /bin
    684 }
    685 INSTALLS += INSTALLBINS
     358# jpeg-turbo
     359#---------------------------------------------------------------------
     360
     361stat_libjpeg_turbo {
     362
     363  win32 {
     364    LIBS += $$BIM_LIBS_PLTFM/turbojpeg-static.lib
     365  } else {
     366    #LIBS += $$BIM_LIBS_PLTFM/libjpeg.a
     367    LIBS += $$BIM_LIBS_PLTFM/libturbojpeg.a
     368  }
     369
     370} # JPEG-TURBO
     371
     372#---------------------------------------------------------------------
     373# ffmpeg
     374#---------------------------------------------------------------------
     375
     376ffmpeg {
     377
     378  win32 {
     379    LIBS += $$BIM_LIBS_PLTFM/avcodec.lib
     380    LIBS += $$BIM_LIBS_PLTFM/avformat.lib
     381    LIBS += $$BIM_LIBS_PLTFM/avutil.lib
     382    LIBS += $$BIM_LIBS_PLTFM/swscale.lib
     383  } macx {
     384    LIBS += $$BIM_LIBS_PLTFM/libavformat.a
     385    LIBS += $$BIM_LIBS_PLTFM/libavcodec.a
     386    LIBS += $$BIM_LIBS_PLTFM/libswresample.a
     387    LIBS += $$BIM_LIBS_PLTFM/libswscale.a
     388    LIBS += $$BIM_LIBS_PLTFM/libavutil.a
     389    LIBS += $$BIM_LIBS_PLTFM/libvpx.a
     390    LIBS += $$BIM_LIBS_PLTFM/libx264.a
     391    LIBS += $$BIM_LIBS_PLTFM/libx265.a
     392    LIBS += $$BIM_LIBS_PLTFM/libxvidcore.a
     393    LIBS += $$BIM_LIBS_PLTFM/libogg.a
     394    LIBS += $$BIM_LIBS_PLTFM/libtheora.a
     395    LIBS += $$BIM_LIBS_PLTFM/libtheoraenc.a
     396    LIBS += $$BIM_LIBS_PLTFM/libtheoradec.a
     397    LIBS += -lpthread
     398    #LIBS += -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
     399  } else:unix {
     400    LIBS += $$BIM_LIBS_PLTFM/libavformat.a
     401    LIBS += $$BIM_LIBS_PLTFM/libavcodec.a
     402    LIBS += $$BIM_LIBS_PLTFM/libswresample.a
     403    LIBS += $$BIM_LIBS_PLTFM/libswscale.a
     404    LIBS += $$BIM_LIBS_PLTFM/libavutil.a
     405    LIBS += $$BIM_LIBS_PLTFM/libvpx.a
     406    LIBS += $$BIM_LIBS_PLTFM/libx264.a
     407    LIBS += $$BIM_LIBS_PLTFM/libx265.a
     408    LIBS += -lpthread -lxvidcore -lopenjpeg -lschroedinger-1.0 -ltheora -ltheoraenc -ltheoradec
     409  }
     410
     411} # FFMPEG
     412
     413#---------------------------------------------------------------------
     414# GDCM - under linux we only use system dynamic version right now
     415#---------------------------------------------------------------------
     416
     417stat_gdcm {
     418
     419  win32 {
     420    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmjpeg12.lib
     421    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmjpeg16.lib
     422    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmjpeg8.lib
     423    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmcharls.lib
     424    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmCommon.lib
     425    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmDICT.lib
     426    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmDSED.lib
     427    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmexpat.lib
     428    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmgetopt.lib
     429    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmIOD.lib
     430    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmMEXD.lib
     431    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmMSFF.lib
     432    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmopenjpeg.lib
     433    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmzlib.lib
     434    LIBS += $$BIM_LIBS_PLTFM/gdcm/socketxx.lib
     435  } else {
     436    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmDICT.a
     437    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmMSFF.a
     438    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmCommon.a
     439    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmDSED.a
     440    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmIOD.a
     441    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmcharls.a
     442    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmexpat.a
     443    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmjpeg8.a
     444    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmjpeg12.a
     445    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmjpeg16.a
     446    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmopenjpeg.a
     447    LIBS += $$BIM_LIBS_PLTFM/gdcm/libgdcmzlib.a
     448  }
     449
     450} # static GDCM
     451
     452dyn_gdcm {
     453  DEFINES += BIM_GDCM_FORMAT
     454  SOURCES += $$BIM_FMT_DICOM/bim_dicom_format.cpp
     455
     456  win32 {
     457#    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmIOD.lib
     458  } else:macx {
     459#    LIBS += $$BIM_LIBS_PLTFM/gdcm/gdcmIOD.a
     460  } else:unix {
     461    LIBS += -lgdcm
     462  }
     463
     464} # System GDCM
  • src_bimread/mex_bimread.cpp

    r194 r429  
    3737#include <string.h>
    3838
    39 #include <xstring.h>
    40 
    41 #include <dim_img_format_interface.h>
    42 #include <dim_img_format_utils.h>
    43 #include <dim_image.h>
    44 #include <dim_format_manager.h>
    45 #include <meta_format_manager.h>
     39#include <BioImageCore>
     40#include <BioImage>
     41#include <BioImageFormats>
    4642
    4743extern "C" {
     
    4945}
    5046
     47using namespace bim;
     48
    5149template <typename T>
    52 void copy_data ( const TDimImage &img, mxArray *plhs[] ) {
    53   T *p = (T *) mxGetData(plhs[0]);
    54   for (unsigned int c=0; c<img.samples(); ++c)
    55   for (unsigned int x=0; x<img.width(); ++x)
    56   for (unsigned int y=0; y<img.height(); ++y) {
    57     T *ip = (T *) img.scanLine( c, y );
    58     *p = ip[x];
    59     ++p;
    60   } // y
     50void copy_data(const Image &img, mxArray *plhs[]) {
     51    T *p = (T *)mxGetData(plhs[0]);
     52    for (unsigned int c = 0; c < img.samples(); ++c)
     53    for (unsigned int x = 0; x < img.width(); ++x)
     54    for (unsigned int y = 0; y < img.height(); ++y) {
     55        T *ip = (T *)img.scanLine(c, y);
     56        *p = ip[x];
     57        ++p;
     58    } // y
    6159}
    6260
     
    6967  typedef size_t    mwSize;
    7068  #endif
    71 #endif
    72 */
     69  #endif
     70  */
    7371//------------------------------------------------------------------------------
    7472// function: mex_bimread - entry point from Matlab via mexFucntion()
     
    8179//------------------------------------------------------------------------------
    8280
    83 void mex_bimread( int nlhs, mxArray *plhs[], int nrhs, const mxArray  *prhs[] )
     81void mex_bimread(int nlhs, mxArray *plhs[], int nrhs, const mxArray  *prhs[])
    8482{
    85         // Check for proper number of input and output arguments
    86         if (nrhs < 1) mexErrMsgTxt("At least 1 input arguments required. Usage: bimread( fname, page_num ).");
    87         if (nlhs < 1) mexErrMsgTxt("At least 1 output argument required. Usage: [ im, format, pages, xyzres, metatxt ] = bimread.");
    88   if (nrhs > 2) mexErrMsgTxt("Too many input arguments. Usage: bimread( fname, page_num ).");
    89   if (nlhs > 5) mexErrMsgTxt("Too many output arguments. Usage: [ im, format, pages, xyzres, metatxt ] = bimread.");
    90 
    91   // input
    92   char *fname;
    93   int  page=0;
    94 
    95   // output
    96   std::string fmt_name = "";
    97   int num_pages=0;
    98   double pixel_size[3] = {0.0, 0.0, 0.0};
    99 
    100   //-----------------------------------------------------------
    101   // get file name
    102   //-----------------------------------------------------------
    103   // Input must be a string
    104   if (mxIsChar(prhs[0]) != 1)
    105     mexErrMsgTxt("Input 1 must be a string.");
    106 
    107   // Input must be a row vector
    108   if (mxGetM(prhs[0]) != 1)
    109     mexErrMsgTxt("Input 1 must be a row vector.");
    110    
    111   // Get the length of the input string.
    112   int buflen = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1;
    113 
    114   // Allocate memory for input and output strings
    115   fname = (char*) mxCalloc(buflen, sizeof(char));
    116 
    117   // Copy the string data from prhs[0] into a C string input_buf
    118   if ( mxGetString(prhs[0], fname, buflen) != 0 )
    119     mexWarnMsgTxt("Not enough space. String is truncated.");
    120 
    121 
    122   //-----------------------------------------------------------
    123   // if page is provided
    124   //-----------------------------------------------------------
    125 
    126   if (nrhs > 1) {
    127     int mrows = mxGetM(prhs[1]);
    128     int ncols = mxGetN(prhs[1]);
    129     if (!mxIsDouble(prhs[1]) || mxIsComplex(prhs[1]) ||
    130         !(mrows == 1 && ncols == 1)) {
    131       mexErrMsgTxt("Input must be a noncomplex scalar double.");
    132     }
    133     double *dv = mxGetPr(prhs[1]);
    134     page = (int) *dv;
    135     page--; // to bring to c convention
    136   } // if page is provided
    137 
    138   #ifdef _DEBUG
    139   mexPrintf("Filename to load: %s\n", fname);
    140   mexPrintf("Page to load: %d\n", page);
    141   #endif
    142 
    143   //-----------------------------------------------------------
    144   // now read image and metadata
    145   //-----------------------------------------------------------
    146  
    147   TMetaFormatManager fm;
    148   TDimImage img;
    149 
    150   if (fm.sessionStartRead( fname ) != 0)
    151     mexErrMsgTxt("Input format is not supported\n");   
    152  
    153   num_pages = fm.sessionGetNumberOfPages();
    154   fmt_name = fm.sessionGetFormatName();
    155 
    156   #if defined (DEBUG) || defined (_DEBUG)
    157   mexPrintf("Number of pages: %d\n", num_pages); 
    158   mexPrintf("Format name: %s\n", fmt_name.c_str()); 
    159   #endif
    160 
    161   if (page<0) {
    162     page=0;
    163     mexPrintf("Requested page number is invalid, used %d.\n", page+1); 
    164   }
    165 
    166   if (page>=num_pages) {
    167     page=num_pages-1;
    168     mexPrintf("Requested page number is invalid, used %d.\n", page+1); 
    169   }
    170 
    171   fm.sessionReadImage( img.imageBitmap(), page );
    172 
    173   // getting metadata fields
    174   fm.sessionParseMetaData(page);
    175   pixel_size[0] = fm.getPixelSizeX();
    176   pixel_size[1] = fm.getPixelSizeY();
    177   pixel_size[2] = fm.getPixelSizeZ();
    178 
    179   #if defined (DEBUG) || defined (_DEBUG)
    180   mexPrintf("Pixel resolution: %.8f, %.8f, %.8f\n", pixel_size[0], pixel_size[1], pixel_size[2]); 
    181   #endif
    182 
    183   // get meta text if required
    184   std::string meta_data_text = "";   
    185   if (nlhs > 4) {
    186     DTagMap meta_data = fm.get_metadata();
    187     meta_data_text = meta_data.join( "; " );
    188   }
    189 
    190   fm.sessionEnd();
    191 
    192 
    193   //-----------------------------------------------------------
    194   // pre-poc input image
    195   //-----------------------------------------------------------
    196  
    197   // make sure red image is in supported pixel format, e.g. will convert 12 bit to 16 bit
    198   img = img.ensureTypedDepth();
    199 
    200   //-----------------------------------------------------------
    201   // create output image
    202   //-----------------------------------------------------------
    203   #if defined(MX_API_VER) && (MX_API_VER > 0x07000000)
    204   const mwSize dims[] = { img.height(), img.width(), img.samples() };
    205   #else
    206   const int dims[] = { img.height(), img.width(), img.samples() };
    207   #endif
    208 
    209   mxClassID t = mxUINT8_CLASS;
    210   if (img.depth()==8  && img.pixelType()==D_FMT_UNSIGNED) t = mxUINT8_CLASS;
    211   else
    212   if (img.depth()==16 && img.pixelType()==D_FMT_UNSIGNED) t = mxUINT16_CLASS;
    213   else
    214   if (img.depth()==32 && img.pixelType()==D_FMT_UNSIGNED) t = mxUINT32_CLASS;
    215   else // SIGNED
    216   if (img.depth()==8  && img.pixelType()==D_FMT_SIGNED)   t = mxINT8_CLASS;
    217   else
    218   if (img.depth()==16 && img.pixelType()==D_FMT_SIGNED)   t = mxINT16_CLASS;
    219   else
    220   if (img.depth()==32 && img.pixelType()==D_FMT_SIGNED)   t = mxINT32_CLASS;
    221   else // FLOAT
    222   if (img.depth()==32 && img.pixelType()==D_FMT_FLOAT)    t = mxSINGLE_CLASS;
    223   else
    224   if (img.depth()==64 && img.pixelType()==D_FMT_FLOAT)    t = mxDOUBLE_CLASS;
    225 
    226   plhs[0] = mxCreateNumericArray( 3, dims, t, mxREAL);
    227 
    228   // UNSIGNED
    229   if (img.depth()==8  && img.pixelType()==D_FMT_UNSIGNED) copy_data<DIM_UINT8>   ( img, plhs );
    230   else
    231   if (img.depth()==16 && img.pixelType()==D_FMT_UNSIGNED) copy_data<DIM_UINT16>  ( img, plhs );
    232   else
    233   if (img.depth()==32 && img.pixelType()==D_FMT_UNSIGNED) copy_data<DIM_UINT32>  ( img, plhs );
    234   else // SIGNED
    235   if (img.depth()==8  && img.pixelType()==D_FMT_SIGNED)   copy_data<DIM_INT8>    ( img, plhs );
    236   else
    237   if (img.depth()==16 && img.pixelType()==D_FMT_SIGNED)   copy_data<DIM_INT16>   ( img, plhs );
    238   else
    239   if (img.depth()==32 && img.pixelType()==D_FMT_SIGNED)   copy_data<DIM_INT32>   ( img, plhs );
    240   else // FLOAT
    241   if (img.depth()==32 && img.pixelType()==D_FMT_FLOAT)    copy_data<DIM_FLOAT32> ( img, plhs );
    242   else
    243   if (img.depth()==64 && img.pixelType()==D_FMT_FLOAT)    copy_data<DIM_FLOAT64> ( img, plhs );
    244 
    245   //-----------------------------------------------------------
    246   // create output meta-data
    247   //-----------------------------------------------------------
    248 
    249   // if need to return format
    250   if (nlhs > 1) {
    251     char *output_buf = (char*) mxCalloc( fmt_name.size()+1, sizeof(char) );
    252     output_buf[fmt_name.size()] = 0;
    253     memcpy( output_buf, fmt_name.c_str(), fmt_name.size() );
    254     plhs[1] = mxCreateString(output_buf);
    255   }
    256 
    257   // if need to return num_pages
    258   if (nlhs > 2) {
    259     plhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL); 
    260     double *v = mxGetPr(plhs[2]);
    261     *v = num_pages;
    262   }
    263 
    264   // if need to return xyzres
    265   if (nlhs > 3) {
    266     plhs[3] = mxCreateDoubleMatrix(3, 1, mxREAL); 
    267     double *v = mxGetPr(plhs[3]);
    268     v[0] = pixel_size[0];
    269     v[1] = pixel_size[1];
    270     v[2] = pixel_size[2];
    271   }
    272 
    273   // if need to return format
    274   if (nlhs > 4) {
    275     char *output_buf = (char*) mxCalloc( meta_data_text.size()+1, sizeof(char) );
    276     output_buf[meta_data_text.size()] = 0;
    277     memcpy( output_buf, meta_data_text.c_str(), meta_data_text.size() );
    278     plhs[4] = mxCreateString(output_buf);
    279   }
     83    // Check for proper number of input and output arguments
     84    if (nrhs < 1) mexErrMsgTxt("At least 1 input arguments required. Usage: bimread( fname, page_num ).");
     85    if (nlhs < 1) mexErrMsgTxt("At least 1 output argument required. Usage: [ im, format, pages, xyzres, metatxt ] = bimread.");
     86    if (nrhs > 2) mexErrMsgTxt("Too many input arguments. Usage: bimread( fname, page_num ).");
     87    if (nlhs > 5) mexErrMsgTxt("Too many output arguments. Usage: [ im, format, pages, xyzres, metatxt ] = bimread.");
     88
     89    // input
     90    char *fname;
     91    int  page = 0;
     92
     93    // output
     94    std::string fmt_name = "";
     95    int num_pages = 0;
     96    double pixel_size[3] = { 0.0, 0.0, 0.0 };
     97
     98    //-----------------------------------------------------------
     99    // get file name
     100    //-----------------------------------------------------------
     101    // Input must be a string
     102    if (mxIsChar(prhs[0]) != 1)
     103        mexErrMsgTxt("Input 1 must be a string.");
     104
     105    // Input must be a row vector
     106    if (mxGetM(prhs[0]) != 1)
     107        mexErrMsgTxt("Input 1 must be a row vector.");
     108
     109    // Get the length of the input string.
     110    int buflen = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1;
     111
     112    // Allocate memory for input and output strings
     113    fname = (char*)mxCalloc(buflen, sizeof(char));
     114
     115    // Copy the string data from prhs[0] into a C string input_buf
     116    if (mxGetString(prhs[0], fname, buflen) != 0)
     117        mexWarnMsgTxt("Not enough space. String is truncated.");
     118
     119
     120    //-----------------------------------------------------------
     121    // if page is provided
     122    //-----------------------------------------------------------
     123
     124    if (nrhs > 1) {
     125        int mrows = mxGetM(prhs[1]);
     126        int ncols = mxGetN(prhs[1]);
     127        if (!mxIsDouble(prhs[1]) || mxIsComplex(prhs[1]) ||
     128            !(mrows == 1 && ncols == 1)) {
     129            mexErrMsgTxt("Input must be a noncomplex scalar double.");
     130        }
     131        double *dv = mxGetPr(prhs[1]);
     132        page = (int)*dv;
     133        page--; // to bring to c convention
     134    } // if page is provided
     135
     136#ifdef _DEBUG
     137    mexPrintf("Filename to load: %s\n", fname);
     138    mexPrintf("Page to load: %d\n", page);
     139#endif
     140
     141    //-----------------------------------------------------------
     142    // now read image and metadata
     143    //-----------------------------------------------------------
     144
     145    MetaFormatManager fm;
     146    Image img;
     147
     148    if (fm.sessionStartRead(fname) != 0)
     149        mexErrMsgTxt("Input format is not supported\n");
     150
     151    num_pages = fm.sessionGetNumberOfPages();
     152    fmt_name = fm.sessionGetFormatName();
     153
     154#if defined (DEBUG) || defined (_DEBUG)
     155    mexPrintf("Number of pages: %d\n", num_pages); 
     156    mexPrintf("Format name: %s\n", fmt_name.c_str()); 
     157#endif
     158
     159    if (page < 0) {
     160        page = 0;
     161        mexPrintf("Requested page number is invalid, used %d.\n", page + 1);
     162    }
     163
     164    if (page >= num_pages) {
     165        page = num_pages - 1;
     166        mexPrintf("Requested page number is invalid, used %d.\n", page + 1);
     167    }
     168
     169    fm.sessionReadImage(img.imageBitmap(), page);
     170
     171    // getting metadata fields
     172    fm.sessionParseMetaData(page);
     173    pixel_size[0] = fm.getPixelSizeX();
     174    pixel_size[1] = fm.getPixelSizeY();
     175    pixel_size[2] = fm.getPixelSizeZ();
     176
     177#if defined (DEBUG) || defined (_DEBUG)
     178    mexPrintf("Pixel resolution: %.8f, %.8f, %.8f\n", pixel_size[0], pixel_size[1], pixel_size[2]); 
     179#endif
     180
     181    // get meta text if required
     182    std::string meta_data_text = "";
     183    if (nlhs > 4) {
     184        TagMap meta_data = fm.get_metadata();
     185        meta_data_text = meta_data.join("; ");
     186    }
     187
     188    fm.sessionEnd();
     189
     190
     191    //-----------------------------------------------------------
     192    // pre-poc input image
     193    //-----------------------------------------------------------
     194
     195    // make sure red image is in supported pixel format, e.g. will convert 12 bit to 16 bit
     196    img = img.ensureTypedDepth();
     197
     198    //-----------------------------------------------------------
     199    // create output image
     200    //-----------------------------------------------------------
     201#if defined(MX_API_VER) && (MX_API_VER > 0x07000000)
     202    const mwSize dims[] = { img.height(), img.width(), img.samples() };
     203#else
     204    const int dims[] = { img.height(), img.width(), img.samples() };
     205#endif
     206
     207    mxClassID t = mxUINT8_CLASS;
     208    if (img.depth() == 8 && img.pixelType() == FMT_UNSIGNED) t = mxUINT8_CLASS;
     209    else
     210    if (img.depth() == 16 && img.pixelType() == FMT_UNSIGNED) t = mxUINT16_CLASS;
     211    else
     212    if (img.depth() == 32 && img.pixelType() == FMT_UNSIGNED) t = mxUINT32_CLASS;
     213    else // SIGNED
     214    if (img.depth() == 8 && img.pixelType() == FMT_SIGNED)   t = mxINT8_CLASS;
     215    else
     216    if (img.depth() == 16 && img.pixelType() == FMT_SIGNED)   t = mxINT16_CLASS;
     217    else
     218    if (img.depth() == 32 && img.pixelType() == FMT_SIGNED)   t = mxINT32_CLASS;
     219    else // FLOAT
     220    if (img.depth() == 32 && img.pixelType() == FMT_FLOAT)    t = mxSINGLE_CLASS;
     221    else
     222    if (img.depth() == 64 && img.pixelType() == FMT_FLOAT)    t = mxDOUBLE_CLASS;
     223
     224    plhs[0] = mxCreateNumericArray(3, dims, t, mxREAL);
     225
     226    // UNSIGNED
     227    if (img.depth() == 8 && img.pixelType() == FMT_UNSIGNED) copy_data<bim::uint8>(img, plhs);
     228    else
     229    if (img.depth() == 16 && img.pixelType() == FMT_UNSIGNED) copy_data<bim::uint16>(img, plhs);
     230    else
     231    if (img.depth() == 32 && img.pixelType() == FMT_UNSIGNED) copy_data<bim::uint32>(img, plhs);
     232    else // SIGNED
     233    if (img.depth() == 8 && img.pixelType() == FMT_SIGNED)   copy_data<bim::int8>(img, plhs);
     234    else
     235    if (img.depth() == 16 && img.pixelType() == FMT_SIGNED)   copy_data<bim::int16>(img, plhs);
     236    else
     237    if (img.depth() == 32 && img.pixelType() == FMT_SIGNED)   copy_data<bim::int32>(img, plhs);
     238    else // FLOAT
     239    if (img.depth() == 32 && img.pixelType() == FMT_FLOAT)    copy_data<bim::float32>(img, plhs);
     240    else
     241    if (img.depth() == 64 && img.pixelType() == FMT_FLOAT)    copy_data<bim::float64>(img, plhs);
     242
     243    //-----------------------------------------------------------
     244    // create output meta-data
     245    //-----------------------------------------------------------
     246
     247    // if need to return format
     248    if (nlhs > 1) {
     249        char *output_buf = (char*)mxCalloc(fmt_name.size() + 1, sizeof(char));
     250        output_buf[fmt_name.size()] = 0;
     251        memcpy(output_buf, fmt_name.c_str(), fmt_name.size());
     252        plhs[1] = mxCreateString(output_buf);
     253    }
     254
     255    // if need to return num_pages
     256    if (nlhs > 2) {
     257        plhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
     258        double *v = mxGetPr(plhs[2]);
     259        *v = num_pages;
     260    }
     261
     262    // if need to return xyzres
     263    if (nlhs > 3) {
     264        plhs[3] = mxCreateDoubleMatrix(3, 1, mxREAL);
     265        double *v = mxGetPr(plhs[3]);
     266        v[0] = pixel_size[0];
     267        v[1] = pixel_size[1];
     268        v[2] = pixel_size[2];
     269    }
     270
     271    // if need to return format
     272    if (nlhs > 4) {
     273        char *output_buf = (char*)mxCalloc(meta_data_text.size() + 1, sizeof(char));
     274        output_buf[meta_data_text.size()] = 0;
     275        memcpy(output_buf, meta_data_text.c_str(), meta_data_text.size());
     276        plhs[4] = mxCreateString(output_buf);
     277    }
    280278}
    281279
    282280
    283281extern "C" {
    284   //--------------------------------------------------------------
    285   // mexFunction - Entry point from Matlab. From this C function,
    286   //   simply call the C++ application function, above.
    287   //--------------------------------------------------------------
    288   void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray  *prhs[] )
    289   {
    290     mex_bimread(nlhs, plhs, nrhs, prhs);
    291   }
    292 }
     282    //--------------------------------------------------------------
     283    // mexFunction - Entry point from Matlab. From this C function,
     284    //   simply call the C++ application function, above.
     285    //--------------------------------------------------------------
     286    void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray  *prhs[])
     287    {
     288        mex_bimread(nlhs, plhs, nrhs, prhs);
     289    }
     290}
Note: See TracChangeset for help on using the changeset viewer.