Why is my prompt inpudlg isn´t functional?
Show older comments
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
Philip G
on 13 Apr 2017
I tried your code and the "fourier_fit" function is missing for me.
Anyways - in line 2 of your model.m it says
tmp = bwboundaries(Img);
After that your tmp variable is a cell array for the boundaries. It seems there is a problem with the variable class. Also - your attached Model.m does not have the line 7 as specified in your error report. I would use debugging to go through the code line by line to see what exactly gives you the error. Just check that bwboundaries is not called with a cell as input but a single matrix.
Veronika
on 13 Apr 2017
KSSV
on 13 Apr 2017
Is this the final output?

Veronika
on 13 Apr 2017
Accepted Answer
More Answers (0)
Categories
Find more on Blue 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!
