Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VolInfo #430

Merged
merged 15 commits into from
Mar 11, 2022
8 changes: 4 additions & 4 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- New cmake option (DGTAL_RANDOMIZED_BUILD_THRESHOLD) to set the
(approximated) % of tools build
(Bertrand Kerautret [#416](https://github.com/DGtal-team/DGtal/pull/416))

- *visualisation*
- 3dImplicitSurfaceExtractorByThickening: adding OBJ export.
(David Coeurjolly [#413](https://github.com/DGtal-team/DGtalTools/pull/413))
Expand All @@ -21,16 +21,16 @@
- *volumetric*
- volSegment: adding new option to get long int images as output (for
longvol exporting). (Bertrand Kerautret [#420](https://github.com/DGtal-team/DGtalTools/pull/420))

- volInfo: get information from a volumetric file. (David Coeurjolly, [#430](https://github.com/DGtal-team/DGtalTools/pull/430))

# DGtalTools 1.2
- *global*
- Fix itk2vol and fix ITK cmake configuaration that was making issues with the ITK image read.
(Bertrand Kerautret [#393](https://github.com/DGtal-team/DGtalTools/pull/393))
- Travis: Fix old default osx_image with xcode12.2 and remove non used boost
cmake references. (Bertrand Kerautret [#394](https://github.com/DGtal-team/DGtalTools/pull/394))
cmake references. (Bertrand Kerautret [#394](https://github.com/DGtal-team/DGtalTools/pull/394))
- Uniform input/output option with previous use of CLI11 (issue #405).
(Bertrand Kerautret [#406](https://github.com/DGtal-team/DGtalTools/pull/406))
(Bertrand Kerautret [#406](https://github.com/DGtal-team/DGtalTools/pull/406))
- Comply with cmake Policy CMP0115 "Source file extensions must be
explicit". (Bertrand Kerautret and David Coeurjolly, [#407](https://github.com/DGtal-team/DGtalTools/pull/407))

Expand Down
17 changes: 9 additions & 8 deletions doc/volumetric.dox
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file volumetric.dox
* @author Bertrand Kerautret
* @author Bertrand Kerautret
* LORIA (CNRS, UMR 7503), University of Lorraine, France
*
* @date 2016/05/12
Expand All @@ -19,7 +19,7 @@


- @ref criticalKernelsThinning3D : applies an criticalKernels thinning algorithm of a 3d image file (vol,longvol,pgm3d...) with 3D viewer.
- @ref Doc3dVolMarchingCubes : outputs the isosurface of the input volume as an OFF file.
- @ref 3dVolMarchingCubes : outputs the isosurface of the input volume as an OFF file.
- @ref homotopicThinning3D : applies an homotopic thinning of a 3d image file (vol,longvol,pgm3d...) with 3D viewer.
- @ref volAddBorder : adds a border of one voxel with value 0 around a vol file.
- @ref volAddNoise : adds Kanungo noise to a binary object with 0 values as background points and values >0 for the foreground ones.
Expand All @@ -32,9 +32,10 @@
- @ref volMask : extracts a new image from the a mask image.
- @ref volReSample : re samples a 3D volumetric image (.vol, .longvol, .pgm3d) with a given grid size.
- @ref volSegment : segments volumetric file from a simple threshold.
- @ref volShapeMetrics : applies shape measures to compare two volumetric images A and B (shape defined from thresholds).
- @ref volShapeMetrics : applies shape measures to compare two volumetric images A and B (shape defined from thresholds).
- @ref volSubSample : brutally sub samples a vol file (division by 2 in each direction).
- @ref volTrValues : applies basic vol image transform from the input values to output values.
- @ref volInfo : to get information (domain size, value distributions) from a VOL file.



Expand All @@ -44,24 +45,24 @@
<tr>
<td> <img height=200px src="res3dVolMarchingCubes2.png"> </td>
<td><img height=200px src="resHomotopicThinning3D.png"></td>
<td><img height=200px src="resVolReSample.png"></td>
<td><img height=200px src="resVolReSample.png"></td>
</tr>
<tr>
<td align = center>@ref Doc3dVolMarchingCubes </td>
<td align = center>@ref homotopicThinning3D </td>
<td align = center>@ref homotopicThinning3D </td>
<td align = center>@ref volReSample</td>

</tr>

<tr>
<td><img height=200px src="resVolTrValues.png"></td>
<td><img height=200px src="resVolTrValues.png"></td>
<td><img height=200px src="resVolSegment.png"></td>
<td><img height=200px src="resVolSubSample.png"></td>
<td><img height=200px src="resVolSubSample.png"></td>
</tr>
<tr>
<td align = center>@ref volTrValues</td>
<td align = center>@ref volSegment</td>
<td align = center>@ref volSubSample</td>
<td align = center>@ref volSubSample</td>
</tr>
</table>
</center>
Expand Down
1 change: 1 addition & 0 deletions volumetric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SET(DGTAL_TOOLS_SRC
volTrValues
volIntensityScale
volFillInterior
volInfo
volMask
)

Expand Down
115 changes: 115 additions & 0 deletions volumetric/volInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/
/**
* @file volInfo.cpp
* @author David Coeurjolly (\c david.coeurjolly@liris.cnrs.fr )
* Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
*
* @date 2022/02/11
*
*
* This file is part of the DGtal library.
*/

#include <iostream>
#include <map>
#include <DGtal/base/Common.h>
#include <DGtal/io/readers/GenericReader.h>
#include <DGtal/helpers/StdDefs.h>
#include <DGtal/images/Image.h>
#include <DGtal/images/ImageContainerBySTLVector.h>

#include "CLI11.hpp"


using namespace std;
using namespace DGtal;
using namespace Z3i;

/**
@page volInfo volInfo

@brief Get information from a vol file (size and values).


@b Usage: ./volumetric/volInfo [OPTIONS] 1 [2]


@b Allowed @b options @b are :
@code
Options:
-h,--help Print this help message and exit
-i,--input TEXT:FILE REQUIRED Input vol file.

Positionals:
1 TEXT:FILE REQUIRED Input vol file.
@endcode

@b Example:
You can retrieve information from the vol file as:
@code
$ volInfo $DGtal/examples/samples/lobster.vol
@endcode

@see
@ref volInfo.cpp

*/

/**
* Missing parameter error message.
*
* @param param
*/
void missingParam ( std::string param )
{
trace.error() <<" Parameter: "<<param<<" is required..";
trace.info() <<std::endl;
exit ( 1 );
}


int main(int argc, char**argv)
{
// parse command line using CLI ----------------------------------------------
CLI::App app;
std::string inputFileName;

app.description("Retreive information from vol file\n Basic usage: \n \tvolInfo <volFileName> ");
app.add_option("-i,--input,1", inputFileName, "Input vol file." )->required()->check(CLI::ExistingFile);

app.get_formatter()->column_width(40);
CLI11_PARSE(app, argc, argv);
// END parse command line using CLI ----------------------------------------------

trace.beginBlock("Loading file");
typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;

MyImageC imageC = GenericReader<MyImageC>::import(inputFileName);

trace.info()<<imageC<<std::endl;
trace.info()<<"Scanning the values:"<<std::endl;

std::map<unsigned char, size_t> values;
for(auto v: imageC.range())
values[ v ] ++;

for(auto val: values)
std::cout<<"\tvalue "<< (int)val.first<<": "<< val.second<<" voxels."<<std::endl;

trace.endBlock();
return 0;
}