Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Urs Hofmann committed Feb 11, 2022
1 parent 79745d4 commit 248229c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
# CLAHE3D

A three dimensional contrast enhancement code written in `C++`. Works as standalone C++ application or through a MATLAB interface specified as a `*.mex` file. Since I am using it at the moment only through `mex` I did not implement any file import or export functions for the `C++` based version but can do that upon reasonable request. Histograms are calculated for subvolumes and afterwards interpolated to the currently adapted pixel through trilinear interpolation.

# MATLAB
Change to folder and run `mex -O clahe3dmex.cpp interpGrid.cpp histeq.cpp`. Afterwards you can use the function as:
`clahe3dmex(vol, volSize, clipLimit, binSize);`
where `vol` is the three dimensional volume of type `single`, `volSize` is the subvolume size specified as a 3 element vector of type `uint64`, `clipLimit` is the clipping threshold specified as `single`, and `binSize` is the number of histogram bins specified as `uint64`.
`clahe3dmex(interpVol, subVolSize, spacingSubVols, clipLimit, binSize);`
where

* `vol` is the three dimensional volume of type `single`,
* `subVolSize` is the container size used to create the histograms subvolume size specified as a 3 element vector of type `uint64`
* `spacingSubVols` is the spacing vector between the histograms specified as `uint64`
* `clipLimit` is the clipping threshold specified as `single`
* and `binSize` is the number of histogram bins specified as `uint64`.

Tested using `MATLAB 2019 A` and `MATLAB 2019 B`.
Tested using `MATLAB 2019 A` and `MATLAB 2019 B`. The function `utest_bone.m` serves as an illustration.

# C++
`makefile` in main folder. Simply clone repository into your local filesystem and compile using `make main`. Tested on ArchLinux using `g++` compiler. Object files will be sotred in 'obj' directory, executable goes to `bin/main`.

The code is compiled using `cmake`.

```bash
cd Debug
cmake ..
make all
./main_exp
```

An example of how to use the main class can be found in `src/main.cpp`.

# Feature request / bug report
Feel free to contact me if you need the addition of a feature or if you want to report a bug. Next step of this project is going to be a `CUDA` capable parallelized version of the code.
10 changes: 7 additions & 3 deletions src/clahe3dmex.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
File: clahe3dmex.cpp
Author: Urs Hofmann
Mail: mail@hofmannu.org
Date: 11.02.2022
*/

#include <fstream>
#include "interpGrid.h"
#include "histeq.h"
Expand All @@ -6,7 +13,6 @@
using namespace std;

// clahe3dmex(interpVol, subVolSize, spacingSubVols, clipLimit, binSize);

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){

float* inputVol = (float *) mxGetData(prhs[0]); // input volume
Expand All @@ -17,9 +23,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
uint64_t * subVolSpacing = (uint64_t*) mxGetData(prhs[2]); // size of bins [z, x, y]
float* clipLimit = (float *) mxGetData(prhs[3]);
uint64_t* binSize = (uint64_t*) mxGetData(prhs[4]);

uint64_t volumeSize[3] = {nZ, nX, nY};


printf("[clahe3d] initializing histogram handler\n");
histeq histHandler;
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ int main(){

// initialize some parameters
const float clipLimit = 0.1;
const uint64_t binSize = 50;
const uint64_t binSize = 250;
const uint64_t subVolSize[3] = {31, 31, 31};
const uint64_t subVolSpacing[3] = {10, 10, 10};
const uint64_t subVolSpacing[3] = {20, 20, 20};
const uint64_t gridSize[3] = {nZ, nX, nY};

histeq histHandler;
Expand Down
2 changes: 0 additions & 2 deletions test.m → utest_bone.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
error("Function returned invalid values");
end

% vtkwrite('/media/hofmannu/hofmannu/clahed.vtk', 'structured_points', 'clahed', saftedVol, 'spacing', Settings.z(2) - Settings.z(1), Settings.dX, Settings.dY, 'BINARY');

newSlice = interpVol(100, :, :);
newSlice = reshape(newSlice, [nx, ny]);

Expand Down

0 comments on commit 248229c

Please sign in to comment.