LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Keep aspect ratio of 2D data in intensity graph

I have a 2D array of doubles representing an image that I want to display using a intensity graph without stretching the image along one axis (i.e. the pixels should remain square). However, as the dimensions of the image may change I can not simple adapt the size of the control to fit the 2D array.

My idea was to pad the 2D array in order to make its aspect ratio equal to that of the intensity graph Im using. To this end I'm computing the aspect ratio of the control by means of the PlotAreaSize property. At first this seemed to work just fine, but I noticed that for some reason the area size of the control would change when I zoom into the picture, which of course than renders the approach useless. Shouldn't this property be constant during runtime? Can I make it constant or is there a better way of achieving what I want after all?

0 Kudos
Message 1 of 8
(2,287 Views)

Basically, you want to have square cells. If you zoom, you are changing the pixel aspect ration unless your zoomed selection displays an array subset that has he same ratio of the two dimensions.

 

I would use a 2D picture indicator instead. 

0 Kudos
Message 2 of 8
(2,248 Views)

This is only the behavior if one zooms in an area (first three options here https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/zooming_on_a_graph_or_char/ ), isn't it? The last two symbols don't change the aspect ratio while zooming. Morever, why would zooming also change the plot area size of the intensity graph?

0 Kudos
Message 3 of 8
(2,233 Views)

The plot area size will not change unless you have "advanced...autoadjust scales" enabled, which would automatically change the plot area to make room for changes in axis marker width (e.g. if they change from "0.2" to "0.456e-6". So disable that! (also pick a useful marker format or e.g. don't even show the axes)

 

altenbach_0-1637165140487.png

 

 

The cell aspect ratio will also change if you only zoom x or y.

 

Unfortunately. you haven't really shown us any of your code, so we don't know how you are doing things.

0 Kudos
Message 4 of 8
(2,215 Views)

I mean the zoom symbols with the arrows ( "Zooms in. Hold <Shift> to zoom out while you are zooming in, and release <Shift> to zoom in again." on the page I previously mentioned)..

 

Disabling the Auto Adjust Scales option is not really feasible as then of course the scales are messed up.

I attached a picture of the vi I use to pad the imaging (which is then just displayed via the intensity graph without further manipulation). The incoming image is acquired via a camera, ie it changes frequently. My LabView program should be compatible with multiple Cameras, thats why I cannot fix the aspect ratio in advance. Since I want to be able to analyse the camera images at runtime I need all the functionalities provided by the intensity graph indicator, which probably rules out the picture indicator..

0 Kudos
Message 5 of 8
(2,195 Views)

Your code is a bit Rube Goldberg. It is typically simpler to initialize an array at the final size and then use replace array subset to add the data at the desired location (or use array subset to zoom into a smaller area, recalculating offset and multiplier.

 

Nobody forces you to use the graph tools. You could ad a "+" and"-" button instead and handle things with events.

 

I still think that using a 2D picture would be a better solution in your case. Intensity graphs only have 256 different colors and it would be simple to map your data into a 8bit color-mapped image of the desired dimension. Pictures always have square pixels!

0 Kudos
Message 6 of 8
(2,155 Views)

You can try to catch Scale Range Change and Autoscale Range Change events, and when a scale changes adjust the other scale to ratio.

 

It won't be easy though. One problem will be that you get two events on a zoom (because both scales change). So you'd probably have to 'delay' the events to a user event or value change event (limited to 1). The delayed event would need to know which scale changed last.

 

You'd be fighting LabVIEW's build in scaling. That is usually hard or simply not possible.

0 Kudos
Message 7 of 8
(2,134 Views)

@phll wrote:

this end I'm computing the aspect ratio of the control by means of the PlotAreaSize property. At first this seemed to work just fine, but I noticed that for some reason the area size of the control would change when I zoom into the picture, which of course than renders the approach useless. Shouldn't this property be constant during runtime? 


The plot area size is adjusted if the scale (labels) need more space. 

 

@phll wrote:

Can I make it constant or is there a better way of achieving what I want after all?


If you make the graph large enough and the plot area size small enough (giving the scales enough room to grow), the plot area size won't change.

0 Kudos
Message 8 of 8
(2,133 Views)