I don't know map server very well, but I know that you can style Rasters from a WMS using SLD (Styled Layer Descriptor), which is simply a xml file that you can pass in a WMS request according to OGC standards.
In other words: You can specify the classification in a XML schema. Following is an example of a simple SLD that styles everything in a raster black except white pixels, which are styled opaque.
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>undefined</Name>
<UserStyle>
<Name>rasterr</Name>
<Title>Rasterr</Title>
<Abstract>A simple raaster style</Abstract>
<FeatureTypeStyle>
<FeatureTypeName>Feature</FeatureTypeName>
<Rule>
<RasterSymbolizer>
<Opacity>1.0</Opacity>
<ColorMap>
<ColorMapEntry color="#ffffff" quantity="0" opacity="0.0" />
<ColorMapEntry color="#000000" quantity="1" />
<ColorMapEntry color="#000000" quantity="2" />
<ColorMapEntry color="#000000" quantity="3" />
<ColorMapEntry color="#000000" quantity="4" />
<ColorMapEntry color="#000000" quantity="5" />
<ColorMapEntry color="#000000" quantity="6" />
<ColorMapEntry color="#000000" quantity="7" />
<ColorMapEntry color="#000000" quantity="8" />
<ColorMapEntry color="#000000" quantity="9" />
<ColorMapEntry color="#000000" quantity="10" />
</ColorMap>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
Pass the SLD like this:
http://demo.mapserver.org/cgi-bin/wms?SERVICE=wms&VERSION=1.1.1&REQUEST=GetMap&LAYERS=country_bounds&SLD=http://demo.mapserver.org/ogc-demos/map/sld/sld_line_simple.xml
Read more here:
http://mapserver.org/ogc/sld.html - This is for mapserver, use the RasterSymbolizer and a ColorMap to do your classification. On that page it is also described how the colormap works.