How can I solve this problem/Error ?

When I execeute the given matlab project I faces the follwoing error when i run the com.m file.I attached the full project file O.P Final.Please help me anyone how can i resolve this problem?
Error Occured:
Error using .*
Matrix dimensions must agree.
Error in comp (line 20)
FPimg = TestMask.*NotTargetMask;
%%% Here com.m file will be given
clc;
TargetImg=imread('tumor.jpg');
[L,path1]=uigetfile('*.jpg','select a input image');
str1=strcat(path1,L);
TestImg=imread(str1);
[u v]=size(TargetImg);
TPrate=zeros(1, u, 2);
FPrate=zeros(1, u, 2);
TargetMask = zeros(size(TargetImg));
TargetMask = TargetImg >0;
NotTargetMask = logical(1-TargetMask);
TestMask = zeros(size(TestImg));
TestMask= TestImg >0;
FPimg = TestMask.*NotTargetMask;
FP = sum(FPimg(:))
TPimg = TestMask.*TargetMask;
TP = sum(TPimg(:))
FNimg = TargetMask-TPimg;
FN = sum(FNimg(:))
TNimg = 1- FPimg;
TN =sum(TNimg(:))
TPrate(1,:,1)=TP/(TP+FN);
FPrate(1,:,1)=FP/(FP+TN);
Sensitivity(1)= TP/(TP+FN)*100
Specificity(1)= TN/(TN+FP)*100
Accuracy(1)=(TP+TN)/(TP+TN+FN+FP)*100
TargetImg(TargetImg>0)=200;
%2. set second image non-zero values as 300
TestImg(TestImg>0)=300;
%3. set overlap area 100
OverlapImage = TestImg-TargetImg;
%4. count the overlap100 pixels
[r,c,v] = find(OverlapImage==100);
countOverlap100=size(r);
%5. count the image200 pixels
[r1,c1,v1] = find(TargetImg==100);
TargetImg_200=size(r1);
%6. count the image300 pixels
[r2,c2,v2] = find(TestImg==200);
TestImg_300=size(r2);
Similarity_index=(2*TP)/(2*TP+FP+FN)*100

댓글 수: 2

Walter Roberson
Walter Roberson 2019년 7월 22일
tumor.jpg is not present in the .zip
Syed Zenith Rhyhan
Syed Zenith Rhyhan 2019년 7월 22일
편집: Syed Zenith Rhyhan 2019년 7월 22일
Sorry Sir it will be test.jpg. I will update the file. But the problem will not be solved.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 7월 22일

1 개 추천

test.jpg and tumor.jpg are both 128 x 128, but all of the other files in the directory are 256 x 256. You cannot multiply a 128 x 128 with a 256 by 256.

댓글 수: 7

Syed Zenith Rhyhan
Syed Zenith Rhyhan 2019년 7월 22일
Sir,I can try this way but can't solve the problem.Please give me the correction in code please,Walter Roberson Sir
TestImg = imresize(imread(str1), size(TargetImg));
Syed Zenith Rhyhan
Syed Zenith Rhyhan 2019년 7월 22일
Sorry when i execute this code this also give error for some image.What can i do now? Walter Roberson Sir
Syed Zenith Rhyhan
Syed Zenith Rhyhan 2019년 7월 22일
e1.JPG
Walter Roberson
Walter Roberson 2019년 7월 22일
What shows up for size() of the two variables?
Syed Zenith Rhyhan
Syed Zenith Rhyhan 2019년 7월 22일
편집: Syed Zenith Rhyhan 2019년 7월 22일
The above screen shot error
Walter Roberson,Sir
Walter Roberson
Walter Roberson 2019년 7월 22일
The above screen shot does not show me how many rows and columns and panes that the variables have. It shows me the error message, but does not tell me how large the variables are.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품

릴리스

R2014a

질문:

2019년 7월 22일

댓글:

2019년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by