Why this demo isn´t working for my image?

1 次查看(过去 30 天)
Dear all,
I tried use this demo by Image Analyst, but for my image I wasn´t successful. Instead of cameraman.tif I gave my image thorax-mdl.jpg, which I attached. I have this error message in Command Window:
Error using imageDisplayValidateParams>validateCData (line 121)
If input is logical (binary), it must be two-dimensional.
Error in imageDisplayValidateParams (line 31)
common_args.CData = validateCData(common_args.CData,image_type);
Error in imageDisplayParseInputs (line 79)
common_args = imageDisplayValidateParams(common_args);
Error in imshow (line 198)
[common_args,specific_args] = ...
Error in DP (line 86)
imshow(binaryImage, []);
Can anyone give me advice? Thank you for your answers.

采纳的回答

Image Analyst
Image Analyst 2016-12-3
You forgot to attach your code. You must have modified a demo of mine somehow and made a new script called DP.m. Evidently the code is expecting a binary image - a 2D logical image - and you're not giving it that. Maybe you're giving it a color image or something. But I can't tell because you didn't supply your code modifications. Please attach your image and DP.m and anything else we need to run your code.
  51 个评论
Image Analyst
Image Analyst 2017-2-9
Possibly, though I don't have it. You'd have to come up with some kind of custom algorithm. Check the literature, either Vision Bib or PubMed.
Veronika
Veronika 2017-3-19
Dear Image Analyst,
I have another problem...
I have code for segmentation parts of image. And I would like to binarization left lung, but I don´t know, why this code isn´t working. This is my code:
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.
% ***
[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);%ekvalizace pomocí histogramu obrazu
% Zobrazení obrazu.
figure(1)
imshow(grayImage, []);
axis on;
caption = sprintf('Originální černobílý obraz, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
% Nastavení obrazu.
% Zvětšení obrazu na celou obrazovku.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Odstranění panelu nástrojů a rozbalovacího menu.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Přidání titulku okna.
set(gcf, 'Name', 'Segmentace', 'NumberTitle', 'Off')
thresholdValue = 120;
binaryImage = grayImage < thresholdValue;
% Odstranění okolí.
binaryImage = imclearborder(binaryImage);
% Vyplnění otvorů.
binaryImage = imfill(binaryImage, 'holes');
labeledImage = bwlabel(binaryImage);
rightLung = ismember(labeledImage, 1);
leftLung = ismember(labeledImage, 2);
%Roztažení binárního obrazu pro přesnější segmentaci
se = strel('line',5,100);
rightLung= imdilate(rightLung,se);
%Roztažení binárního obrazu pro přesnější segmentaci
se = strel('line',5,100);
leftLung= imdilate(leftLung,se);
subplot (2, 3, 3)
imshow(binaryImage, []);
axis on;
caption = sprintf('Binární obraz plic');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
labeledImage = bwlabel(binaryImage);
rightLung = ismember(labeledImage, 1);
leftLung = ismember(labeledImage, 2);
subplot (2, 3, 4)
imshow(leftLung, []);
axis on;
caption = sprintf('Binární obraz levé plíce');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
subplot (2, 3, 5)
imshow(rightLung, []);
axis on;
caption = sprintf('Binární obraz pravé plíce');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
I attach original image. Can you advise me? Thank you for your answer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by