How to set noise density

1 次查看(过去 30 天)
i have edittext box and also checkbox.user can set the value of noise density from 0.1-1.0.what i want to do is, user can key in the value in edittext and after that press the checkbox,so that the noise will add to the image.How to do this?please help me
function chkSaltPepper_Callback(hObject, eventdata, handles)
x = get(handles.TxtNoiseDensity,'String');
d = get(handles.TxtNoiseDensity,'Value');
if isempty(x)
errordlg('Error:Please enter noise density');
else
noiseImage = imnoise(noiseImage,'salt & pepper',d);
function TxtNoiseDensity_Callback(hObject, eventdata, handles)
input = str2double(get(hObject,'String'));
if isnan(input)
errordlg('You must enter a numeric value','Invalid Input','modal')
uicontrol(hObject)
return
else
display(input);
end

采纳的回答

Walter Roberson
Walter Roberson 2016-11-10
function chkSaltPepper_Callback(hObject, eventdata, handles)
x = get(handles.TxtNoiseDensity,'String');
if isempty(x)
errordlg('Error:Please enter noise density');
else
d = str2double(x);
noiseImage = imnoise(noiseImage,'salt & pepper',d);
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by