How Do I Resize an Image in LabVIEW?

您所在的位置:网站首页 如何调整gif图片大小和像素 How Do I Resize an Image in LabVIEW?

How Do I Resize an Image in LabVIEW?

2024-07-17 11:35| 来源: 网络整理| 查看: 265

The LabVIEW Development Environment, by itself, does not have any built-in VIs for image manipulation that ship with the Base, Full, or Professional versions. Here are some approaches to manipulate your image: The聽Zoom Factorproperty node of the聽2D Picture聽control can be used to resize the image. For example, a zoom factor of .5 will cause the image to be displayed at half of its native resolution. An image can also be placed in a custom image container, fit to the size of the image, using the聽Draw Area Size聽property node of the聽2D Picture聽control. 聽 To Resize an Image to Fit in a Picture Control: In order to find out the maximum zoom factor that can be used, you will need to divide both the height and width of the picture control by the height and width of the image, respectively. The smallest of these two quotients is the largest zoom factor that can be used while still having the whole image visible.聽The images below show the front panel and block diagram of this process. To Resize an Image Control to Fit to the Picture: Alternatively, you could programmatically resize the control to display the full image at its native resolution using the聽Draw Area Size聽property node of the聽2D Picture聽control.The images below shows the front panel and block diagram of this process. To Save the Resized Image to a File: There is a Picture Control invoke node method called聽Get Image聽that returns the image data from the picture. You can use this after adjusting the zoom factor to get the resized image data, which can then be written to a file using the Write JPG File, Write PNG File, or Write BMP File VIs.

However, this method may significantly distort the image. The recommended method to resize image data is using the functions provided by the LabVIEW Vision Development Module for this purpose. For more information about the LabVIEW Vision Development Module, follow the link in the section below.

Manual Resize or Resampling as an Array (Advanced): You can also write your own algorithm to resize an image, but this can be a difficult task. In the Full and Professional versions of LabVIEW, you can import a picture and convert it to a Pixmap.

A Pixmap is a 2D array of numeric values that correspond to the color values of the individual pixels of the image. This conversion is done by importing an image into LabVIEW using the Read JPG File, Read PNG File, or Read BMP File VIs to read the appropriate file format.

Once the image has been read into LabVIEW, you can use the Unflatten Pixmap VI to convert the picture information to a Pixmap. These VIs, which are only available in the Full and Professional Versions of LabVIEW, are located on the聽Functions禄Graphics and Sound禄Graphics Formats聽palette.

Once you have the image as a Pixmap, you can treat it as an array and do array manipulation to alter the image. At this point, you must write your own algorithm to manipulate the Pixmap to resize the image.聽 Keep in mind that resizing an image cannot add new information when making an image larger, and will inevitably lose some information when making an image smaller, so careful consideration is needed to design an algorithm which preserves the most useful information for your application.聽 For example, averaging neighboring pixel colors may tend to blur hard edges, making edge detection more difficult.聽 Resampling images is still an active area of study with significant tradeoffs between efficiency and accuracy.聽 For predicable results, the聽Vision Development Module 聽provides tools to resize or resample images.

You can then use the Flatten Pixmap VI to flatten the Pixmap back into the image data, and then save it to file with the Write JPG File, Write PNG File, or Write BMP File VIs.聽

Using the Zoom to fit feature: If you are uing "Image Display" control or indicateur provided in the Vision control palette, you can right click on the image and select Zoom to fit.聽This will either zoom out or zoom in to your figure.聽You need the Vision Development Module to use that spefic Image control. Additional Information Third Party Software:In addition, you can always use 3rd party image software such as Adobe Photoshop or ACDSee to do image manipulation. Some such packages may even offer ActiveX interfaces which allow them to be programmatically controlled from LabVIEW.


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3