Changeset 7529


Ignore:
Timestamp:
01/13/11 14:32:59 (9 years ago)
Author:
hinerm
Message:

Backport latest bf-itk to 4.2 branch.

Location:
branches/4.2/components/native/bf-itk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/components/native/bf-itk

  • branches/4.2/components/native/bf-itk/CMakeLists.txt

    r5718 r7529  
    144144 
    145145if(NOT DEFINED BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR) 
    146   set(BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR lib/ITKFactories) 
     146  set(BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR lib/) 
    147147endif(NOT DEFINED BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR) 
    148148 
  • branches/4.2/components/native/bf-itk/build.properties

    r5726 r7529  
    2020component.runtime-cp     = ${component.classpath} 
    2121 
    22 bf-cpp.dir.windows = ../bf-cpp/build/Debug 
    23 bf-cpp.dir.other   = ../bf-cpp/build 
     22bf-cpp.build.windows = ../bf-cpp/build/Debug 
     23bf-cpp.build.other   = ../bf-cpp/build 
     24 
     25jace.build.windows = ../bf-cpp/build/jace/Debug 
     26jace.build.other   = ../bf-cpp/build/jace 
     27 
     28bf-itk.lib.windows = ../bf-itk/build/lib/Debug 
     29bf-itk.lib.other   = ../bf-itk/build/lib 
     30 
     31bf-itk.build.windows = ../bf-itk/build/Debug 
     32bf-itk.build.other   = ../bf-itk/build 
    2433 
    2534# Override if Ant cannot find your Java runtime classes. 
  • branches/4.2/components/native/bf-itk/build.xml

    r7007 r7529  
    161161      <isset property="isWindows"/> 
    162162      <then> 
    163         <property name="bf-cpp.dir" value="${bf-cpp.dir.windows}"/> 
    164       </then> 
    165       <else> 
    166         <property name="bf-cpp.dir" value="${bf-cpp.dir.other}"/> 
    167       </else> 
    168     </if> 
    169     <copy file="${bf-cpp.dir}/loci_tools.jar" todir="${bf-itk.dist.dir}"/> 
    170     <copy file="${bf-cpp.dir}/jace-runtime.jar" todir="${bf-itk.dist.dir}"/> 
     163        <property name="bf-cpp.build" value="${bf-cpp.build.windows}"/> 
     164        <property name="jace.build" value="${jace.build.windows}"/> 
     165        <property name="bf-itk.lib" value="${bf-itk.lib.windows}"/> 
     166        <property name="bf-itk.build" value="${bf-itk.build.windows}"/> 
     167      </then> 
     168      <else> 
     169        <property name="bf-cpp.build" value="${bf-cpp.build.other}"/> 
     170        <property name="jace.build" value="${jace.build.other}"/> 
     171        <property name="bf-itk.lib" value="${bf-itk.lib.other}"/> 
     172        <property name="bf-itk.build" value="${bf-itk.build.other}"/> 
     173      </else> 
     174    </if> 
     175    <copy file="${bf-cpp.build}/loci_tools.jar" todir="${bf-itk.dist.dir}"/> 
     176    <copy file="${bf-cpp.build}/jace-runtime.jar" todir="${bf-itk.dist.dir}"/> 
    171177 
    172178    <echo/> 
     
    174180    <echo/> 
    175181    <copy todir="${bf-itk.dist.dir}"> 
    176       <fileset dir="${bf-cpp.dir}" includes="*.so"/> 
    177       <fileset dir="${bf-cpp.dir}" includes="*.dylib"/> 
    178       <fileset dir="${bf-cpp.dir}" includes="*.jnilib"/> 
    179       <fileset dir="${bf-cpp.dir}" includes="*.dll"/> 
     182      <fileset dir="${bf-cpp.build}" includes="*.so"/> 
     183      <fileset dir="${bf-cpp.build}" includes="*.dylib"/> 
     184      <fileset dir="${bf-cpp.build}" includes="*.jnilib"/> 
     185      <fileset dir="${bf-cpp.build}" includes="*.dll"/> 
     186      <fileset dir="${jace.build}" includes="*.so"/> 
     187      <fileset dir="${jace.build}" includes="*.dylib"/> 
     188      <fileset dir="${jace.build}" includes="*.jnilib"/> 
     189      <fileset dir="${jace.build}" includes="*.dll"/> 
     190    </copy> 
     191 
     192    <echo/> 
     193    <echo>-- Copying Bio-Formats IO library --</echo> 
     194    <echo/> 
     195    <copy todir="${bf-itk.dist.dir}"> 
     196      <fileset dir="${bf-itk.build}" includes="*.so"/> 
     197      <fileset dir="${bf-itk.build}" includes="*.dylib"/> 
     198      <fileset dir="${bf-itk.build}" includes="*.jnilib"/> 
     199      <fileset dir="${bf-itk.build}" includes="*.dll"/> 
    180200    </copy> 
    181201 
     
    191211    <echo/> 
    192212    <copy todir="${bf-itk.dist.dir}"> 
    193       <fileset dir="${build.dir}/lib"/> 
     213      <fileset dir="${bf-itk.lib}"/> 
    194214    </copy> 
    195215 
     
    226246you can test the plugin with the following commands: 
    227247 
    228   export ITK_AUTOLOAD_PATH="${build.dir}/lib/ITKFactories" 
     248  export ITK_AUTOLOAD_PATH="${build.dir}/lib/" 
    229249  cd "${itk-bin.dir}" 
    230250  ./ImageHistogram1 /path/to/sample/dataset 
     251 
     252If you run the ant dist target, use this command instead: 
     253 
     254  export ITK_AUTOLOAD_PATH="${build.dir}/dist/bf-itk/" 
    231255 
    232256If you use a TIFF file, you can compare the histogram results between 
  • branches/4.2/components/native/bf-itk/itkBioFormatsImageIO.cxx

    r7096 r7529  
    6969#include <stdlib.h> 
    7070 
     71#if defined (_WIN32) 
     72#define PATHSTEP ';' 
     73#define SLASH '\\' 
     74#else 
     75#define PATHSTEP ':' 
     76#define SLASH '/' 
     77#endif 
     78 
    7179//-------------------------------------- 
    7280// 
     
    8290 
    8391    try { 
    84       // initialize the Java virtual machine 
    85       itkDebugMacro("Creating JVM..."); 
    86       jace::StaticVmLoader loader(JNI_VERSION_1_4); 
    87       jace::OptionList list; 
    88  
    89       const char name[] = "ITK_AUTOLOAD_PATH"; 
    90       const char* namePtr; 
    91       namePtr = name; 
    92       char* path; 
    93       path = getenv(name); 
    94       std::string dir(""); 
    95       if( path != NULL) { 
    96         dir.assign(path); 
    97       } 
    98       list.push_back(jace::ClassPath( 
    99  
    100  // To solve issue where JARs must live in current working directory: 
    101  // somehow discover my own origin directory 
    102  // e.g.: I am part of libBioFormatsIOPlugin.dylib 
    103  // and I live in folder: 
    104  //   /Users/hinerm/loci/bioformats/components/native/bf-itk/build/dist/bf-itk 
    105  // so, we want a string variable "dir" containing that folder name. 
    106  // Then, can pass classpath elements with that prefix. 
    107  //        dir+"jace-runtime.jar:"+dir+"bio-formats.jar:"+dir+"loci_tools.jar" 
    108       dir+"jace-runtime.jar:"+dir+"bio-formats.jar:"+dir+"loci_tools.jar" 
    109       )); 
    110       list.push_back(jace::CustomOption("-Xcheck:jni")); 
    111       list.push_back(jace::CustomOption("-Xmx256m")); 
    112       list.push_back(jace::CustomOption("-Djava.awt.headless=true")); 
    113       //list.push_back(jace::CustomOption("-verbose")); 
    114       //list.push_back(jace::CustomOption("-verbose:jni")); 
    115       jace::helper::createVm(loader, list, false); 
    116       itkDebugMacro("JVM created."); 
     92      jace::StaticVmLoader* tmpLoader = (jace::StaticVmLoader*)jace::helper::getVmLoader(); 
     93      if(tmpLoader == NULL) { 
     94 
     95        // initialize the Java virtual machine 
     96        itkDebugMacro("Creating JVM..."); 
     97        jace::OptionList list; 
     98        jace::StaticVmLoader loader(JNI_VERSION_1_4); 
     99 
     100        const char name[] = "ITK_AUTOLOAD_PATH"; 
     101        const char* namePtr; 
     102        namePtr = name; 
     103        char* path; 
     104        path = getenv(name); 
     105        std::string dir(""); 
     106        if( path != NULL) { 
     107          dir.assign(path); 
     108        } 
     109 
     110        if( dir.at(dir.length() - 1) != SLASH ) { 
     111          dir.append(1,SLASH); 
     112        }  
     113 
     114        list.push_back(jace::ClassPath( 
     115        dir+"jace-runtime.jar"+PATHSTEP+dir+"bio-formats.jar"+PATHSTEP+dir+"loci_tools.jar" 
     116        )); 
     117        list.push_back(jace::CustomOption("-Xcheck:jni")); 
     118        list.push_back(jace::CustomOption("-Xmx256m")); 
     119        list.push_back(jace::CustomOption("-Djava.awt.headless=true")); 
     120        list.push_back(jace::CustomOption("-Djava.library.path=" + dir)); 
     121        //list.push_back(jace::CustomOption("-verbose")); 
     122        //list.push_back(jace::CustomOption("-verbose:jni")); 
     123        jace::helper::createVm(loader, list, false); 
     124        itkDebugMacro("JVM created."); 
     125      } 
    117126    } 
    118127    catch (JNIException& jniException) { 
     
    250259        << "\tSizeT = " << sizeT << std::endl 
    251260        << "\tRGB Channel Count = " << rgbChannelCount << std::endl 
    252         << "\tEffective SizeC = " << rgbChannelCount << std::endl 
     261        << "\tEffective SizeC = " << effSizeC << std::endl 
    253262        << "\tImage Count = " << imageCount); 
    254263 
     
    287296 
    288297      // get physical resolution 
    289       double physX = 1, physY = 1; 
     298      double physX = 1, physY = 1, physZ = 1, timeIncrement = 1; 
    290299      // CTR - avoid invalid memory access error on some systems (OS X 10.5) 
    291300      //MetadataRetrieve retrieve = MetadataTools::asRetrieve(omeMeta); 
    292301      //physX = retrieve.getPixelsPhysicalSizeX(0).doubleValue(); 
    293302      //physY = retrieve.getPixelsPhysicalSizeY(0).doubleValue(); 
     303      //physZ = retrieve.getPixelsPhysicalSizeZ(0).doubleValue(); 
     304      //timeIncrement = retrieve.getPixelsTimeIncrement(0).doubleValue(); 
    294305      m_Spacing[0] = physX; 
    295306      m_Spacing[1] = physY; 
    296       if (imageCount > 1) m_Spacing[2] = 1; 
    297  
    298       itkDebugMacro("Physical resolution = " << physX << " x " << physY); 
     307      // TODO: verify m_Spacing.length > 2 
     308      if (imageCount > 1) m_Spacing[2] = physZ; 
     309      m_Spacing[3] = timeIncrement; 
     310 
     311      itkDebugMacro("Physical resolution = " << physX << " x " << physY 
     312        << " x " << physZ << " x " << timeIncrement); 
    299313    } 
    300314    catch (Exception& e) { 
     
    375389      } 
    376390      int bytesPerPlane = xCount * yCount * bpp * rgbChannelCount; 
     391      bool isInterleaved = reader->isInterleaved(); 
    377392 
    378393      itkDebugMacro("Region extents:" << std::endl 
     
    383398        << "\tT: start = " << tStart << ", count = " << tCount << std::endl 
    384399        << "\tC: start = " << cStart << ", count = " << cCount << std::endl 
    385         << "\tBytes per plane = " << bytesPerPlane); 
     400        << "\tBytes per plane = " << bytesPerPlane << std::endl 
     401        << "\tIsInterleaved = " << isInterleaved); 
     402 
    386403 
    387404      int imageCount = reader->getImageCount(); 
    388405 
    389406      // allocate temporary array 
    390       bool canDoDirect = rgbChannelCount == 1; 
     407      bool canDoDirect = (rgbChannelCount == 1 || isInterleaved); 
    391408      jbyte* tmpData = NULL; 
    392409      if (!canDoDirect) tmpData = new jbyte[bytesPerPlane]; 
     
    398415          for (int z=zStart; z<zStart+zCount; z++) { 
    399416            int no = reader->getIndex(z, c, t); 
    400             itkDebugMacro("Reading image plane " << no 
     417            itkDebugMacro("Reading image plane " << no + 1 
    401418              << " (Z=" << z << ", T=" << t << ", C=" << c << ")" 
    402419              << " of " << imageCount << " available planes)"); 
Note: See TracChangeset for help on using the changeset viewer.