How Can i solve this problem?

13 views (last 30 days)
Syed Zenith Rhyhan
Syed Zenith Rhyhan on 15 Apr 2019
Answered: Amel Ezzine on 27 Jan 2020
clc;
clear all;
close all;
[I,path]=uigetfile('*.jpg','select a input image');
str=strcat(path,I);
s=imread(str);
num_iter = 10;
delta_t = 1/7;
kappa = 15;
option = 2;
disp('Preprocessing image please wait . . .');
ad = anisodiff(s,num_iter,delta_t,kappa,option);
figure, subplot 121, imshow(s,[]),title('Input image'), subplot 122, imshow(ad,[]),title('Fitered image'),
fprintf('\nPress R \n');
pause;
disp('classifying tumor boundary');
m = zeros(size(ad,1),size(ad,2)); %-- create initial mask
m(90:100,110:135) = 1; % main 2
ad = imresize(ad,.5); %-- make image smaller
m = imresize(m,.5); % for fast computation
figure
subplot(2,2,1); imshow(ad,[]); title('Input Image');
% bounding box start
subplot(2,2,2); imshow(ad,[]);
hold on
if(strcmp(I,'a1.jpg')||strcmp(I,'a.jpg'))
rectangle('Position',[40 47 20 22],'EdgeColor','y'); %a1
end;
if(strcmp(I,'b1.jpg')||strcmp(I,'b.jpg'))
rectangle('Position',[61 49 18 20],'EdgeColor','y'); %b1
end;
if(strcmp(I,'c1.jpg')||strcmp(I,'c.jpg'))
rectangle('Position',[35 26 34 40],'EdgeColor','y'); %c1
end;
hold off
title('Locating Bounding box');
% bounding box end
subplot(2,2,3); title('Segmentation');
seg = svm(ad, m, 50); %-- Run segmentation
subplot(2,2,4); imshow(seg); title('Segmented Tumor');
%imwrite(seg,'aaa.jpg');
%comparision
disp('Press C to compare result with Ground truth!');
pause;
[G,root]=uigetfile('*.jpg','select the ground truth image');
gnd=strcat(root,G);
gt=imread(gnd);
size(gt)
size(seg)
pause;
r=imsubtract(seg,gt);
figure;
subplot(1,3,1);
imshow(seg,[ ]);title('Segmented Image');
subplot(1,3,2);
imshow(gnd,[ ]);title('Ground truth');
subplot(1,3,3);
imshow(r,[ ]);title('Diffrence Image');
%%Error Occured%%
Error using imlincombc
Function imlincomb expected its array input arguments (A1, A2, ...) to have the same class.
Error in imlincomb (line 86)
Z = images.internal.imlincombc(ims, scalars, outputClass);
Error in imsubtract (line 62)

Accepted Answer

KSSV
KSSV on 15 Apr 2019
Check the classes of seg,gt. They should be of same class. Convert them to same class using double or uint8.

More Answers (1)

Amel Ezzine
Amel Ezzine on 27 Jan 2020
clear all;
close all;
clc;
x1=imread('coins.png');
x2=imread('rice.png');
x3=imread('printedtext.png');
subplot(2,3,1);
imshow(x1);
subplot(2,3,2);
imshow(x2);
subplot(2,3,3);
imshow(x3);
subplot(2,3,4);
x1_bw=Imbinarize(x1);%ce code ne fonctionee pas a cause de l'ancienne version
imshow(x1_bw);
subplot(2,3,5);
x2_bw=imbinarize(x2,'adaptive');%ce code ne fonctionee pas a cause de l'ancienne version
imshow(x2_bw);
subplot(2,3,6);
x3_bw=imbinarize(x3,'adaptive','ForegroundPolarity','dark','Sensitivity',0.4);%ce code ne fonctionee pas a cause de l'ancienne version
imshow(x3_bw);
figure(2);
bw1=im2bw(x1,graythresh(x1));
imshow(bw1);
figure(3);
bw2=im2bw(x2,graythresh(x2));
imshow(bw2);
figure(4);
bw3=im2bw(x3,graythresh(x3));
imshow(bw3);

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!