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

Renaming BasicColorToScalarFunctor:: to functors:: #857

Merged
merged 3 commits into from
Jul 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@
- *IO*
- Bug fix for reading PGM(P2) 3D. (Kacper Pluta,
[#853](https:/DGtal-team/DGtal/pull/853))

- Renaming BasicColorToScalarFunctors namespace to functors:: (David
Coeurjolly, [#857](https:/DGtal-team/DGtal/pull/857))

=== DGtal 0.7 ===

*General*
Expand Down
27 changes: 9 additions & 18 deletions src/DGtal/io/colormaps/BasicColorToScalarFunctors.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@

namespace DGtal
{

/*! @namespace DGtal::BasicColorToScalarFunctors
* @brief Contains basic functors to convert DGtal::Color to scalar values.
*/
namespace BasicColorToScalarFunctors
namespace functors
{
/**
* Basic color to scalar functor which returns the red channel.
Expand All @@ -63,7 +59,7 @@ namespace DGtal
inline
unsigned char operator() (const Color &aCol) const
{
return aCol.red();
return aCol.red();
}
};

Expand All @@ -77,7 +73,7 @@ namespace DGtal
inline
unsigned char operator() (const Color &aCol) const
{
return aCol.blue();
return aCol.blue();
}
};

Expand All @@ -91,7 +87,7 @@ namespace DGtal
inline
unsigned char operator() (const Color &aCol) const
{
return aCol.green();
return aCol.green();
}
};

Expand All @@ -105,7 +101,7 @@ namespace DGtal
inline
unsigned char operator() (const Color &aCol) const
{
return static_cast<unsigned char>( ((int)aCol.green() + (int)aCol.blue() + (int)aCol.red()) / 3);
return static_cast<unsigned char>( ((int)aCol.green() + (int)aCol.blue() + (int)aCol.red()) / 3);
}
};

Expand All @@ -121,20 +117,15 @@ namespace DGtal
inline
Value operator() (const Color &aCol) const
{
return static_cast<Value> (aCol.getRGB());
return static_cast<Value> (aCol.getRGB());
}
};






} //namespace BasicColorToScalarFunctors
} //namespace functors
} // namespace DGtal

// //
///////////////////////////////////////////////////////////////////////////////
// //
///////////////////////////////////////////////////////////////////////////////

#endif // !defined ColorToScalarFunctors_h

Expand Down
8 changes: 4 additions & 4 deletions src/DGtal/io/doc/moduleIO.dox
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ offer better colormap for scientific visualisation purposes.

In some situations, we may have to convert colors into scalar
values (see below). In this case, basic conversion functors are
available in the DGtal::BasicColorToScalarFunctors namespace. For
example, you would find in this namespace a DGtal::BasicColorToScalarFunctors::RedChannel converter or a
DGtal::BasicColorToScalarFunctors::MeanChannels converter.
available in the DGtal::functors namespace. For
example, you would find in this namespace a DGtal::functors::RedChannel converter or a
DGtal::functors::MeanChannels converter.

Hence, to implement a functor taking values and returning the red
channel of a colormap, you just have to compose the two functors with
Expand All @@ -53,7 +53,7 @@ the help of the Composer:
#include "DGtal/io/colormaps/BasicColorToScalarFunctors.h"

typedef GradientColorMap<unsigned char, CMAP_JET > JetMap;
typedef BasicColorToScalarFunctors::RedChannel RedChan;
typedef functors::RedChannel RedChan;
typedef Composer< JetMap, RedChan, unsigned char> RedFunctor;
RedFunctor redFunctor( JetMap(0,255), RedChan() );

Expand Down
4 changes: 2 additions & 2 deletions src/DGtal/io/readers/PPMReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace DGtal
*
*/
template <typename TImageContainer,
typename TFunctor=BasicColorToScalarFunctors::ColorRGBEncoder<typename TImageContainer::Value> >
typename TFunctor=functors::ColorRGBEncoder<typename TImageContainer::Value> >
struct PPMReader
{
// ----------------------- Standard services ------------------------------
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace DGtal
* @return an instance of the ImageContainer.
*/
static ImageContainer importPPM(const std::string & aFilename,
const Functor & aFunctor = BasicColorToScalarFunctors::ColorRGBEncoder<Value>(),
const Functor & aFunctor = functors::ColorRGBEncoder<Value>(),
bool topbotomOrder = true) throw(DGtal::IOException);


Expand Down
4 changes: 2 additions & 2 deletions tests/io/writers/testPNMRawWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ bool testPNMWriter()
PPMWriter<Image,RedShade2>::exportPPM("export-red2.ppm",image,RedShade2(0,255));

//TestingFunctor
typedef Composer< Jet, BasicColorToScalarFunctors::RedChannel, unsigned char> RedFunctor;
RedFunctor redFunctor( Jet(0,255), BasicColorToScalarFunctors::RedChannel() ) ;
typedef Composer< Jet, functors::RedChannel, unsigned char> RedFunctor;
RedFunctor redFunctor( Jet(0,255), functors::RedChannel() ) ;
PGMWriter<Image, RedFunctor>::exportPGM("export-jet-red.pgm",image, redFunctor);


Expand Down