Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have 4-band NAIP imagery that require the following processing steps:

  1. Convert to 8 bit unsigned B/W
  2. Reverse (note not inverse) the image, so that dark values appear light and light values appear dark. Moderate values should remain relatively unchanged.

Could someone please point me in the right direction for a Python or Arc raster calculator approach?

share|improve this question
    
Do you have the Spatial Analyst extension? You're out of luck if you don't as the Raster Calc requires it. As an alternative, QGIS has a raster calculator that can do what you need. –  Geoist Jul 3 '12 at 12:49
    
Yes, I have the Spatial Analyst ext. –  Aaron Jul 3 '12 at 12:52
    
And, just to be clear are you looking for information on how to do points 1 and 2, or information on how to do points 1 and 2 iteratively. –  Geoist Jul 3 '12 at 12:54
add comment

1 Answer

up vote 2 down vote accepted

In python (with numpy, assuming "naip" is your 4 band image as a numpy array), the following will rescale your data to 0-255 in reverse:

rescaled=((naip - naip.max()) * -255 / (naip.max() - naip.min())).astype(numpy.uint8)

If your data is already >0 and <255 and you don't want to scale it from 0-255, but just reverse it:

reversed=((naip - naip.max()) * -1 + naip.min()).astype(numpy.uint8)

An ArcGIS raster calculator solution would be quite similar, though you would have to operate on the bands individually then combine them again afterwards.

share|improve this answer
    
This is a great solution, thanks Luke. –  Aaron Jul 11 '12 at 15:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.