imbinarize(I) returning "Error using > , Matrix dimensions must agree."

조회 수: 4 (최근 30일)
Jacquie
Jacquie 2022년 2월 18일
답변: Jacquie 2022년 2월 18일
Hi, I'm having trouble thresholding my grayscale images and my errors don't match any issues I've seen online. I ran into this issue originally with my own grayscale jpegs, but I'm replicating the issue here with the image "George" from this post so that others can run my code if needed.
imbinarize(I) is throwing an error, but imbinarize(I, T) is not:
>> url = 'https://blogs.mathworks.com/images/steve/36/george.jpg';
>> I = imread(url);
>> imshow(I)
>> T = 0.5;
>> bw = imbinarize(I, T);
>> imshow(bw)
>> bw = imbinarize(I);
Error using >
Matrix dimensions must agree.
Error in imbinarize>binarize (line 162)
BW = I > T*classrange(2);
Error in imbinarize (line 152)
BW = binarize(I,T);
Additionally, I tried using graythresh() to determine the threshold, but for some reason it gives me a logical array:
>> T = graythresh(I);
>> whos T
Name Size Bytes Class Attributes
T 256x1 256 logical
Interestingly, multithresh does work:
>> T = multithresh(I)
T =
uint8
112
I recently updated Matlab to ensure that this wasn't a compatibility issue or something, and it's still happening. I'm sure I can use multithresh() to make this if needed, but I'd really like to do this right and to make sure I'm not missing something in my image processing.
Thank you!
  댓글 수: 1
Voss
Voss 2022년 2월 18일
I don't run into the error here:
url = 'https://blogs.mathworks.com/images/steve/36/george.jpg';
I = imread(url);
imshow(I)
T = 0.5;
bw = imbinarize(I, T);
imshow(bw)
bw = imbinarize(I);
imshow(bw)

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

채택된 답변

Jacquie
Jacquie 2022년 2월 18일
Update: issue fixed in R2021b
I had been using R2018b, so I tried downloading R2021b and the issue is resolved. I still don't know why I ran into that error, but I'll be working in the new install now.
Thanks!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by