|
||||||
|
AVS TechnotePlacing image contours on top of imagesRecently, it was asked, "How can I display an image and its contour in the same window?" There is an easy answer to this, but there are some unexpected ramifications: The easy answer is: the Graph Viewer module has three visible input ports. The right most one is for 1D data, the middle one is for 2D (contour plot) data, and the left-most one is background image data. So, to display a (colorized) 2D scalar data set with it's contours, you need to build a network like this: GENERATE COLORMAP READ FIELD
|_____ _______|
| | |
COLORIZER |
|__ ____|
| |
GRAPH VIEWER
Now, we start getting to the interesting part... Images have their origin in the upper left corner, and everything else in AVS considers the origin to be in the lower left corner. In AVS3, the above network will produce a picture with the image right side up and the graph upside down relative to it. In AVS4, this problem was partially fixed by having the Graph Viewer flip the image data so that they are both upside down. This can be worked around with the following modification to the previous network: GENERATE COLORMAP READ FIELD
| |
| MIRROR
|_____ _________|
| | |
COLORIZER |
|__ ______|
| |
GRAPH VIEWER
(remember, I said it was a hack!) Ok, fine. Now, what do you do if the data is small relative to the screen (say 20 x 20). If you tried the above network, you would get a very small graph viewer window with a small plot inside it. Some folks have tried to work around this by using cascaded interpolate modules to bump up the size of the colorized data set. But with AVS4, there is an easier way: Use the Image Viewer module, Normalize the image to be the size of the Image Viewer window and output this to the Graph Viewer. With the mirror module in place, the new network looks like: GENERATE COLORMAP READ FIELD
| |
| MIRROR
|_____ _________|
| | |
COLORIZER |
| |
IMAGE VIEWER |
|__ ______|
| |
GRAPH VIEWER
Caution: if your data set is not square, you will need to resize the Image Viewer's window to exactly fit the extent of the image. This can easily be done by calculating the size of the window to be a multiple of the data set's dimensions and setting it with the following CLI command: image_set_view_size screen_x screen_y (x_dim*scale) (y_dim*scale) To upsize a 20x30 data set 5 times, this might be: image_set_view_size 0 0 100 150 This is not exactly pretty but it gets the job done
| |||||