필터 지우기
필터 지우기

How to Enter Threshold Value Depend on the Selected Image

조회 수: 1 (최근 30일)
Murat Kocaman
Murat Kocaman 2018년 6월 11일
답변: Image Analyst 2018년 6월 11일
Hello,
I am using the standard code to enter threshold value as a text and copy it at Matlab screen to run. I would like to enter seperate value independently after the program is run.
My code ;
erosion=imerode(binary,strel('disk',35));
Any solution?

채택된 답변

Image Analyst
Image Analyst 2018년 6월 11일
Try this to ask your user for an integer value for the threshold:
% Ask user for one integer number.
defaultValue = 45;
titleBar = 'Enter an integer value';
userPrompt = 'Enter the threshold';
caUserInput = inputdlg(userPrompt, titleBar, 1, {num2str(defaultValue)});
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
% Round to nearest integer in case they entered a floating point number.
integerValue = round(str2double(cell2mat(caUserInput)));
% Check for a valid integer.
if isnan(integerValue)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
integerValue = defaultValue;
message = sprintf('I said it had to be an integer.\nTry replacing the user.\nI will use %d and continue.', integerValue);
uiwait(warndlg(message));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by