|
@@ -201,6 +201,45 @@ int RegionSegmentationMethod::segRegions ( const NICE::ColorImage & cimg, NICE::
|
|
return segRegions ( img, mask );
|
|
return segRegions ( img, mask );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int RegionSegmentationMethod::segRegions (
|
|
|
|
+ const NICE::MultiChannelImage3DT<double> & img,
|
|
|
|
+ NICE::MultiChannelImageT<int> & mask,
|
|
|
|
+ const int isGray
|
|
|
|
+ ) const
|
|
|
|
+{
|
|
|
|
+ const int xsize = img.width();
|
|
|
|
+ const int ysize = img.height();
|
|
|
|
+ const int zsize = img.depth();
|
|
|
|
+
|
|
|
|
+ int amountRegions = -1;
|
|
|
|
+ mask.reInit( xsize, ysize, zsize );
|
|
|
|
+ for (int z = 0; z < zsize; z++)
|
|
|
|
+ {
|
|
|
|
+ NICE::Matrix reg;
|
|
|
|
+ int aR;
|
|
|
|
+ if ( isGray )
|
|
|
|
+ {
|
|
|
|
+ NICE::Image slice = img.getChannel(z);
|
|
|
|
+ aR = segRegions( slice, reg );
|
|
|
|
+ } else {
|
|
|
|
+ NICE::ColorImage slice = img.getColor(z);
|
|
|
|
+ aR = segRegions( slice, reg );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( aR > amountRegions ) amountRegions = aR;
|
|
|
|
+
|
|
|
|
+ for (int y = 0; y < ysize; y++)
|
|
|
|
+ {
|
|
|
|
+ for (int x = 0; x < xsize; x++)
|
|
|
|
+ {
|
|
|
|
+ mask.set( x, y, reg(x,y), (uint)z );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return amountRegions;
|
|
|
|
+}
|
|
|
|
+
|
|
void RegionSegmentationMethod::markContours ( const NICE::ColorImage & cimg, NICE::Matrix & mask, std::vector<int> &color, NICE::ColorImage &marked )
|
|
void RegionSegmentationMethod::markContours ( const NICE::ColorImage & cimg, NICE::Matrix & mask, std::vector<int> &color, NICE::ColorImage &marked )
|
|
{
|
|
{
|
|
// mark contours
|
|
// mark contours
|