Why is my prompt inpudlg isn´t functional?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Veronika
 el 13 de Abr. de 2017
  
    
    
    
    
    Comentada: Veronika
 el 17 de Abr. de 2017
            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 comentarios
Respuesta aceptada
  KSSV
      
      
 el 13 de Abr. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Matrix Indexing en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







