imbinarize(I) returning "Error using > , Matrix dimensions must agree."
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Voss
il 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)
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


