I = imread('image.jpg');
imshow(I);
K = imadjust(I,[0.35 0.45],[]);
figure
imshow(K)
imwrite(K,'image.jpg')
我想要一个弹出对话框供用户输入[0.35 0.45]的值。如何修改提供的编码以提示用户输入?
答案 0 :(得分:3)
使用inputdlg
:
I = imread('cameraman.tif');
imshow(I);
% prompts for the two inputs
prompt = {'Enter LOW contrast limit:','Enter HIGH contrast limit:'};
% title of the dialog box
dlg_title = 'Input';
% number of input lines available for each variable
num_lines = 1;
% default answer for each input
defaultans = {'0','1'};
% generate the dialog box and wait for answer
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
% convert string answers into doubles
lo_in = str2double(answer{1});
hi_in = str2double(answer{2});
% apply on image
K = imadjust(I,[lo_in hi_in],[]);
figure
imshow(K)