There are probably many ways to make rule-based classifications using IDL. One very obvious and commonly-used way is to use thresholds as your rule and to use IDL's WHERE function as the tool to implement the rules. Thus, let's say that you had some data that ranged from 0 to 29.99; I make some example data below:
seed = 1
coreData = randomu(seed, 30, 20) * 30.
; The below makes a 300 x 200 array of smoothly distributed data with values 0.00 - 29.99
image = congrid(coreData, 300, 200, /INTERP)
Let's say you know that certain target data has values of 1.7 - 3.6, a second target has data values from 14.8 - 18.3, and a third target has any values greater than 27.1. You could then define a classification system as follows:
; get thje coordinates of the data for our three targets
targetData1indexes = where(image gt 1.7 and image lt 3.6)
targetData2indexes = where(image gt 14.8 and image lt 18.3)
targetData3indexes = where(image gt 27.1)
; apply the indexes returned to the definition of a new classification image
imgDims = size(image, /DIMENSIONS)
classImage = bytarr(imgDims[0], imgDims[1]) ; Makes an image with all 0's
classImage[targetData1indexes] = 1
classImage[targetData2indexes] = 2
classImage[targetData3indexes] = 3
At the end of the above, we have an image where all the data has been classified into values 0, 1, 2 or 3. We could then set these values equal to specific display colors, so that the command "tv, classImage" would show a very clear mapping of our target data.
James Jones
|