imbinarize(I) returning "Error using > , Matrix dimensions must agree."
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jacquie
am 18 Feb. 2022
Beantwortet: Jacquie
am 18 Feb. 2022
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 Kommentar
Voss
am 18 Feb. 2022
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)
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


