Annoying ROIs

This article is about the difference between the way that IDLgrROI renders and the use of the IDLanROI::ComputeMask method.

The IDLanROI::ComputeMask() method uses the PIXEL_CENTER keyword to indicate where the centre of the pixel is. The default value is PIXEL_CENTER =[0,0]indicating that the lower left pixel is centred at 0,0 of the image. This follows a similar convention to many other toolkits.

However, when displaying the ROI it does not appear to line up properly.

rkbcontrol_scale, [oROI], XRANGE=[0.,5.], YRANGE=[0.,5.]

The reason for the problem is that XCONV_COORD and YCONV_COORD must be tweaked to correctly display the ROI. You need to specify that the point 0,0 on the ROI is actually displayed at the point 0.5,0.5 on the graphics device.

rkbcontrol_scale, [oROI], XRANGE=[-0.5,4.5], YRANGE=[-0.5,4.5]

This is the correct way to display a ROI so that the co-ordinates in your ROI correspond to coordinates in your image.

I’ve included another example of how to use ComputeMask if you insist on rendering your ROIs at the point 0,0 on the graphics device.

Source Code

A visual example - IDL binary