Skip to content

Recipe for building DIPimage on macOS

Follow the guide below to build DIPimage on a macOS computer. All the instructions must be given via a command-line. The total installation time will take you about 15 to 20 minutes.

Before proceeding, it’s essential to identify the CPU (chip) type in your computer. You can do this by choosing the About This Mac option from the Apple menu (located at the top left). If the Chip is labelled as Apple M followed by a number, your computer is equipped with an Apple Silicon chip. Alternatively, if the Processor field contains Intel, it indicates that your computer has an Intel chip.

  • open the application Terminal

Only for computers with an Apple Silicon chip (M1, M2 etc.)

  • install Intel emulator

    softwareupdate --install-rosetta
    
  • start shell with Intel emulator

    arch -x86_64 zsh
    

Note: all following command-line instructions must be given in this shell!

For all computers (Intel and Apple Silicon)

Prepare compiler and prerequisites

  • install a recent version of MATLAB

    Note: currently DIPimage is not yet supported on MATLAB 2023b!

  • install Java Development Kit (jdk)

  • install Xcode command line tools

    xcode-select --install
    
  • install Homebrew package manager

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  • install prerequisites

    brew install cmake
    brew install glfw
    brew install python3
    

Get the DIPlib source code

DIPimage is the MATLAB interface for DIPlib. When building DIPlib this interface is also build.

  • clone the repository

    mkdir ~/src
    cd ~/src
    git clone https://github.com/DIPlib/diplib.git
    
  • patch one file (FindMatlab.cmake) in the repository

    cd ~/src/diplib/tools
    git checkout 376fb4fd10b9b0a969a1a042fc222e6f99a87e8b -- FindMatlab.cmake
    

Build DIPimage

  • prepare with cmake, build with make

    Note: to speed up the compilation use -j with make. Always use one core less than the total amount of cores available on your computer. You can find the total number of cores by holding the alt-key (a.k.a. option-key) and selecting the System Information menu-item under the Apple menu (top left). In the following example the computer has 8 cores so -j7 is used with make

    mkdir ~/src/diplib/target
    cd ~/src/diplib/target
    cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dip
    make -j7 check
    make -j7 install
    

    Note: if there are errors during compilation try to rerun the cmake command including the following options -DDIP_BUILD_JAVAIO -DDIP_BUILD_PYDIP followed by the two make commands.

Using DIPimage

  • start MATLAB

    Note: all following command must be given in MATLAB!

  • tell MATLAB where DIPimage is installed

    addpath('/Users/<your_username_here>/dip/share/DIPimage')
    

    Note: replace <your_username_here> with your login name on your computer

  • get help with using DIPimage

    help DIPimage
    
  • …or start the GUI

    dipimage
    

Last update: 2024-02-07