Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1488 |
|
Package | general | |
Module | images | |
Tool | regionmanager |
region1 | in | The first world region | |
Allowed: | Region tool | ||
region2 | in | The second world region | |
Allowed: | Region tool | ||
comment | in | A comment stored with the region | |
Allowed: | String |
This function (short-hand name diff) creates a region which is the difference of two world regions. The order of the regions is important.
- im := image('hcn') - cs := im.coordsys() - drm.setcoordinates(cs) - - blc := "10pix 10pix" - trc := "60pix 60pix" - r1 := drm.wbox(blc,trc,[1,2]) - - blc := "50pix 50pix" - trc := "80pix 80pix" - r2 := drm.wbox(blc, trc, [1,2]) - - r3 := drm.difference(r1, r2) # r1 - r2 - - im.stats(region=r1) # Some output discarded Selected bounding box [10, 10] to [60, 60] No pts = 2601 - - im.stats(region=r3) # Some output discarded Selected bounding box [10, 10] to [60, 60] No pts = 2480 - - - r4 := drm.difference(r2, r1) # r2 - r1 - - im.stats(region=r2) # Some output discarded Selected bounding box [50, 50] to [80, 80] No pts = 961 - - im.stats(region=r4) # Some output discarded Selected bounding box [50, 50, 1] to [80, 80, 64] No pts = 840
We use pixel units and boxes in this example to make it clear what is happening. The two regions overlap in the top right corner area of region r1 by an area of 11 x 11 = 121 pixels. Therefore, the difference region r3 has 2601 - 121 = 2480 pixels in it. For difference region r4, the region of overlap is the bottom left corner area of region r2 and still contains 121 pixels. We expect 961 - 121 = 840 pixels in the differnce region.