By using LabVIEW's Picture Functions and Graphics Formats palettes, you can easily read, crop, and save an image file.
- Use the appropriate Read X File VI for your image file type (where "X" is your file type: JPEG, BNG, PNG, etc) to process the image file.
- Convert the image into a 2D array using the Unflatten Pixmap VI in the Graphics Formats palette. This 2D array holds the image's pixel data.
- Wire this array into Array Subset , and specify the indices of the desired image subsection to create an array of the subsection pixel data.
- Input this new subsection array into the Flatten Pixmap VI to convert the pixels back into image data.
- Use the Write X File VI to save the data, or the Draw Flattened Pixmap VI (located in the Picture Functions palette) to display the cropped version of the image on the front panel.
: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.