Reputation: 21
I want to get some subarea of an image and make it a new image, and then execute further functions on it.
How can I use mouse to select a subarea of an image?
I know img[]
could get the subarea of img
, but I need some function by which I can interact with img
. I mean, I want to get a WYSIWYG effect.
Is there any commands available, or is there any methods of ROI capable?
Upvotes: 0
Views: 125
Reputation: 2949
There different ways to do what you want in a script: You could ask the user to place an ROI and then use the [] to address this area. If you want to get a new image from this selection (CTRL + C
and CTRL + SHIFT + V
without scripting) you would write:
ShowImage( ImageClone( img[] ) )
orimg[].ImageClone().ShowImage()
If you want to place a ROI for the user, you can used SetSelection()
for a simple, rectangle, volatile ROI, or you use the full ROI commands like in this example:
image img := RealImage( "Test", 4, 256, 256 ) // create image
img.ShowImage() // show the image (so that it has a display)
imageDisplay disp = img.ImageGetImageDisplay(0) // Get the 'display' of an image
ROI myR = NewRoi() // create ROI
myR.ROISetRectangle( 110, 120, 130, 140 ) // Make it a rectangle of given area
myR.ROISetVolatile( 0 ) // make it non-volatile
myR.ROISetLabel( "Selection" ) // give it a label
myR.ROISetColor( 0, 1, 0 ) // make it green
disp.ImageDisplayAddROI( myR ) // add it to the display
A full list of ROI commands can be found in the following section of the F1 help documentation:
Upvotes: 0