Why is my prompt inpudlg isn´t functional?

1 次查看(过去 30 天)
Dear all,
I would like to use prompt (inputdlg) for setting my points in segmentation like this:
fontSize = 15;
% baseFileName = '110.jpg';
baseFileName = 'thorax-mdl.jpg';
folder = pwd
fullFileName = fullfile(folder, baseFileName);
% Načtení obrazu.
grayImage = imread(fullFileName);
grayImage_pater = imread (fullFileName);
% Dimenze obrazu.
% numberOfColorBands by měl být = 1.
% ***
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% Máme barevný obraz, musíme ho převést na černobílý = vybereme zelený kanál
grayImage = grayImage(:, :, 2); % zelený kanál
end
eq_grayImage = histeq(grayImage);%ekvalizace pomocí histogramu obrazu
[rows, columns, numberOfColorChannels] = size(grayImage_pater);
if numberOfColorChannels > 1
% Máme barevný obraz, musíme ho převést na černobílý = vybereme zelený kanál
grayImage_pater = grayImage_pater(:, :, 2); % zelený kanál
grayImage_pater(425:end, :) = 0;
end
eq_grayImage_pater = histeq(grayImage_pater);%
%Práh pro vytvoření binárního obrazu okolí
thresholdValue = 180;
binaryImage_okoli = eq_grayImage > thresholdValue;
% Odstranění okolí.
binaryImage_okoli = imclearborder(binaryImage_okoli);
% Vyplnění otvorů.
binaryImage_okoli = imfill(binaryImage_okoli, 'holes');
% Vymazání menších otvorů.
binaryImage_okoli = bwareaopen(binaryImage_okoli, 750);
se = strel('line',5,100);
binaryImage_okoli= imdilate(binaryImage_okoli,se);
figure(5);
imshow(grayImage);
hold on
prompt = {'Nastavení počtu komponentů:'};
dlg_title = 'Nastavení parametrů segmentace';
defaultans = {'50'};
num_lines = [ones(size(defaultans')) ones(size(defaultans'))*75];
answer = inputdlg(prompt, dlg_title,num_lines, defaultans);
% a = str2double( x{1,1} );
a = str2double(answer);
Npts1 = 35; % počet bodů interpolovaných hranic
% Npts2 = 25; % počet bodů interpolovaných hranic
% Npts3 = 5; % počet bodů interpolovaných hranic
Ncomps = a; % počet komponentů
shape.thorax=Model(binaryImage_okoli,Ncomps,Npts1);
tmp=shape.thorax{1};
plot(tmp(:,2), tmp(:,1), 'o-b')
legend('Okolí hrudníku')
And I attach my function Model and original image thorax-mdl.jpg.
But I have this error:
Error using bwboundaries
Expected input number 1, BW, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was cell.
Error in bwboundaries>parseInputs (line 173)
validateattributes(BW_in, {'numeric','logical'}, {'real','2d','nonsparse'}, ...
Error in bwboundaries (line 135)
[BW, conn, findHoles] = parseInputs(varargin{:});
Error in Model (line 7)
Components{i} = bwboundaries(bwboundaries(tmp{i}, Ncomps), linspace(0, 1,
Npts1));
Error in opraveni (line 62)
shape.thorax=Model(binaryImage_okoli,Ncomps,Npts1);
Thank you for your answers.
  4 个评论

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2017-4-13
There is no problem with inputdlg. Instead of calling function model.m, use:
% shape.thorax=Model(binaryImage_okoli,Ncomps,Npts1);
shape.thorax=bwboundaries(binaryImage_okoli);
If you use this, there is no purpose of inputdlg.
  14 个评论
Veronika
Veronika 2017-4-17
But, I have still one problem this blue curve isn´t closed. I mean this:
Is there any option for connect these points? Thank you for your answer.
Veronika
Veronika 2017-4-17
Stephen Cobeldick: I tried str2double, but this error appears:
Cell contents reference from a non-cell array object.
Error in DP_segment_final>Okoli_Callback (line 420)
params.Height = answer{1};
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in DP_segment_final (line 44)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DP_segment_final('Okoli_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Can you advice me?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by