public static <T extends ImageBase<T>>
	void visualize(GrayS32 pixelToRegion , T color , int numSegments  )
	{
		// Computes the mean color inside each region
		ImageType<T> type = color.getImageType();
		ComputeRegionMeanColor<T> colorize = FactorySegmentationAlg.regionMeanColor(type);

		FastQueue<float[]> segmentColor = new ColorQueue_F32(type.getNumBands());
		segmentColor.resize(numSegments);

		GrowQueue_I32 regionMemberCount = new GrowQueue_I32();
		regionMemberCount.resize(numSegments);

		ImageSegmentationOps.countRegionPixels(pixelToRegion, numSegments, regionMemberCount.data);
		colorize.process(color,pixelToRegion,regionMemberCount,segmentColor);

		// Draw each region using their average color
		BufferedImage outColor = VisualizeRegions.regionsColor(pixelToRegion,segmentColor,null);
		// Draw each region by assigning it a random color
		BufferedImage outSegments = VisualizeRegions.regions(pixelToRegion, numSegments, null);

		// Make region edges appear red
		BufferedImage outBorder = new BufferedImage(color.width,color.height,BufferedImage.TYPE_INT_RGB);
		ConvertBufferedImage.convertTo(color, outBorder, true);
		VisualizeRegions.regionBorders(pixelToRegion,0xFF0000,outBorder);

		// Show the visualization results
		ListDisplayPanel gui = new ListDisplayPanel();
		gui.addImage(outColor,"Color of Segments");
		gui.addImage(outBorder, "Region Borders");
		gui.addImage(outSegments, "Regions");
		ShowImages.showWindow(gui,"Superpixels", true);
	}
public static < T extends ImageBase < T > > void visualize ( GrayS32 pixelToRegion , T color , int numSegments ) { ImageType < T > type = color . getImageType ( ) ; ComputeRegionMeanColor < T > colorize = FactorySegmentationAlg . regionMeanColor ( type ) ; FastQueue < float [ ] > segmentColor = new ColorQueue_F32 ( type . getNumBands ( ) ) ; segmentColor . resize ( numSegments ) ; GrowQueue_I32 regionMemberCount = new GrowQueue_I32 ( ) ; regionMemberCount . resize ( numSegments ) ; ImageSegmentationOps . countRegionPixels ( pixelToRegion , numSegments , regionMemberCount . data ) ; colorize . process ( color , pixelToRegion , regionMemberCount , segmentColor ) ; BufferedImage outColor = VisualizeRegions . regionsColor ( pixelToRegion , segmentColor , null ) ; BufferedImage outSegments = VisualizeRegions . regions ( pixelToRegion , numSegments , null ) ; BufferedImage outBorder = new BufferedImage ( color . width , color . height , BufferedImage . TYPE_INT_RGB ) ; ConvertBufferedImage . convertTo ( color , outBorder , true ) ; VisualizeRegions . regionBorders ( pixelToRegion , 0xFF0000 , outBorder ) ; ListDisplayPanel gui = new ListDisplayPanel ( ) ; gui . addImage ( outColor , "Color of Segments" ) ; gui . addImage ( outBorder , "Region Borders" ) ; gui . addImage ( outSegments , "Regions" ) ; ShowImages . showWindow ( gui , "Superpixels" , true ) ; }
Visualizes results three ways.  1) Colorized segmented image where each region is given a random color.
2) Each pixel is assigned the mean color through out the region. 3) Black pixels represent the border
between regions.