MATLAB's graphical interface for adding Gaussian noise to images

        This content is about the graphical interface design through MATLAB, adding Gaussian noise with specified parameters to the picture and displaying it. The content requires a basic understanding of MATLAB's gui, Gaussian noise, and image processing.

(1) First enter guide in the command line window to create a blank interface (Blank GUI), and then use the provided controls to create an interface as shown in the figure below.

(2) Set the corresponding controls:

① pushbutton1 (generate picture), directly enter the pushbutton1_Callback section through the selection in the fig file:

global a;
ave=str2num(get(handles.edit1,'string'));
var=str2num(get(handles.edit2,'string'));
b=imnoise(a,'gaussian',ave,var);
image(b,'Parent',handles.axes2);    %将图片显示到坐标区
set( handles.axes2, 'xTick', [] ); %去掉x轴的刻度 
set( handles.axes2, 'yTick', [] ); %去掉y轴的刻度

② pushbutton1 (select the picture), directly enter the pushbutton2_Callback section through the selection in the fig file:

global a;
[fname,pname,index] = uigetfile('*.jpg','选择图片');  %创建图片选择对话框
if index    %确定选择的是图片
    str = [pname fname];%获取所选图片的路径及文件名
    a = imread(str);        %读取图片数据到矩阵a
    image(a,'Parent',handles.axes1);    %将图片显示到坐标区
    set( handles.axes1, 'xTick', [] ); %去掉x轴的刻度 
    set( handles.axes1, 'yTick', [] ); %去掉y轴的刻度
end

        After setting the callback functions of pushbutton1 and pushbutton2, the graphical interface can already execute functions.

 

(3) Generate exe file: Enter mcc -e filename in the command line window to generate the corresponding exe file.

Guess you like

Origin blog.csdn.net/weixin_58351753/article/details/127279871