Current location - Recipe Complete Network - Complete breakfast recipes - Matlab GUI- a simple example of image input and output
Matlab GUI- a simple example of image input and output
This paper introduces the operation of image input and output through a simple example, which can be used for reference by self-learners.

1. Create a new blank GUI. This example will use static text, buttons, axes and panels. First drag a static text into the interface, change the "string" column in its properties to "input and output picture examples", and adjust the font size to 20, as shown below.

2. Drag two panels into the interface, and then change the "string" column of the two panels to "input picture" and "output picture" respectively. Images are displayed on the axis control in GUI. If the axis control is not placed in the panel control, the displayed image will change according to the image size. If the axis is framed by the panel, the size of the image can be fixed to avoid changing. So the general panel and coordinate axis are used together.

3. Drag two coordinate axes to the panel respectively, as shown in the figure, and adjust the size. Double-click to open the properties of the coordinate axis, and change the values of "XTick" and "YTick" in their properties to 0, because the coordinate axis has horizontal and vertical coordinates by default when it is displayed, but in this example, the coordinate axis is used to display pictures, so horizontal and vertical coordinates are not needed.

4. Drag in four more buttons and change their "string" columns to "Import Picture", "Add Gaussian Noise", "Add Salt and Pepper Noise" and "Add Poisson Noise" respectively, and the font is set to 20.

5. Enter the callback function of the button "Import Picture", and type the program segment as shown in the figure in the callback function. The function of each program is marked in the diagram, so it is not repeated here.

6. Enter the callback function of the "Add Gaussian Noise" button, and type the program segment as shown in the figure in the callback function.

7. Enter the callback function of the button "Add Salt and Pepper Noise", and type the program segment as shown in the figure in the callback function.

8. Enter the callback function of the button "Add Poisson Noise", and type the program segment as shown in the figure in the callback function.

9. The final result is shown in the figure below.