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

Add LookUpTableFunctions #1155

Merged
merged 4 commits into from
May 4, 2016

Conversation

phcerdan
Copy link
Member

@phcerdan phcerdan commented Mar 27, 2016

Add LookUpTableFunctions

New functions to deal with pre-computed look up tables.
The motivation is to speed up large computation that use predicate
functions depending on voxel neighborhood, such as isSimple.

Add new folder /topology/tables containing:

  • NeighborhoodConfigurationGenerators, function used to generate the tables.
  • compressed .tar.gz tables for simplicity.

Modify example generateSimplicityTables3d:

  • using functions from new header.
  • create tables for different topologies.
  • user can choose 26_6,6_26, 18_6 and 6_18 topologies.
  • Generated tables are heavy, 64MB, so they have been added
    to the source code after compressed using:
    cmake -E tar cvzf table26_6.tar.gz simple_table26_6.txt resulting in a light (<500KB) tar file.

Add CMake rules:

  • TablesConfig.cmake dealing with decompress,
    copy and install tables. Linked in root CMakeLists.txt
  • ConfigTables.h.in . CONFIGURE_FILE with strings pointing
    to all available tables. The generated ConfigTables.h
    change location of tables depending on Build or Install.

Checklist

  • Unit-test of your feature with Catch.
  • Doxygen documentation of the code completed (classes, methods, types, members...)
  • Documentation module page added or updated.
  • New entry in the ChangeLog.md added.
  • No warning raised in Debug cmake mode (otherwise, Travis C.I. will fail).
  • All continuous integration tests pass (Travis & appveyor)

@JacquesOlivierLachaud
Copy link
Member

It seems a good idea to me.
I was wondering if we should not do the same for the 2D case ;-)

@phcerdan
Copy link
Member Author

The only concern I have is that every 3D table (with 2^26 configurations) is 64 MB after decompression.
Not sure if it is better to decompress at build/install time (this PR) or include an external library, such as zlib or minizip, to decompress at run time. (there is a boost filter that works as a zlib wrap )

I don't know how keen you are to add the zlib external dependency. For a few tables this approach looks all right though.

@JacquesOlivierLachaud Yeah, 2D tables are straight forward to add, and much lighter. I will push them.


namespace DGtal
{
namespace lut {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global functions should be in the DGtal::functions:: namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DGtal::functions::simplicityhas namespace ? lut is too generic IMHO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a similar way, the filename LookUpTableFunctions is not great.. I have the feeling that it could be confusing. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will add the functions:: namespace asap.

The motivation of this PR is related to the other PR #1147 , where we use look up tables to calculate the (way more expensive) isIsthmus that depends on the neighborhood of voxels. If lut is too generic, simplicity is not able to capture the isthmus case. Maybe tables::?

I am completely open to suggestions of changing the name, but I cannot really think in anything better or more clarifying/descriptive. The user probably will only interact with this using the loadTable("string_variable_pointing_to_table_file") from ConfigTable.h.in. Other names: NeigborhoodConfigurations, PreComputedTables, PreComputedConfiguration ? Not sure, sorry!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 no idea, too

NeigborhoodConfigurations is ok for the filename but I don't know for the namespace... neighborhood:: ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a name related to the objective of lut... here topology, homotopy, simplicity, etc ... as you wish

----- Mail original -----

De: "David Coeurjolly" [email protected]
À: "DGtal-team/DGtal" [email protected]
Cc: "Jacques-Olivier Lachaud" [email protected]
Envoyé: Lundi 11 Avril 2016 11:16:01
Objet: Re: [DGtal-team/DGtal] Add LookUpTableFunctions (#1155)

In src/DGtal/topology/tables/LookUpTableFunctions.h :

+#if !defined LookUpTableFunctions_h
+/** Prevents repeated inclusion of headers. */
+#define LookUpTableFunctions_h
+//////////////////////////////////////////////////////////////////////////////
+// Inclusions
+#include
+#include
+#include
+#include "DGtal/topology/Object.h"
+#include "DGtal/helpers/StdDefs.h"
+#include <unordered_map>
+#include "boost/dynamic_bitset.hpp"
+
+namespace DGtal
+{

  • namespace lut {

no idea, too

NeigborhoodConfigurations is ok for the filename but I don't know for the namespace... neighborhood:: ?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@dcoeurjo
Copy link
Member

could you please also consider to add something in the doc (moduleDigitalTopology.dox, last sections) ?
thx

@dcoeurjo
Copy link
Member

BTW, maybe the dgtaltools should also be updated (ping @kerautret )

@phcerdan
Copy link
Member Author

What do you prefer NeigborhoodConfigurations or NeighborhoodPredicates for the file name?
I am moving NeigborhoodXXX.h/ih into the folder topology/ and put the compressed tables and the configure file NeighborhoodTables.h.in in topology/tables ... better?

I like the split of the namespaces for the different tables.
simplicity sounds great, but for the Isthmus case? topology ? Or isthmuscity :)?

I will update the docs, and the log meanwhile.

@phcerdan phcerdan force-pushed the look-up-tables branch 3 times, most recently from 2e2452d to 601e5d4 Compare April 17, 2016 13:40
@phcerdan
Copy link
Member Author

phcerdan commented Apr 18, 2016

Last two commits:
Rename files.

  • Add object interface to tables with setTable method: it sets CowPtr<T> members with a Clone argument.
  • Modified isSimple to use the tables if setTable has been called.
  • No new constructors added to Object.
  • Add docs with an extract of testObject.cpp using the setTable interface.
  • Split header into helpers such as getOccupancyConfiguration for object and complex (to avoid recursive inclusion). And also the generateTables is there.
  • Changed loadTable from std::shared_ptr<dynamic_bitset> to CountedPtr<dynamic_bitset> to fit better with the Alias<dynamic_bitset> argument of setTable.

Rebased all branch commits

New functions to deal with pre-computed look up tables.
Motivation is to speed up large computation that use predicate
functions depending on voxel neighborhood, such as isSimple.

Add new folder /topology/tables containing:
 - NeighborhoodConfigurations.h loading table and map.
 - NeighborhoodConfigurationsHelpers.h helpers for Object
 and CubicalComplex.
 - compressed .tar.gz tables for simplicity.

Modify example generateSimplicityTables3D, and 2D:
 - using functions from new header.
 - create tables for different topologies.
 - user can choose 26_6,6_26, 18_6 and 6_18 topologies in 3D and
 8_4,4_8 in 2D.
 - Generated tables are then compressed using:
`cmake -E tar cvzf table26_6.tar.gz simple_table26_6.txt`

Add CMake rules:
 - NeighborhoodTablesConfig.cmake dealing with decompress,
copy and install tables. Linked in root CMakeLists.txt
 - NeighborhoodTablesConfig.h.in . CONFIGURE_FILE with strings pointing
 to all available tables. The generated NeighborhoodTablesConfig.h
 change location of tables depending on Build or Install.
foreach(zip_table ${DGTAL_TABLES_COMPRESSED})
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${zip_table}
WORKING_DIRECTORY ${unzip_folder}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work on Windows ? Should we add something in the Windows install guide (like install tar archive tool) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMake provides it, and it is mulit-platform, but I am not really sure what version of cmake is required.

@JacquesOlivierLachaud
Copy link
Member

Nice PR. Sorry for the long delay for reviewing it, I had several deadlines in the last weeks (SGP and ICPR). I check that everything compiles on my computer and the documentation and I merge.

@phcerdan
Copy link
Member Author

Thanks a lot for the reviewing and feedback, I am learning a lot with this library! I am right now contributing some segmentation filter in ITK, that I need for my thesis, but will try to improve this and the PR #1147 as soon as possible.

@JacquesOlivierLachaud
Copy link
Member

It is very nice for us to have contributors from far (far) away ! I was really surprised to see somebody from New Zealand who knows about isthmus and such stuff (so french :) )

@JacquesOlivierLachaud
Copy link
Member

JacquesOlivierLachaud commented Apr 26, 2016

Do you know Reinhardt Klette (he is in Auckland) ? He is one of the few guy in our community. Well, he is retiring at the moment I think.

@phcerdan
Copy link
Member Author

No, I don't know him, I have the bad excuse that I am closer to Wellington. And yeah I know it is far away hehe, I am Spanish! Currently doing a PhD here in the antipodes, in a biophysics group , but I have been migrating to computer vision to characterize geometry/connectivity/topology of biopolymer networks

@JacquesOlivierLachaud
Copy link
Member

Everything is fine for me and it works nicely on my computer. I wait for the few minor fixes (change of names mostly) and I merge.
And I think it will be time for you to go to bed, no ? :-)

@phcerdan
Copy link
Member Author

haha indeed. I will make the changes soon. Have a good afternoon!

 * Add typedef NeighborhoodConfiguration = uint_32 in
topology/helpers/NeighborhoodConfigurationHelper.h.
 * Remove NeighborhoodConfigurationHelpers.h.
   * Move generateTable to
topology/tables/NeighborhoodConfigurationGenerators.
   * Rename and move getOccupancyXXX functions, to Object class function and
CubicalComplexFunctions respectively.
 * Fix indendation in testObject.
 * Rename and add documentation to helper function mapping zero
neighborhood points to configuration bit masks.
/**
* Get the occupancy configuration of the neighborhood of a point in a cubical
* complex.
* The neighborhood size is considered DxD for dimension D of the point

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean 3^d in dD, so 3x3 in 2D and 3x3x3 in 3D.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, changed.

@JacquesOlivierLachaud
Copy link
Member

Except from the above remark, it is fine for me to merge.

@JacquesOlivierLachaud
Copy link
Member

Fine. I merge.

@JacquesOlivierLachaud JacquesOlivierLachaud merged commit 1211956 into DGtal-team:master May 4, 2016
@phcerdan phcerdan deleted the look-up-tables branch January 28, 2017 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants