Scripting Resources for DigitalMicrograph™ |
Example: Extract RGB Channels |
|
Function |
An example script which shows how to extract the reg, green and blue images from an RGB image. |
Version |
version:20040609, v1.1 |
Author |
D. R. G. Mitchell |
Acknowledgements |
|
Comments |
Needs an RGB image to be foremost when run. |
System Requirements |
Should be compatible with all recent versions of DigitalMicrograph. |
Known Issues |
|
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
// Demo script to show how to split a RGB image into // its component channels
// D. R. G. Mitchell, adminnospam@dmscripting.com (remove the nospam to make this email address work) // version:20040609 // v1.1, June 2004
// Check to make sure the foremost image is an RGB
image temp:=getfrontimage() if(!imageisdatatypeRGB(temp)) { okdialog("This script works only on RGB images!") exit(0) }
rgbimage front:=getfrontimage() string name=getname(front)
// Split the image into its component channels
image redimage, greenimage, blueimage
blueimage=blue(front) greenimage=green(front) redimage=red(front)
// Display the component channels
showimage(Front) setwindowposition(front, 142,24)
showimage(redimage) setname(redimage,"Red "+name) setwindowposition(redimage, 172,54)
showimage(greenimage) setname(greenimage,"Green "+name) setwindowposition(greenimage, 202,84)
showimage(blueimage) setname(blueimage,"Blue "+name) setwindowposition(blueimage, 232,114) |