フィルターのクリア

I want to do a knob for salt and pepper noise but the value of the noise dose not change

1 回表示 (過去 30 日間)
changingValue = event.Value;
input=im2gray(a); %a is my image
imshow(input,'Parent',app.UIAxes_2);
app.SaltpepperButton_2.Value=true;
J=input;
J =imnoise(J,'salt & pepper');
imshow(J,'Parent',app.UIAxes_2);
end
  2 件のコメント
Chris
Chris 2023 年 1 月 14 日
編集済み: Chris 2023 年 1 月 14 日
Is this inside a callback function? And are you using app designer, or winging it?
rama
rama 2023 年 1 月 14 日
it is inside a callback function, I am using app designer

サインインしてコメントする。

採用された回答

Chris
Chris 2023 年 1 月 14 日
編集済み: Chris 2023 年 1 月 14 日
function UIAxesButtonDown(app, event)
% The default button style doesn't have a value.
% changingValue = event.Value;
% You can't grab "a" from nowhere. If you didn't generate it in
% this callback, or if you want to store it for later use,
% it should be a property of the app.
input=im2gray(app.a);
imshow(input,'Parent',app.UIAxes_2);
% app.SaltpepperButton_2.Value=true;
J=input;
J =imnoise(J,'salt & pepper');
% You just used these axes. Depending on your computer, or how
% Matlab optimizes the function,
% the change will be too fast to see/skipped over.
pause(.5)
imshow(J,'Parent',app.UIAxes_2);
end

その他の回答 (1 件)

Image Analyst
Image Analyst 2023 年 1 月 14 日
You need to call imnoise with the parameter that controls the amount of noise added to the image. You get this value by getting the value of a slider or knob, or edit field, or however the user is going to indicate the level of noise to be added to the image. For example, if the noise density is controlled by a slider, in the slider callback
% Get noise level from the control on the GUI.
noiseDensity = app.sldNoiseDensity.Value;
% Apply this density to the noise-free image:
noisyImage = imnoise(originalImage, 'salt & pepper', noiseDensity);

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by