Undefined operator '&' for input arguments of type 'matlab.graphics.primitive.Image'. why i am getting this error. i have to multiply 2 binary images pixel by pixel in matlab. groungtruth and output are two binary images. both are same but are segmented with two different techniques.
function r=eval_metrics(output,groundtruth)
TP_image=groundtruth&output;
TP=sum(TP_image(:));% # of hits (True Positive)
FN_image=groundtruth&~output;

댓글 수: 2

Image Analyst
Image Analyst 2020년 12월 25일
편집: Image Analyst 2020년 12월 25일
Before the error, put this:
whos output
whos groundtruth
What do you see in the command window? How did you actually get the image that is not a logical array but is actually of type 'matlab.graphics.primitive.Image'?
where we're not sure if you've accepted an answer or not and never attached your image so people can run your code. If so, then why? If not, what's the difference?
Rik
Rik 2020년 12월 27일
Not really the Christmass spirit, to edit away your question. I restored it from the Google cache.

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

 채택된 답변

Steven Lord
Steven Lord 2020년 12월 25일
편집: Steven Lord 2020년 12월 25일

0 개 추천

Generally you're going to want to perform arithmetic and/or logical operations on the image data not the image graphics object.
im = imread('eight.tif');
h = imagesc(im);
whos im h
Name Size Bytes Class Attributes h 1x1 8 matlab.graphics.primitive.Image im 242x308 74536 uint8
Arithmetic and logical operations are defined on variables of class uint8 but not on variables of class matlab.graphics.primitive.Image.
im(1, 1) & im(1, 2) % works
ans = logical
1
h(1, 1) & true % does not work
Operator '&' is not supported for operands of type 'matlab.graphics.primitive.Image'.

댓글 수: 13

Though if I recall correctly you can
h(1, 1) ~= 0 & true
Walter Roberson
Walter Roberson 2020년 12월 26일
one of your two inputs is not a matrix of data, and is instead the handle to an image() or imshow() or imagesc() when it should not be. We would need to see the code you are calling the function with
Syeda Noor
Syeda Noor 2020년 12월 26일
Can you give me your email, so i can share my files with you.
Steven Lord
Steven Lord 2020년 12월 26일
Using the variables in my example, don't try to perform arithmetic or logical operations on h, the output of a call to image or imagesc. Instead perform arithmetic or logical operations on im, the raw data.
I suspect that you did
out = imshow(array > Threshold)
and assumed that the output would be the image array resulting from the comparison. The output of imshow is the handle to a graphic object.
output = imshow(imcomplement(y));
As I said, the output of imshow is a graphics handle, not the array of data. Save the result of imcomplement to output and imshow(output)
As Walter said, replace:
output = imshow(imcomplement(y));
eval_metrics(output,groundtruth);
with something like:
C = imcomplement(y);
output = imshow(C);
eval_metrics(C,groundtruth);
Syeda Noor
Syeda Noor 2020년 12월 27일
Yes it works.
Syeda Noor
Syeda Noor 2020년 12월 27일
Can you please help me, how to make a binary mask of circular colored image. Which i have to apply on that image for segmentation.
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 12월 27일
편집: KALYAN ACHARJYA 2020년 12월 27일
From the Original Image or any other means?
Walter Roberson
Walter Roberson 2020년 12월 27일
Try imbinarize()
Syeda Noor
Syeda Noor 2020년 12월 27일
편집: Syeda Noor 2020년 12월 27일
Yes from original color image. Image is in round shape
Walter Roberson
Walter Roberson 2020년 12월 27일
You have not posted a sample image.

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

추가 답변 (0개)

카테고리

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

질문:

2020년 12월 25일

댓글:

2020년 12월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by