Browse Source

ClassNames::labelToRGB: more than 256 labels

Sven Sickert 10 năm trước cách đây
mục cha
commit
e14ef69cb7
2 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 12 1
      cbaselib/ClassNames.cpp
  2. 1 0
      cbaselib/ClassNames.h

+ 12 - 1
cbaselib/ClassNames.cpp

@@ -411,7 +411,7 @@ void ClassNames::getClassnoFromColor ( int & classno, int r, int g, int b ) cons
   }
 }
 
-void ClassNames::labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb ) const
+void ClassNames::labelToRGB ( const NICE::ImageT<int> & img, NICE::ColorImage & rgb ) const
 {
   int red, green, blue;
 
@@ -429,6 +429,17 @@ void ClassNames::labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb )
 
 }
 
+void ClassNames::labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb ) const
+{
+    NICE::ImageT<int> imgInt ( img.width(), img.height() );
+
+    for ( int y = 0 ; y < img.height(); y++ )
+      for ( int x = 0 ; x < img.width(); x++ )
+          imgInt.setPixelQuick( x, y, img.getPixelQuick(x,y) );
+
+    labelToRGB ( imgInt, rgb );
+}
+
 int ClassNames::getBackgroundClass () const
 {
   if ( existsClassCode ( "various" ) )

+ 1 - 0
cbaselib/ClassNames.h

@@ -118,6 +118,7 @@ class ClassNames : public NICE::Persistent
     /** colorize a labeled image using color information given in the class
      *  information file */
     void labelToRGB ( const NICE::Image & img, NICE::ColorImage & rgb ) const;
+    void labelToRGB ( const NICE::ImageT<int> & img, NICE::ColorImage & rgb ) const;
 
     int getBackgroundClass () const;