Why is my prompt inpudlg isn´t functional?

1 view (last 30 days)
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 Comments
Veronika
Veronika on 13 Apr 2017
Yes! Please, how did you do that?

Sign in to comment.

Accepted Answer

KSSV
KSSV on 13 Apr 2017
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 Comments
Veronika
Veronika on 17 Apr 2017
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 on 17 Apr 2017
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?

Sign in to comment.

More Answers (0)

Categories

Find more on Scope Variables and Generate Names in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!