diff --git a/Data/Output/buildingExtractionIndexed_scaled.png b/Data/Output/buildingExtractionIndexed_scaled.png new file mode 100644 index 0000000000000000000000000000000000000000..f5c8ecd3189513614019da20e01580e77f2eddc5 --- /dev/null +++ b/Data/Output/buildingExtractionIndexed_scaled.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90304742fc7c5d8d88cff5abc627954337856160799856adb5dcb352db484ddd +size 17406 diff --git a/Data/Output/buildingExtractionRGB.png b/Data/Output/buildingExtractionRGB.png new file mode 100644 index 0000000000000000000000000000000000000000..0dbdd3d556a7aabcd2c736d68e3fbedc8b53301e --- /dev/null +++ b/Data/Output/buildingExtractionRGB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a91156558f5de2353efe3d8e3b17ef2284e74200a0bd1fed5d36bffcf720fc7a +size 26026 diff --git a/Examples/BasicFilters/IndexedToRGBExample.cxx b/Examples/BasicFilters/IndexedToRGBExample.cxx index adba63456d9ca821727c58f18b15b81477c563f0..d7a8226949d33aa41c6e1a43f8c0ed00dc8f453b 100644 --- a/Examples/BasicFilters/IndexedToRGBExample.cxx +++ b/Examples/BasicFilters/IndexedToRGBExample.cxx @@ -24,25 +24,11 @@ */ -// Some algorithms produce an indexed image as output. In such images, -// each pixel is given a value according to the region number it belongs to. -// This value starting at 0 or 1 is usually an integer value. -// Often, such images are produced by segmentation or classification algorithms. -// -// If such regions are easy to manipulate -- it is easier and faster to compare two integers -// than a RGB value -- it is different when it comes to displaying the results. -// -// Here we present a convient way to convert such indexed image to a color image. In -// such conversion, it is important to ensure that neighborhood region, which are -// likely to have consecutive number have easily dicernable colors. This is done -// randomly using a hash function by the \doxygen{itk}{ScalarToRGBPixelFunctor}. - #include "otbImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "itkUnaryFunctorImageFilter.h" #include "itkScalarToRGBPixelFunctor.h" - #include "itkRescaleIntensityImageFilter.h" int main(int argc, char* argv[]) @@ -65,10 +51,8 @@ int main(int argc, char* argv[]) reader->SetFileName(inputFilename); - // The \doxygen{itk}{UnaryFunctorImageFilter} is the filter in charge of - // calling the functor we specify to do the work for each pixel. Here it is the - // \doxygen{itk}{ScalarToRGBPixelFunctor}. - + // The UnaryFunctorImageFilter is the filter in charge of calling the functor + // we specify to do the work for each pixel. Here it is the ScalarToRGBPixelFunctor typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long> ColorMapFunctorType; typedef itk::UnaryFunctorImageFilter<ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType; ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New(); @@ -93,17 +77,4 @@ int main(int argc, char* argv[]) writer2->SetFileName(outputScaledFilename); writer2->SetInput(rescaler->GetOutput()); writer2->Update(); - - // Figure~\ref{fig:INDEXTORGB_FILTER} shows the result of the conversion - // from an indexed image to a color image. - // \begin{figure} - // \center - // \includegraphics[width=0.44\textwidth]{buildingExtractionIndexed_scaled.eps} - // \includegraphics[width=0.44\textwidth]{buildingExtractionRGB.eps} - // \itkcaption[Scaling images]{The original indexed image (left) and the - // conversion to color image.} - // \label{fig:INDEXTORGB_FILTER} - // \end{figure} - - return EXIT_SUCCESS; } diff --git a/Examples/BasicFilters/IndexedToRGBExample.rst b/Examples/BasicFilters/IndexedToRGBExample.rst new file mode 100644 index 0000000000000000000000000000000000000000..a99740c8b7235955f59fcd1ea2bfc6e41a411777 --- /dev/null +++ b/Examples/BasicFilters/IndexedToRGBExample.rst @@ -0,0 +1,24 @@ +Some algorithms produce an indexed image as output. In such images, +each pixel is given a value according to the region number it belongs to. +This value starting at 0 or 1 is usually an integer value. +Often, such images are produced by segmentation or classification algorithms. + +If such regions are easy to manipulate -- it is easier and faster to compare two integers +than a RGB value -- it is different when it comes to displaying the results. + +Here we present a convient way to convert such indexed image to a color image. In +such conversion, it is important to ensure that neighborhood region, which are +likely to have consecutive number have easily dicernable colors. This is done +randomly using a hash function by ``ScalarToRGBPixelFunctor``. + +.. |image1| image:: /Output/buildingExtractionIndexed_scaled.png + +.. |image2| image:: /Output/buildingExtractionRGB.png + +.. _Figure1: + ++--------------------------+-------------------------+ +| |image1| | |image2| | ++--------------------------+-------------------------+ + + The original indexed image (left) and the conversion to color image.